Question: I'm stuck on step 5. That is all I need, below is my code. Can someone tell me what I'm doing wrong? %asking for user



I'm stuck on step 5. That is all I need, below is my code. Can someone tell me what I'm doing wrong?
%asking for user input
Q = input('What is the volumetric flowrate (ft^3/s): ');
D = input('What is the inner pipe diameter (ft): ');
p = input('What is the density (lbm/ft^3): ');
r = input('What is the viscosity (cP): ');
E = input('What is the pipe roughness (ft): ');
l = input('What is the length of the pipe (ft): ');
dz = input('What is the height difference (ft): ');
%convert viscosity to lbm/ft.s
u = r*0.00067196899481;
%calculate mean velocity
Vm = (4*Q)/(pi*D^2);
%Calculate Reynolds number
Re = (p*Vm*D)/(u);
%Calulate the roughness ratio
RR = (E)/(D);
%Determine Friction Factor (Ff)
Ff = 0.007;
Y1 = 1/sqrt(Ff);
Y2 = -1.737*log((0.269*RR)+(1.257/Re*sqrt(Ff)));
PDiff = (Y1 - Y2)/(0.5*(Y1 + Y2));
while PDiff > 0.001
Ff = Ff + 0.0001;
Y1 = 1/sqrt(Ff);
Y2 = -1.737*log((0.269*RR)+(1.257/Re*sqrt(Ff)));
PDiff = (Y1 - Y2)/(0.5*(Y1 + Y2));
end
Ff;
g = 32.174; %ft/s&2
%Calculate pressure drop
dPc= -(2*p*Ff*(Vm^2)*(l/D)+p*g*dz);
dP = dPc * 2.158*10^-4;
fprintf('Um= %f (ft/s) ', Vm)
fprintf('Re= %f (lbm^2/Ft.s^2) ', Re)
fprintf('E/D= %f ', RR)
fprintf('Ff= %f ', Ff)
fprintf('-dP= %.0f (psig) ', dP)
Step 5: Determine the friction factor fr via E 1.257 -17371n | 0.269, + Note: You will need to iteratively solve the f (LHS) with an initial guess of fr (RHS). If the solved (LHS) matches your initial guess fE (RHS) by within 0.1%, then you may proceed. Else, use your solved (LHS) as your new initial guess fE (RHS) and iterate until you reach the 0.1% difference. This requires the use of a while!oop. Define error = 1 and counter-0 before starting the loop. Your conditional statement is to iterate until error is lessthan 0.1%. To refresh your understanding look at the script file of the Newton-Raphson code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
