Flow over bicycle using Python
The aim of this project is to calculate the amount of drag force acting against the cyclist and to study the various factors affecting the drag force.
Drag Force is defined as:
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.
The expression for drag force is given as:
`F=1/2 ρAV^2 C_d`
Where `rho` is the density of Air
A is the frontal area of the cyclist
V is the velocity with which the cyclist is moving
Cd is the drag coefficient
A Python code was written and compiled using Sublime Text to calculate the drag force on a cyclist in different conditions.
First the code to calculate the effect of velocity of cyclist on drag force was executed. The code sample is as below:
#Program to calculate drag force on a bicycle
#Abhinandhan Narayanan
import matplotlib.pyplot as plt
#Constant Inputs
c_d = 0.8 #Drag Coefficient
A = 0.1 #Frontal Area
rho= 1.2 #Denisty of Air
#Velocity of cycle
velocities= [1,2,3,4,5,6,7,8,9,10]
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()
The first two lines of the codes are comments which show why the program was written and the author of the program.
Then the matplotlib module was imported using the short name plt. It is the plotting module in python and an extension of Numpy the numerical mathematics module. Graphs can be plotted only after the module has been imported.
Following this all the inputs have been initialised. For the first case the drag coefficient has been assumed to be constant at 0.8. The frontal area of the cyclist has been assumed to be 0.1 m2. The shape and dimensions of the cyclist has not been taken into consideration to avoid complication. The density of air can be assumed as constant as this is an incompressible flow simulation. 1.2 kg/m^3 was assumed to be the density.
The velocity of the cyclist was assumed to be from 1 m/s to 10 m/s and an array was initialised and the values were assigned. An empty array was created to store the values of drag force that would be calculated.
Inside the for loop the drag force of each and every value of velocity is calculated and then being appended in the drag force array. The loop runs 10 times as there are 10 values of velocity.
After the loop has ended each value of the drag force is printed out using the print command. And a plot between velocity and drag force is made using the plot command. The show command must always accompany the plot command to ensure that the plot is displayed.
The plot between velocity and drag force is as seen below:
We can see that drag force increases in some sort of exponential curve as velocity increases. The smoothness of the curve can be increased by calculating drag force for finer velocity values. The increase in drag force w.r.t velocity can be attributed by the fact that the force is proportional to the square of velocity.
Variation of Drag force with Drag Coefficient:
The code to figure out the variation of drag force with respect to drag coefficient can be seen below:
#Program to calculate drag force on a bicycle
#Abhinandhan Narayanan
import matplotlib.pyplot as plt
#Constant Inputs
velocity = 10 #Let us assume the velocity to be constant at 10m/s
A = 0.1 #Frontal Area
rho= 1.2 #Denisty of Air
#Velocity of cycle
c_drags= [1.28,1.14,0.295,0.7,0.045,0.165]
drag_force = []
for c_drag in c_drags:
drag_force.append((0.5*rho*A*velocity*velocity*c_drag))
print (drag_force)
plt.plot(c_drags,drag_force)
plt.xlabel('Drag Coefficient')
plt.ylabel('Drag Force')
plt.show()
The code structure is similar to the previous program. The first two lines are comments and then initialisation of values follow. In this case the velocity was assumed to be the constant value at 10 m/s, and not drag coefficient. The values of area and density were assumed to be the same. Now an array of drag coefficient was initialized. The value of c_d for different shapes are NASA prescribed values of drag coefficient for different shapes.
The variation of drag force with drag coefficient can be seen as below:
The variation of drag force is observed to be linear with drag coefficient. This can be reasoned using the fact that drag force is directly proportional to drag coefficient.
Conclusion:
The program for calculating the drag force on a cyclist has been written and compiled and the effect of velocity and drag coefficient on the force has been studied.