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
|
from math import log10
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import UnivariateSpline
from fluids.friction import Crane_fts, Crane_fts_Ds, friction_factor, roughness_Farshad
roughness = .05E-3
plt.plot(Crane_fts_Ds, Crane_fts, 'o', label='Crane data')
spline_obj = UnivariateSpline(Crane_fts_Ds, Crane_fts, k=3, s=5e-6)
Ds_interp = np.linspace(Crane_fts_Ds[0], Crane_fts_Ds[-1], 500)
plt.plot(Ds_interp, spline_obj(Ds_interp), label='Cubic spline')
ft_crane_correlation = [.25/log10(roughness/(Di)/3.7)**2 for Di in Crane_fts_Ds]
plt.plot(Crane_fts_Ds, ft_crane_correlation,
label='Crane formula')
plt.plot(Crane_fts_Ds, [round(i, 3) for i in ft_crane_correlation], '.',
label='Crane formula (rounded)')
eDs_Farshad = [roughness_Farshad(ID='Carbon steel, bare', D=D)/D for D in Crane_fts_Ds]
fts_good = [friction_factor(Re=7.5E6*Di, eD=ed) for ed, Di in zip(eDs_Farshad, Crane_fts_Ds)]
plt.plot(Crane_fts_Ds, fts_good, label='Colebrook')
plt.plot(Crane_fts_Ds, [round(i, 3) for i in fts_good], 'x', label='Colebrook (rounded)')
plt.legend()
plt.title("Comparison of implementation options")
plt.xlabel('Pipe actual diameter, [m]')
plt.ylabel('Darcy friction factor, [-]')
#plt.show()
|