#Program to calculate Drag force in Newtons
# Note: This program provides information of both Velocity and C_d variation with drag
import matplotlib.pyplot as plt
import numpy as np
#Inputs in SI units
c_d = np.linspace(0.1,1.0,10) #(rows)
A = 0.2 ; rho = 1.0 # Constants
velocity = np.linspace(2,30,10) # Columns
row = len(velocity); col= len(c_d);
drag = [] # Declare a null matrix
# Enter the Formulae for computation here.
drag = [[0.5*c_d[i]*A*velocity[j]*velocity[j]*rho for j in range(row)] for i in range(col)]
print(drag) # in results, col varies with velocity and row varies with c_d
# Plot the results
for j in range(row):
plt.plot(velocity,drag[:][j])
plt.xlabel('velocities in SI'); plt.ylabel('drag in SI'); plt.title('Variation of velocity vs Drag')
plt.legend(c_d, title = "Variation for Various draf coeff")
plt.show()# This always comes in the end