Chapter 4 - Fluid Dynamics

Example 1 - Pg 79

In [1]:
#calculate dp/ds at both upper and lower ends
#Initialization of variables
rho=1.5 #g/cc
g=32.2 #ft/s^2
dzds=-0.5
x1=0
x2=3
#calculations
def func(s):
    dpds=-rho*g*dzds - rho*(3+9*s)*9
    return dpds

r1=func(x1)
r2=func(x2)
#results
print '%s %.1f %s' %("At the upper end, dp/ds =",r1,"lb/ft^2 per foot")
print '%s %.1f %s' %("\n At the lower end, dp/ds =",r2,"lb/ft^2 per foot")
At the upper end, dp/ds = -16.3 lb/ft^2 per foot

 At the lower end, dp/ds = -380.9 lb/ft^2 per foot

Example 2 - Pg 80

In [2]:
#calculate the pressure difference between the two points
#Initialization of variables
g=32.2 #ft/s^2
v1=3. #ft/s
z1=1.5 #ft
rho=1.5 #g/cc
z2=0
v2=30. #ft/s
#calculations
dp= rho*(v2*v2 /2. - g*z1 +g*z2 - v1*v1 /2.)
#results
print '%s %.1f %s' %("pressure difference =",dp,"lb/ft^2")
pressure difference = 595.8 lb/ft^2

Example 3 - Pg 85

In [3]:
#calculate the net power transferred
#Initialization of variables
pd=15. #psia
rhod=0.005#slug/ft^3
pi=150. #psia
rhoi=0.03 #slug/ft^3
dz=-25. #ft
vd=1000. #ft/s
vi=100. #ft/s
ud=200. #Btu/slug
ui=250. #Btu/slug
g=32.2 #ft/s^2
J=778.
uff=5. #ft/s
Q=50. #Btu/sec
#calculations
pr=pd/rhod*144. - pi/rhoi *144.
zr=g*(dz)
vr=(vd*vd -vi*vi)/2.
ur=(ud-ui)*J
jeh=J*Q*g/uff
gem=pr+zr+vr+ur+jeh
power=gem*uff/g
#results
print '%s %d %s' %("Power transferred =",power,"ft-lb/sec")
print '%s' %("The answers are a bit different from textbook due to rounding off error")
Power transferred = 64877 ft-lb/sec

Example 4 - Pg 89

In [4]:
#calculate the kinetic energy correction factor
#Initialization of variables
import math
import scipy
from scipy import integrate
r0=1. 
ri=0.
#calculations
def func1(y):
    v= 2*math.pow(y,(1./7.)) *(y-1)
    return v

V,err=scipy.integrate.quad(func1,ri,r0)
def func2(y):
    alpha= 1/ (math.pi*V*V*V) *2*math.pi *math.pow((y),(3./7.)) *(y-1) 
    return alpha

a2,err2=scipy.integrate.quad(func2,ri,r0)
#results
print '%s %.2f' %("Kinetic energy correction factor = ",a2)
Kinetic energy correction factor =  1.06

Example 5a - Pg 92

In [5]:
#calculate the pressure at the lower end if friction is neglected
#Initialization of variables
gam=62.4
pu=40. #psia
zu=25. #ft
vu=8. #ft/s
g=32.2 #ft/s^2
vl=8. #ft/s
zl=0 #ft
#calculations
pl= gam*(pu*144. /gam +zu-zl+ (vu*vu -vl*vl)/(2*g))/144.
#results
print '%s %.2f %s' %("Pressure at the lower end if friction is neglected =",pl,"psig")
Pressure at the lower end if friction is neglected = 50.83 psig

Example 5b - Pg 92

In [6]:
#calculate the pressure at the lower end if friction is not neglected
#Initialization of variables
hl=5.
gam=62.4
pu=40. #psia
zu=25. #ft
vu=8. #ft/s
g=32.2 #ft/s^2
vl=8. #ft/s
zl=0 #ft
#calculations
pl= gam*(pu*144. /gam +zu-zl-hl+ (vu*vu -vl*vl)/(2*g))/144.
#results
print '%s %.2f %s' %("Pressure at the lower end if friction is neglected =",pl,"psig")
Pressure at the lower end if friction is neglected = 48.67 psig

Example 6a - Pg 94

In [8]:
#calculate the discharge flow rate.
#Initialization of variables
import math
gam=62.4
pa=0
za=15. #ft
va=0
pg=0
zg=0
g=32.2 #ft/s^2
dg=2. #in
#calculations
vg= math.sqrt(2*g*(pa/gam +za+va*va /(2*g) -pg/gam - zg))
Ag=math.pi/4. *(dg/12.)*(dg/12.)
Q=Ag*vg
#results
print '%s %.2f %s' %("discharge =",Q,"ft^3/sec")
discharge = 0.68 ft^3/sec

Example 6b - Pg 95

In [9]:
#calculate the pressure at the points C,D,E and F
#Initialization of variables
import math
gam=62.4
pa=0
za=15. #ft
va=0
pg=0
zg=0
g=32.2 #ft/s^2
d=4. #in
dg=2. #in
zd=25.  #ft
#calculations
vg= math.sqrt(2*g*(pa/gam +za+va*va /(2*g) -pg/gam - zg))
Ag=math.pi/4. *(dg/12.)*(dg/12.)
Q=Ag*vg
A=math.pi/4. *(d/12.)*(d/12.)
v4=Q/A
pc=-v4*v4 *gam/(2*g*144.)
pgd= za-zd - v4*v4 /(2*g)
pd=pgd*gam/144.
pe=-v4*v4 *gam/(2*g*144.)
pfg= za- v4*v4 /(2*g)
pf=pfg*gam/144.
#results
print '%s %.2f %s' %("Pressure at C =",pc," psig")
print '%s %.2f %s' %("\n Pressure at D =",pd," psig")
print '%s %.2f %s' %("\n Pressure at E =",pe," psig")
print '%s %.2f %s' %("\n Pressure at F =",pf," psig")
Pressure at C = -0.41  psig

 Pressure at D = -4.74  psig

 Pressure at E = -0.41  psig

 Pressure at F = 6.09  psig

Example 7 - Pg 97

In [1]:
#calculate the time required
#Initialization of variables
import math
import scipy
from scipy import integrate
d1=6. #ft
d2=3. #in
pa=2. #ft
d=13.6 
sg=0.75
h1=5. #sec
h2=3. #sec
g=32.2 #ft/s^2
#calculations
pag=pa/12. *d/sg
def  func(h):
    time= -d1*d1 /(d2/12.)/(d2/12.) /(math.sqrt(2*g)) *math.pow((pag+h),(-0.5))
    return time
ti,err=scipy.integrate.quad(func,h1,h2)
#results
print '%s %.1f %s' %("Time required =",ti," sec")
print '%s' %("The answers are a bit different from textbook due to rounding off error")
Time required = 54.3  sec
The answers are a bit different from textbook due to rounding off error

Example 8 - Pg 100

In [11]:
#calculate the rate of flow 
#Initialization of variables
import math
x=12. #ft
angle=30.*math.pi/180. #degrees
g=32.2 #ft/s^2
z=-2. #ft
d=2. #in
#calculations
vj= x/math.cos(angle) *math.sqrt(g/(2*(x*math.tan(angle) -z)))
Q=math.pi/4. *(d/12.)*(d/12.) *vj
#results
print '%s %.2f %s' %("Rate of flow =",Q," ft^3/s")
Rate of flow = 0.41  ft^3/s

Example 9 - Pg 103

In [12]:
#calculate the net discharge
#Initialization of variables
import math
x=10. #in of mercury
sg=13.6 #g/cc
d1=8. #in
d2=4. #in
g=32.2 #ft/s^2
#calculations
vdiff=x/12. *sg- x/12.
Vts=vdiff/(1-math.pow((d2/d1),4))
Vt=math.sqrt(2*g*Vts)
Q=Vt*math.pi/4. *(d2/12.)*(d2/12.)
#results
print '%s %.2f %s' %("Discharge =",Q,"ft^3/s")
Discharge = 2.34 ft^3/s

Example 11 - Pg 107

In [13]:
#calculate the horsepower input of the test pump
#Initialization of variables
import math
gam=62.4
ds=12. #in
dd=10. #in
Q=4. #ft^3/s
pd=40. #psia
ps=-6. #psia
zd=5. #ft
zs=0
g=32.2 #ft/s^2
#calculations
vs=Q/(math.pi/4. *math.pow((ds/12.),2))
vd=Q/(math.pi/4. *math.pow((dd/12.),2))
emp = (pd-ps)*144./gam + zd-zs + (vd*vd - vs*vs)/(2*g)
hpp=emp*Q*gam/550.
#results
print '%s %.1f %s' %("Horsepower input of the test pump =",hpp,"hp")
Horsepower input of the test pump = 50.6 hp

Example 12 - Pg 117

In [2]:
#calculate the horizontal and vertical components of force
#Initialization of variables
import math
d1=12. #in
d2=8. #in
v1=15. #ft/s
p1=12. #psig
p2=5.85 #psig
rho=1.94 #ft^3/slug
angle=60.*math.pi/180. #degrees
#calculations
Q=math.pi/4. *(d1/12.)*(d1/12.) *v1
v2=Q/(math.pi/4. *(d2/12.)*(d2/12.))
pa1=p1*math.pi/4. *(d1)*(d1)
pa2=p2*math.pi/4. *(d2)*(d2)
qv1=rho*Q*v1
qv2=rho*Q*v2
Fx=pa1+qv1+ math.cos(angle)*(pa2+qv2)
Fy=math.sin(angle)*(pa2+qv2)
#results
print '%s %d %s' %("Horizontal component of force =",Fx,"lb")
print '%s %d %s' %("\n Vertical component of force =",Fy,"lb")
print '%s' %("The answers are a bit different from textbook due to rounding off error")
Horizontal component of force = 2232 lb

 Vertical component of force = 922 lb
The answers are a bit different from textbook due to rounding off error

Example 14a - Pg 127

In [3]:
#calculate the exit velocity of the pump
#Initialization of variables
import math
de=4. #in
T=1000. #lb
g=32.2 #ft/s^2
vele=8.5 #lb/s
pe=16.5 #psia
pa=14.7 #psia
#calculations
Ae=math.pi/4. *de*de
Ve= (T-(pe-pa)*Ae)*g/vele
#results
print '%s %d %s' %("Exit velocity =",Ve,"ft/s")
print '%s' %("The answers are a bit different from textbook due to rounding off error")
Exit velocity = 3702 ft/s
The answers are a bit different from textbook due to rounding off error

Example 14b - Pg 127

In [5]:
#calculate the thrust in the pipe
#Initialization of variables
import math
de=4. #in
T=1000. #lb
g=32.2 #ft/s^2
vele=8.5 #lb/s
pe=16.5 #psia
pa=14.7 #psia
pa2=1 #psia
#calculations
Ae=math.pi/4 *de*de
Ve= (T-(pe-pa)*Ae)*g/vele
T2=vele/g *Ve + (pe-pa2)*Ae
#results
print '%s %d %s' %("Thrust =",T2,"lb")
Thrust = 1172 lb

Example 16 - Pg 133

In [17]:
#calculate the downstream depth and horsepower dissipation
#Initialization of variables
q=240. #ft^3/sec/ft
v1=60. #ft/s
gam=62.4 
rho=1.94 #slug/ft^3
g=32.2 #ft/s^2
#calculations
y1=q/v1
v2=8.6 #ft/s
y2=28. #ft
hl= (y1+ v1*v1 /(2*g)) - (y2+ v2*v2 /(2*g))
hpp=hl*q*gam/550.
#results
print '%s %.1f %s' %("Downstream depth =",y2,"ft")
print '%s %d %s' %("\n Horsepower dissipation =",hpp,"hp per foot width")
Downstream depth = 28.0 ft

 Horsepower dissipation = 837 hp per foot width

Example 17 - Pg 137

In [18]:
#calculate the acceleration required
#Initialization of variables
dh=3. #in
L=12. #in
g=32.2 #ft/s^2
#calculations
a=dh/L *g
#results
print '%s %.2f %s' %("Acceleration =",a," ft/s^2")
Acceleration = 8.05  ft/s^2