#Calculate the pressure gradient
import math
# variables
v=1. #ft/s
d=0.5 #ft
# calculation
A=(math.pi)/4*d**2 #ft**2
Q=v*A #ft**3/s
#Let DP denote the pressure gradient
n=0.41 #dimentionless
K=0.66 #kg/m/s
#1 m = 3.281 ft
Q1=Q/3.281**3 #m**3/s
d1=d/3.281 #m
DP=(Q1*8*(3*n+1)/(n*(math.pi)*d1**3))**n*(4*K/d1) #Pa/m
# result
print "The pressure gradient is %f Pa/m"%DP
#Calculate the fanning friction factor and reynolds number by power law
# variables
DP=61.3 #Pa/m (pressure gradient)
D=0.152 #m
V_avg=0.305 #m/s
rho=1000. #kg/m**3
# calculation
f=DP*D/(4*rho*V_avg**2/2.) #dimentionless
print "The fanning friction factor is %f"%f
n=0.41 #dimentionless
K=0.66 #dimentionless
R_pl=8*rho*V_avg**(2-n)*D**n/(K*(2*(3*n+1)/n)**n) #dimentionless
# result
print "The reynolds number is %f"%R_pl
if (R_pl<2000):
print "The flow is Laminar"
else:
print "The flow is turbulent"
#Calculate the pressure gradient
# variables
D=0.152 #m
V_avg=3.04 #m/s
rho=1000. #kg/m**3
n=0.41 #dimentionless
K=0.66 #dimentionless
# calculation
R_pl=8*rho*V_avg**(2-n)*D**n/(K*(2*(3*n+1)/n)**n) #dimentionless
#print "The reynolds number is %f"%R_pl
f=0.004 #dimentionless (fanning friction factor)
#Let DP denote the pressure gradient
DP=4*f*(rho/D)*(V_avg**2/2)/1000 #KPa/m
# result
print "The pressure gradient is %f KPa/m"%DP
#Calculate the headstrom ,reynold numbers and the fanning friction factor
# variables
tow_yield=3.8 #Pa
mew=0.00686 #Pa.s
D=0.0206 #m
rho=1530.0 #kg/m**3
V=3.47 #m/s
# calculation and Result
He=tow_yield*D**2*rho/mew**2 #dimentionless (headstrom number)
print "The headstrom number is %f"%He
R=D*V*rho/mew #dimentionless (reynolds number)
print "The reynolds number is %f"%R
dP=11069. #Pa/m
f=dP*D/(4*rho*V**2/2) #dimentionless (fanning friction factor)
print "The fanning friction factor is %f"%f