Darcy friction factor f as a function of Reynolds number Re and pipe relative roughness ε / d, fitting the data of experimental studies of turbulent flow in smooth and rough pipes. The equation can be used to (alliteratively) solve for the Darcy–Weisbach friction factor f. For a conduit flowing completely full of fluid at Reynolds numbers greater than 4000, it is expressed as: 1/√(f) = -2*log((e / d) / 3.7 + 2.51/(Nre * √(f)) As can see from the formula, simple calculation is not possible, so user should use iterative calculations or a solver to find the value of f that satisfies the formula. Pipe Material Commercial Steel, e = 0.05 Pipe Internal Diameter (d, mm) = 25 Reynold's Number (Re) = 100000 Relative Roughness (ε/D) 0.002 Friction factor (f) 0.023
import math import numpy as np def frictionfactor(piping, d, Nre):
piping = "Commercial Steel" if piping == "Commercial Steel": e = 0.05 if piping == "Cast Iron": e = 0.26 if piping == "Galvanized Iron": e = 0.15 if piping == "Asphalted Cast Iron": e = 0.12 if piping == "Drawn Tubing": e = 0.0015
if (Nre > 1 and Nre <= 2000): f_result = 64 / Nre
elif Nre > 4000:
delta_result = 1 delta = 1
for f in np.arange(0.001, 0.1, 0.001): lhs = 1 / math.sqrt(f) rhs = -2 * math.log10((e / d) / 3.7 + 2.51 / (Nre * math.sqrt(f))) delta = abs(lhs - rhs) if (delta < delta_result): delta_result = delta f_result = f else: pass return f_result
f = frictionfactor("Commercial Steel", 25, 10000) print("darcy friction factor = ", f)When run the code, you will receive the following results. darcy friction factor = 0.034
|