#!/usr/bin/env pltthon3 # -*- coding: utf-8 -*- """ ENGG1811 lecture 7 Example: Simulate the parachutist's speed by formula """ # Import #import para_formula_lib as para import matplotlib.pyplot as plt import numpy as np import math # Constants g = 9.81 # Problem parameters mass = 70 # Mass of the parachutist tc = 4 # Time at which the parachute is deployed air_drag_coeff = 12.5 # Drag coefficient for air para_drag_coeff = 80 # Drag coefficient for parachute # Create a list of regularly spaced time instants # [0,0.25,0.5,0.75,...,20] start = 0 end = 20 step = 0.25 time_array = np.arange(start, end + step/2 , step) #%% speed_array = np.zeros_like( time_array) #%% for k in range(0, len(time_array)) : t = time_array[k] if t < tc : speed = (g*mass/air_drag_coeff) * (1 - math.exp(-1*air_drag_coeff * t / mass )) else : vp0 = (g*mass/air_drag_coeff) * (1 - math.exp( -1*air_drag_coeff*tc/mass ) ) speed = vp0 * math.exp((-1*para_drag_coeff/mass)*(t - tc)) + \ (g*mass/para_drag_coeff)* (1 - math.exp((-para_drag_coeff/mass)*(t-tc)) ) speed_array[k] = speed # Plot the figure fig1 = plt.figure() plt.plot(time_array,speed_array ,label = 'Parachute by formula') plt.legend() plt.xlabel('time [seconds]') plt.ylabel('speed [m/s]') plt.show() # plt.savefig('para1.png')