Question

In: Mechanical Engineering

Fluid Mechanics Friction Problem: Write one MATLAB m-file that solves the Type I and II problems...

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.

Solutions

Expert Solution

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


Related Solutions

show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio...
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds), takes Fourier transform of the signal (probably FFT).
Write a .m function file on MATLAB that reads the parameters stored in the file missile...
Write a .m function file on MATLAB that reads the parameters stored in the file missile data.txt into MATLAB. The function should have the following declaration: function [X0, Y0, Z0, m0, mf, Thmag0, theta, phi, Tburn] = read input( input filename, M id) where input filename is a string variable denoting the name of the file to be read and M_id is an integer which denotes the missile ID. The outputs are the initial position (X0, Y0, Z0), initial and...
6) For the following problems, identify the hypotheses, define Type I and Type II errors, and...
6) For the following problems, identify the hypotheses, define Type I and Type II errors, and discuss the consequences of each error. (When you set up the hypotheses, consider which is the hypothesis you are ”trying to prove”, and that is your alternative. The null hypothesis is then the status quo.) a. The FDA judges the safety of new drugs. When faced with a new drug, there are two possible decisions: approve the drug or disapprove the drug. b. You...
Write a Matlab script-file probl1.m to execute the requested commands (as much as possible) in the...
Write a Matlab script-file probl1.m to execute the requested commands (as much as possible) in the exercises below. Increase N a number of times according to N = 4, 8, 16, 32, 64, 128, . . . (1) Determine for each N the (exact) error. (2) Determine for N ≥ 16 also the convergence ratio q(h/2). This script should be based on a function-file trap.m (trapezoidal integration) as follows: function [totarea] = trap(N) format long; a = 0; b =...
what is meant by Type I and Type II errors. Why are these important? Name one...
what is meant by Type I and Type II errors. Why are these important? Name one thing that can be done to improve internal validity of a study.
1. Explain Type I and Type II errors. Which one is not controllable by the experimenter?
1. Explain Type I and Type II errors. Which one is not controllable by the experimenter?
Fluid Mechanics Pipe Problem Type 2 EXAMPLE. Water at 20°C (r=1000 kg/m3 , µ= 0.001 Ns/m2...
Fluid Mechanics Pipe Problem Type 2 EXAMPLE. Water at 20°C (r=1000 kg/m3 , µ= 0.001 Ns/m2 ) is flowing through 100 m 3/8" steel Sch 80 pipe. Inlet pressure is 11 kPa and outlet pressure is 10 kPa. Z1 = 10 m and Z2 = 2 m. Find Q.
Which one is the best? Type I error of Type II error? Support your choice as...
Which one is the best? Type I error of Type II error? Support your choice as an industrial engineer
Provide one example each of both a Type I and Type II error that could occur...
Provide one example each of both a Type I and Type II error that could occur when running predictive engines relevant to sports betting. Which is likely to be more costly and why?
Write a MATLAB script file to numerically solve any first order initial value problem using Rulers...
Write a MATLAB script file to numerically solve any first order initial value problem using Rulers method. Once code is working use it to solve the mixing tank problem below. Use a step size of 1 minute, and simulate the solution until the tank contains no more salt. Plot both the Euler approximation and the exact solution on the same set of axes. A tank contains 100 gallons of fresh water. At t=0 minutes, a solution containing 1 lb/gal of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT