#calculate the mass and partial volumes of of oxygen, nitrogen
#Initialization of variables
P=70. #psia
Pt=110. #psia
V=20. #cu ft
R0=1545. #Universal gas constant
T=540. #R
M=32. #Molecular weight of Oxygen
M2=28. #Molecular weight of Nitrgoen
#calculations
N=P*V*144/(R0*T)
mo=M*N
Pn=Pt-P
N2=Pn*V*144/(R0*T)
mn=N2*M2
Vo=N*R0*T/(144*Pt)
Vn=N2*R0*T/(144*Pt)
Vn2=V-Vo
#results
print '%s %.2f %s' %("Mass of oxygen =",mo," lb")
print '%s %.2f %s' %("\n Mass of nitrogen =",mn," lb")
print '%s %.2f %s' %("\n Partial volume of oxygen =",Vo," cu ft")
print '%s %.2f %s' %("\n Partial volume of nitrogen =",Vn," cu ft")
print '%s %.2f %s' %("\n In case 2, Partial volume of nitrogen =",Vn2," cu ft")
#calculate the change in entropy
#Initialization of variables
import math
P=50. #psia
V=4. #cu ft
dv=3. #cu ft
J=778.
T=560. #R
#calculation
ds= 144*P*V*math.log((V+dv)/V) /(J*T)
#results
print '%s %.3f %s' %("Change in entropy =",ds,"unit")
#Calculate the change in entropy
#Initialization of variables
import math
p1=50. #psia
t1=100+460. #R
R1=48.3
R2=55.2
v1=4. #cu ft
p2=100. #psia
v2=3. #cu ft
t2=200.+460 #R
cv1=0.157
cv2=0.177
cpm=0.219
J=778.
#calculations
m1=144*p1*v1/(R1*t1)
m2=144*p2*v2/(R2*t2)
tf=(m1*cv1*(t1-460) + m2*cv2*(t2-460))/(m1*cv1+m2*cv2)
Po2=v1/(v1+v2) *(tf+460)/t1 *p1
ds=cpm*math.log((tf+460)/t1) - R1/J *math.log(Po2/p1)
dss=ds*m1
#results
print '%s %.4f %s' %("Change in entropy =",dss,"unit")
#Calculate the change in entropy
#Initialization of variables
import math
p1=30 #psia
t1=80.+460 #R
R1=48.3
R2=55.2
m1=20. #lb/min
p2=50. #psia
m2=35. #lb/min
t2=160.+460 #R
cp1=0.219
cp2=0.248
J=778
#calculations
tf=(m1*cp1*(t1-460) + m2*cp2*(t2-460))/(m1*cp1+m2*cp2)
Po2=m1/32/(m1/32+m2/28) *p1
ds=cp1*math.log((tf+460)/t1) - R1/J *math.log(Po2/p1)
dss=ds*m1
#results
print '%s %.4f %s' %("Change in entropy =",dss,"units/min")
print '%s' %("The answer is a bit different fromm textbook due to rounding off error in textbook")
#calculate the weight per mole and also the gas constant
#Initialization of variables
import numpy
x=([0.15, 0.08, 0.77])
M=([44, 32, 28])
#calculations
b=len(x)
y=numpy.zeros(b)
yt=numpy.zeros(b)
mt=numpy.zeros(b)
per=numpy.zeros(b)
wt=numpy.zeros(b)
R=numpy.zeros(b)
for i in range (0,b):
y[i]=x[i]/M[i]
yt=sum(y)
for i in range (0,b):
mt[i]=y[i]/yt
per[i]=mt[i]*100
wt=1. /yt
R=1545. /wt
#results
print '%s' %("Volumetric analysis")
print '%s' %('percent by volume')
print (per)
print '%s %.1f %s' %("Weight per mole =",wt," lb")
print '%s %.1f' %("\n Gas constant =",R)
print '%s' %("The answer is a bit different fromm textbook due to rounding off error in textbook")
#calculate the theoretical air and amount of nitrogen
#Initialization of variables
x1=0.885 #mole fraction of Ch4
x2=0.115 #mole fraction of c2h6
x3=0.4/100. #mole fraction of N2
n1=2. #Moles of Ch4
n2=3.5 #Moles of c2h6
n3=1. #moles of ch4 in case 2
n4=2. #moles of c2h6 in case 2
#calculations
y1=n1*x1
y2=n2*x2
y=y1+y2
vec2=([y1, y2])
air=y/0.21
y3=n3*x1
y4=n4*x2
yy=y3+y4
vec3=([y3 ,y4])
air2=y/0.21 *0.79
#results
print '%s %.2f %s' %("Theoretical air =",air," moles of air per mole of fuel")
print '%s' %("Oxygen analysis")
print(vec2)
print '%s %.2f %s' %("\n Amount of nitrogen =",air2," moles of nitrogen per mole of fuel")
print '%s' %("Dry analysis")
print(vec3)
print '%s %.3f %s' %("total =",yy," moles")
print '%s' %("The answer is a bit different fromm textbook due to rounding off error in textbook")
#calculate the theoretical air fuel ratio
#Initialization of variables
import numpy
x=([0.74, 0.06, 0.01]) #mole fraction of C, H and S respectively
y=([8./3., 8, 1]) #Pounds O2 per pound substance of C,H and S respectively
oxy=0.08 #Oxygen in coal
z=0.232 #mass of coal
#calculations
b=len(x)
pou = numpy.zeros(b)
for i in range (0,b):
pou[i]=x[i]*y[i]
tot=sum(pou)
oxy2=tot-oxy
air=oxy2/z
#results
print '%s %.2f %s' %("Theoretical air fuel ratio =",air,"lb of air per pound of coal")
#calculate air fuel ratio and also molal analysis
#Initialization of variables
o2=12.5 #moles of O2
h20=9 #moles of H2O
x=0.21 #Mole fraction of Oxygen in air
M=28.97 #Molar mass of air
M2=56. #molar mass of C4H8
M1=8*12+18. #molecular mass of c8h18
#calculations
air=o2/x
pound=air*M
AR=pound/M1
y1=h20/M2 *100.
y2=o2*(79./21) /M2 *100.
#results
print '%s %.2f %s' %("Air fuel ratio =",AR,"lb of air per pound of fuel")
print '%s %.2f %s %.2f %s' %("\n Molal or volumetric analysis is",y1, "percent of CO2 and",y2, "percent N2")
#calculate the volumetric analysis and also volume of wet products
#Initialization of variables
x=18.5 #Moles of O2
c=12. #Moles of CO2
vap=13. #moles of H2O
P=15. #psia
R=1545. #Universal gas constant
#calculations
excess=x*0.5
M=12*12+2*vap
n2=(x+excess)*79/21.
nt=n2+excess+c
dry=([c, x/2, n2])
b= len(dry)
for i in range(0,b):
dry[i] = dry[i] /nt *100
wet=nt+vap
fue=100./(M)
mol=wet*fue
vol=mol*R*1460./(144*P)
#results
print '%s' %("Volumetric analysis in percentage")
print (' CO2 O2 N2')
print (dry)
print '%s %d %s' %("Volume of wet products =",vol,"cfm")
#calculate the volumetric analysis
#Initialization of variables
import numpy
from numpy import linalg
from numpy.linalg import inv
A=numpy.array([[1, 1], [0.5, 1]])
B=numpy.array([[1],[ 0.9]])
x=0.9
#calculations
N2=x*79./21.
C=numpy.linalg.solve(A,B)
vec= ([ C[0], C[1], N2])
su=sum(vec)
b= len(vec)
vec2=numpy.zeros(b)
for i in range (0,b):
vec2[i]=vec[i]/su *100.;
#results
print '%s' %("Volumetric analysis")
print '%s' %('CO CO2 N2')
print (vec2)
#calculate the Moles of dry products per pound of coal
#Initialization of variables
c=0.74
ref=0.02
co2=0.12
co=0.1/100.
M=12.
#calcualtions
carbon=c-ref
car2=co2+co
wt=car2*M
amount=carbon/wt
#results
print '%s %.3f %s' %("Moles of dry products per pound of coal =",amount," mole")
#calculate the Number of moles of dry products per pound of fuel
#Initialization of variables
x1=0.128
x2=0.035
x3=0.002
M=12.
N=26.
#calculations
c=x1+x3
mole=12./c
wt=M*M+N
num=mole/wt
#results
print '%s %.3f %s' %("Number of moles of dry products per pound of fuel =",num," mole")
#calculate the weight of air and excess air percentage
#Initialization of variables
c=0.74
ref=0.02
co2=0.12
co=0.1/100.
o2=0.065
M=12
x=0.79
M=28.97
#calcualtions
n2=1-(co2+co+o2)
mol=n2/x
wt=mol*M
wt2=0.496
pou=wt2*wt
ta=10.27
EA=(pou-ta)/ta *100
#results
print '%s %.2f %s' %("Weight of air per pound of fuel =",pou,"lb")
print '%s %.1f %s' %("\n Excess air percentage =",EA,"percent")