72 lines
2.2 KiB
Python
72 lines
2.2 KiB
Python
from apc_perf import ApcPerfdata
|
|
import matplotlib.pyplot as plt
|
|
from typing import Collection
|
|
from dataclasses import dataclass
|
|
from collections import defaultdict
|
|
import numpy as np
|
|
|
|
def plot_prop_op_points(apc_data: ApcPerfdata, rpm: float):
|
|
|
|
rpm_series = apc_data.rpm_series[rpm]
|
|
min_speed = min(op.speed for op in rpm_series)
|
|
print(min_speed)
|
|
max_speed = max(op.speed for op in rpm_series)
|
|
print(max_speed)
|
|
speeds = np.linspace(min_speed, max_speed, 500)
|
|
thrusts = []
|
|
torques = []
|
|
for speed in speeds:
|
|
print(speed)
|
|
op = apc_data.get_op_interpspeed(rpm, speed)
|
|
thrusts.append(op.thrust)
|
|
torques.append(op.torque)
|
|
|
|
fig, ax1 = plt.subplots(figsize=(10, 6))
|
|
|
|
ax1.plot(speeds, thrusts, label="Thrust", marker='o', color='tab:blue')
|
|
ax1.set_xlabel("Speed")
|
|
ax1.set_ylabel("Thrust", color='tab:blue')
|
|
ax1.tick_params(axis='y', labelcolor='tab:blue')
|
|
|
|
ax2 = ax1.twinx()
|
|
ax2.plot(speeds, torques, label="Torque", marker='s', color='tab:orange')
|
|
ax2.set_ylabel("Torque", color='tab:orange')
|
|
ax2.tick_params(axis='y', labelcolor='tab:orange')
|
|
|
|
plt.title(f"PropOppoint Variables vs Speed at RPM {rpm}")
|
|
|
|
fig.tight_layout()
|
|
plt.show()
|
|
|
|
def plot_op_with_rpm_range(apc_data: ApcPerfdata, speed: float):
|
|
rpms = list(apc_data.rpms_at_speed(speed))
|
|
min_rpm = rpms[0]
|
|
max_rpm = rpms[-1]
|
|
rpms = np.linspace(min_rpm, max_rpm, 500)
|
|
|
|
thrusts = []
|
|
torques = []
|
|
for rpm in rpms:
|
|
op = apc_data.get_op_interp(rpm, speed)
|
|
thrusts.append(op.thrust)
|
|
torques.append(op.torque)
|
|
fig, ax1 = plt.subplots(figsize=(10, 6))
|
|
ax1.plot(rpms, thrusts, label="Thrust", color='tab:blue')
|
|
ax1.set_xlabel("RPM")
|
|
ax1.set_ylabel("Thrust", color='tab:blue')
|
|
ax1.tick_params(axis='y', labelcolor='tab:blue')
|
|
|
|
ax2 = ax1.twinx()
|
|
ax2.plot(rpms, torques, label="Torque", color='tab:orange')
|
|
ax2.set_ylabel("Torque", color='tab:orange')
|
|
ax2.tick_params(axis='y', labelcolor='tab:orange')
|
|
|
|
plt.title(f"PropOppoint Variables vs RPM at Speed {speed} m/s")
|
|
|
|
fig.tight_layout()
|
|
plt.show()
|
|
|
|
# p = ApcPerfdata.from_file('./data/PERFILES2/PER3_10x3.dat')
|
|
# plot_op_with_rpm_range(p, 15)
|
|
# plot_prop_op_points(p, 9000)
|