FLOW OVER THE BICYCLE USING PYTHON
AIM: To determine the drag force over the flow of bicycle and plot the graph between drag force vs velocity and drag force vs drag coefficient.
For the calculation of the drag force following expressesion is given :
`F=.5*cd*rho*A*v^2`
Factor involove in the calculation of the drag force is drag coeffiecient ,velocity , density and the frontal are
Stepwise explanation f the code :
- First of all import tha python module like math, matplotlib.plot and numpy show that tha mathematical operation can be perform and plot should obtain.
- After that define the input variables and coefficient of drag and velocity in tha array form.
- module .
- Again use the for loop to obtain the different value of the drag force corresponfing to the different value of drag coefficient and plot them.
- To save the image use the command savefig and define the format i.e png
CODE FOR THE CALCULATION OF THE DRAG FORCE:
# drag force calculation
# input variables
import math
import matplotlib.pyplot as plt
import numpy as np
# drag coefficient
cd=.5
drag_coeffs=[.22,.24,.26,.28,.30,.32,.34,.36,.38,.40,.42,.44,.46,.48,.50,.52,.54,.56,.58,.60,.62,.64,.66,.68,.7]
# density
rho=1.2
# area
a=2
# velocity
V=[2,2.5,3,3.5,4,4.5,5,5.5,6,6.5,7,7.5,8,8.5,9,9.5,10,10.5,11,11.5,12,12.5,13,13.5,14]
# drag force calculation
drag_forces=[]
for v in V:
drag_forces.append(.5*cd*rho*pow(v ,2))
print(drag_forces)
plt.plot(V,drag_forces)
plt.xlabel('velocity')
plt.ylabel('drag_force')
plt.savefig('plot1.png')
plt.show()
drag_forces_cd=[]
for drag_coeff in drag_coeffs:
drag_forces_cd.append(.5*drag_coeff*rho*a*pow(v,2))
print(drag_forces_cd)
plt.plot(drag_coeffs,drag_forces_cd)
plt.xlabel('drag_coeff')
plt.xlabel('drag_force')
plt.savefig('plot2.png')
plt.show()
RESULTS:
1. Drag force vs velocity
2. Drag force vs drag coefficient: