FLOW OVER BICYCLE USING PYTHON
1.AIM :
TO WRITE A PYHTON PROGRAM TO CALCULATE DRAG FORCE AGAINST A CYCLIST
2.OBJECTIVE:
- To write a Python program to calculate drag force against a cyclist.
- To plot Velocity vs Drag force.
- To plot Drag Co-efficient vs Drag force.
3.INTRODUCTION:
When a body moves in a fluid medium against the flow, the body experiences force and this force can be resolved into 2 components, which is Drag force (along the direction of flow) and Lift force (perpendicular to the direction of flow).
Here, this work is performed for flow over a bicycle and drag force against a cyclist is calculated.
The drag force against a body is calculated using equation:
`F_d = 1/2*rho*A*V^2*C_d`
where, `F_d = "Drag force"`
`rho = "density of fluid"`
`A = "Frontal area"`
`V="Velocity"`
`C_d ="Drag coefficient"`
Here a Python program is written to calculate drag force against a cyclist and plots are made for 2 cases.
CASE 1
Here Drag force is calculated for various velocities and plot for Velocity vs Drag force is made.
25 values between 1 and 5 m/s are given as an input to calculate drag force.
CASE 2
For the same frontal area, the coefficient of drag varies for different shapes.
Here Drag force is calculated for various Drag coefficient and plot for Drag Coefficient vs Drag force is made.
25 values of Drag coefficient is given as an input to calculate drag force.
Input values - 0.045, 0.07, 0.08, 0.09, 0.10, 0.12, 0.15, 0.18, 0.20, 0.22, 0.25, 0.295, 0.30, 0.32, 0.35, 0.38, 0.40, 0.42, 0.45, 0.46, 0.48, 0.49, 0.50, 1.14, 1.28
4.PYTHON PROGRAM :
CASE 1
#Program to calculate the drag force
import matplotlib.pyplot as plt
import numpy as np
#inputs
#Drag co-efficient
cd=0.8
#Frontal area (m^2)
A=0.1
#density (kg/m^3)
rho=1.2
#Bicycle velocity
v = np.linspace(1,5,25)
#initializing drag force variable
drag_forces=[]
#calculating drag force corresponding to each velocity
for velocity in v:
drag_forces.append((0.5*cd*rho*A*velocity*velocity))
#plotting velocity v/s drag force curve
plt.plot(v, drag_forces)
plt.xlabel('Velocity')
plt.ylabel('Drag force')
plt.show()
Explanation:
- Initially matplotlib and numpy library is imported, matplotlib is used for plotting and numpy is used for linspace function.
- Input variables Drag coefficient, Frontal Area, Density of air is initilaized and for velocity an array is initialized with 25 elements from 1 to 5 m/s (using linspace function).
- Using for loop the value for drag force is calculated at every velocity velocity and appended to the drag force variable array using append command.
- Finally after calculating every value velocity v/s drag force plot is made and graph axis are labelled with respective name.
CASE 2
#Program to calculate the drag force
import matplotlib.pyplot as plt
#inputs
#Drag co-efficient
cd=[0.045, 0.07, 0.08, 0.09, 0.10, 0.12, 0.15, 0.18, 0.20, 0.22, 0.25, 0.295, 0.30, 0.32, 0.35, 0.38, 0.40, 0.42, 0.45, 0.46, 0.48, 0.49, 0.50, 1.14, 1.28 ]
#Frontal area (m^2)
A=0.1
#density (kg/m^3)
rho=1.2
#Bicycle velocity
v = 2
#initializing drag force variable
drag_forces=[]
#calculating drag force corresponding to each velocity
for CD in cd:
drag_forces.append((0.5*CD*rho*A*v*v))
#plotting drag coefficent v/s drag force curve
plt.plot(cd, drag_forces)
plt.xlabel('Drag coefficent')
plt.ylabel('Drag force')
plt.show()
Explanation:
- Initially matplotlib library is imported, this library is used for plotting.
- Input variables Velocity, Frontal Area, Density of air is initilaized and for Drag coefficient an array is initialized with 25 elements.
- Using for loop the value for drag force is calculated at every Drag coefficient value and appended to the drag force variable array using append command.
- Finally after calculating every value Drag coefficient v/s drag force plot is made and graph axis are labelled with respective name.
5.RESULTS :
CASE 1
Velocity v/s Drag force plot
As it can be seen from the Drag force formula, the drag force is directly proportional to square of velocity, this is why the plot has a parabolic nature and drag force being proportional to velocity increases with increase in velocity.
CASE 2
Drag coefficient v/s Drag force plot
As it can be seen from the Drag force formula, the drag force is directly proportional to the drag coefficient, this is why the plot has a linear nature and drag force being proportional to drag coefficient increases with increase in velocity.
6.CONCLUSION :
The python program to calculate drag force against a cyclist was written and plot for Velocity v/s Drag force and Drag coefficient v/s Drag force was made successfully.
7.REFERENCES :