Project

Flow over bicycle using Python

Flow over bicycle using Python

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

Objectives - Program to calculate drag force against a cyclist and plot

Velocity vs Drag force

Drag Co-efficient vs Drag force

Python Code For Drag Force

import math
import matplotlib.pyplot as plt
import numpy as np

# Drag Force Calculation
#Inputs

# Frontal Area(m^2)
A = 0.4

# Velocities(m/s)
velocities = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]

# Drag Coefficients 
cd = [0.0454,0.295,1.14,1.28]

# Density  of Air(kg/m^3)
rho = 1.225

Drag_Force = []

for velocity in velocities:
	for c_d in cd:
		Drag_Force.append((0.5*rho*A*c_d*velocity*velocity))


print(Drag_Force)

Python Code for Drag force for various velocities

import math
import matplotlib.pyplot as plt
import numpy as np

# Drag Force Calculation
#Inputs

# Frontal Area(m^2)
A = 0.4

# Velocities(m/s)
velocities = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]

# Drag Coefficients 
cd = 0.8

# Density  of Air(kg/m^3)
rho = 1.225

Drag_Force = []

for velocity in velocities:
	Drag_Force.append((0.5*rho*A*cd*velocity*velocity))


print(Drag_Force)

plt.plot(velocities,Drag_Force)
plt.xlabel('velocity')
plt.ylabel('Drag Force')
plt.show()

Python Code for Drag force for various drag coefficients

import math
import matplotlib.pyplot as plt
import numpy as np

# Drag Force Calculation
#Inputs

# Frontal Area(m^2)
A = 0.4

# Velocities(m/s)
velocity = 2

# Drag Coefficients for different shapes
cd = [0.0454,0.295,1.14,1.28]

# Density  of Air(kg/m^3)
rho = 1.225

Drag_Force = []

for c_d in cd:
	Drag_Force.append((0.5*rho*A*c_d*velocity*velocity))


print(Drag_Force)

plt.plot(cd,Drag_Force)
plt.xlabel('Drag Coefficients')
plt.ylabel('Drag Force')
plt.show()

Output Plots

Drag Co-efficient vs Drag force

Velocity vs Drag force

Explanation for Output Plots

1. For plot of drag force vs drag coefficients , the graph is a straight line because the drag coefficient is directly proportional to drag force.

2. For plot of drag force vs velocity, the graph is parabolic because the drag force is directly proportional to the square of the velocities.

3. The main code was written for an array of velocities and an array of drag coefficients and the drag forces were calculated.

Conclusion

Hence the code for drag force with varying velocities and drag coefficients are calculated and the results plotted.

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.