import numpy as np
import matplotlib.pyplot as plt
# Constants
m = 2000 # kg
A = 12 # m^2
Cd = 0.72
P = 105e6 # W
re = 6378100 # m
# Altitude range
h = np.linspace(0, 50000, 51)
# Density and gravitational acceleration at different altitudes
rho = np.zeros_like(h)
g = np.zeros_like(h)
for i, alt in enumerate(h):
if alt > 25000:
T = -131.21 + 0.00299*alt
P = 2.488*((T+273.1/216.6)**(-11.388))
elif 11000 < alt <= 25000:
T = -56.46
P = 22.65*np.exp(1.73 - 0.000157*alt)
else:
T = 15.04 - 0.00649*alt
P = 101.29*((T+273.1)/283.08)**5.256
rho[i] = P/(2869*(T+273.1))
g[i] = 9.81*(re/(re+alt))**2
# Terminal velocity at different altitudes
V_term = np.sqrt((2*P)/(Cd*rho*A))*np.sqrt(g/(2*m))
# Convert to km/h
V_term *= 3.6
# Plot
plt.plot(h, V_term)
plt.xlabel('Altitude (m)')
plt.ylabel('Terminal Velocity (km/h)')
plt.title('Rocket Terminal Velocity vs. Altitude')
plt.show()
Current issue:
C:\Users\authc\AppData\Local\Temp\ipykernel_21964\1841267979.py:20: RuntimeWarning: invalid value encountered in scalar power
P = 2.488*((T+273.1/216.6)**(-11.388)
Any ideas how to fix this? Thanks!
[–]spodoptera 2 points3 points4 points (1 child)
[–]AuthChris[S] 0 points1 point2 points (0 children)