This section explains the assumptions made to ultimately calculate dynamic pressure as a function of time, which requires a brief discussion about physics.
The equation for dynamic pressure q is where is the density of air and V is velocity. You want to build two equations so that you have density and velocity as functions of time (so that we can calculate dynamic pressure as ).
Velocity
The rocket needs to go from 0 mph to about 18,000 mph, and the average rocket launch lasts about 8.5 minutes to go from launchpad to “space” [1]. Thus, you will use the average acceleration of 18,000 mph / 8.5 minutes = 51.76 . You will also assume that this acceleration is constant (e.g. the rocket is constantly accelerating at 51.76 from 0 mph to 18,000 mph), which allows you to use simple physics equations. This is an incorrect assumption, but use it to start, then refine the average acceleration as needed. For constant acceleration, . Since the rocket is starting motionless on the launchpad, . You now have a Python function that will calculate velocity based off of acceleration and time. It will look something like this:
instant_velocity = velocity(acceleration, time) = acceleration * time
Density
The density of air scales with temperature which decreases with higher altitude. For density, you will need to separately create an equation for altitude from velocity, use that altitude to get air temperature at that altitude, then use that air temperature to get density. You will use another constant acceleration toolbox equation to get altitude as a function of time. The basic equation is: .
again, so the equation becomes .
In Python pseudocode:
Altitude = time_to_altitude(acceleration, time) = 0.5 * acceleration * time ** 2
One last reminder: in order to calculate exponents, use the **
operator.
NASA has a basic altitude-temperature model [2] that shows the relationship between altitude, temperature, and density. You can build this model into a density()
equation that takes altitude as an input, internally calculates temperature, calculates density, then returns density. In Python pseudocode:
density = density(altitude) = temperature_to_density(altitude_to_temperature(altitude))
This is a nested argument that was discussed in the Variables and String Methods lesson; the Python interpreter will evaluate the line from inside out and dynamically calculate each function. In other words, it will evaluate altitude_to_temperature(altitude)
to calculate a temperature from altitude, then evaluate temperature_to_density(temperature)
from the result to calculate density from temperature. Now, you should be able to calculate dynamic pressure since you have equations for density and velocity written as functions of time. One last time, in Python pseudocode:
dynamic_pressure(density(altitude), velocity(acceleration, time)) = 0.5 * density(time_to_altitude(acceleration, time)) * velocity(acceleration, time)**2
Now, back to the regularly scheduled Python programming.
Get hands-on with 1400+ tech skills courses.