Flow over a Bicycle
AIM :
To plot the variation of Drag Force with respect to the Velocity of the object and Drag Co-Efficient using PYTHON programming Language.
INTRODUCTION :
Drag is the external resistance experienced by an object while moving through a given medium.Drag is the phenomenon by which the surrounding medium opposes the motion of a body.Every body moving in medium experiences drag.Drag is the most prominent factor that influences the velocity of the vehicle.
There are different types of drag.They are:
- Parasite drag
- Form drag or pressure drag
- Skin friction drag
- Profile drag
- Interference drag
- Lift induced drag
- Wave drag
OBJECTIVES OF THE PROJECT :
- Understand the phenomenon of Drag and its Variation.
- To write a program in python to calculate the drag force.
- Plot the variation of Drag force v/s velocity of the object using python programming.
- Plot the variation of Drag force v/s Drag Co-efficient using python programming.
GOVERNING EQUATIONS :
Drag force is given by,
`F_d=1/2*rhoAV^2C_d`
where,
`F_d`=Drag Force
`rho`=Density of the medium(basically air)=1.225
A=Frontal area(It is the projected area of theobject along the direction of drag)=Affected area
V= Velocity of the object
`C_d`=Drag Co-Efficient =0.5(for conical shape)
From the above equation we can say that , Drag Force is directly proprtional to the square of velocity of the object i.e., `F_d prop V^2` .Hence the curve will be parabolic.
Drag Force is directly proportional to the Drag-Coefficient i.e., `F_dprop C_d`.Hence the curve is Linear.
Python program to plot the variation of Drag force V/s Velocity of the object :
import matplotlib.pyplot as plt
import numpy as np
#Frontal Area of the object
A=0.3
#Density of the surrounding Medium
rho=1.225
#Velocities of the object
v=np.linspace(0,25,26)
print(v)
#Drag coefficient for the Conical Shape
cd=0.5
#Drag Force
F=0.5*rho*A*v*v*cd
print('The Force values is given as:')
print('F=',F)
#Plotting the graph
plt.plot(v,F)
plt.axis([0,30,0,70])
#Labelling the axes
plt.xlabel('Velocity(m/s)')
plt.ylabel('Drag Force(N)')
plt.show()
EXPLAINATION :
The above python program plots the variation of Drag Force versus Velocity of the object.The program is explained in the following steps:
- Our Aim is to write a program in python that can plot the variation.
- In order to generate the plot in python we need to import library called matplotlib.pyplot
- The Matplotlib library is imported as plt.
- In the above program math library is also imported but it is not actually recquired compulsorily.
- Since we are using the linspace command we are importing library called numpy.
- The library numpy is imported as np.
- After all this the initial values are declared as it is commented in the program .
- The range of Velocities of the object are taken from 0 to 25.This is done using a linspace command .The velocity array is given below:
V=[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25.]
- For each value of Velocity ,drag force is calculated using the formula stated before.
- The print command is used to print the values of Forces.
- All the text that is enclosed in the single quotes in print command is displayed as it is as a string.This can be seen in the output.
- 'plt.plot(v,F)'.This statement is used to plot a graph of Drag Force versus Velocity of the object.
- The Range for axes is given by plt.axis([0,30,0,70]).
- For the above command the first two numbers indicate the range of X-axis i.e., from 0 to 30 and the next two values indicate the range of Y-axis i.e., from 0 to 70.
- Thus the axes ranges are setup for the plot.
- Now the labelling of axes is done for better understanding.
- This is done using plt.xlabel('Velocity(m/s)') for labelling X-axis.
- Similarly it is done for Y-Axis also.
- The output and the plot for the above program is given below.
OUTPUT :
[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17.
18. 19. 20. 21. 22. 23. 24. 25.]
The Force values is given as:
F= [ 0. 0.091875 0.3675 0.826875 1.47 2.296875 3.3075
4.501875 5.88 7.441875 9.1875 11.116875 13.23 15.526875
18.0075 20.671875 23.52 26.551875 29.7675 33.166875 36.75
40.516875 44.4675 48.601875 52.92 57.421875]
[Finished in 3.3s]
Every statement and the variables present inside the print statement is displayed in the output window.By seeing the output we can justify that the execution time of the program is 3.3 seconds.
PLOT FOR VARIATION OF DRAG FORCE V/S VELOCITY OF THE OBJECT :
Python program to plot the variation of Drag force V/s Drag-Coefficient of the object :
import matplotlib.pyplot as plt
import numpy as np
#Frontal Area of the object
A=0.3
#Density of the surrounding Medium
rho=1.225
#Velocity of the object(assuming V=100 m/s)
v=50
#Values of Drag coefficients
cd=np.linspace(0.47,12,25)
print('cd=',cd)
#Drag Force
F=0.5*rho*A*v*v*cd
print('The Force values is given as:')
print('F=',F)
#Plotting the graph
plt.plot(cd,F)
plt.axis([0,14,0,6000])
#Labelling the axes
plt.xlabel('Drag Co-Efficient')
plt.ylabel('Drag Force(N)')
plt.show()
EXPLAINATION :
The above python program plots the variation of Drag Force versus Drag-Coefficient of the object.The program is explained in the following steps:
- Our Aim is to write a program in python that can plot the variation.
- In order to generate the plot in python we need to import library called matplotlib.pyplot
- The Matplotlib library is imported as plt.
- In the above program math library is also imported but it is not actually recquired compulsorily.
- Since we are using the linspace command we are importing library called numpy.
- The library numpy is imported as np.
- After all this the initial values are declared as it is commented in the program.
- The value of velocity is assumed as 100 m/s.
- The range of Drag Coefficients for the circular shape for different Reynolds Number is taken into consideration.
- The value of Drag coefficients are given using the linspace command 'cd=np.linspace(0.47,12,25)'.This command takes 25 values between 0.47 to 12.
- For each value of Drag Co-Efficient,drag force is calculated using the formula as stated above.
- The print command is used to print the values of Forces.
- All the text that is enclosed in the single quotes in print command is displayed as it is as a string.This can be seen in the output.
- 'plt.plot(cd,F)'.This statement is used to plot a graph of Drag Force versus Drag-Coefficient of the object.
- The Range for axes is given by plt.axis([0,14,0,6000]).
- For the above command the first two numbers indicate the range of X-axis i.e., from 0 to 14 and the next two values indicate the range of Y-axis i.e., from 0 to 6000.
- Thus the axes ranges are setup for the plot.
- Now the labelling of axes is done for better understanding.
- This is done using plt.xlabel('Drag Co-efficient') for labelling X-axis.
- Similarly it is done for Y-Axis also.
- The output and the plot for the above program is given below.
OUTPUT :
Cd= [ 0.47 0.95041667 1.43083333 1.91125 2.39166667 2.87208333
3.3525 3.83291667 4.31333333 4.79375 5.27416667 5.75458333
6.235 6.71541667 7.19583333 7.67625 8.15666667 8.63708333
9.1175 9.59791667 10.07833333 10.55875 11.03916667 11.51958333
12. ]
The Force values is given as:
F= [ 215.90625 436.59765625 657.2890625 877.98046875 1098.671875
1319.36328125 1540.0546875 1760.74609375 1981.4375 2202.12890625
2422.8203125 2643.51171875 2864.203125 3084.89453125 3305.5859375
3526.27734375 3746.96875 3967.66015625 4188.3515625 4409.04296875
4629.734375 4850.42578125 5071.1171875 5291.80859375 5512.5 ]
[Finished in 8.1s]
The Execution time of the code is 8.1 sec.All the statements and variables present in the print command are displayed in the output window.
PLOT FOR VARIATION OF DRAG FORCE V/S DRAG CO-EFFICIENT :
ERRORS OCCURED :
1.Improper positioning of plt.show() command: This error is occured due to the improper place given to plt.show() command.The plt.show() command was placed before plt.axis([0,30,0,70]).
The program with error was as follows:
import matplotlib.pyplot as plt
import numpy as np
#Frontal Area of the object
A=0.3
#Density of the surrounding Medium
rho=1.225
#Velocities of the object
v=np.linspace(0,25,26)
print(v)
#Drag coefficient for the Conical Shape
cd=0.5
#Drag Force
F=0.5*rho*A*v*v*cd
print('The Force values is given as:')
print('F=',F)
#Plotting the graph
plt.plot(v,F)
plt.show()
plt.axis([0,30,0,70])
#Labelling the axes
plt.xlabel('Velocity(m/s)')
plt.ylabel('Drag Force(N)')
Then the solver didn't display any error but the graph was displayed without labels.When I wrote the program with this error the plot was as follows:
So this was the plot that I got .As you can see that the plot does not have predefined axes and the labels for axes are also not present .
This happened because of improper positioning of the plt.show() command.
PYTHON is a scripting Language and hence works on the interpreter.The Interpreter executes the code line by line.Hence the interpreter will execute the plt.axis([0,30,0,70]) and other commands after executing the plt.show() command.Hence all the plotting commands present before the plt.show() will only be displayed and others after the command will not be shown in the plot.
CORRECTION :
Place the plt.show() command after all the plotting commands to see the variations in the graph.
REFERENCES:
The following picture was taken for reference in order choose the values for Drag coefficient:
The Range of Drag Coefficient was taken for the circular shape to draw the plot.
CONCLUSION :
The Objectives of the project are achieved and the graphs of Drag force V/S Velocity and Drag Co-Efficient are drawn.