Meghan

%************************************************

%* Name: Meghan McDuff Date: 02/26/16           *

%* Seat: 00 File: Fluid Mechanics Program       *

%* Instructor: DMG 12:40                        *

%************************************************

fprintf (‘\n’)

fprintf (‘\n************************************************’)

fprintf (‘\n* Name: Meghan McDuff Date: 02/26/16           *’)

fprintf (‘\n* Seat: 00 File: Fluid Mechanics Program       *’)

fprintf (‘\n* Instructor: DMG 12:40                        *’)

fprintf (‘\n************************************************’)

fprintf (‘\n\n’)

fprintf(‘              Fluid Mechanics Program               \n’);

fprintf(‘This program is written for a rectangular channel that, when given\n’);

fprintf(‘any n-1 of the following parameters: \n’);

fprintf(‘(1) Volumetric Flow Rate\n’);

fprintf(‘(2) Width\n’);

fprintf(‘(3) Height\n’);

fprintf(‘(4) Length\n’);

fprintf(‘(5) Delta P\n’);

fprintf(‘(6) Viscosity\n’);

fprintf(‘will calculate the missing parameter along with the average velocity,\n’);

fprintf(‘shear stress at the wall, Reynolds number and the entrance length.\n’);

fprintf(‘The program will output the calculated values in a table along with\n’);

fprintf(‘a plot of the velocity and shear stress across the channel.\n’);

fprintf(‘The user will be prompted to enter the number corresponding to the\n’);

fprintf(‘missing parameter. The user will then be prompted to enter the values\n’);

fprintf(‘for the known values, entering the number then pressing the <enter> key.\n’);

fprintf(‘Once all the values have been obtained, the program will perform the\n’);

fprintf(‘neccesary calculations and output the values and the plot.\n’);

fprintf(‘If the user wants to run the program again, they can simply hit the\n’);

fprintf(‘<run> button again.\n\n’);

fprintf(‘Which of the following parameters is unknown?\n’);

fprintf(‘(1) Volumetric Flow Rate?\n’);

fprintf(‘(2) Width?\n’);

fprintf(‘(3) Height?\n’);

fprintf(‘(4) Length?\n’);

fprintf(‘(5) Delta P?\n’);

fprintf(‘(6) Viscosity?\n’);

parameter=input(‘Enter the number corresponding to the missing parameter\n’);

if parameter==1

   W=input(‘Enter the value for the width of the channel\n’);

   H=input(‘Enter the value for the height of the channel\n’);

   L=input(‘Enter the length of the channel\n’);

   deltaP=input(‘Enter the delta p value for the channel\n’);

   u=input(‘Enter the viscosity for the channel\n’);

   Q=(W*H^3*deltaP)/(12*u*L);

end

if parameter==2

   Q=input(‘Enter the value for the volumetric flow rate\n’);

   H=input(‘Enter the value for the height of the channel\n’);

   L=input(‘Enter the length of the channel\n’);

   deltaP=input(‘Enter the delta p value for the channel\n’);

   u=input(‘Enter the viscosity for the channel\n’);

   W=(12*Q*L*u)/(deltaP*H^3);

end

if parameter==3

   Q=input(‘Enter the value for the volumetric flow rate\n’);

   W=input(‘Enter the value for the width of the channel\n’);

   L=input(‘Enter the length of the channel\n’);

   deltaP=input(‘Enter the delta p value for the channel\n’);

   u=input(‘Enter the viscosity for the channel\n’);

   H=((Q*12*u*L)/(deltaP*W))^(1/3);

end

if parameter==4

   Q=input(‘Enter the value for the volumetric flow rate\n’);

   W=input(‘Enter the value for the width of the channel\n’);

   H=input(‘Enter the value for the height of the channel\n’);

   deltaP=input(‘Enter the delta p value for the channel\n’);

   u=input(‘Enter the viscosity for the channel\n’);

   L=(W*H^3*deltaP)/(12*u*Q);

end

if parameter==5

   Q=input(‘Enter the value for the volumetric flow rate\n’);

   W=input(‘Enter the value for the width of the channel\n’);

   H=input(‘Enter the value for the height of the channel\n’);

   L=input(‘Enter the length of the channel\n’);

   u=input(‘Enter the viscosity for the channel\n’);

   deltaP=(Q*12*u*L)/(W*H^3);

end

if parameter==6

   Q=input(‘Enter the value for the volumetric flow rate\n’);

   W=input(‘Enter the value for the width of the channel\n’);

   H=input(‘Enter the value for the height of the channel\n’);

   L=input(‘Enter the length of the channel\n’);

   deltaP=input(‘Enter the delta p value for the channel\n’);

   u=(W*H^3*deltaP)/(Q*L*12);

end

p=1;

v_avg=(H^2*deltaP)/(12*u*L);

twall=((H/2)*deltaP)/(L);

Dh=(4*W*H)/(2*W+2*H);

Re=(p*v_avg*Dh)/u;

Le=(0.06*Re*Dh);

%all parameters, v_avg, twall, Re, Le

fprintf(‘\n         Fluid Mechanics Program Output          \n’);

fprintf(‘Volumetric flow rate        %.3f cm^3/s\n’,Q);

fprintf(‘Width of channel            %.3f cm    \n’,W);

fprintf(‘Height of channel           %.3f cm    \n’,H);

fprintf(‘Length of channel           %.3f cm    \n’,L);

fprintf(‘Delta P of channel          %.3f cm    \n’,deltaP);

fprintf(‘Viscosity                   %.3f g/cm*s\n’,u);

fprintf(‘Average velocity            %.3f cm/s  \n’,v_avg);

fprintf(‘Shear stress at the wall    %.3f dynes/cm^2\n’,twall);

fprintf(‘Reynolds number             %.3f unitless\n’,Re);

fprintf(‘Entrance length             %.3f cm      \n’,Le);

fprintf(‘\n’);

for x=1:1:100

   y(x)=-H/2+(x-1)*H/100;

   v(x)=(deltaP/(8*u*L))*((H^2)-4*(y(x)^2));

   twall(x)=deltaP*abs(y(x))/L;

end

figure()

plot(y,v)

title(‘Velocity vs. Height of Channel’);

xlabel(‘Height of channel (cm)’);

ylabel(‘Velocity (cm/s)’);

figure()

plot(y,twall);

title(‘Shear Stress at the Wall vs. Height of Channel’);

xlabel(‘Height of channel (cm)’);

ylabel(‘Shear Stress dynes/cm^2’);