Created
February 21, 2014 21:08
-
-
Save kcajf/283a2ef905ae231419f2 to your computer and use it in GitHub Desktop.
MATLAB friction factor iterator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Re_guess = 2e4; | |
r = 0.002; % roughness | |
R = 0.075; % pipe radius | |
D = 2*R; | |
p = 1000; % density | |
visc = 1.141e-3; % viscosity | |
latest_q = q_from_f(f_guess, R) | |
penultimate_q = 1; | |
Re = Re_guess; | |
f = Moody(Re_guess, r); | |
tolerance = 0.001; | |
while (penultimate_q - latest_q)/penultimate_q > tolerance | |
Re = (4*latest_q*p) / (pi*visc*D); | |
f = Moody(Re, r); | |
penultimate_q = latest_q; | |
latest_q = q_from_f(f, R) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment