Project

FLOW OVER AN BICYCLE BY USING PYTHON

AIM :

To write a python program to calculate a drag force against a bicyclist and factors involved are velocity, drag coefficient, frontal area and density of air.

OBJECTIVE :

Write a python program for plotting an drag force against function of velocity.

Write a python program for plotting and drag force against function of drag coefficient.

INTRODUCTION :

In fluid dynamics, drag is a something called air resistance, type of friction or fluid resistance, it acting opposite to the relative motion of any object moving with respect to a surrounding fluid. This can exist between two fluid layers or surfaces or a fluid and solid surface. Unlike other resistive forces, such as dry friction, which are nearly independent of velocity, drag forces.

Drag force is proportional to the velocity for a laminar flow and the squared velocity for a turbulent flow. Even though the ultimate cause of a drag is viscuous friction, the turbulent drag is independent of viscosity.

EQUATION :

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

Where,

Fd = Drag force

Rho = Density of the fluid

v = Velocity of a object

A = Cross sectional area

Cd = Drag coefficient

PYTHON CODE FOR CALCULATING AN DRAG FORCE WITH FUNCTION OF VELOCITY :

import math
import matplotlib.pyplot as plt
import numpy

# Inputs for calculating drag force with function of velocity
# Drag coefficient
C_d = 0.8

# Frontal area of an object(m^3)
A = 0.1

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

# Velocity of the bicycle
Velocities =numpy.linspace(1,25,25)

# Drag forces of a bicycle
drag_force = []

for velocity in Velocities:
	drag_force.append((0.5*rho*A*C_d*velocity*velocity))

plt.figure()
plt.plot(Velocities,drag_force)
plt.xlabel('Velocity in m/s')
plt.ylabel('Drag force in Newtons')
plt.savefig('Velocity Vs Drag force')
plt.show()

PROGRAM ILLUSTRATION :

1) Importing the all needed modules in our programming at where type on top.

2) Math module is one of the mathematical function, it contains functions for calculating various trigonometric ratios for a given angle. The functions like sine, cosine, tangent, etc need the angle in radians or degree as an argument.

3) Matplotlib module is another one of the mathematical function, it is plotting library for python programming language.

4) Numpy module is another one of the mathematical function in python language,it is python library used for working with arrays.

5) Provide the valves to respective factors involved like velocity, drag forces, drag coefficients and density of air.

6) Linspace command generally helps us to split the definite range of values at which linearly spaced distance. Numpy module helps to recognize to python, what kind of mathematical operation have to do depends upon which respective command

7) Velocity factor only varying over the each and every looping from the velocity list or array. Resting of the factor are not changing.

8) Creating the empty array for which storing appending the drag force value at each and every for loop.

9) Each count of for loop, stores the only one value and appending into the drag force empty array.

10) Create the figure, provide the X axis & Y axis according to our need, labeling the name appropriately and finally save the writed figure with title name.

11) After, all has to done, a plot will pop up.

PYTHON CODE FOR CALCULATING AN DRAG FORCE WITH FUNCTION OF DRAG COEFFICIENTS :

import math
import matplotlib.pyplot as plt
import numpy

# Inputs for calculating drag force with function of drag coefficients
# Drag coefficient
Drag_coefficients = numpy.linspace(1,2,25)

# Frontal area of an object(m^3)
A = 0.1

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

# Velocity of the bicycle
Velocity = 10

# Drag forces of a bicycle
drag_force = []

for C_d in Drag_coefficients:
	drag_force.append((0.5*rho*A*C_d*Velocity*Velocity))

plt.figure()
plt.plot(Drag_coefficients,drag_force)
plt.xlabel('Drag_coefficients')
plt.ylabel('Drag force in Newtons')
plt.savefig('Drag coefficients Vs Drag force')
plt.show()

PROBLEM ILLUSTRATION :

1) All modules & factors are same for this case as we discussed in previous case as well.

2) Make a drag coefficient array by using an linspace command & numpy module, instead making a velocity array in previous case.

3) Drag coefficient factor only varying over the each and every looping from the drag coefficient list. Resting of the factor are not changing.

4) Remaining process are still same as we discussed in previous case.

RESULTS AND DISCUSSIONS :

Plot 1 :

A drag force is varies proportional to square times of velocity. It looks like quadratic curve.

Plot 2 :

A drag force varies linearly proportional to drag coefficient of object. It looks like linear curve.

CONCLUSION :

1) A drag force varies with function of velocity have been varies quadratically.

2) A drag force varies with function of drag coefficient have been varies linearly.

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.