Project

Week 1 - Flow over Bicycle

clear;close all;clc;
% A programe to calculate the drag force on a bicycle by calling external function %f_DragForce().m


%% PART 1: Incorporate a function to plot Drag force vs Velocity
%Inputs
cd = 0.8; % Drag coefficient []
A = 0.1; % Area [m^2]
rho = 1.2; % Density [kg/m^3]
V = 1:50; % Velocity [m/s]
% Call Drag Force function
[ Fd ] = f_DragForce( rho,A,V,cd );
% Plot
plot(V,Fd)
xlabel(\'Velocity $$[m \\cdot s^{-1}]$$\',\'Interpreter\',\'Latex\')
ylabel(\'Drag Force $$[kg \\cdot m \\cdot s^{-2}]$$\',\'Interpreter\',\'Latex\')
title(\'Drag Force vs. Velocity Plot\')
grid on

%% PART 2: Plot of drag force as a function of drag coeffiecient of various shapes at constant velocity
% Assume Velocity
V=50;


% Create Cell Array with Shape Name
Shape_Name={\'Airfoil\';\'Bullet\';\'Cone\';\'Cube\';\'Cube Angled\';\'Cylinder Long\';
\'Cylinder Short\';\'Plate Flate\';\'Prism\';\'Sphere\';\'Sphere Half\';
\'Streamlined Body\';\'Streamlined Body Half\'};


% Create Column Vector with respective Shape Drag Coefficient
Shape_Cd=[0.045 0.295 0.50 1.05 0.80 0.82 1.15 1.28 1.14 0.47 0.42 0.04 0.09];


% Get lenght of vector
S=size(Shape_Cd); S=S(2);


% Initialize Drag Force column vector
Fd=zeros(S(1),1);


% Plot drag force as a function of drag coeffiecient
Markers = {\'+\',\'o\',\'*\',\'.\',\'x\',\'s\',\'d\',\'^\',\'v\',\'>\',\'<\',\'p\',\'h\'};
Marker_Counter=1;
figure(2)
for i=1:S
Fd(i) = f_DragForce( rho,A,V,Shape_Cd(i));
plot(Shape_Cd(i),Fd(i),Markers{Marker_Counter});
Marker_Counter=Marker_Counter+1;
hold on
end
grid on;
legend(Shape_Name,\'Location\',\'northeastoutside\')
xlabel(\'Drag Coefficient []\',\'Interpreter\',\'Latex\')
ylabel(\'Drag Force $$[kg \\cdot m \\cdot s^{-2}]$$\',\'Interpreter\',\'Latex\')
title([\'C_d of Various Shapes @ Constant Velocity V = \', num2str(V),\' [m/s]\'])
%----------------------------END------------------------------------------%

function [ Fd ] = f_DragForce( rho,A,V,cd )
%Drag Force Equation
% INPUT:
% c_d = Drag Coefficient []
% A = Area [m^2]
% rho = Density [kg/m^3]
% V = Velocity [m/s]
% OUTPUT:
% Fd = Drag Force [kg m/s^2]
%-------------------------------------------------------------------------%
Fd = 0.5*rho*A*V.^2.*cd;
end

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.