Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fanning friction factor (f) is predicted for a given Reynold\'s number, Re, by t

ID: 2085655 • Letter: F

Question

Fanning friction factor (f) is predicted for a given Reynold's number, Re, by the von Karman equation: 1/squareroot f = 4.0 middot log_10 (Re squareroot f) - 0.4 Use Matlab and the von Karman equation to: Derive an equation that allows the calculation of the Fanning friction factor (f) for a given value of Reynolds Number (Re) via root finding. Create a Matlab function that calculates the equation. It should receive values of f and Re and return a value that will equal zero when the von Karman equation is satisfied. Note that this can be a separate function in its own M-file or an anonymous function created within the script file below. Write a script file to execute the following solution steps: Set the Reynolds number to 50,000. Use linspace to create an array of friction factors from .001 to .01. Call your function with the given Reynolds number and the array of friction factor values. Plot the resulting array as a function of the friction factor, f Turn on the grid Add a title and X and Y labels Capture the plot for insertion into a Word or other format document By inspection, estimate the value of the root (the value of friction factor that satisfies the von Karman equation for a Reynolds number of 50,000).

Explanation / Answer

function f = moody(ed,Re,verbose)

% moody Find friction factor by solving the Colebrook equation (Moody Chart)

%

% Synopsis: f = moody(ed,Re)

%

% Input: ed = relative roughness = epsilon/diameter

% Re = Reynolds number

%

% Output: f = friction factor

%

if Re<0

error(sprintf(’Reynolds number = %f cannot be negative’,Re));

elseif Re<50000

f = 64/Re; return % laminar flow

end

if ed>0.05

warning(sprintf(’epsilon/diameter ratio = %f is not on Moody chart’,ed));

end

if Re<4000, warning(’Re = %f in transition range’,Re); end

% --- Use fzero to find f from Colebrook equation.

% coleFun is an inline function object to evaluate F(f,e/d,Re)

% fzero returns the value of f such that F(f,e/d/Re) = 0 (approximately)

% fi = initial guess from Haaland equation, see White, equation 6.64a

% Iterations of fzero are terminated when f is known to whithin +/- dfTol

coleFun = inline(’1.0/sqrt(f) + 2.0*log10( ed/3.7 + 2.51/( Re*sqrt(f)) )’,...

’f’,’ed’,’Re’);

fi = 1/(1.8*log10(6.9/Re + (ed/3.7)^1.11))^2; % initial guess at f

dfTol = 5e-6;

f = fzero(coleFuntion,fi,optimumset(’TolX’,dfTol,’Display’,’off’),ed,Re);

% --- sanity check:

if f<0, error(sprintf(’Friction factor = %f, but cannot be negative’,f)); end