Project

Flow Over Bicycle using Python

Aim: Program to calculate the Drag Force against a cyclist and to plot -

i) Velocity vs Drag Force

ii) Drag Coefficient vs Drag Force

Governing Equation: FD = ½*ρ* A* V² *CD

where;

FD -------> Drag Force (Kg m/s^2)

CD -------> Drag coefficient

ρ ---------> Density (Kg/m^3)

A ---------> Frontal Area (m^2)

V ---------> Flow velocity relative to the object (m/s)

Theory:

Drag force always opposes the motion of an object. Unlike simple friction, the drag force is proportional to some function of the velocity of the object in that fluid. This functionality is complicated and depends upon the shape of the object, its size, its velocity, and the fluid it is in. For most large objects such as bicyclists, cars, and baseballs not moving too slowly, the magnitude of the drag force FD is found to be proportional to the square of the speed of the object. We can write this relationship mathematically as,

FD ∝ V²

When taking into account other factors, this relationship becomes,

FD = ½* ρ * A* V² *C

In this project, I have made use of Python as a scripting language to compute the Drag Force.

Plots:

(1) A program to calculate drag force against a cyclist and to plot Velocity vs Drag Force.

#Program to calculate the Drag Force on a bicycle
#Importing the basic libraries/ modules
import math

import matplotlib.pyplot as plt

#inputs

#Drag co-efficient
c_d = 0.8

#Frontal area(m^2)
A =0.1

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

#Bicycle velocity (m/s)
velocities = [5,6,7,8,9,10,11,12]
drag_forces =[]

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

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

plt.show()

Concise Description of the code:

In the above program, we are going to find the drag force acting on a person riding a bicycle.

In order to successfully execute the program, we import two basic libraries: namely math library and mathplot library.

As drag force depends upon the following parameters- Drag coefficient, density of fluid, frontal area, and velocity. So, we create the variables for these parameters and later assign the values to these variables.

As we have to plot two different figures, we are assigning a constant drag coefficient for the first plot. Here, velocity is an array as we have to calculate different values of drag force for different velocities to understand the variation between velocity and drag force.

Later, the darg_forces array is kept as null, and a for loop is executed to calculate the drag force for different values of velocities using the formula and the values are then appended and stored in the drag_forces array. For doing so, here we make use of 'append' command which stores every value of drag force as the loop proceeds.

Using plot command the graph gets plotted, and corresponding labels are assigned for both x-axis and y-axis.

Finally, using the show command the plot appears on the screen.

Plot:

The above plot depicts that the drag force is directly proportional to the square of the velocity. The plot is a parabolic curve.

(2)A program to calculate drag force against cyclist and to plot Drag Co-efficient vs Drag force.

#Program to calculate the Drag Force on a Bicycle
#Importing the basic libraries/ modules
import math

import matplotlib.pyplot as plt

#inputs

#Drag co-efficient of various shapes like sphere, hemisphere, cone, cube etc
C_d = [0.04,0.09,0.42,0.47,0.50,0.80,0.82,1.05,1.15]

#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*velocity*velocity*A)

plt.plot(C_d,drag_forces)
plt.xlabel('Drag co-efficient')
plt.ylabel('Drag Force')
plt.title('Drag co-efficient vs Drag Force')

plt.show()

Concise description of the code:

Firstly, we import the two basic libraries/modules - math library and mathplot library.

Next, we create the variables for the parameters which affect the Drag Force and assign the values to them.

Here, different drag coefficients are considered to understand the variation between drag coefficient and drag force. Also, we assign a constant to the velocity variable.

Later, the darg_forces array is kept as null, and a for loop is executed to calculate the drag force for different values of drag coefficients using the formula and the values are then appended and stored in the drag_forces array. For doing so, here we make use of 'append' command which stores every value of drag force as the loop proceeds.

Using plot command the graph gets plotted, and corresponding labels are assigned for both x-axis and y-axis.

Finally, using the show command the plot appears on the screen.

Plot:

This resultant plot shows that the drag force is increasing linearly with the drag coefficient values. Hence, we can say it is linearly proportional.

RESULT :

Thus, the drag forces were calculated and the two graphs are plotted for the questions mentioned.

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.