#!/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 # 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 = 80 # Drag coefficient for parachute # Create a list of regularly spaced time instants # [0,0.25,0.5,0.75,...,20] # time_array = np.arange(0,20.1,0.25) # The function for calculating speed is in a separate file # Use for loop to get the speed speed_by_formula_array = np.zeros_like(time_array) for k in range(0,len(time_array)): time = time_array[k] speed_para = para.parachute(time,mass,air_drag_coeff,time_deploy,para_drag_coeff) speed_by_formula_array[k] = speed_para # Plot the figure fig1 = plt.figure() plt.plot(time_array,speed_by_formula_array,label = 'Parachute by formula') plt.legend() plt.xlabel('time [seconds]') plt.ylabel('speed [m/s]') plt.show() # plt.savefig('para1.png')