Flow over Bicycle using Python
In this program, we are going to code a program to find the drag force acting on a person riding a bicycle. The drag force depends on the following parameters namely - Drag coefficient, density of fluid, frontal area, velocity. Since we have to plot two different figures, we are assigning a constant drag coefficient for the first plot whereas on the second plot, we are assigning a constant velocity. The values of drag force are gievn as input in a for loop according to the variable used. The code is seen below -
"""
Program to calculate the drag force
by Danish
"""
# Importing matplot function for plotting
import matplotlib.pyplot as plt
# Inputs
# Drag coefficient
c_d_constant = 0.8
coefficients = [0.5,0.6,0.7,0.8,0.9,1,1.1,1.2]
# Frontal Area
A = 0.1
# Deansity
rho = 1.2
# Bi-cycle velocity
v_constant = 8
velocities = [5,6,7,8,9,10,11,12]
# Drag forces
drag_forces_1 = []
drag_forces_2 = []
for velocity in velocities:
drag_forces_1.append(0.5*rho*A*c_d_constant*velocity*velocity)
for coefficient in coefficients:
drag_forces_2.append(0.5*rho*A*coefficient*v_constant*v_constant)
# Plotting first figure
plt.figure(1)
plt.plot(velocities,drag_forces_1)
plt.xlabel('Velocity')
plt.ylabel('Drag force')
plt.show()
# Plotting second figure
plt.figure(2)
plt.plot(coefficients,drag_forces_2)
plt.xlabel('Drag Coefficient')
plt.ylabel('Drag force')
plt.show()
The results can be viewed in the plots below -