main.py
from numpy import log as In, sqrt, pi
E = 2.71828
def Case_2():
P_drop = float(input('Pressure drop (psi) - '))
D = float(input('Diameter (ft) - '))
e = float(input('roughness ratio - '))
L = float(input('length of the pipe (ft) - '))
rho = float(input('density (ibm/ft^3) - '))
v = float(input('viscosity (ibm/ft s) - '))
Re = float(input('guess Re number - '))
gc = 32.2
ln2 = 144
g = 32.2
output = "| Re | fF | u (ft/s) |\n"
output += "|---|----|----------|\n"
for i in range(20):
u = (P_drop * (D**5) * (gc**0.5) / (L * (e**1.5) * (rho**0.5)))**0.2
output += "| %d | %g | %g |\n" % (Re, fF, u)
Re_new = rho * u * D / v
if int(Re_new) == int(Re):
output += "| %d | %g | %g |\n" % (Re, fF, u)
break
return output
with open("Case2.md", "a") as file:
file.write(Case_2())