UPF_moody_f(): Friction loss according to Moody chart

About:
Calculate the friction loss in a pipe, with uniform flow according to the Moody chart.
This function is applied to laminar and turbulent flow, i.e., to all the range of Reynolds number.
Source: Wikipedia
Module: UniformPressurizedFlow
Function: UPF_moody_f(q,e,t,s,d)
Definition of variables:
  • q, flow - m3/s;
  • e, pipe roughness - m;
  • t, temperature - ÂșC;
  • s, salinity - g/kg;
  • d, internal diameter - m.
Sample code:
from UniformPressurizedFlow import*

q = 0.01        #(m3/s)
e = 0.000003    #(m)
t = 15          #(oC)
s = 2.5         #(g/kg)
d = 0.75        #(m)

f = UPF_moody_f(q,e,t,s,d)

print("f:",f, "m/m")
Result:
f: 0.02783272130932784 m/m