#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')
#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")
#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")
#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")
#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")
#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")
#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")
#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);
rad=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])
rad[i]=dia[i]/2.
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.title('Radius vs Pressure')
pyplot.xlabel('Pressure in psia')
pyplot.ylabel('Radius in in')
pyplot.plot(P2,rad)
#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)
#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")
#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")