# Chapter 11 - Thermodynamics of Fluid flow¶

## Example 1 - Pg 181¶

In [1]:
#calculate the reynolds number
#Initialization of variables
d=2.067 #in
P=20 #psia
R=53.35
T=600 #R
mu=0.0486 #lb /ft.hr
v=50 #ft/s
#calculations
rho=P*144./(R*T)
Re=d*v*rho*3600./(12*mu)
#results
print '%s %d' %("Reynolds number = ",Re)
print '%s' %('The answers are a bit different due to rounding off error in textbook')

Reynolds number =  57398
The answers are a bit different due to rounding off error in textbook


## Example 2 - Pg 184¶

In [2]:
#calculate the change in pressure and the percent change
#Initialization of variables
eps=0.00015
D=2.067/12. #ft
l=100 #ft
P=20 #psia
R=53.35
T=600 #R
mu=0.0486 #lb /ft.hr
v=50 #ft/s
g=32.17 #ft/s^2
#calculations
rho=P*144/(R*T)
Re=D*v*rho*3600./(mu)
ed=eps/D
print '%s' %("From figure 11.5")
f=0.0235
dp=f*l*rho*v*v /(2*D*g) /144.
change=dp/P *100.
#results
print '%s %.2f %s' %("Change in pressure =",dp,"psi")
print '%s %.2f %s' %("\n Percentage change in pressure =",change," percent")

From figure 11.5
Change in pressure = 0.33 psi

Percentage change in pressure = 1.66  percent


## Example 3 - Pg 190¶

In [3]:
#calculate the final pressure
#Initialization of variables
v1=60. #ft/s
d1=10. #in
d2=15. #in
P=15. #psia
R=53.35
T=540. #R
g=32.17 #ft/s^2
v1=60. #ft/s
#calculations
v2=v1*d1*d1 /d2/d2
rho=P*144/(R*T)
dp=rho*(v2*v2 -v1*v1)/(2*g) /144.
p2=P-dp
#results
print '%s %.2f %s' %("Final pressure =",p2," psia")

Final pressure = 15.02  psia


## Example 4 - Pg 192¶

In [4]:
#calculate the change in entropy
#Initialization of variables
J=778 #ft.lb/Btu
D=2.067/12. #ft
l=100 #ft
P=20 #psia
R=53.35
T=600 #R
mu=0.0486 #lb /ft.hr
v=50 #ft/s
g=32.17 #ft/s^2
#calculations
f=0.0235
ds=f*v*v *l /(J*2*D*g*T)
#results
print '%s %.6f %s' %("Change in entropy =",ds," Btu/lbm R")

Change in entropy = 0.001136  Btu/lbm R


## Example 5 - Pg 193¶

In [5]:
#calculate the pressure, enthalpy, entropy, temperature and density of the gas
#Initialization of variables
v=210 #ft/s
g=32.17 #ft/s^2
p=200. #psia
z=5. #ft
x=2.361
h=1210.3
J=778.
#calculations
P0=p + v*v /(2*g*144*x) + z/(144*x)
h0=h + v*v /(2*J*g) +z/J
S=1.5594 #units/lb
S0=S
t0=401.9 #F
v0=2.342 #cu ft/lb
rho0=1./v0
#results
print '%s %d %s' %("Pressure =",P0,"psia")
print '%s %.2f %s' %("\n Enthalpy =",h0," Btu/lb")
print '%s %.4f %s' %("\n Entropy  =",S0,"units/lb")
print '%s %.1f %s' %("\n Temperature =",t0," F")
print '%s %.3f %s' %("\n Density =",rho0," lb/cu ft")

Pressure = 202 psia

Enthalpy = 1211.19  Btu/lb

Entropy  = 1.5594 units/lb

Temperature = 401.9  F

Density = 0.427  lb/cu ft


## Example 6 - Pg 197¶

In [1]:
#calculate the exit temperature
#Initialization of variables
%matplotlib inline
import matplotlib
from matplotlib import pyplot
import math
p1=40. #psia
t1=80. #F
p2=30. #psia
ar=0.5 #sq ft
v1=200. #ft/s
R=53.35
cp=0.24
g=32.17
J=778.
#calculations
rho1=144*p1/(R*(t1+460))
G=rho1*v1
h10= cp*t1 + p1*p1 /(2*g*rho1*rho1 *J)
t2=78 #F
h2=cp*t2
g2=h10-h2
rho2=math.sqrt(p1*p1 /(2*g*g2*J))
P2=rho2*R*(t2+460)/144.
ds2=cp*math.log((t2+460.)/(t1+460.)) - R/J *math.log(P2/p1)
t3=77 #F
h3=cp*t3
g3=h10-h3
rho3=math.sqrt(p1*p1 /(2*g*g3*J))
P3=rho3*R*(t3+460)/144.
ds3=cp*math.log((t3+460.)/(t1+460.)) - R/J *math.log(P3/p1)
t4=79 #F
h4=cp*t4
g4=h10-h4
rho4=math.sqrt(p1*p1 /(2*g*g4*J))
P4=rho4*R*(t4+460)/144.
ds4=cp*math.log((t4+460)/(t1+460.)) - R/J *math.log(P4/p1)
h5=18.62
t5=h5/cp
Gv=([h4, h2, h3])
Pv=([P4, P2, P3])
Sv=([ds4, ds2, ds3])
pyplot.figure(1)
pyplot.title("Fanno line diagram , Enthalpy vs Entropy")
pyplot.xlabel("Entropy")
pyplot.ylabel("Enthalpy Btu/lb")
pyplot.plot(Sv,Gv)

pyplot.figure(2)
pyplot.title("Fanno line diagram , Pressure vs Entropy")
pyplot.xlabel("Entropy")
pyplot.ylabel("Pressure psia")
pyplot.plot(Sv,Pv)
warn=False
#results
print '%s %.1f %s' %("Temperature at exit =",t5," F")

Temperature at exit = 77.6  F


## Example 7 - Pg 199¶

In [18]:
#calculate the velocity required
#Initialization of variables
p1=40 #psia
t1=80. #F
p2=30 #psia
ar=0.5 #sq ft
v1=200 #ft/s
R=53.35
cp=0.24
g=32.17
J=778.
t2=78. #F
#calculations
G=40 #lb/sq ft/sec
rho2=144*p2/(R*(t2+460.))
v2=p1/rho2
#results
print '%s %d %s' %("Velocity =",v2,"ft/s")

Velocity = 265 ft/s


## Example 8 - Pg 206¶

In [3]:
#calculate the velocity, diameter, specific volume, density and diameter of nozzle
#Initialization of variables
%matplotlib inline
import math
import numpy
import matplotlib
from matplotlib import pyplot
P2=([180., 160., 140., 120., 100., 80., 60., 40., 20.])
k=1.4
p1=200 #psia
t1=240+460. #R
cp=0.24
J=778.
gc=32.2
R=53.35
m=4. #lb/sec
#calculations
b = len(P2)
pr=numpy.zeros(b);
prr=numpy.zeros(b);
T2=numpy.zeros(b);
dt=numpy.zeros(b);
dh=numpy.zeros(b);
v2=numpy.zeros(b);
vol=numpy.zeros(b);
A2=numpy.zeros(b);
dia=numpy.zeros(b);
den=numpy.zeros(b);
for i in range (0,b):
pr[i] = p1/P2[i]
prr[i]=math.pow(pr[i],((k-1)/k))
T2[i]=t1 /prr[i]
dt[i]= t1 -T2[i]
dh[i]=dt[i]*cp
v2[i]=math.sqrt(2*gc*J*dh[i])
vol[i]=(R*T2[i]) /(P2[i]*144.)
A2[i]=m*vol[i]*144. /v2[i]
dia[i]=math.sqrt(4/ math.pi *A2[i])
den[i]=1. /vol[i]

pyplot.figure(1)
pyplot.title ('Velocity vs pressure')
pyplot.xlabel('Pressure in psia')
pyplot.ylabel('velocity in ft/s')
pyplot.plot(P2,v2)

pyplot.figure(2)
pyplot.title('specific volume vs pressure')
pyplot.xlabel('Pressure in psia')
pyplot.ylabel('specific volume in cu ft/lb')
pyplot.plot(P2,vol)

pyplot.figure(3)
pyplot.xlabel('Pressure in psia')
#results
print '%s' %('Velocity in ft/s')
print (v2)
print '%s' %('Specific volume in cu ft/lb')
print (vol)
print '%s' %('Density in lb/cu ft')
print (den)
print '%s' %('Diameter of nozzle in in')
print (dia)

Velocity in ft/s
[  499.61112617   721.04131991   903.0653517   1069.14361272  1229.75524527
1392.40468067  1565.24666139  1761.46433404  2014.34825773]
Specific volume in cu ft/lb
[ 1.39805384  1.52076257  1.6729549   1.86768387  2.12745999  2.4950706
3.06425423  4.09358926  6.71623201]
Density in lb/cu ft
[ 0.71528003  0.65756484  0.59774475  0.53542252  0.47004409  0.40079026
0.32634368  0.2442844   0.14889301]
Diameter of nozzle in in
[ 1.43255795  1.24370371  1.16559809  1.1318789   1.12638708  1.14637045
1.19822204  1.30551392  1.56373036]


## Example 9 - Pg 210¶

In [19]:
#calcualte the nozzle exit area
#Initialization of variables
import math
p1=200. #psia
t1=480. #F
eff=0.95
g=32.2 #ft/s^2
J=778.
mf=3.4 #lb/s
#calculations
print '%s' %("From steam tables,")
h1=1257.8
h2=1210.5
dh=eff*(h1-h2)
ve=math.sqrt(2*g*J*dh)
h3=h1-dh
vs=3.961
Ae=mf*vs/ve *144.
#results
print '%s %.3f %s' %("Nozzle exit area =",Ae,"sq.in")

From steam tables,
Nozzle exit area = 1.292 sq.in


## Example 10 - Pg 216¶

In [20]:
#calculate the final temperature, pressure and exit velocity in both cases
#Initialization of variables
import math
import numpy
from numpy import roots
R=53.35
v=300. #ft/s
p=100 #psia
t1=200 #F
q=500 #Btu/s
gc=32.2 #ft/s^2
J=778
#calculations
rho1=p*144/(R*(460.+t1))
s=([1., -0.206, 0.00535])
vec=numpy.roots(s)
rho2=vec[0]
t2=(236.6 - 0.301/rho2/rho2)/0.248
P2=rho2*R*(t2+462) /144.
v2=math.sqrt(2*gc*J*(236.6-0.248*t2))
v22=rho1*v/rho2
#results
print '%s %.1f %s' %("Final temperature =",t2," F")
print '%s %.1f %s' %("\n Final pressure =",P2," psia")
print '%s %.1f %s' %("\n Exit velocity in case 1 =",v2,"ft/s")
print '%s %.1f %s' %("\n Exit velocity in case 2 =",v22," ft/s")

Final temperature = 914.6  F

Final pressure = 89.5  psia

Exit velocity in case 1 = 699.7 ft/s

Exit velocity in case 2 = 699.0  ft/s