#Initialization of variables
p1=100 #psia
p2=14.7 #psia
k=1.4
T1=700 #R
R=10.73/29
V=50
cv=0.171
cp=0.24
R2=1.986/29
#calculations
T2=T1/ (p1/p2)**((k-1)/k)
m1=p1*V/(R*T1)
m2=p2*V/(R*T2)
Wrev= cv*(m1*T1 - m2*T2) - (m1-m2)*(T2)*cp
#results
print "Work done in case 1 = %d Btu"%(Wrev)
from __future__ import division
from scipy import log
#Initialization of variables
p1=100 #psia
p2=10 #psia
n=1.3
T1=800 #R
cv=0.172
R=1.986/29
T0=537 #R
cp=0.24
#calculations
T2=T1*(p2/p1)**((n-1)/n)
dwir=cv*(T1-T2)
dwr=R*(T2-T1)/(1-n)
dq=dwr-dwir
dI=-T0*(cp*log(T2/T1) - R*log(p2/p1))
#results
print "The friction of the process per pound of air = %.1f Btu/lbm"%(dq)
print "\n Loss of available energy = %.2f Btu/lbm"%(dI)
#Initialization of variables
ms=10 #lbm
den=62.3 #lbm/ft**3
A1=0.0218 #ft**2
A2=0.00545 #ft**2
p2=50 #psia
p1=100 #psia
gc=32.2 #ft/s**2
dz=30 #ft
T0=537 #R
T1=620 #R
T2=420 #R
#calculations
V1=ms/(A1*den)
V2=ms/(A2*den)
df=-144/den*(p2-p1) - (V2**2 -V1**2)/(2*gc) - dz
dI=-T0/T1 *df
dI2= -T0/T2 *df
#results
print "Friction = %.1f ft-lbf/lbm"%(df)
print "\n Available energy loss in case a = %.1f ft-lbf/lbm"%(dI)
print "\n Available energy loss in case b = %.1f ft-lbf/lbm"%(dI2)
#Initialization of variables
r=2.5 #in
mf=160 #cfm
rho=1/14
mu=0.0000121
v=14 #ft**3/lbm
g=32.2 #ft/s**2
z=100 #ft
#calculations
A=3.14*(r/12)**2
V=mf/A /60
Re=(2*r/12)*V*rho/mu
print "From fig 12.4,"
f=0.0225/4
dp=4*f*(rho)*(V/v)**2 /(2*g*(2*r/12)) *z
#dp=2.32
#results
print "Pressure drop = %.2f lbf/ft**2 100 ft"%(dp)
print "The answer in the textbook is wrong. Please use a calculator to verify it."
from math import pi,sqrt
#Initialization of variables
D=0.0724 #ft
gc=32.2 #ft/s**2
rho=1.0/14
L=100 #ft
mu2=1.46*10**(-10)
dp=2.32
dia=5.0 #in
rho2=48500.0
vol=14.0 #ft**3/lbm
#calculations
ref=D**3 *2*dp*gc*rho/(mu2*L)
mf=rho2*pi/4 *(dia/12) *sqrt(mu2)
mfr=mf*vol*60
#results
print "Mass rate of air flow = %d cfm"%(mfr)
print "The answer is a bit different due to rounding off error in textbook"
from math import log
#Initialization of variables
cp=0.25
T=3460 #R
T0=520 #R
dG=1228 #Btu/lbm
#calculations
hf=cp*(T-T0)-T0*cp*log(T/T0)
dC=hf-dG
Ec=hf/dG
#results
print "Loss of available energy = %d Btu/lbm mixture "%(dC)
print "\n Effectiveness of combustion = %.3f "%(Ec)
#Initialization of variables
cp1=0.25
T=3460 #R
T0=946.2 #R
T00=520 #R
dG=1228 #Btu/lbm
cp=0.45
#calculations
dqa=cp1*(T-T0)
w=cp*dqa
hf=cp1*(T-T00)-T00*cp1*log(T/T00)
heat=w-hf
eff=w/hf
epower=w/dG
#results
print "Loss of available energy = %.1f Btu/lbm mixture "%(heat)
print "\n Efficiency of cycle = %.3f "%(eff)
print "\n Effectiveness of overall cycle = %.2f"%(epower)
print "The answer is a bit different due to rounding off error in textbook"
#Initialization of variables
p1=400 #psia
t1=600 #F
h1=1306.9 #Btu/lbm
b1=480.9 #Btu/lbm
p2=50 #psia
h2=1122 #Btu/lbm
h3=1169.5 #Btu/lbm
b3=310.9 #Btu/lbm
#calculations
print "All the values are obtained from Mollier chart,"
dw13=h1-h3
dw12=h1-h2
dasf=b3-b1
etae=dw13/dw12
eta=abs(dw13/dasf)
dq=dw13+dasf
#results
print "Engine efficiency = %.1f percent"%(etae*100)
print "\n Effectiveness = %.1f percent"%(eta*100)
print "\n Loss of available energy = %.1f Btu/lbm"%(dq)