[eval_records]

- use hourse on x-axis

[luftwiderstand]
- refactored
This commit is contained in:
2025-06-20 13:23:20 +02:00
parent 512fe8cdb8
commit d4ebd12320
2 changed files with 49 additions and 27 deletions
+2
View File
@@ -274,6 +274,8 @@ def main() -> None:
# Convert x-axis # Convert x-axis
dt_h = (np.array(time_h) - time_h[0]) / 3600 / 24 + settings.sel_days[0] dt_h = (np.array(time_h) - time_h[0]) / 3600 / 24 + settings.sel_days[0]
dt_h -= settings.sel_days[0]
dt_h *= 24
v_energy = [] v_energy = []
v_consumption = [] v_consumption = []
energy = 0 energy = 0
+47 -27
View File
@@ -10,7 +10,7 @@ g_RS = 287.54
# CW-Wert und Stirnfläche # CW-Wert und Stirnfläche
c_val_id3 = 0.267 c_val_id3 = 0.267
area_id3 = 2.360 # m^3 area_id3 = 2.360 # m^2
car_list = [ car_list = [
{ {
@@ -50,6 +50,10 @@ car_list = [
} }
] ]
temp_list = [-20, -10, 0, 10, 20, 30]
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
# rho: [kg/m3] # rho: [kg/m3]
def rho(temperature_degc: float, p_pa: float =g_p0): def rho(temperature_degc: float, p_pa: float =g_p0):
return p_pa/(g_RS*(temperature_degc + 273.15)) return p_pa/(g_RS*(temperature_degc + 273.15))
@@ -61,19 +65,14 @@ def fd(rho: float, velocity_kmh: float, c_val: float, area: float):
res = 0.5*rho*vel*vel*cwa res = 0.5*rho*vel*vel*cwa
return res return res
def main() -> None: def plot_1(fd_reference):
# Fd vs. velocity, param: temperature temps_list_leg = [f"{t}°C" for t in temp_list]
temps_list = [-20, -10, 0, 10, 20, 30]
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
reference = fd(rho(20), 100, c_val_id3, area_id3)
temps_list_leg = [f"{t}°C" for t in temps_list]
plot.figure() plot.figure()
for temp_degc in temps_list: for temp_degc in temp_list:
rho_t = rho(temp_degc) rho_t = rho(temp_degc)
y_fd = [] y_fd = []
for vel_kmh in vel_list: for vel_kmh in vel_list:
fd_t = (fd(rho_t, vel_kmh, c_val_id3, area_id3)/reference - 1) * 100 fd_t = (fd(rho_t, vel_kmh, c_val_id3, area_id3)/fd_reference - 1) * 100
y_fd.append(fd_t) y_fd.append(fd_t)
plot.plot(vel_list, y_fd) plot.plot(vel_list, y_fd)
@@ -84,14 +83,12 @@ def main() -> None:
plot.legend(temps_list_leg) plot.legend(temps_list_leg)
plot.grid() plot.grid()
# Fd vs. velocity, param: car def plot_2(temp=20):
temp = 20 ''' Fd vs. velocity, param: car '''
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160] # [kmh]
car_list_leg = [f"{t['car']}" for t in car_list] car_list_leg = [f"{t['car']}" for t in car_list]
rho_t = rho(temp) rho_t = rho(temp)
reference = fd(rho_t, 100, c_val_id3, area_id3) reference = fd(rho_t, 100, c_val_id3, area_id3)
plot.figure() plot.figure()
for car in car_list: for car in car_list:
y_fd = [] y_fd = []
@@ -103,19 +100,12 @@ def main() -> None:
plot.ylabel("Luftwiderstand ID.3 [%]") plot.ylabel("Luftwiderstand ID.3 [%]")
plot.xlabel("Geschwindigkeit [km/h]") plot.xlabel("Geschwindigkeit [km/h]")
plot.title(f"Windwiderstand vs Geschwindigkeit, Temperature {temp}°C") plot.title(f"Luftwiderstand vs Geschwindigkeit, Temperature {temp}°C")
plot.legend(car_list_leg) plot.legend(car_list_leg)
plot.grid() plot.grid()
y_fd = [] def plot_3(y_fd, y_pwr, temp=20):
y_pwr = [] car_list_leg = [f"{t['car']}" for t in car_list]
y_energy = []
for vel_kmh in vel_list:
fd_t = fd(rho_t, vel_kmh, c_val_id3, area_id3)
y_fd.append(fd_t)
y_pwr.append(fd_t*vel_kmh/1000/3.6)
y_energy.append(fd_t*vel_kmh/1000/3.6*100/vel_kmh)
fig, ax1 = plot.subplots() fig, ax1 = plot.subplots()
ax1.plot(vel_list, y_fd) ax1.plot(vel_list, y_fd)
ax1.set_ylabel("Luftwiderstand [N]") ax1.set_ylabel("Luftwiderstand [N]")
@@ -123,11 +113,13 @@ def main() -> None:
ax1.set_title(f"Luftwiderstand vs Geschwindigkeit, Temperature {temp}°C") ax1.set_title(f"Luftwiderstand vs Geschwindigkeit, Temperature {temp}°C")
ax1.legend(car_list_leg) ax1.legend(car_list_leg)
ax2 = ax1.twinx() ax2 = ax1.twinx()
ax2.set_ylabel("Antriebsleistung [kw]", color='tab:red') ax2.set_ylabel("Antriebsleistung [kW]", color='tab:red')
ax2.plot(vel_list, y_pwr, color='tab:red') ax2.plot(vel_list, y_pwr, color='tab:red')
ax2.tick_params(axis='y', labelcolor='tab:red') ax2.tick_params(axis='y', labelcolor='tab:red')
ax1.grid() ax1.grid()
def plot_4(y_fd, y_energy, temp=20):
car_list_leg = [f"{t['car']}" for t in car_list]
fig, ax1 = plot.subplots() fig, ax1 = plot.subplots()
ax1.plot(vel_list, y_fd) ax1.plot(vel_list, y_fd)
ax1.set_ylabel("Luftwiderstand [N]") ax1.set_ylabel("Luftwiderstand [N]")
@@ -135,11 +127,39 @@ def main() -> None:
ax1.set_title(f"Luftwiderstand vs Geschwindigkeit, Temperature {temp}°C") ax1.set_title(f"Luftwiderstand vs Geschwindigkeit, Temperature {temp}°C")
ax1.legend(car_list_leg) ax1.legend(car_list_leg)
ax2 = ax1.twinx() ax2 = ax1.twinx()
ax2.set_ylabel("Antriebsenergie [kwh]", color='tab:red') ax2.set_ylabel("Antriebsenergie [kWh/100km]", color='tab:red')
ax2.plot(vel_list, y_energy, color='tab:red') ax2.plot(vel_list, y_energy, color='tab:red')
ax2.tick_params(axis='y', labelcolor='tab:red') ax2.tick_params(axis='y', labelcolor='tab:red')
ax1.grid() ax1.grid()
plot.show() plot.show()
def main() -> None:
# Fd vs. velocity, param: temperature
reference = fd(rho(20), 100, c_val_id3, area_id3)
temp_ref = 20
# Luftwiderstand [%] vs. Geschwindigkeit [kmh], Param: Temperatur
plot_1(reference)
# Luftwiderstand [%] vs. Geschwindigkeit [kmh] at 20°C, Param: Car Model
plot_2(temp_ref)
y_fd = []
y_pwr = []
y_energy = []
for vel_kmh in vel_list:
fd_t = fd(rho(temp_ref), vel_kmh, c_val_id3, area_id3)
y_fd.append(fd_t)
y_pwr.append(fd_t*vel_kmh/1000/3.6)
y_energy.append(fd_t*vel_kmh/1000/3.6*100/vel_kmh)
# Luftwiderstand [N] / Antriebsleistung [kW] vs. Geschwindigkeit [kmh], Param: Temp
plot_3(y_fd, y_pwr, temp_ref)
# Luftwiderstand [N] / Antriebsenergie [kWh/100km] vs. Geschwindigkeit [kmh], Param: Temp
plot_4(y_fd, y_energy, temp_ref)
if __name__ == '__main__': if __name__ == '__main__':
main() main()