Python program to calculate drag force against a cyclist
AIM: Write a Python program to calculate drag force against a cyclist. Write a program to plot Velocity vs Drag force(25 points) and Write a program to plot Drag Co-efficient vs Drag force(25 points).
SOLUTION:
Coding:
- Velocity vs Drag force
"""
Calculation of drag force against a cyclist
"""
import matplotlib.pyplot as plt
# Given data for calculating drag force
drag_coeff=0.8 # no units
area=0.1 # in m2
density=1.2 # in kg/m3
velocities=[] # in m/s
for i in range(1,26):
velocities.append(i)
# Calculation of drag force
drag_force=[]
for velocity in velocities:
drag_force.append((0.5*area*density*velocity*velocity*drag_coeff))
print(drag_force)
plt.plot(velocities,drag_force)
plt.xlabel('Velocity')
plt.ylabel('Drag force')
plt.show()
- Drag Co-efficient vs Drag force
"""
Calculation of drag force against a cyclist
"""
import matplotlib.pyplot as plt
# Given data for calculating drag force
drag_coeff=[0.04,0.07,0.09,0.42,0.47,0.5,0.59,0.80,0.82,1.05,1.15,1.16,1.17,1.20,1.30,1.38,1.42,1.50,1.55,1.63,1.98,2.0,2.05,2.20,2.30] # no units
area=0.1 # in m2
density=1.2 # in kg/m3
velocity=2 # in m/s
# Calculation of drag force
drag_force=[]
for c_d in drag_coeff:
drag_force.append((0.5*area*density*velocity*velocity*c_d))
print(drag_force)
plt.plot(drag_coeff,drag_force)
plt.xlabel('Drag coefficient')
plt.ylabel('Drag force')
plt.show()
Outputs:
- Velocity vs Drag force
- Drag Co-efficient vs Drag force
Report:
- A drag force is the resistance force caused by the motion of a body through a fluid, such as water or air. A drag force acts opposite to the direction of the oncoming flow velocity. This is the relative velocity between the body and the fluid.
- The drag force F exerted on a body traveling though a fluid(air) is given by, F=0.5*frontal_area*density of air*velocity^2*drag_coefficient
- From the first program, we calculate drag fore for different values of velocities. In that, initially density,frontal area,drag coefficients values are given.
- So, by using the above formula, we calculate drag force for all the values of velocities and plot the graph between them, as shown in the first output.
- Similarly, the second program calculate the drag force for different values of drag coefficient. In that density,area,velocity values are given.
- By using drag force formula, we calculate the drag force for all the values of drag coefficient and plot the graph between them, as shown in the second output.