refactored
This commit is contained in:
+54
-52
@@ -54,7 +54,6 @@ car_list = [
|
||||
def rho(temperature_degc: float, p_pa: float =g_p0):
|
||||
return p_pa/(g_RS*(temperature_degc + 273.15))
|
||||
|
||||
|
||||
# Force : N = kg·m·s2
|
||||
def fd(rho: float, velocity_kmh: float, c_val: float, area: float):
|
||||
vel = velocity_kmh / 3.6
|
||||
@@ -62,63 +61,66 @@ def fd(rho: float, velocity_kmh: float, c_val: float, area: float):
|
||||
res = 0.5*rho*vel*vel*cwa
|
||||
return res
|
||||
|
||||
def main() -> None:
|
||||
# Fd vs. velocity, param: temperature
|
||||
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]
|
||||
|
||||
# Fd vs. velocity, param: temperature
|
||||
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()
|
||||
for temp_degc in temps_list:
|
||||
rho_t = rho(temp_degc)
|
||||
y_fd = []
|
||||
for vel_kmh in vel_list:
|
||||
fd_t = (fd(rho_t, vel_kmh, c_val_id3, area_id3)/reference - 1) * 100
|
||||
y_fd.append(fd_t)
|
||||
|
||||
plot.figure()
|
||||
for temp_degc in temps_list:
|
||||
rho_t = rho(temp_degc)
|
||||
plot.plot(vel_list, y_fd)
|
||||
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.ylabel("Windwiderstand [%]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.legend(temps_list_leg)
|
||||
plot.grid()
|
||||
|
||||
# Fd vs. velocity, param: car
|
||||
temp = 20
|
||||
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
|
||||
car_list_leg = [f"{t['car']}" for t in car_list]
|
||||
|
||||
rho_t = rho(temp)
|
||||
reference = fd(rho_t, 100, c_val_id3, area_id3)
|
||||
|
||||
plot.figure()
|
||||
for car in car_list:
|
||||
y_fd = []
|
||||
for vel_kmh in vel_list:
|
||||
fd_t = (fd(rho_t, vel_kmh, car['cw'], car['area'])/reference - 1) * 100
|
||||
y_fd.append(fd_t)
|
||||
|
||||
plot.plot(vel_list, y_fd)
|
||||
|
||||
plot.ylabel("Windwiderstand ID.3 [%]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.legend(car_list_leg)
|
||||
plot.grid()
|
||||
|
||||
plot.figure()
|
||||
y_fd = []
|
||||
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)
|
||||
y_fd.append(fd_t)
|
||||
|
||||
plot.plot(vel_list, y_fd)
|
||||
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.ylabel("Windwiderstand [%]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.legend(temps_list_leg)
|
||||
plot.grid()
|
||||
plot.ylabel("Windwiderstand [N]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.legend(car_list_leg)
|
||||
plot.grid()
|
||||
plot.show()
|
||||
|
||||
# Fd vs. velocity, param: car
|
||||
temp = 20
|
||||
vel_list = [20, 40, 60, 80, 100, 120, 130, 140, 160]
|
||||
car_list_leg = [f"{t['car']}" for t in car_list]
|
||||
|
||||
rho_t = rho(temp)
|
||||
reference = fd(rho_t, 100, c_val_id3, area_id3)
|
||||
|
||||
plot.figure()
|
||||
for car in car_list:
|
||||
y_fd = []
|
||||
for vel_kmh in vel_list:
|
||||
fd_t = (fd(rho_t, vel_kmh, car['cw'], car['area'])/reference - 1) * 100
|
||||
y_fd.append(fd_t)
|
||||
|
||||
plot.plot(vel_list, y_fd)
|
||||
|
||||
plot.ylabel("Windwiderstand ID.3 [%]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.legend(car_list_leg)
|
||||
plot.grid()
|
||||
|
||||
plot.figure()
|
||||
y_fd = []
|
||||
for vel_kmh in vel_list:
|
||||
fd_t = fd(rho_t, vel_kmh, c_val_id3, area_id3)
|
||||
y_fd.append(fd_t)
|
||||
|
||||
plot.plot(vel_list, y_fd)
|
||||
|
||||
plot.ylabel("Windwiderstand [N]")
|
||||
plot.xlabel("Geschwindigkeit [km/h]")
|
||||
plot.title("Windwiderstand vs Geschwindigkeit")
|
||||
plot.legend(car_list_leg)
|
||||
plot.grid()
|
||||
plot.show()
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user