Tuesday, April 15, 2008

Calculating friction factor using colebrook equation

Colebrook equation can be used for calculation of  friction factor in the pipes.The implicit form of the equation can be solved for (Re>4000) using Newton-Raphson Method.Following code can be used to solve the equation iteratively.


"D=.1; %diameter
Q=6;%flow
d=1;% density
u=.001;%viscocity
Vel=Q/(.25*pi*D^2); % velocity
Re=D*Vel*d/u % Reynolds number
f=64/Re; % initial guess
e=.0021;%roughness
ee=e/D
er=1;
n=1;
while er>1e-6
F =( 1/sqrt(f)+2*(log10( (e/(3.7*D))+(2.51/(Re*sqrt(f))))));
H=((e/(3.7*D))+(2.51/(Re*sqrt(f))));
G= -.5*f^-1.5+(.8686*( -1.255/(Re*f^1.5)))/H;
h=-F/G;
fn=f+h;
er=fn-f;
n=n+1;
f=fn;
end
n
er
fn
The next post will be on calculating exit velocity in a circular pipe.

No comments:

Post a Comment

Top ad

Your Ad Here