Analysis of Aerodynamic Drag Force against a cyclist using Python
Aim:
To write programs in Python to calculate Drag force against a cyclist and to create the following plots:
(1) Velocity vs Drag Force
(2) Drag co-efficient vs Drag Force
Introduction to Drag force:
Drag is a force acting opposite to the relative motion of any object moving with respect to a surrounding fluid. It depends on the properties of the fluid and on the size, shape and speed of an object.
The Drag force is calculated using the formula:
`F = 1/2* rho * A * v^2 * C_d`
where,
`F` is the drag force in `N`
`rho` is the Air density in `(kg)/(m^3)`
`A` is the Frontal area of bicycle with the cyclist in `m^2`
`v` is the Velocity in `m/s`
`C_d` is the Drag co-efficient and is a dimensionless constant
(1) Velocity vs Drag Force:
Python Program:
"""
Program to calculate Drag Force
by Sree Vignesh
"""
import math
import numpy as np
import matplotlib.pyplot as plt
"""
To calculate Drag force:
Drag force = 0.5*rho*A*v*v*C_d
rho = Air density in kg/m^3
A = Frontal area in m^2
v = Velocity of the cyclist in m/s
C_d = Drag co-efficient, a dimensionless constant
"""
#Inputs
#Air density in kg/m^3
rho = 1.225
#Velocity of cyclist in m/s
v = np.linspace(5,10,25)
#Frontal Area in m^2
A = 0.5
#Drag co-efficient
C_d = 1.1
#Drag Force
drag_force = 0.5*rho*A*v*v*C_d
plt.plot(v, drag_force)
plt.xlabel('Velocity (m/s)')
plt.ylabel('Drag Force (N)')
plt.title('Velocity vs Drag Force')
plt.savefig('Velocity vs Drag Force')
plt.show()
Explanation:
Using comments, the title of the program is specified at the start.
The modules such as math, numpy and matplotlib are imported firstly so that we can perform mathematical operations and plotting.
The formula to compute Drag Force is entered under comments section.
Inputs to the program such as Air density, Drag co-efficient, Velocity and Frontal Area are assigned to the respective variables.
The Air density is a constant which is 1.225 kg/m^3
Based on research, the average frontal area of a bicycle and the rider is 0.5 m^2 and the velocity is considered to vary from 5 m/s to 10 m/s on an average.
Velocity is specified using linspace command since there are values ranging from 5 m/s to 10 m/s and 25 values are there in total. linspace can be performed only if numpy module is imported and as np is the keyword for the module, np.linspace() has been entered to perform the operation.
Note that we can also define velocity as an array with values as required and compute drag force. Using linspace command is my choice to execute this program.
The bicycle and the rider are considered to be at the upright position and hence the Aerodynamic drag co-efficient is 1.1
The drag force is calculated using the formula as discussed on the Introduction part
Velocity vs Drag force is plotted using the plot command. To access plot command matplotlib module should be imported and since plt is the keyword to access the module, plt.plot() has been entered to perform plotting operation.
The x and y axes are named as Velocity (m/s) and Drag Force (N) respectively, using plt.xlabel(), plt.ylabel() and title is also given using plt.title() command.
plt.savefig() is used to save the plot with a desired name and plt.show() is used to display the plot after computation.
Result:
We can see that the Drag force varies as the square of velocity and due to this, the curve is parabolic.
(2) Drag Co-efficient vs Drag force:
The above picture shows how the Drag co-efficient varies for various shapes.
Based on this data, we need to observe how the Drag force varies for different values of Drag co-efficients considering same frontal area and velocity.
Python Program:
"""
Variation of Drag force for various shapes
by Sree Vignesh
"""
import math
import numpy as np
import matplotlib.pyplot as plt
"""
Drag coefficient for various shapes
0.47 for Sphere
0.42 for Halfsphere
0.50 for Cone
1.05 for Cube
0.80 for Angled Cube
0.82 for Long cylinder
1.15 for Short cylinder
0.04 for Streamlined body
0.09 for Streamlined Halfbody
"""
#Inputs
#Air density in kg/m^3
rho = 1.225
#Velocity in m/s
v = 10
#Frontal Area in m^2
A = 0.5
#Drag co-efficient
C_d = [0.47,0.42,0.5,1.05,0.80,0.82,1.15,0.04,0.09]
#Drag Force
drag_forces = []
for c_d in C_d:
drag_forces.append(0.5*rho*A*v*v*c_d)
plt.plot(C_d, drag_forces)
plt.xlabel('Drag co-efficient')
plt.ylabel('Drag Force (N)')
plt.title('Drag co-efficient vs Drag Force')
plt.savefig('Drag co-efficient vs Drag Force')
plt.show()
Explanation:
Using comments, the title of the program is specified at the start.
The modules such as math, numpy and matplotlib are imported firstly so that we can perform mathematical operations and plotting.
The data of how Drag co-efficient is varying for each shape are entered under comments section.
Inputs to the program such as Air density, Velocity and Frontal Area are assigned to the respective variables.
The Air density is a constant which is 1.225 kg/m^3
Based on research, the average frontal area of a bicycle and the rider is 0.5 m^2 and the velocity is considered to a constant of 10 m/s
The Drag co-efficient is assigned to a variable C_d as an array (list) with the values as per the picture shown above and in the same order.
The drag force is calculated using the formula as discussed on the Introduction part and since we get an array of values, first I have assigned drag_forces as an empty array. Then, to compute drag force for each value of C_d, I have used for loop and each time when the loop runs, the value is added to the drag_forces array. This is done with the help of append() command.Note that c_d is the iterative variable.
Velocity vs Drag force is plotted using the plot command. To access plot command matplotlib module should be imported and since plt is the keyword to access the module, plt.plot() has been entered to perform plotting operation.
The x and y axes are named as Drag co-efficient and Drag Force (N) respectively, using plt.xlabel(), plt.ylabel() and title is also given using plt.title() command.
plt.savefig() is used to save the plot with a desired name and plt.show() is used to display the plot after computation.
Result:
As we can see from the plot, the drag force varies linearly as the drag co-efficient. Hence the graph is a straight line.
Conclusion:
Drag force against a cyclist was calculated using Python programming and its variation as the square of velocity was observed with the help of a plot. To know how Drag force varies for different values of Drag co-efficient for various shapes, a separate program considering same frontal area and velocity was also coded.