Project

Flow over bicycle using Python

Aim : To calculate drag force over a bicycle using Python

Introduction : Drag force is also called air resistance is a force that acts in the opposite direction to the motion of the object. This force can exist between two surfaces of solid or fluid layers. Drag force depends on velocity.

Drag force is proportional to the velocity for a laminar flow and the squared velocity for a turbulent flow. Even though the ultimate cause of a drag is viscous friction, the turbulent drag is independent of viscosity.

Drag forces always decrease fluid velocity relative to the solid object in the fluid's path.

where,

Following are the coefficient of discharge for some examples :

OBJECT

Cd

Airfoil

0.05

Toyota Camry

0.28

Sphere

0.45

Skydiver (horizontal)

1.0

Honda Civic

0.36

Circular flat plate

1.12

Dodge Ram pickup

0.43

Code to calculate Drag force :

import math
import matplotlib.pyplot as plt
import numpy as ny
A = 0.1
rho = 1.1
C_d = 0.8

V = int(input("Enter number of velocities: "))
Velocities=[]
for i in range(1,V+1):
    Velocities.append(int(input("Enter the value of Velocity {}: ".format(i))))
   
print(Velocities)
drag_force = []
for velocity in Velocities:
    drag_force.append(0.5*rho*A*velocity*velocity*C_d)

print(drag_force)
plt.plot(Velocities,drag_force)
plt.xlabel('Velocity')
plt.ylabel('Drag Force')
plt.show()

Code Explanation :

  • First import the required libraries like math and matplotlib.pyplot in order to perform mathematical operations and create plots respectively.
  • The A, rho and C_d are the known values and represent Frontal area, Air density and Coefficient of Discharge respectively. The code then asks the user to enter the number of velocities for which drag force is to be calculated.
  • The for loop is used in order to fill-up the array of Velocities. For this .append command is used.
  • Similarly another blank drag force array is nominated to store the values of the calculated drag force for each velocity. This is performed using another drag force.
  • The results are obtained by printing the array.
  • Next in order to plot the graph between Velocities and drag forces plt.plot command is used. Here we should note that the imported library matplotlib.pyplot is used as plt.

Code to calculate Coefficient of Drag :

import math
import matplotlib.pyplot as plt
import numpy as ny

c_d = ny.linspace(0.6,1.2,20)
rho = 1.2
A = 0.1
V = 15
drag_force =[]
for cd in c_d:
    drag_force.append(0.5*rho*A*V*V*cd)
print(drag_force)
plt.plot(c_d,drag_force)
plt.xlabel('Coefficient of Discharge')
plt.ylabel('Drag Force')
plt.show()

Code Explanation :

  • First import the required libraries like math and matplotlib.pyplot in order to perform mathematical operations and create plots respectively. numpy library is used to use the command linspace.
  • The A, rho and C_d are the known values and represent Frontal area, Air density, and Coefficient of Discharge respectively.
  • Next, a blank array is created namely drag_force.
  • Then for loop is used to calculate the value of drag force for each value of the coefficient of drag. And with the help of .append command the drag_force array is filled with the values of drag forces.
  • Then the values of drag_force array is printed and plt.plot command is used to plot the plotg between coefficient of drag and drag force.
  • show() command shows the generated plot.

Results :

  • Plot 1 : Velocity V/S Drag Force.

  • Plot 2: Coefficient of Discharge V/S Drag Force.

Inference :

  • From plot 2, it can be seen that the Drag force Linearly increases with an increase in the Coefficient of drag. It could be seen that the Drag Force is directly proportional to the Coefficient of Drag.
  • From plot1 it can be seen that there is drastic growth in the drag force with an increase in the Velocity.

Reference :

Bert Blocken , Thijs van Druenen , Yasin Toparlar , Thomas Andrianne, Aerodynamic analysis of different cyclist hill descent positions

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.