#Initialization of variables
n=1.3
T1=460+60 #R
P1=14.7 #psia
P2=125 #psia
R=1545
M=29
#calculations
T2=T1*(P2/P1)**((n-1)/n)
wrev=R/M *(T2-T1)/(1-n)
#results
print "Work done = %d ft-lbf/lbm"%(wrev)
print "The answer is a bit different due to rounding off error in textbook"
#Initialization of variables
P2=10 #psia
P1=100 #psia
T1=900 #R
w=50 #Btu/lbm
k=1.39
cp=0.2418
#calculations
T2=T1*(P2/P1)**((k-1)/k)
T2=477
KE=-w-cp*(T2-T1)
#results
print "Change in kinetic energy = %.1f Btu/lbm"%(KE)
#Initialization of variables
T1=900 #R
P1=100 #psia
P2=10 #psia
#calculations
print "From table B-9"
pr1=8.411
pr2=pr1*P2/P1
T2=468 #R
#results
print "Final temperature = %d R "%(T2)
#Initialization of variables
cr=6
p1=14.7 #psia
t1=60.3 #F
M=29
R=1.986
#calculations
print "from table b-9"
vr1=158.58
u1=88.62 #Btu/lbm
pr1=1.2147
vr2=vr1/cr
T2=1050 #R
u2=181.47 #Btu/lbm
pr2=14.686
p2=p1*(pr2/pr1)
dw=u1-u2
h2=u2+T2*R/M
#results
print "final temperature = %d R"%(T2)
print "\n final pressure = %.1f psia"%(p2)
print "\n work done = %.2f Btu/lbm"%(dw)
print "\n final enthalpy = %.1f Btu/lbm"%(h2)
from __future__ import division
#Initialization of variables
m1=10 #lbm
m2=15 #lnm
p=50 #psia
t=60+460 #R
M1=32
M2=28.02
R0=10.73
#calculations
n1=m1/M1
n2=m2/M2
x1=n1/(n1+n2)
x2=n2/(n1+n2)
M=x1*M1+x2*M2
R=R0/M
V=(n1+n2)*R0*t/p
rho=p/(R0*t)
rho2=M*rho
p1=x1*p
p2=x2*p
v1=x1*V
v2=x2*V
#results
print "part a"
print "Mole fractions of oxygen and nitrogen are %.3f and %.3f respectively"%(x1,x2)
print "part b"
print "Average molecular weight = %.1f "%(M)
print "part c"
print "specific gas constant = %.4f psia ft**3/lbm R"%(R)
print "part d"
print "volume of mixture = %.1f ft**3"%(V)
print "density of mixture is %.5f mole/ft**3 and %.2f lbm/ft**3"%(rho,rho2)
print "part e"
print "partial pressures of oxygen and nitrogen are %.2f psia and %.2f psia respectively"%(p1,p2)
#Initialization of variables
m1=10 #lbm
m2=15 #lnm
p=50 #psia
t=60+460 #R
M1=32
M2=28.02
R0=10.73
#calculations
n1=m1/M1
n2=m2/M2
x1=n1/(n1+n2)
x2=n2/(n1+n2)
M=x1*M1+x2*M2
R=1545/M
V=(n1+n2)*R0*t/p
rho=p/(R0*t)
rho2=M*rho
p1=x1*p
p2=x2*p
v1=x1*V
v2=x2*V
pt=p1+p2
vt=v1+v2
#results
print "part a"
print "Mole fractions of oxygen and nitrogen are %.3f and %.3f respectively"%(x1,x2)
print "part b"
print "Average molecular weight = %.1f "%(M)
print "part c"
print "specific gas constant = %.4f lbf ft/lbm R"%(R)
print "part d"
print "volume of mixture = %.1f ft**3"%(V)
print "\n density of mixture is %.5f mole/ft**3 and %.3f lbm/ft**3"%(rho,rho2)
print "part e"
print "partial pressures of oxygen and nitrogen are %.2f psia and %.2f psia respectively"%(p1,p2)
print "\n partial volumes of oxygen and nitrogen are %.2f ft**3 and %.2f ft**3 respectively"%(v1,v2)
print "\n Net partial pressure in case of oxygen = %.2f psia"%(pt)
print "\n Net partial volume =%.2f ft**3"%(vt)
#Initialization of variables
m1=5.28
m2=1.28
m3=23.52
#calculations
m=m1+m2+m3
x1=m1/m
x2=m2/m
x3=m3/m
C=12/44 *m1/ m
O=(32/44 *m1 + m2)/m
N=m3/m
sum1=(x1+x2+x3)*100
sum2=(C+N+O)*100
#results
print "From gravimetric analysis, co2 = %.1f percent , o2 = %.1f percent and n2 = %.1f percent"%(x1*100,x2*100,x3*100)
print "\n From ultimate analysis, co2 = %.2f percent , o2 = %.2f percent and n2 = %.2f percent"%(C*100,O*100,N*100)
print "\n Sum in case 1 = %.1f percent"%(sum1)
print "\n Sum in case 2 = %.1f percent"%(sum2)
from __future__ import division
from scipy import log
#Initialization of variables
x1=1/3
n1=1
n2=2
x2=2/3
p=12.7 #psia
cp1=7.01 #Btu/mole R
cp2=6.94 #Btu/mole R
R0=1.986
T2=460+86.6 #R
T1=460 #R
p0=14.7 #psia
#calculations
p1=x1*p
p2=x2*p
ds1= cp1*log(T2/T1) - R0*log(p1/p0)
ds2= cp2*log(T2/T1) - R0*log(p2/p0)
S=n1*ds1+n2*ds2
#results
print "Entropy of mixture = %.2f Btu/R"%(S)
print "\n the answer given in textbook is wrong. please check using a calculator"
from __future__ import division
from scipy import log
#Initialization of variables
c1=4.97 #Btu/mol R
c2=5.02 #Btu/mol R
n1=2
n2=1
T1=86.6+460 #R
T2=50+460 #R
#calculations
du=(n1*c1+n2*c2)*(T2-T1)
ds=(n1*c1+n2*c2)*log(T2/T1)
#results
print "Change in internal energy = %d Btu"%(du)
print "\n Change in entropy = %.3f Btu/R"%(ds)
from __future__ import division
#Initialization of variables
n1=1
n2=2
c1=5.02
c2=4.97
t1=60 #F
t2=100 #F
R0=10.73
p1=30 #psia
p2=10 #psia
#calcualtions
t=(n1*c1*t1+n2*c2*t2)/(n1*c1+n2*c2)
V1= n1*R0*(t1+460)/p1
V2=n2*R0*(t2+460)/p2
V=V1+V2
pm=(n1+n2)*R0*(t+460)/V
#results
print "Pressure of mixture = %.1f psia"%(pm)
print "\n Mixing temperature = %.1f F"%(t)
from __future__ import division
from scipy import log
#Initialization of variables
T2=546.6 #R
T1=520 #R
T3=560 #R
v2=1389.2
v1=186.2
R0=1.986
c1=5.02
c2=4.97
n1=1
n2=2
v3=1203
#calculations
ds1=n1*c1*log(T2/T1) + n1*R0*log(v2/v1)
ds2=n2*c2*log(T2/T3)+n2*R0*log(v2/v3)
ds=ds1+ds2
ds3=n1*c1*log(T2/T1)+n2*c2*log(T2/T3)
ds4=n2*R0*log(v2/v3)+ n1*R0*log(v2/v1)
dss=ds3+ds4
#results
print "Change in entropy for gas 1 = %.3f Btu/R"%(ds1)
print "\n Change in entropy for gas 1 = %.3f Btu/R"%(ds2)
print "\n Net change in entropy = %.3f Btu/R"%(ds)
print "\n In case 2, change in entropy = %.3f Btu/R"%(dss)
print "The answer is a bit different due to rounding off error in the textbook"
from __future__ import division
from scipy import log
#Initialization of variables
m1=1 #lbm
m2=0.94 #lbm
M1=29
M2=18
p1=50 #psia
p2=100 #psia
t1=250 +460 #R
R0=1.986
cpa=6.96
cpb=8.01
#calculations
xa = (m1/M1)/((m1/M1)+ m2/M2)
xb=1-xa
t2=t1*(p2/p1)**(R0/(xa*cpa+xb*cpb))
d=R0/(xa*cpa+xb*cpb)
k=1/(1-d)
dsa=cpa*log(t2/t1) -R0*log(p2/p1)
dSa=(m1/M1)*dsa
dSw=-dSa
dsw=dSw*M2/m2
#results
print "Final remperature = %d R"%(t2)
print "\n Change in entropy of air = %.3f btu/mole R and %.5f Btu/R"%(dsa,dSa)
print "\n Change in entropy of water = %.4f btu/mole R and %.5f Btu/R"%(dsw,dSw)
print "The answers are a bit different due to rounding off error in textbook"
from __future__ import division
#Initialization of variables
T=250 + 460 #R
p=29.825 #psia
pt=50 #psia
vg=13.821 #ft**3/lbm
M=29
R=10.73
#calculations
pa=pt-p
V=1/M *R*T/pa
ma=V/vg
xa=p/pt
mb=xa/M *18/(1-xa)
#results
print "In case 1, volume occupied = %.2f ft**3"%(V)
print "\n In case 1, mass of steam = %.2f lbm steam"%(ma)
print "\n In case 2, mass of steam = %.3f lbm steam"%(mb)
from __future__ import division
#Initialization of variables
ps=0.64 #psia
p=14.7 #psia
M=29
M2=46
#calculations
xa=ps/p
mb=xa*9/M *M2/(1-xa)
#results
print "percentage = %.1f percent"%(mb*100)
from __future__ import division
#Initialization of variables
ps=0.5069 #psia
p=20 #psia
m1=0.01
m2=1
M1=18
M2=29
#calculations
xw= (m1/M1)/(m1/M1+m2/M2)
pw=xw*p
#results
print "partial pressure of water vapor = %.3f psia"%(pw)