Project

TO WRITE THE PROGRAM FOR FLOW OVER BICYCLE USING PYTHON

AIM

To write a Python program to calculate drag force against a cyclist and plot the different graph as mention below

  1. Velocity vs Drag force
  2. Drag Co-efficient vs Drag force

FORMULA USED

Drag force,

`F= 1/2.Cd.ρ. A.V^2`

Where,

Cd = Drag coefficient

ρ= Density of the fluid or air (`(Kg)/m^3`)

A = Area (`m^2`)

V = velocity (`m/s`)

BODY OF CONTENT

Introduction

A drag force is the resistance force caused by the motion of a body through a fluid, such as water or air. A drag force acts opposite to the direction of the oncoming flow velocity. This is the relative velocity between the body and the fluid

Different shape having different values of coefficient of drag like sphere, cone cube, angle cube, half sphere, cylinder, streamlined body etc which is shown below

Steps of program to be used for both the cases

  1. Provide topic of the code which is under comment
  1. Calling of library which will used for plotting and calculating.
  1. Providing input data

For case 1- when drag coefficient is constant and velocity array is used to obtain the plot for different velocity.

For case 2- when velocity is constant and drag coefficient array is used to obtain the plot for different drag coefficient.

  1. Creating a empty array for storing data which is named as drag_force
  1. By the help of for loop we calculate and stored the value of drag force inside the empty array by the help of append command.

Case 1. For drag coefficient to be constant

Case 2. For velocity to be constant

  1. At last the program is used to plot the curve and to enable feature which is used in plot like labelling and grid used.

After that final step is to give a command to show the plot.

Program For Flow Over Bicycle

Case 1. When drag coefficient is assumed to be constant to obtain the velocity vs drag force plot

"""
Program to calculate drag force
"""

#Importing math library 
import matplotlib.pyplot as plt


#input
#drag coefficient
c_d = 0.8

#frontal area (m^2)
A = 0.1

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

# Bicycle velocity (m/s)
velocities = [50,60,70,80,90,100,110,120]

#empty array of drag force
drag_forces = []


#For loop for calculation of drag force
for velocity in velocities:


	#Calculating and Storing the values of drag force inside the aaray
	drag_forces.append(0.5*rho*A*c_d*velocity*velocity)


#plot of velocity vs drag force
plt.plot(velocities,drag_forces)

#labelling of X and Y axis
plt.xlabel('Velocity')
plt.ylabel('Drag forces')
#To show the grid lines on the plot
plt.grid() 

#command to show the plot generated
plt.show()

Case 2. When velocity is assumed to be constant to obtain the drag coefficient vs drag force plot

"""
Program to calculate drag force for different coefficient of drag values
"""

#Importing math library
import matplotlib.pyplot as plt

#input

#frontal area (m^2)
A = 0.1

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

# Bicycle velocity (m/s)
velocity = 50

#array of drag coefficient
c_d = [0.04,0.09,0.42,0.47,0.50,0.80,0.82,1.05,1.15]

#empty array of drag force
drag_forces = []


#For loop for calculation of drag force which takes the value from C_d and give to drag coeffficient 
for drag_coefficient in c_d:


	#Calculating and Storing the values of drag force inside the aaray
	drag_forces.append(0.5*rho*A*drag_coefficient*velocity*velocity)


#plot of Drag coefficient vs drag force
plt.plot(c_d,drag_forces)

#labelling of X and Y axis
plt.xlabel('Drag coefficient')
plt.ylabel('Drag forces')
#To show the grid lines on the plot
plt.grid() 

#command to show the plot generated
plt.show()

RESULTS

Case 1. Plot of velocity vs drag force

Case 2. Plot of coefficient of drag vs drag force

ERROR OBTAIN DURING PROGRAMMIG

  1. I have used drag_coefficient in for loop but I have not change it inside the for loop I have written c_d inside the for loop. So by changing the c_d inside the for loop program is working

CONCLUSION

Case1. The curve is not linear, it is actually a polynomial of second order because in drag force formula there is term velocity which is having power two.

Case2. The curve is linear because here the velocity is assumed to be constant. So the curve is linear.

REFERENCES

  1. skill lync video lecture
  2. https://en.wikipedia.org/wiki/Drag_coefficient
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.