In: Mechanical Engineering
Fluid Mechanics Friction Problem: Write one MATLAB m-file that solves the Type I and II problems presented in class based on the file posted for the Type III problem (use Colebrook to estimate f). Type I: Solve hL for v=0.74x10-5ft^2/s, D=3 in, L=1000 ft, e=0.006 in, and Re=80000. f=0.0258 from Moody Chart. Type II: Solve Q for v=10^-6 m^2/s, D=0.2 m, L=500 m, e=0.046 mm, and hL=30m. Use “rough” Colebrook to generate an estimate for f.
Type III: matlab function to calculate friction factor by colbrook equation:
function F = colebrook(Re,K)
% F = COLEBROOK(Re,K) computation of the
% Darcy-Weisbach friction factor F
according to the Colebrook equation:
%
-
-
%
1
| K
2.51 |
% --------- = -2 * Log_10 | ----- + ------------- |
%
sqrt(F)
| 3.7 R * sqrt(F)
|
%
-
-
% INPUT:
% R : Reynolds' number (should be >= 2300).
% K : Equivalent sand roughness height divided by the
hydraulic
% diameter (default K=0).
%
% OUTPUT:
% F : Friction factor.
%
% FORMAT:
% R, K and F are either scalars or compatible
arrays.
%
% EXAMPLE: F = colebrook([3e3,7e5,1e100],0.01)
%
% Edit the m-file for more details.
% Check for errors.
if any(Re(:)<2300) == 1,
warning('The Colebrook equation is valid for
Reynolds'' numbers >= 2300.');
end,
if nargin == 1 || isempty(K) == 1,
K = 0;
end,
if any(K(:)<0) == 1,
warning('The relative sand roughness must be
non-negative.');
end,
% Initialization.
X1 = K .* Re *
0.123968186335417556;
% X1 <- K * R * log(10) / 18.574.
X2 = log(Re) -
0.779397488455682028;
% X2 <- log( R * log(10) / 5.02
);
% Initial
guess.
F = X2 - 0.2;
% First iteration.
E = ( log(X1+F) - 0.2 ) ./ ( 1 + X1 + F );
F = F - (1+X1+F+0.5*E) .* E .*(X1+F) ./ (1+X1+F+E.*(1+E/3));
% Second iteration (remove the next two lines for moderate
accuracy).
E = ( log(X1+F) + F - X2 ) ./ ( 1 + X1 + F );
F = F - (1+X1+F+0.5*E) .* E .*(X1+F) ./ (1+X1+F+E.*(1+E/3));
% Finalized solution.
F = 1.151292546497022842 ./
F;
% F <- 0.5 * log(10) / F;
F = F .*
F;
% F <- Friction factor.
Save this function in your matlab directory first:
type 1: matlab code: with output
clc;
clear;
%given values converted into SI units
Re=80000;
vis=0.74*10^(-5)*(.3048)^2; %viscosity
D=3*0.0254; %diameter of
pipe
L=1000*0.3048; %length of pipe
e=0.006*0.0254; %surface roughness
g=9.81; %acceleration due
to gravity
v=Re*vis/D; %velicity
%output
f=colebrook(Re,e); %calculate f using colebrook equation
function
hL= (f*L*v^(2))/(2*g*D); %head loss
fprintf('head loss in pipe is %.4f m \n',hL);
output:
Type II: matlab code with output
clc;
clear;
%given values converted into SI units
vis=10^(-6); %viscosity
D=0.2; %diameter of pipe
L=500; %length of pipe
e=0.046*10^(-3); %surface roughness
g=9.81; %acceleration due
to gravity
hL=30; %head loss
%output
%using colebrook equation and inserting reynold equation and head
loss equation,
%derive a formula for velocity
v=
-sqrt(hL*2*g*D/L)*(1.8)*log(((e/D)/3.7)+2.51*vis/(D*sqrt(2*hL*g*D/L)));
%velocity
A=(pi*D^2)/4; %area
Q=A*v; %flowrate
fprintf('flow rate in pipe is %.4f m^2/s \n',Q);
OUTPUT:
this equation is used for velocity