π¬
Solver Purpose & Physical Scope
Calculate accurate minor head losses in pipe fittings using Darby 3-K method (2001): loss coefficient K, total head loss (m), pressure drop (kPa), and equivalent length (Leq) across laminar, transitional, and turbulent regimes.
π Discipline: Fluid-mechanics
β‘ Precision: IEEE-754 64-bit Real(`real(8)`)
π₯ Total Downloads: 334 times
π Source File:
darby_2k_3k_fittings_head_loss.f90
π calcul/FluidMechanics /
darby_2k_3k_fittings_head_loss.f90
program darby_2k_3k_fittings_head_loss
implicit none
integer :: iostat_val, fitting_type, num_fittings
double precision :: D_pipe_mm, Q_flow_m3h, rho_kgm3, mu_Pas, roughness_mm
double precision :: D_inch, D_m, A_pipe, V_ms, Re_D, f_darcy
double precision :: K1_val, Kinf_val, Kd_val, K_3K, hL_single_m, hL_tot_m, dp_tot_kPa, L_eq_m
double precision, parameter :: PI = 3.141592653589793d0
! Read inputs
read(*,*,iostat=iostat_val) fitting_type ! 1=90 Std Elbow, 2=90 Long Radius, 3=45 Elbow, 4=Tee Branch, 5=Globe Valve, 6=Gate Valve, 7=Swing Check, 8=Butterfly
read(*,*,iostat=iostat_val) num_fittings ! Fitting Quantity N (e.g. 4)
read(*,*,iostat=iostat_val) D_pipe_mm ! Pipe Inner Diameter [mm] (e.g. 100.0)
read(*,*,iostat=iostat_val) Q_flow_m3h ! Flow Rate [m3/h] (e.g. 85.0)
read(*,*,iostat=iostat_val) rho_kgm3 ! Fluid Density [kg/m3] (e.g. 998.0)
read(*,*,iostat=iostat_val) mu_Pas ! Dynamic Viscosity [Pa.s] (e.g. 0.0010)
if (iostat_val /= 0) then
write(*,*) 'ERROR: Invalid input data for Darby 3K fittings calculation.'
stop
end if
if (D_pipe_mm <= 0.0d0 .or. Q_flow_m3h <= 0.0d0 .or. num_fittings <= 0) then
write(*,*) 'ERROR: Pipe diameter, flow rate and fitting count must be positive.'
stop
end if
roughness_mm = 0.045d0 ! Commercial steel
D_m = D_pipe_mm / 1000.0d0
D_inch = D_pipe_mm / 25.4d0
A_pipe = PI * (D_m**2) / 4.0d0
V_ms = (Q_flow_m3h / 3600.0d0) / A_pipe
Re_D = (rho_kgm3 * V_ms * D_m) / max(1.0d-6, mu_Pas)
! Pipe friction factor for equivalent length
if (Re_D < 2300.0d0) then
f_darcy = 64.0d0 / max(1.0d0, Re_D)
else
f_darcy = 0.25d0 / (log10((roughness_mm / (3.7d0 * D_pipe_mm)) + (5.74d0 / (Re_D**0.9d0)))**2)
end if
! Darby 3K Fitting Coefficients (K1, K_infinity, Kd)
if (fitting_type == 1) then ! 90 deg Standard Elbow
K1_val = 800.0d0; Kinf_val = 0.140d0; Kd_val = 4.0d0
else if (fitting_type == 2) then ! 90 deg Long Radius Flanged
K1_val = 800.0d0; Kinf_val = 0.071d0; Kd_val = 4.2d0
else if (fitting_type == 3) then ! 45 deg Standard Elbow
K1_val = 500.0d0; Kinf_val = 0.070d0; Kd_val = 4.0d0
else if (fitting_type == 4) then ! Standard Tee (Branch flow)
K1_val = 1000.0d0; Kinf_val = 0.400d0; Kd_val = 4.0d0
else if (fitting_type == 5) then ! Globe Valve Full Open
K1_val = 1500.0d0; Kinf_val = 1.700d0; Kd_val = 3.6d0
else if (fitting_type == 6) then ! Gate Valve Full Open
K1_val = 300.0d0; Kinf_val = 0.037d0; Kd_val = 3.9d0
else if (fitting_type == 7) then ! Swing Check Valve
K1_val = 1500.0d0; Kinf_val = 0.460d0; Kd_val = 4.0d0
else ! Butterfly Valve
K1_val = 800.0d0; Kinf_val = 0.250d0; Kd_val = 4.0d0
end if
! Darby (2001) 3K Correlation
K_3K = (K1_val / max(1.0d0, Re_D)) + Kinf_val * (1.0d0 + (Kd_val / (D_inch**0.3d0)))
! Head loss and pressure drop
hL_single_m = K_3K * (V_ms**2) / (2.0d0 * 9.80665d0)
hL_tot_m = hL_single_m * dble(num_fittings)
dp_tot_kPa = (rho_kgm3 * 9.80665d0 * hL_tot_m) / 1000.0d0
! Equivalent length (L_eq = K * D / f)
L_eq_m = (K_3K * D_m / f_darcy) * dble(num_fittings)
! Output Results
write(*,'(A)') '============================================================'
write(*,'(A)') ' THERMOFLUIDCALC β DARBY 3K PIPE FITTINGS HEAD LOSS'
write(*,'(A)') '============================================================'
write(*,'(A,F10.2,A,F10.2,A)') 'Flow Rate / Pipe Velocity = ', Q_flow_m3h, ' m3/h / ', V_ms, ' m/s'
write(*,'(A,F10.1,A,I3,A)') 'Pipe ID / Fitting Count = ', D_pipe_mm, ' mm / ', num_fittings, ' units'
write(*,'(A,F10.1)') 'Pipe Reynolds Number (Re) = ', Re_D
write(*,'(A)') '------------------------------------------------------------'
write(*,'(A,F10.4)') 'Darby 3K Loss Coefficient K = ', K_3K
write(*,'(A,F10.3,A)') 'TOTAL FITTING HEAD LOSS = ', hL_tot_m, ' meters'
write(*,'(A,F10.2,A)') 'TOTAL PRESSURE DROP (ΞP) = ', dp_tot_kPa, ' kPa'
write(*,'(A,F10.2,A)') 'Equivalent Pipe Length Leq = ', L_eq_m, ' meters'
write(*,'(A)') '============================================================'
end program darby_2k_3k_fittings_head_loss
π» How to Compile & Run Locally
1. Compilation (GNU Fortran / Intel oneAPI):
gfortran -O3 darby_2k_3k_fittings_head_loss.f90 -o darby_2k_3k_fittings_head_loss
2. Execution with input.txt redirection:
darby_2k_3k_fittings_head_loss < input.txt
π Sample input.txt File Structure
Sample Data:
1 6 100.0 85.0 998.0 0.0010
Parameter Description:
Fitting Type (1=90 Std Elbow, 2=90 LR Flanged, 3=45 Elbow, 4=Tee Branch, 5=Globe Valve, 6=Gate Valve, 7=Swing Check, 8=Butterfly)\nFitting Count N\nPipe Inner Diameter [mm]\nFlow Rate [mΒ³/h]\nFluid Density [kg/mΒ³]\nDynamic Viscosity [PaΒ·s]