#calculate the drop in pressure per unit length in a pipe
import math
# Variables
q=50.0 #gal/min flow rate
d=3.068 #in inner diameter
# Calculation
a=(math.pi)*(3.068/12.0)**2/4.0 #ft^2
#1 ft^3 = 7.48 gal
#1 min = 60 sec
v_avg=q/a/60.0/7.48 #ft/s
mew=50.0 #cP
#1 cP = 0.000672 lbm/ft/s
rho=62.3 #lbm/ft^3
# Result
R=(d/12)*v_avg*rho/(mew*0.000672) #dimentionless reynold's no.
if (R<2000):
print "Laminar flow"
else:
print "Turbulent flow"
dx=3000.0 #ft length of pipe
#1 gal = 231 in^3
#1 cP.ft^3 = 0.0000209 lbf.s
dp=(q/60)*(128/math.pi)*(mew/d**4)*dx*231*0.0000209/12 #lbf/in^2 or psi
#let D represent d/dx
Dp=(dp/dx)*100 #psi/ft
print "The pressure gradient in the pipe is %f psi/100ft"%Dp
#calculate viscosity of fluid using a viscometer
import math
# Variables
rho=1050. #Kg/m^3
g=9.81 #m/s^2
dz=0.12 #m change in height
d=0.001 #m inner diameter of capillary of viscometer
q=10**(-8) #m^3/s
dx=0.1 #m length of capillary
# Calculation
mew=(rho*g*dz*(math.pi)*d**4)*1000/128./(q*dx) #cP
# Result
print "The viscosity of the fluid is %f cP"%mew
#Calculate the fanning friction factor
# Variables
R=10**5. #dimentionless reynold's no.
ratio_ED=0.0002 #dimentionless
# Calculation
f=0.001375*(1+(20000*ratio_ED+10**6/R)**(1./3)) #dimentionless
# Result
print "The fanning friction factor is %f"%f
#Calculate the gauge pressure in the tank
import math
# Variables
q=300. #gal/min flow rate
d=3.068 #in inner diameter
# Calculation
a=(math.pi)*(3.068/12.0)**2/4.0 #ft^2
#1 ft^3 = 7.48 gal
#1 min = 60 sec
v_avg=13. #q/a/60.0/7.48#ft/s
f=0.0091 #dimentionless fanning friction factor
dx=3000. #ft
rho=62.3 #lbm/ft^3
dp=4*f*(dx/(d/12.0))*rho*(v_avg**2/2.0)/32.2/144.0 #lbf/in^2 or psi
# Result
print "The gauge pressure in the tank is %d psi"%dp
#Calculate volumetric flow rate of gasoline through a pipe
import math
# Variables
d=0.1 #m internal diameter of pipe
A=math.pi*d**2/4.0 #m^2
dx=100.0 #m length of pipe
f=0.005 #dimentionless fanning friction factor
dz=10.0 #m difference in water level
g=9.81 #m/s^2
# Calculation
v=((2*g*dz/4/f)*(0.1/100))**0.5 #4.0/f)*d/dx)**0.5#m/s
# Result
print "The velocity of gasoline through pipe is %f m/s"%v
q=A*v#m^3/s
print "The volumteric flow arte od gasoline through the pipe is %f m^3/s"%q
#Calculate pressure difference across the duct
import math
# Variables
p=14.75 #lbf/in^2
M=29. #lbm/lbmol
R=10.73 #lbf.ft^3/(in^2.lbmol.R)
T=500. #R Rankine temperature scale
rho=p*M/(R*T) #lbm/ft^3
q=500. #ft^3/min
d=1. #ft
A=(math.pi)*d**2/4 #ft^2
v=(q/60.0)/A #ft/s
mew=0.017 #cP
#1cP = 0.000672 lbm/ft/s
R=d*v*rho/(mew*0.000672) #dimentionless reynold's no.
f=0.00465 #fanning friction factor
dx=800. #ft lenght of duct
#1 ft = 12 in
#1 lbf.s^2 = 32.2 lbm.ft
# Calculation
dP=rho*(4*f*(dx/d)*(v**2/2))/32.2/144. #lbf/in^2
# Result
print "The pressure drop across the duct is %f lbf/in^2"%dP
#Calculate the pump power required
# Variables
q=200. #gal/min
rho=62.3 #lbm/ft^3
#1 ft^3 = 7.48 gal
# Calculation
m=(q/60)*rho/7.48 #lbm/s
dx=2000. #ft
dp=3.87 #psi/100ft
F=(dp/100)*dx/rho*32.2*144 #ft
#1 hp = 550 lbf.ft/s
Po=F*m/550. #hp
# Result
print "The pump power required is %f hp"%Po
#Calculate the drop in pressure per unit length in a pipe
# Variables
dp=0.1 #psi
dx=800. #ft
#let D represent d/dx
#1 psi = 6895 Pa
#1 m = 3.28 ft
# Calculation
Dp=(dp/dx)*6895*3.28 #Pa/m
# Result
print "The drop in pressure per unit length in the pipe is %f Pa/m"%Dp
#Calculate the pressure difference created due to expansion and contraction
# Variables
rho=62.3 #lbm/ft^3
K=1.5 #dimentionless
v=13. #ft/s
#1 ft = 12 in
#1 lbf.s^2 = 32.2 lbm.ft
# Calculation
dp=rho*K*(v**2/2)/32.2/144 #lbf/in^2
# Result
print "The pressure drop due to expansion and contraction is %f lbf/in^2"%dp
#Calculate the pressure drop in the pipe due to fittings
# Variables
dx=3000.0 #ft actual length of pipe
dx1=281. #ft equivalent length of fittings
p=484. #psi
# Calculation
dx_total=dx+dx1 #ft
dp_total=p*(dx_total/dx) #psi
dp_vnf=dp_total-p #psi pressure drop fue to valves and fittings
# Result
print "The pressure drop due to valves and fittings is %d psi"%dp_vnf
#Calculate pressure drop due to valves and fittings
# Variables
K=27.56 #deimentionless
rho=62.3 #lbm/ft^3
v=13. #ft/s
# Calculation
#1 ft = 12 in
#1 lbf.s^2 = 32.2 lbm.ft
dp=rho*K*(v**2/2)/32.2/144. #psi
# Result
print "THe pressure drop due to valves and fittings is %d psi"%dp
#Calculate the gasoline leakage rate through a seal
import math
# Variables
p=100.0 #lbf/in^2
l=1. #in length od seal in direction of leak
mew=0.6 #cP
d=0.25 #in diameter of valve stem
t=0.0001 #in thickness of valva stem
# Calculation
#1 cP = 0.0000209 lbf.s/ft^2
#1 ft = 12 in
q=(p/l)*(1/12.0/mew)*(math.pi)*d*t**3/0.0000209*144*3600. #in^3/hr
# Result
print "The volumetric leakage rate of gasoline is %f in^3/hr"%q
rho=0.026 #lbm/in^3
m=q*rho #lbm/hr
print "The mass leakage rate of gasoline is %f lbm/hr"%m