Python program to calculate drag force against a cyclist
Objectives:
- To write a program to plot Velocity vs Drag force
- To write a program to plot Drag Co-efficient vs Drag force
Formula:
Drag Force(Fd) = 0.5*rho*frontal area*Velocity^2* Coefficient of drag(C_d)
The factors involved are Velocity, Drag coefficient, Frontal Area, Density of air
1. Programme to plot Velocity vs Drag forces
"""
Programme to calculate the drag force
"""
import matplotlib.pyplot as plt
# Inputs
#Density (kg/m^3)
rho = 1.2
#Frontal Area(m^2)
A = 0.1
# Velocity (m/s)
Velocities = [5,6,7,8,9,10,11,12]
drag_forces = []
# Drag Coefficient
c_d = 0.8
for values in Velocities:
drag_forces.append((0.5*rho*A*c_d*values*values))
plt.plot(Velocities, drag_forces)
plt.xlabel('Velocities')
plt.ylabel('drag_forces')
plt.show()
Array of Drag Forces = [1.2, 1.7280000000000002, 2.3520000000000003, 3.072, 3.888, 4.8, 5.808, 6.912000000000001]
Plot:
2. Program to plot Drag Co-efficient vs Drag force
"""
Programme to plot Coefficient drag vs Drag Forces
"""
import matplotlib.pyplot as plt
# Inputs
#Density (kg/m^3)
rho = 1.2
#Frontal Area (m^2)
A = 0.1
#Velocity (m/s)
V = 10
#Coefficient of drag
#Shapes
"""
Flat Plate = 1.28
Prism = 1.14
Bullet = 0.295
Sphere = 0.07
Airfoil = 0.045
"""
c_d = [1.28,1.14,0.295,0.07,0.045]
# Drag Forces
drag_forces = []
for values in c_d:
drag_forces.append((0.5*A*rho*V*V*values))
plt.plot(c_d,drag_forces)
plt.xlabel('Coefficient of drag')
plt.ylabel('Drag Forces')
plt.show()
An array of Drag Forces = [7.68, 6.84, 1.77, 0.42000000000000004, 0.27]
Plot:
Observation and Conclusion:
In Velocity vs Drag Forces plot, we get parabolic shaped curved line ascending upwards. This is because drag force is directly proportional to (velocity)^2 which defines a Parabola.
In Drag Coefficient vs Drag Forces, we get a straight ascending line with positive slope because of Drag Force is directly proportional to Drag Coefficient.