Project

Flow over Bicycle (Python)

Aim: To write a program in Python to calculate drag force against a cyclist and to plot

  • Velocity vs Drag force
  • Drag Co-efficient vs Drag force

Theory:

A drag force is the resistance force caused by the motion of a body through a fluid, such as water or air. Drag always acts in the direction opposite to the motion.

The Drag force formula is given by,

FD = ½* `rho`*A*V2 *CD

Where, `rho`=Density (kg/m^3)

A=Frontal area (m^2)

V=Velocity(m/s)

CD =Drag Co-efficient

The Drag force depends upon the shape of the object, velocity, size and the fluid in it.

Lower the drag coefficient, the object will have less aerodynamic drag.

If the area is more, it means more of the area is in contact with the air which results in more drag.

The cyclist will experience drag force when the cycling velocity increases, hence the cyclists change their riding position frequently so as to reduce drag force i.e. change in the position will change the frontal area and the drag force experienced by the cyclist will be reduced.

To plot Velocity vs Drag force

#program to calculate the drag force
import math
import matplotlib.pyplot as plt

#Inputs
#Drag coefficient
C_d=0.8

#Frontal Area(m^2)
A=0.1

#Density(kg/m^3)
rho=1.2

#Bicycle velocity
velocities=[5,6,7,8,9,10,11,12]
drag_forces=[]

for velocity in velocities:
    drag_forces.append(0.5*C_d*rho*A*velocity*velocity)
print(drag_forces)

#Plotting
plt.plot(velocities,drag_forces)
plt.xlabel('Velocity')
plt.ylabel('Drag Force')
plt.title('Velocity vs Drag Force')
plt.show()


Explanation of code

1.First import the math library and matplotlib libary.

2.Creating the variables required and assigning values to them.

3.Here velocity is considered as an array so as to calculate different values of drag force for different velocities to understand the variation of velocity with drag force.

4.Next, drag_forces array is kept null and 'for loop' is executed to calculate the drag force for different velocities using the formula and are then stored in the drag_forces array using 'append' command.

5.Then plt.plot(), plt.title, plt.xlabel and plt.ylabel commands are used to get the graph, title and labels.

6.plt.Show() command is used for showing the plot.

To plot Drag-coefficient vs Drag Force

#program to calculate the drag force
import math
import matplotlib.pyplot as plt

#Inputs
#Drag coefficient
C_d=[0.47,0.42,0.50,1.05,0.80,0.82,1.15,0.04,0.09]

#Frontal Area(m^2)
A=0.1

#Density(kg/m^3)
rho=1.2

#Bicycle velocity
velocity=5
drag_forces=[]

for c_d in C_d:
    drag_forces.append(0.5*c_d*rho*A*velocity*velocity)
    
#plotting
plt.plot(C_d,drag_forces)
plt.xlabel('Drag Coefficient')
plt.ylabel('Drag Force')
plt.title('Drag Coefficient vs Drag Force')
plt.show()

Explanation of code

1.First import the math library and matplotlib libary.

2.Creating the variables required and assigning values to them.

3.Here the coefficient of drag for different shapes are considered to get a varying drag force to understand the variation of drag coefficient with drag force.

4.Next, drag_forces array is kept null and 'for loop' is executed to calculate the drag force for different drag coefficients using the formula and are then stored in the drag_forces array using 'append' command.

5.Then plt.plot(), plt.title, plt.xlabel and plt.ylabel commands are used to get the graph, title and labels.

6.plt.Show() command is used for showing the plot.

Plots:

Errors in programming: No errors were obtained.

Result:

For Velocity vs Drag force, a parabolic curve is obtained as Drag force varies proportionally to V2

For Drag Co-efficient vs Drag force, they vary linearly, hence a straight line is obtained

Conclusion:

The drag force experienced by the cyclists can be reduced by getting down low in a crouched position with elbows in, as there is more streamlined shape and there is less frontal area.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.