#calculate the HHV and LHV at constant volume
#Initalization of variables
lhs=8.5 #moles of reactants
rhs=6 #moles of CO2
n=3. #moles of H2O
R=1545. #Universal gas constant
R2=18.016 #molar mass of water
J=778. #Work conversion constant
T=537. #R
T2=1050.4 #R
T3=991.3 #R
Qhp=1417041. #Btu/mol
#calculations
Qhpv=(lhs-rhs)*R*T/J
Qhv=Qhp-Qhpv
hfg=(rhs-n)*R2*T2
Qlp=Qhp-hfg
Qlpv=(lhs-rhs-n)*R/J *T
Qlv=Qlp-Qlpv
Qhlv=(rhs-n)*R2*T3
Qlv3=Qhv-Qhlv
#results
print '%s %d %s' %("Higher heating value at constant volume =",Qhv,"Btu/mol")
print '%s %d %s' %("\n Lower heating value at constant pressure =",Qlp,"Btu/mol")
print '%s %d %s' %("\n In case 1,Lower heating value at constant volume =",Qlv," Btu/mol")
print '%s %d %s' %("\n In case 2,Lower heating value at constant volume =",Qlv3,"Btu/mol")
print '%s' %("The answers might differ a bit from textbook due to rounding off error.")
#calculate the change in chemical energy during complete combustion and LHV at constant volume
#Initalization of variables
print '%s' %("From table 5-4,")
no=7.5
n1=3.
n2=6.
Q=1360805. #Btu/mol
#calculations
Uo=337+no*85
Uf=n1*104+n2*118
delo= Q-(Uo-Uf)
Uo2=1656+no*402
Uf2=n1*490+n2*570
Qv=Uo2-Uf2+delo
#results
print '%s %d %s' %("Change in chemical energy during complete combustion =",delo,"Btu/mol")
print '%s %d %s' %("\n Lower heating value at constant volume =",Qv,"Btu/mol")
#calculate the heat removed in the process
#Initalization of variables
print '%s' %("From table 5-4,")
a=1 #moles of C6H6
b=7.5 #moles of O2 in reactant
c=1.875 #moles of excess O2
d=35.27 #moles of N2
e=3 #moles of H2O
flow=40. #lb/min
w=1360850. #Btu/mol
#calculations
U11=a*337
U12=(b+c)*85
U13=d*82
U14=(a+b+c+d)*1066
Ua1=U11+U12+U13+U14
U21=c*2539
U22=d*2416
U23=e*3009
U24=2*e*3852
U25=(c+d+e+2*e)*1985
Ua2=U21+U22+U23+U24+U25
Q=Ua1+w-Ua2
fuel=flow/(6*12+2.*e)
Q2=Q*fuel
#results
print '%s %d %s' %("Heat removed =",Q2,"Btu/min")
print '%s' %("The answers might differ a bit from textbook due to rounding off error.")
#calculate the furnace efficiency
#Initalization of variables
rate=10700. #lb/min
t2=97.90
t1=33.05
r1=46. #lb/min
#calculations
print '%s' %("From steam tables,")
Hv=1417041.
Qw=rate*(t2-t1)
Q=r1/(12*6+6) *Hv
eff=Qw/Q*100.
#results
print '%s %.1f %s' %("Furnace efficiency =",eff,"percent")
#calculate the thermal efficiency
#Initalization of variables
rate=94. #lb/hr
hp=197. #hp
c=8.
h=18.
Lv=17730. #Btu/hr
H=2368089. #Btu/hr
#calculations
amount=rate*c/12 +h
amount=0.824
Lvv=H-Lv
eff=hp*2544/(amount*Lvv) *100
#results
print '%s %.2f %s' %("Thermal efficiency =",eff," percent")
#calculate the thermal efficiency
#Initalization of variables
rate=94. #lb/hr
hp=197. #hp
c=8.
h=18.
mole=9.
H=2350359. #Btu/hr
#calculations
amount=rate*c/12 +h
amount=0.824
Lvv=H-mole*18.016*1050.4
eff=hp*2544/(amount*Lvv) *100
#results
print '%s %.2f %s' %("Thermal efficiency =",eff,"percent")
print '%s' %("The answer in the textbook is a different due to rounding off error")
#calculate the total available energy
#Initalization of variables
import math
hv=14000. #Btu/lb
ef=0.4
tmin=80. #F
tmid=300. #F
m=13. #lb
c=0.27
tmean=2300. #F
#calculations
heat=ef*hv
Qavail=heat*(tmean-tmin)/(tmean+460)
Q=m*c*(tmean-tmid)
Q2=Q- (tmin+460)*m*c*math.log((tmean+460)/(tmid+460))
tot=Qavail+Q2
#results
print '%s %d %s' %("Total available energy =",tot," Btu/lb of fuel")
print '%s' %("The answer is a bit different due to rounding off error in textbook")
#calculate the max amount of work available
#Initalization of variables
print '%s' %("From table 14-2,")
G1=55750. #Btu/mol
co2=-169580. #Btu/mol
h2o=-98290. #Btu/mol
#calculations
G2=6*co2+3*h2o
avail=G1-G2
#results
print '%s %d %s' %("Max. amount of work =",avail,"Btu/mol")