Calculation of Drag Force against a Cyclist using Python
Objectives:
- Write a Python program to calculate drag force against a cyclist.
- Write a program to plot Velocity vs Drag force
- Write a program to plot Drag Co-efficient vs Drag force.
What is Drag?
In fluid dynamics, drag is a force acting opposite to the relative motion of any object moving with respect to a surrounding fluid. This can exist between two fluid layers (or surfaces) or a fluid and a solid surface.
Coefficient of drag is a dimensionless number that relates an objects drag force to its area and speed, it ranges upwards from 0.
Drag Force Equation:
Fd = 0.5*rho*A*v.^2*cd
where,
rho - Density
A - Frontal Area
v - velocity
cd - drag coefficient
Code: 1
To plot Velocity vs Drag force.
#program to calculate drag force on the cyclist and plot velocity vs Drag force
import matplotlib.pyplot as plt
#inputs
#drag coeff
c_d=0.8
def plot_dragforce_vs_velocity(velocities,drag_force):
plt.plot(velocities,drag_force,'*-g')
plt.xlabel('Velocity')
plt.ylabel('Drag Force')
plt.title('Velocity vs Drag Force')
plt.show()
#frontal area
a=0.1
#velocity
velocities=[6,7,8,9,10,11,12]
#density of the air
rho=1.2
drag_force=[]
for v in velocities:
#calculation of drag force
drag_force.append((0.5*rho*c_d*a*v*v))
print(drag_force)
plot_dragforce_vs_velocity(velocities,drag_force)
Output:
Code:2
Code to plot Drag Co-efficient vs Drag force.
#Calculation of drag force on a cyclist and plot drag cofficient vs drag force
import matplotlib.pyplot as plt
def plot_dragforce_vs_dragcoefficient(drag_coefficient,drag_force):
plt.plot(drag_coefficient,drag_force,'*-y')
plt.title('Drag Coefficient vs Drag Force')
plt.xlabel('Drag Coefficient')
plt.ylabel('Drag Force')
plt.show()
#inputs
#density of air (kg/m^3)
rho=1.2
#velocity of the cyclist (m/s)
v=1
#frontal area (m^2)
A=0.1
#drag coefficient for various shapes
drag_coefficient=[0.47,0.42, 0.50 ,1.05, 0.80 ,0.82, 1.15, 0.04, 0.09]
#defining an empty array
drag_force=[]
#calculation of drag force
for c_d in drag_coefficient:
drag_force.append((0.5*c_d*A*rho*v*v))
print(drag_force)
plot_dragforce_vs_dragcoefficient(drag_coefficient,drag_force)
Output:
Conclusion: Python program to calculate drag force against a cyclist has been written and required graph are plotted.