Calculating the flow over a bicycle using Matlab
Aim:-
To write a Matlab program to calculate drag force against a cyclist.
Abstract:-
The objective of this project is to write two programs. One for plotting Velocity vs Drag force and another program to plot Drag Co-efficient vs Drag force. Firstly, the drag force must be calculated using a single value of the drag coefficient. For the second program, since the coefficient of drag varies for different shapes, different values of the drag coefficient will be used.
Introduction:-
Drag: is a force acting opposite to the relative motion of any moving object. The force a flowing fluid exerts on a body in the flow direction. Unlike other resistive forces, such as dry friction, which are nearly independent of velocity, drag forces depend on velocity.
Drag force (Fd)is proportional to the velocity for a laminar flow and the squared velocity for a turbulent flow.
The formula for drag force is shown below in figure 1.
Figure 1: Drag force formula
where:
- ρ is the density of the fluid
- v is the flow velocity relative to the object
- A is the reference area or the planform area, which is the area seen by a person looking at the body from above in a direction normal to the body.
- Cd is the drag coefficient in which a dimensionless quantity that is used to quantify the drag or resistance of an object in a fluid environment, such as air or water
Figure 2 shows an example of a frontal area for a bicycle.
Figure 2: Projected Frontal area of a bike
Figure 3 shows the different values of the drag coefficient for various shapes
Figure 3: Different shape and values of the coefficient of drag
Code for the first plot:
% A program to calculate the drag force on a bicycle
% Objective: To plot Velocity vs Drag Force graph
clear all
close all
clc
% inputs of the drag force equation
% Drag coefficient
c_d = 0.8;
% Area (m^2)
A= 0.1;
% Density (kg/m^3)
rho = 1.2;
% Velocity (m/s)
v = [1:50];
% Drag Force in (N)
drag_force = rho*A*v.^2*c_d*0.5;
%To plot Velocity vs Drag Force graph
plot(v, drag_force)
xlabel('Velocity [m/s]')
ylabel('Drag force[N]')
grid on
Figure 4: Code for the first plot of the project
Explanation of the code:-
Before writing the code, it's important to start with clear all, close all and clc commands since
Clear all - removes data from the workspace, freeing up system memory
Close all- deletes the current figure or the specified figure
clc - clears all input and output from the Command Window display, giving you a "clean screen
Next step is to define the inputs and its values. Drag coefficient, Area, Density and Velocity were all defined with their values. Since the first plot is about Velocity vs Drag force, the velocity values were set from 1 (m/s) to 50 (m/s) range. So the drag force can be calculated for every change in velocity values.
After defining the steps, the formula shown in figure 1 was used to calculate the drag force.
After calculating the drag force, the plot command is used to plot the function with velocity being the x-axis and drag force being the y-axis. Grid command was turned on so the graph can look more clear
The outputs for both the velocity and the drag force are shown below
v =
Columns 1 through 23
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Columns 24 through 46
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Columns 47 through 50
47 48 49 50
drag_force =
Columns 1 through 13
0.0480 0.1920 0.4320 0.7680 1.2000 1.7280 2.3520 3.0720 3.8880 4.8000 5.8080 6.9120 8.1120
Columns 14 through 26
9.4080 10.8000 12.2880 13.8720 15.5520 17.3280 19.2000 21.1680 23.2320 25.3920 27.6480 30.0000 32.4480
Columns 27 through 39
34.9920 37.6320 40.3680 43.2000 46.1280 49.1520 52.2720 55.4880 58.8000 62.2080 65.7120 69.3120 73.0080
Columns 40 through 50
76.8000 80.6880 84.6720 88.7520 92.9280 97.2000 101.5680 106.0320 110.5920 115.2480 120.0000
Figure 5: Values for both the velocity and drag force
Figure 6 shows the Velocity vs Drag force graph
Figure 6: Graph for the first plot
Code for the second plot:
% A program to calculate the drag force on a bicycle
% Objective: To plot Drag coefficient vs Drag Force graph
clear all
close all
clc
% inputs of the drag force equation
% Drag coefficient
c_d = [ 0.47 0.42 0.82 1.15 0.04 0.09]
% Area (m^2)
A= 0.1;
% Density (kg/m^3)
rho = 1.2;
% Velocity (m/s)
v = 10;
% Drag Force in (N)
drag_force = rho*A*v.^2*c_d*0.5
%To plot Velocity vs Drag Force graph
plot(c_d, drag_force, 'color', 'r')
xlabel('Drag Coefficient]')
ylabel('Drag force[N]')
grid on
Figure 7: Code for the second plot of the project
Explanation of the code:-
Before writing the code, it's important to start with clear all, close all and clc commands since
Clear all - removes data from the workspace, freeing up system memory
Close all- deletes the current figure or the specified figure
clc - clears all input and output from the Command Window display, giving you a "clean screen
Next step is to define the inputs and its values. Drag coefficient, Area, Density and Velocity were all defined with their values. Since the second plot is about Drag coefficient vs Drag force, the drag coefficient values were set from the values shown in Figure 3. So the drag force can be calculated for every change in drag coefficient values.
After defining the steps, the formula shown in figure 1 was used to calculate the drag force.
After calculating the drag force, the plot command is used to plot the function with the drag coefficient being the x-axis and drag force being the y-axis. Grid command was turned on so the graph can look more clear.
The outputs for both the drag coefficients and the drag force are shown below
c_d =
0.4700 0.4200 0.8200 1.1500 0.0400 0.0900
drag_force =
2.8200 2.5200 4.9200 6.9000 0.2400 0.5400
Figure 8: values for drag coefficients and drag force
Figure 9 shows the Drag coefficient vs Drag force graph
Figure 9: Plot for the second part of the project
Conclusion:-
From the two graphs, we can deduce that the drag force and drag coefficient are linearly proportional as seen in figure 9, while in figure 6 we see that the drag force is proportional to the velocity squared. We also see that in Figure 3 the values of the drag coefficient decreases when the body becomes more streamlined, this is because pressure drag decreases by delaying boundary layer separation
and thus reducing the pressure difference between the front and back of the body but increases the friction drag by increasing the surface area. The end result depends on which effect dominates. The drag coefficient decreases drastically as the ellipse becomes slimmer. The reduction in the drag coefficient at high aspect ratios is primarily due to the boundary layer staying attached to the surface longer and the resulting pressure recovery. Streamlining has the added benefit of reducing vibration and noise.
References:-
FLUID MECHANICS: FUNDAMENTALS AND APPLICATIONS, THIRD EDITION