Flow over bicycle and other shapes using PYTHON
AIM: A Python program to calculate drag force.
INTRODUCTION: Here to calculate the drag force the required parameters are velocity, density, frontal area, drag co-efficient respectively.
`F_d=1/2*rho*A*v^2*C_d`
`F_d` - Drag force (kg.m/s)
`rho` - density(kg/m^3)
A - frontal area (m^2)
V - velocity (m/s)
`C_d` - Drag co-efficient
Implementation
-To plot Velocity vs Drag force using Python
The inputs given are the area, drag co-efficeint, density which are single valued entities and also velocity which is an array type where in this program it is written in the form of a loop with incremental velocity which is appended to the defined empty array in order to form an array of various input velocity values for which the drag fore is to be calculated as per the above equation respecively for each value of the velocity and the optained value of drag force is appended to the defined empty array of the drag force.
Later the found values of velocity and drag force in the form of an array are used to plot a graph by using the matplotlib.pyplot module which is to imported and used as plt (for simple usage).
In order to use the module, syntax is as follows
plt.plot(velocity,drag force)
The following is the code for the plot between velocity vs drag force.
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
velocities=[]
drag_forces=[]
velocity=4
for i in range(0,7):
v=velocity+i
fd=0.5*rho*c_d*A*pow(v,2)
velocities.append(v)
drag_forces.append(fd)
print(velocities)
print(drag_forces)
plt.plot(velocities,drag_forces)
plt.xlabel('velocity')
plt.ylabel('drag force')
plt.title('velocity vs drag co-efficient')
plt.show()
The above code gives the following output and plot.
It is observed that the variation of the drag force with respect to the velocity is not linear.
This is because as the other inputs like frontal area, density, drag co-efficients are contants and velocity varies so, drag force is directly proportional to the square of the velocity i.e. there is quadratic relationship, there by we can say that the plot between velocity anadd drag force is always non linear.
- To plot Drag Co-efficient vs Drag force using Python
The inputs given are the density, frontal area, velocity as a single valued entities and also the drag co-efficient as an array of multiple values of different types of shapes with the same frontal area. This array is formed by using the data from online research and are as follows.
| Shape | Drag Coefficient |
| Sphere | 0.47 |
| Half-sphere | 0.42 |
| cone | 0.5 |
| cube | 1.05 |
| angled cube | 0.85 |
| long cylinder | 0.82 |
| Short cylinder | 1.15 |
| Streamlined body | 0.04 |
| Streamlined half-body | 0.09 |
| flat plat | 1.24 |
| Bullet | 0.29 |
By using the above informtion an array of drag coefficients is used and it is indexed using a for loop to acces each value in order to evaluate the value of the drag force and the found value is appended to the defined empty array of the drag force. Doing so, the final array of the drag force for the respective drag co-efficients is found and then they are plotted using the matplotlib.pyplot module as plt (for simple usage)
The following is code for the plot of drog co-efficientt vs drag force.
mport math
import matplotlib.pyplot as plt
#inputs
#frontal area(m^2)
A=0.1
#density(kg/m^3)
rho=1.2
#velocity(m/s)
v=20;
'''
drag coefficients for different shapes with same area
1.Sphere cd=0.47
2.Half-sphere cd=0.42
3.cone cd=0.5
4.cube cd=1.05
5.angled cube cd=0.85
6.long cylinder cd=0.82
7.Short cylinder cd=1.15
8.streamlined body cd=0.04
9.streamlined half-body cd=0.09
10.flat plat cd=1.24
11.Bullet cd=0.29
'''
drag_force=[]
c_d=[0.47,0.42,0.5,1.05,0.85,0.82,1.15,0.04,0.09,1.24,0.29]
for cd in c_d:
fd=0.5*rho*A*cd*pow(v,2)
drag_force.append(fd)
print(drag_force)
plt.plot(c_d,drag_force)
plt.xlabel('drag co-efficeint')
plt.ylabel('drag force')
plt.title('drag co-efficent vs drag force')
plt.show()
The output for the above code is as follows
It is observed that from the above plot that the variation of the drag force with respect to the drag co-efficient is linear. As the inputs of frontal area, velocity density are constant and the drag co-efficent varies for the same frontal area, the drag force is dieclty proportional to the drag co-efficient as a linear relation.