Project

Analysis of drag force over a bicycle using python

"""
Program to calculate the drag force over a bicycle
by Roop
"""
import matplotlib.pyplot as plt
import matplotlib.pyplot as plt2

#Inputs

#Drag co-efficient
c_d = [0.82,0.85,0.87,0.92,1.04,1.08,1.14]

#Frontal area (m^2)
A = 0.57

# Density (Kg/m^3)
rho = 1.2

# Bicycle Velocity (m/s)
velocities = [5,6,7,8,9,10,11]

drag_forces = []

for i in range(len(velocities)):
	
  drag_forces.append((0.5*rho*A*c_d[i]*velocities[i]*velocities[i]))


for drag in drag_forces:
   print(drag) 


plt.plot(velocities,drag_forces)
plt.xlabel('Velocity')
plt.ylabel('Drag Force')
plt.show()

plt2.plot(c_d,drag_forces)
plt2.xlabel('Drag co-efficient')
plt2.ylabel('Drag Force')
plt2.show()

Output Graphs :

1. The graph is for Drag force v/s Velocity

2. The graph is for Drag Force v/s Drag co-efficient of different shapes

3. The value of drag forces

In the given problem we had to find out the drag foce for different velociteis and differnt drag coefficient of different commont shapes. The formula for drag force is:

`Fd=1/2*rho*A*Cd*v^2`

Where, Fd - drag force

Cd - drag co-effeicent

A - frontal area

`rho`- density of fluid

v- velocity of cyclist

Explaination of submitted code:

  • At start we had to import matpolt library as we need plots for our output. But i have imported 2 different matplot library variables namely plt & plt 2 this is to avoid of over writing of plots.
  • After that we define the variables we require for execution of programme, namely , Cd , A , rho , v. While defining Cd we have used an array as we need multiple values for differnt shapes having same area simliarly we need different velocities. But when we defined drag forces we have put it as an empty array as we want the calculated values to fill up the array.
  • First loop i have used range and length operators to go full length of velocity i.e 0,1,2,3,4,5,6 this helps in getting each value of velocity to be used in the loop and same goes for drag force coefficent. The range operator fixed the range of 0-6 and no extra values are to be included. This loop gives values of the drag force and fills the empty array of drag foce.
  • The second loop prints the values of the out put drag forces.
  • The plot commands at the end plots the required graps we had already defined the variable for plotting as plt & plt2 so we are able to obtain 2 graphs as our output .
  • Also , we have used the append command in calcualtion of drag force as , append adds the argument at the end of the list i.e every new value is added in the list after being calculated . The new value is added from the end .
Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.