#!/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 = 100 # 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 = 80 # Drag coefficient for parachute speed0 = 0 # Initial speed height0 = 4000 #Initial height # Simulation parameters time_start = 0 time_end = 20 time_increment = 0.25 # 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) 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 speed_array[k+1] = speed_array[k] + (g - drag_coeff_now * speed_array[k] / mass) * dt # 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')