Airplane velocity#
Example#
An airplane is initially flying at an initial velocity of \(v_0 = 85 \ m/s\), when it starts accelerating horizontally by exerting a force of \(3000 \ N\). An aerospace engineer wants to know its instantaneous velocity, every second, for \(1\) minute. The equation of air resistance is \(F_{\text{air}} = kv^2\) with \(k = 0.24 \ \frac{kg}{m}\). The mass of the airplane is \(2000 \ kg\).
From physics we know that,
- \(v_i = v_{i-1} + a_{i-1}(t_i-t_{i-1})\)
- \(F_{\text{air},i} = k\cdot v_i^2\)
- \(F_{\text{R},i}=F - F_{\text{air},i} = m\cdot a_i\)
where \(t_i\) refers to the \(i\)-th time instant and in our case \(t_i-t_{i-1}=1\) s. Your task is to return
v
, a list containing the velocity of the plane at \(t = 0 \ s\), \(t = 1 \ s\), …, \(t = 60 \ s\). (Therefore, v
should have \(61\) elements).
Solution#
We start by importing numpy and defining the input variables to solve the problem.
import numpy as np
time = np.arange(0,61,1) # [s]
velocity = np.zeros(len(time))
acceleration = np.zeros(len(time))
initial_velocity = 85 # [m/s]
velocity[0] = initial_velocity # [m/s]
force = 3000 # [N]
k = 0.24 # [kg/m]
airplane_mass = 2000 # [kg]
Let’s break it down
Here’s a step-by-step explanation of the code:
import numpy as np
: This line imports the NumPy library and assigns it the alias “np” for easier usage in the code.time = np.arange(0,61,1) # [s]
: This line creates an array called “time” using thearange
function from NumPy. It starts from 0, goes up to 61 (exclusive), and increments by 1, resulting in an array with values [0, 1, 2, …, 59, 60]. This represents time in seconds.velocity = np.zeros(len(time))
: This line creates an array called “velocity” using thezeros
function from NumPy. It has the same length as the “time” array (i.e., the number of elements in the “time” array), and all its elements are initialized to 0. This will be used to store the velocity values for each time step.acceleration = np.zeros(len(time))
: This line creates an array called “acceleration” using thezeros
function from NumPy. It has the same length as the “time” array, and all its elements are initialized to 0. This will be used to store the acceleration values for each time step.initial_velocity = 85 # [m/s]
: This line sets the initial velocity of the simulation to 85 meters per second. This value is assigned to the first element of the “velocity” array, as specified in the next line.velocity[0] = initial_velocity
: This line assigns the value of “initial_velocity” to the first element of the “velocity” array. This represents the initial velocity of the simulation at time t=0.Lastly,
force = 3000 # [N]
,k = 0.24 # [kg/m]
andairplane_mass = 2000 # [kg]
: sets the values of the variables that we will use in the next steps.
We use the given equations to solve the problem. A for loop is used to compute the velocities.
for i in range(1,len(time)):
velocity[i] = velocity[i-1] + acceleration[i-1]*(time[i]-time[i-1])
air_resistance = k * velocity[i]**2
resistance = force - air_resistance
acceleration[i] = resistance / airplane_mass
print(f'The velocities in m/s are:\n {np.round(velocity,2)}' )
The velocities in m/s are:
[ 85. 85. 85.63 86.25 86.86 87.45 88.04 88.61 89.16 89.71
90.25 90.77 91.28 91.78 92.27 92.75 93.21 93.67 94.12 94.56
94.98 95.4 95.81 96.21 96.6 96.98 97.35 97.71 98.07 98.41
98.75 99.08 99.4 99.72 100.02 100.32 100.61 100.9 101.18 101.45
101.71 101.97 102.22 102.47 102.71 102.94 103.17 103.4 103.61 103.82
104.03 104.23 104.43 104.62 104.81 104.99 105.17 105.34 105.51 105.67
105.83]
Exercise#
An airplane is initially flying at a speed of \(v_0 = 105\) m/s, when it starts accelerating horizontally by exerting a force of \(4000\) \(N\). The mass of the airplane is \(2500\) \(kg\). Compute the instantaneous speed, every second, for half of a minute and answer the following questions.
What is the acceleration of the plane at 30 seconds?
What is the velocity of the plane at 29 seconds?
Toolbox
Here are your tools to solve this exercise:
Import numpy and load the data set.
Define the input variables.
Use the given equations on the example to compute \(v\) and \(a\)
You can use the following numpy functions (but not limited to):
np.arange()
, np.zeros()
, np.max()
, np.where()
, np.round()
, len
Jupyter Lite session
Start a Jupiter lite session here to open a new tab where you can freely write and run your code.
Wait until the message “You may begin!” is printed.