#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jul 16 09:41:54 2020 @author: ashesh Example: Simulate the parachutist's speed by ODE - Raw """ # Import import matplotlib.pyplot as plt import numpy as np # Problem parameters mass = 70 # Mass of the parachutist time_deploy = 6 # Time at which the parachute is deployed air_drag_coeff = 12.5 # Drag coefficient for air para_drag_coeff = 90 # Drag coefficient for parachute speed0 = 0 # Initial speed height0 = 4000 #Initial height # Simulation parameters time_start = 0 time_end = 600 time_increment = 0.0025 # Create a list of regularly spaced time instants # [0,0.25,0.5,0.75,...,20] # time_array = np.arange(time_start,time_end+time_increment/2, time_increment) # 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] if time_now <= time_deploy: drag_coeff_now = air_drag_coeff else: drag_coeff_now = para_drag_coeff # 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 landing_ht = np.min(height_array[height_array > 0]) landing_time = np.max(time_array[height_array > 0]) # Plot the figure fig1 = plt.figure() #plt.plot(time_array, speed_array, label = 'ODE (speed)') plt.plot(time_array, height_array, label = 'height') plt.legend() plt.xlabel('time [seconds]') #plt.ylabel('speed') plt.ylabel('height') plt.grid() plt.show() plt.savefig('para1.png')