Project

Python - Flow over Bicycle

Drag Force acting over a Cyclist - Python

1.AIM:

  • To calculate drag force acting on a cyclist driving the cycle using Python.

2.GOVERNING EQUATIONS IF ANY:

`Drag(F)= 1/2 ρAV^2 C_d`

Where, ρ= density of the fluid in which cycle and cyclists exist (`(kg)/m^3`)

A= Frontal area / front area of exposure of cyclist (`m2`)

V = velocity of the cyclist respective to the fluid (`m/s`)

`C_d`= Drag coefficient (unitless)

Pressure = and thus, Drag Force = Pressure x Area x (some constant,`C_d` )

So, we get Drag Force (F) = `1/2 ρV^2 AC_d`

3.OBJECTIVES OF THE PROJECT:

- To find the total drag force acting on cyclist and cycle travelling with some velocity through a fluid medium.

- Write a Python program to calculate drag force against a cyclist.

- Write a program to plot Velocity vs Drag force.

- Write a program to plot Drag Co-efficient vs Drag force.

4.FLOW OF THE PROJECT

  1. Assign values to the input variables.
  2. Get the value of drag force using the formula.
  3. Plot the graphs mentioned in the objectives.

5.PYTHON CODE

import matplotlib.pyplot as plt
import numpy as np

#Input parameters
c_d = [0.04,0.09,0.42,0.47,0.82,1.15]       #Drag coefficient
A = 0.1                                     #Frontal Area (m^2)
rho = 1.2                                   #Density (kg/m^3)
v = [5,6,7,8,9,10,11,12]                    #bicycle velocity (m/s)

plt.figure(1)
for cd in c_d:                                       #assuming 1 value of c_d at a time because we want to plot velocity v/s drag force
	drag_force = []                                  #Empty array to store drag force values
	for vel in v:                                    #for every velocity value we are calculating drag force
		drag_force.append(0.5*rho*cd*A*vel*vel)      #drag force getting added into the drag_force array
	plt.plot(v,drag_force)                           #plotting graph of velocity vs drag force
	plt.xlabel('Velocity')
	plt.ylabel('Drag Force')
	plt.grid(True)                                   #Enabling the grid
plt.axis([0,12,0,10])                                #Setting up the axis in ([x1,x2,y1,y2])
plt.xticks(np.arange(0,13,1))                        #Uniformly adding the ticks in x axis from 0 to 12 with gap of 1 unit
plt.savefig('vel_force')                             #saving current figure
plt.show()                                           #Display graph on screen

plt.figure(2)
for vel in v:
	drag_force = []
	for cd in c_d:
		drag_force.append(0.5*rho*cd*A*vel*vel)
	plt.plot(c_d,drag_force)
	plt.xlabel('Drag Coefficient')
	plt.ylabel('Drag Force')
	plt.grid(True)
plt.axis([0,1.2,0,10])
plt.yticks(np.arange(0,11,1))
plt.savefig('coeff_force')
plt.show()

Code Explaination:

- Apart from the code comments, one thing has to be noted, that is in the 2 for loops used, in case 1, `C_d` is treated as constant per plot line and in case 2, velocity is treated as constant per plot line because for plotting graph of Velocity v/s Drag force, rest all is constant, similarly for Drag coefficient v/s drag force.

- Numpy is imported just for getting a array of numbers for x-ticks and y-ticks on graph.

6. OBSERVATIONS:

Figure 1: Velocity v/s Drag Force

Figure 2: Drag Coefficient v/s Drag Force

7. CONCLUSION:

- From Figure 1, we can say that as velocity increases, drag force also increases. The plot verifies the quadratic nature of the direct proportion of drag force with velocity.

- From Figure 2, we can say that as drag coefficient increases, drag force also increases. The plot verifies the linear nature of direct proportion of drag coefficient with drag force.

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.