-
Notifications
You must be signed in to change notification settings - Fork 3
/
f_ColebrookWhite.m
38 lines (30 loc) · 1.26 KB
/
f_ColebrookWhite.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function f = f_ColebrookWhite(D,Re,aRou,fTol,MaxIter)
%% Calculates the Darcy-Weisbach friction factor for pressure loss calculations
% via solving the implicit Colebrook&White expression, details in https://doi.org/10.1098/rspa.1937.0150
% by Tol,Hakan Ibrahim from the PhD study at Technical University of Denmark
% PhD Topic: District Heating in Areas with Low-Energy Houses
%% DESCRIPTION
% INPUTS (scalar or vector)
% aRou : Absolute roughness of pipe [mm]
% D : Inner diameter of the pipe [mm]
% Re : Reynolds Number [-]
% INPUTS (scalar)
% fTol : Termination Tolerance(Iteration) [-]
% MaxIter : Max. limit (Iteration) [-]
% OUTPUTS
% f : Friction factor (scalar or vector) [-]
% tElapsed : Elapsed time (scalar) [s]
%% Initializing the Iteration
err=10; % Iteration error
IterNum=0; % Iteration steps number
% Initial estimate
x0=f_SwameeJain(D,Re,aRou);
% Fasten your seat belts, iteration starts
while err>fTol & IterNum<MaxIter | isnan(x1) | ~isreal(x1) | isinf(x1)
IterNum=IterNum+1;
x1 = (2.*log10((aRou./D)./3.7+2.51./(Re.*sqrt(x0)))).^(-2);
err=abs(x1-x0);
x0=x1;
end
f=x1;
end