Project

Calculation of Drag force against a cyclist using python

Objective:

  • To find the Drag forces against a cyclist and
  • To show the variation of Drag forces w.r.t velocities and Drag_coefficient and show in a graph.

Problem Statement:

  • The problem here defined is to show the result of different values of Drag force when we change the parameter viz., velocity, and drag_coefficient separately.
  • To show the result by using python.

Solution procedure:

I hereby mention below the following steps where I explained the procedure to get the required result that I code in python.

  • First I understand the Drag force and their mathematical relation with their dependent variable.

The mathematical relation is......

Drag force = (0.5⋅ρ⋅area⋅cd⋅velocity⋅velocity)

where, ρ=density; area=Frontal area; cd=Drag coefficient.

  • And here comes the coding part.
  1. Here the problem-related to flow over a bicycle is depicted for different velocities and Drag_coefficient separately.
  2. First I import the required module viz., math, and matplotlib.
  3. Secondly, I put the required constant parameter viz., frontal area, density. and here we need to change the velocity and drag_coefficient separately. and the catch here is while we want to see the change of drag forces w.r.t velocity than we need to keep the drag_coefficient constant and vice versa.
  4. Here we want to see the variation, therefore, the array is used for velocity variation and the same for Drag_coefficient variation. In both cases, we used an empty array to store the value of the Drag force.
  5. And using a for loop and append we could see the variation of Drag force w.r.t different velocity and Drag_coefficient separately. and Print the Drag forces.
  6. Now giving a title and plotting a graph using matplotlib. Here I do mention the color for both title and label in Y and X-axis.
  7. Naming the X-axis and Y-axis and putting the legend and lastly used the function to show the graph all by using matplotlib.

I hereby wrote the code clearly and depicted whatever I mention above in the numbered list.

Result and Discussion:

  • We could finally see the Drag force for different velocities and Drag_coefficient separately.
  • We could plot the graph for... 1) Drag force Vs Velocity; 2) Drag force Vs drag_coefficient.
  • As the graph for Drag force Vs Velocity clearly shows that the graph's curve forms a parabola, which clearly indicates that the relationship between Drag force and Velocity is Quadratic in nature. On the contrary, the graph for Drag force Vs Drag_coefficient is linear in nature.
"""
Problem-related to flow over a bicycle
and plotting the graph for Velocity vs Drag force
"""
# importing the required module
import matplotlib.pyplot as plt
import math

#input
# Drag coefficient (unitless)
c_d = 0.8

# Frontal area (m^2)
A = 0.2

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

# Bicycle velocity
velocities = [5,6,7,8,9,10,11,12,13,14]
drag_forces = []

for velocity in velocities:
	drag_force = (0.5*rho*A*c_d*velocity*velocity)
	drag_forces.append(drag_force)
print(drag_forces)

# Giving a title to my graph
plt.title('Velocity Vs Drag_force', color = 'blue')

# Plotting the velocities and drag_forces
plt.plot(velocities,drag_forces, color ='green', linestyle ='dashed', linewidth = 2,label = 'Drag_force wrt velocity')

# Naming the x- axis
plt.xlabel('Velocity',color = 'red')

# Naming the y- axis
plt.ylabel('Drag_force', color = 'red')

plt.legend()

# Function to show the plot
plt.show()
.................................................................................
""" Calculating the Drag_forces for bicycle 
    and plotting the graph for Drag co-efficient vs Drag force
"""

# importing the required modules
import matplotlib.pyplot as plt
import math

# input
# Bicycle velocity (m/s)
velocity = 8

# Frontal area (m^2)
A = 0.2

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

# Drag coefficient (unitless)
c_ds = [0.04,0.09,0.42,0.47,0.50,0.80,0.82,1.05,1.15]
drag_forces = []

for c_d in c_ds:
	drag_force = (0.5*rho*A*c_d*velocity*velocity)
	drag_forces.append(drag_force)
print(drag_forces)

# Giving a title to my graph
plt.title('Drag_force Vs Drag_coefficient', color = 'blue')

# Plotting the drag_coefficient and drag_forces
plt.plot(c_ds,drag_forces, label ="Drag_force wrt drag_coefficient", color = 'brown', linestyle = 'dashed', linewidth = 2)

# Naming the X- axis
plt.xlabel('drag_coefficient', color = 'red')

# Naming the Y- axis
plt.ylabel('Drag_force', color = 'red')

plt.legend()

# Function to show the plot
plt.show()
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.