def para_speed_height_ODE(time_array, mass, speed0, height0, drag_air, time_deploy, drag_para): # # # Purpose: # This Python function computes the speed of the parachutist # at the time instances given in the array time_array by solving an # ODE # # Inputs: # # time_array (array) of time instances # mass Mass of parachutist # speed0 Initial speed of parachutist # height0 Initial height of parachutist # drag_air Drag coefficients for air # time_deploy Deployment time of parachute # drag_para Drag coefficient for parachute # # Output: # speed_array (Vector) speed_array has the same shape as time_array # This output is the speed of the parachutist # at the correspoding time in t # # Constants: # g acceleration due to gravity # # Import import numpy as np # Constants g = 9.81 # determine time increment dt = time_array[2]-time_array[1] # Simulation output speed_array = np.zeros_like(time_array) height_array = np.zeros_like(time_array) # Assign initial speed speed_array[0] = speed0 height_array[0] = height0 # simulation loop for k in range(0,len(time_array)-1): time_now = time_array[k] drag_coeff_now = get_drag_coeff(time_now,time_deploy,drag_air,drag_para) # To be completed in lecture speed_array[k+1] = speed_array[k] + \ (g-drag_coeff_now*speed_array[k]/mass)*dt height_array[k+1] = height_array[k] - \ speed_array[k] * dt return speed_array, height_array def get_drag_coeff(t,time_deploy,drag_air,drag_para): # # Function to determine the drag coefficient at time time t if t <= time_deploy: drag_coeff = drag_air else: drag_coeff = drag_para return drag_coeff