Fluid Dynamics 10 marks Design MatLAB functions to 1 request
Fluid Dynamics [10 marks] Design MatLAB functions to: 1. request the density and the dynamic viscosity of the working fluid, the diameter and the length of the uniformed horizontal pipe, and the mass flowrate to calculate the Reynolds number, the Pressure Drop and to identify the flow pattern as laminar, turbulent or transitional. Plot velocity profile in the pipe. [2 marks] 2. construct the Moody Diagram for the ranges of the Reynolds Number and the Relative roughness specified by a user. Figure 1 presents an example of the figure produced by the MatLAB function.
Solution
rho=input(\'Enter the density of fluid: \');
 mu =input(\'Enter dynamic viscosity value of fluid: \');
 d= input(\'Input the diameter of pipe: \');
 l= input(\'Input the length of pipe: \');
 m_dot=input(\'Mass flow rate required: \');
 Area = (pi/4)*d^2; % Area of cross-section of pipe
 v=m_dot/(rho*Area); % Velocity of fluid
Re = rho*v*d/mu ; % Reynold\'s Number
if(Re<2100)
 fprintf(\'Flow is laminar \ \');
 elseif(Re>4000)
 fprintf(\'Flow is turbulent\ \');
 else
 fprintf(\'Flow is transitional \ \')
 end
 Delta_P = 32*mu*v*l/d^2; % Pressure Drop
 fprintf(\'Pressure drop across the Pipe = %d\ \',Delta_P);
p_gradient= -32*mu*v/(d^2); % Pressure gradient
r= 0:0.1:d/2;
 u= -1/(4*mu) * p_gradient * (d^2/4 - r.^2);
 plot(u,r)
![Fluid Dynamics [10 marks] Design MatLAB functions to: 1. request the density and the dynamic viscosity of the working fluid, the diameter and the length of the  Fluid Dynamics [10 marks] Design MatLAB functions to: 1. request the density and the dynamic viscosity of the working fluid, the diameter and the length of the](/WebImages/23/fluid-dynamics-10-marks-design-matlab-functions-to-1-request-1055209-1761550418-0.webp)
