In [18]:

```
# Given:-
# Part(a)
# The combustion equation can be written in the form of
# C8H18 + a(O2 + 3.76N2) --> b CO2 + c H2O + d N2
# Using conservation of mass principle
b = 8.00
c = 18.00/2.00
a = (2.00*b+c)/2.00
d = 3.76*a
# The airâ€“fuel ratio on a molar basis is
AFbar = a*(1+3.76)/1.00
Ma = 28.97 # molar mass of air
MC8H18 = 114.22 # molar mass of C8H18
# The airâ€“fuel ratio expressed on a mass basis is
AF = AFbar*(Ma/MC8H18)
# Result
print '-> The airâ€“fuel ratio on a molar basis is: '
print AFbar
print '-> The airâ€“fuel ratio expressed on a mass basis is: '
print round(AF,2)
# Part(b)
# For 150% theoretical air, the chemical equation for complete combustion takes the form
# c8H18 + 1.5*12.5*(O2 + 3.76N2) ---> b CO2 + c H2O + d N2 + e O2
# Using conservation of mass
# Calculations
b = 8.00
c =18.00/2.00
e = (1.5*12.5*2 - c -2*b)/2.00
d = 1.5*12.5*3.76
# The airâ€“fuel ratio on a molar basis is
AFbar = 1.5*12.5*(1+3.76)/1
# The airâ€“fuel ratio expressed on a mass basis is
AF = AFbar*(Ma/MC8H18)
# Results
print '-> The airâ€“fuel ratio on a molar basis is: '
print AFbar
print '-> The airâ€“fuel ratio expressed on a mass basis is: '
print round(AF,2)
```

In [19]:

```
# Given:-
# Part(a)
# The chemical equation
# a CH4 + b*(O2 + 3.76N2) ---> 9.7CO2 + .5CO + 2.95O2 + 86.85N2 + cH2O
# Calculations
# Applying conservation of mass
a = 9.7 + 0.5
c = 2.0*a
b = ((9.7)*(2.0)+(0.5)+((2.0)*(2.95))+c)/2.00
Ma = 28.97 # molar mass of air
MCH4 = 16.04 # molar mass of methane
# On a molar basis, the airâ€“fuel ratio is
AFbar = (b*(1+3.76))/a
# On a mass basis
AF = AFbar*(Ma/MCH4)
# Results
print '-> The air-fuel ratio on a molar basis is: '
print AFbar
print '-> The air-fuel ratio on a mass basis is: '
print round(AF,2)
# Part(b)
# The balanced chemical equation for the complete combustion of methane with the theoretical amount of air is
# CH4 + 2(O2 + 3.76N2) ---> CO2 + 2H2O + 7.52N2
# The theoretical airâ€“fuel ratio on a molar basis is
# Calculations
AFbartheo = 2.00*(1+3.76)/1.0
# The percent theoretical air is
Ta = AFbar/AFbartheo
# Result
print '-> The percent theoretical air is: '
print round(Ta*100,2)
# Ppart(c)
# The mole fraction of the water vapor is
yv = 20.4/(100+20.4)
pv = yv*1
# Interpolating in Table A-2,
T = 57 # in degree celcius
# Result
print '-> The dew point temperature of the products, in C, if the mixture were cooled at 1 atm is: '
print T
```

In [20]:

```
# Given:-
# Part(a)
# The chemical equation
# (.8062CH4 + .0541C2H6 + .0187C3H8 + .0160C4H10 + .1050N2) + a(O2 + 3.76N2) ----> b(.078CO2 + .002CO + .07O2 + .85N2) + c H2O
# Calculations
# Using mass conservation
b = (0.8062 + 2*.0541 + 3*.0187 + 4*.0160)/(.078 + .002)
c = (4*.8062 + 6*.0541 + 8*.0187 + 10*.0160)/2
a = (b*(2*.078+.002+2*.07) + c)/2
# The airâ€“fuel ratio on a molar basis is
AFbar = a*(1+3.76)/1
# Result
print '-> The air-fuel ratio on a molar mass basis is: '
print round(AFbar,2)
# Part(b)
p = 1.0 # in bar
V = 100.0 # in m^3
Rbar = 8314.0 # in N.m/kmol.K
T = 300.0 # in kelvin
# Calculations
# The amount of fuel in kmol
nF = (p*10**5*V)/(Rbar*T)
# The amount of product mixture that would be formed from 100 m3 of fuel mixture is
n = nF*(b+c)
# Result
print '-> The amount of products in kmol that would be formed from 100 m3 of fuel mixture at 300 K and 1 bar is: '
print round(n,2)
# Part(c)
# The balanced chemical equation for the complete combustion of the fuel mixture with the theoretical amount of air is
# (10.8062CH4 + 0.0541C2H6 + 0.0187C3H8 + 0.0160C4H10 + 0.1050N2) + 2(O2 + 3.76N2) ----> 1.0345CO2 + 1.93H2O + 7.625N2
# Calculations
# The theoretical airâ€“fuel ratio on a molar basis is
AFbartheo = 2*(1+3.76)/1
# The percent theoretical air is
Ta = AFbar/AFbartheo
# Result
print '-> The percent of theoretical air is: '
print round(Ta*100,2)
```

In [21]:

```
# Given:-
# The balanced chemical equation for complete combustion with the theoretical amount of air is obtained from the solution to Example 13.1 as
# C8H18 +12.5O2 + 47N2 -----> 8CO2 + 9H2O + 47N2
# From tabel A-25
hRbar = -249910 # in kj/kmol
mfdot = 1.8e-3 # mass flow rate of liquid octane in kg/s
M = 114.22 # molar mass of octane
Wcvdot = 37 # power output of the engine in kw
# Calculations
# With enthalpy of formation values for CO2 and H2O(g) from Table A-25, and enthalpy values for N2, H2O, and CO2 from Table A-23
hpbar = 8*(-393520 + (36876 - 9364)) + 9*(-241820 + (31429 - 9904)) + 47*((26568 - 8669))
nFdot = mfdot/M # molar flow rate of the fuel in kmol/s
Qcvdot = Wcvdot + nFdot*(hpbar-hRbar) # in kw
# Result
print '-> The rate of heat transfer from the engine, in kW is: '
print round(Qcvdot,2)
```

In [22]:

```
# Given:-
# When expressed on a per mole of fuel basis, the balanced chemical equation obtained in the solution to Example 13.2 takes the form
# CH4 + 2.265O2 + 8.515N2 ------> .951CO2 + .049CO + .289O2 + 8.515N2 + 2H2O
cpbar = 38.00 # specific heat in KJ/kmol.K
# From table A-25
hfnotbar = -74850.00 # enthalpy of formation for methane
# From table A-23
deltahbarO2 = 14770-8682
deltahbarN2 = 14581-8669
# Calculations
hRbar = hfnotbar + cpbar*(400-298) + 2.265*deltahbarO2 + 8.515*deltahbarN2 # in kj/kmol
# With enthalpy of formation values for CO2, CO, and H2O(g) from Table A-25 and enthalpy values from Table A-23
hpbar = .951*(-393520 + (88806 - 9364)) + .049*(-110530 + (58191 - 8669)) + .289*(60371 - 8682) + 8.515*(57651 - 8669) + 2*(-241820 + (72513 - 9904))
Qcvdot = hpbar - hRbar # in kj/kmol
# Result
print '-> The rate of heat transfer from the combustion chamber in kJ per kmol of fuel is: '
print round(Qcvdot,2)
```

In [23]:

```
# Given:-
nCH4 = 1.00 # moles of methane in kmol
nO2 = 2.00 # moles of oxygen in kmol
T1 = 25.00 # in degree celcius
p1 = 1.00 # in atm
T2 = 900.00 # in kelvin
Rbar = 8.314 # universal gas constant
# The chemical reaction equation for the complete combustion of methane with oxygen is
# CH4 + 2O2 ----> CO2 + 2H2O
# Part(a)
# with enthalpy of formation values from table A-25
hfbarCO2 = -393520
hfbarH2O = -241820
hfbarCH4 = -74850
# Calculations
# with enthalpy values from table A-23
deltahbarCO2 = 37405-9364
deltahbarH2O = 31828-9904
Q = ((hfbarCO2 + deltahbarCO2)+2*(hfbarH2O + deltahbarH2O) - hfbarCH4) + 3*Rbar*(T1+273-T2)
# Result
print '-> The amount of heat transfer in kJ is: '
print round(Q,2)
# Part(b)
p2 = p1*(T2/(T1+273)) # in atm
# Result
print '-> The final pressure in atm is: '
print round(p2,2)
```

In [24]:

```
# Given:-
# The combustion equation is
# CH4 + 2O2 + 7.52N2 ----> CO2 + 2H2O + 7.52N2
# Part(a)
# With enthalpy of formation values from Table A-25
hfbarCO2 = -393520 # in kj/kmol
hfbarH2O = -285830 # in kj/kmol
hfbarCH4 = -74850 # in kj/kmol
M = 16.04 # molar mass of CH4 in kg/kmol
# Calculations
hRPbar = hfbarCO2 + 2*hfbarH2O - hfbarCH4 # in kj/kmol
hRP = hRPbar/M # in kj/kg
# Result
print '-> Part(a)the enthalpy of combustion of gaseous methane, fuel is: ',hRP,'kJ/kg.'
# Part(b)
hfbarCO2 = -393520 # in kj/kmol
hfbarH2O = -241820 # in kj/kmol
hfbarCH4 = -74850 # in kj/kmol
# Calculations
hRPbar = hfbarCO2 + 2*hfbarH2O - hfbarCH4 # in kj/kmol
hRP = hRPbar/M # in kj/kg
# Result
print '-> Part(b)the enthalpy of combustion of gaseous methane, fuel is: ',hRP,'kJ/kg'
# Part(c)
# From table A-23
deltahbarO2 = 31389-8682 # in kj/kmol
deltahbarH2O = 35882-9904 # in kj/kmol
deltahbarCO2 = 42769-9364 # in kj/kmol
# Using table A-21
# Calculations
# function cpbar = f(T)
T=298 # in kelvin
from scipy import integrate
cpbar = lambda T: (3.826 - (3.979e-3)*T + 24.558e-6*T**2 - 22.733e-9*T**3 + 6.963e-12*T**4)*8.314
deltahbarCH4 = integrate.quad(cpbar,298,1000)
var = deltahbarCH4[0]
hRPbar = hRPbar + (deltahbarCO2 + 2*deltahbarH2O - var -2*deltahbarO2)
hRP = hRPbar/M # in kj/kg
# Result
print '-> Part(c)the enthalpy of combustion of gaseous methane, per kg of fuel is ',hRP,'kJ/kg'
```

In [25]:

```
# Given:-
# Part(a)
# For combustion of liquid octane with the theoretical amount of air, the chemical equation is
# C8H18(l) + 12.5 O2 + 47N2 -------> 8 CO2 + 9 H2O(g) + 47N2
# with enthalpy of formation data from Table A-25
hfbarC8H18 = -249910.0 # in kj/kmol
hfbarCO2 = -393520.0
hfbarH2O = -241820.0
# Calculations
RHS = hfbarC8H18 -(8*hfbarCO2 + 9*hfbarH2O) # in kj/kmol
# at temperature 2400k
LHS1 = 5089337.0 # in kj/kmol
# at temperature 2350 k
LHS2 = 4955163.0 # in kj/kmol
# Interpolation between these temperatures gives
Tp = 2400.00 + ((2400.0-2350.0)/(LHS1-LHS2))*(RHS-LHS1)
# Result
print '-> The temperature in kelvin with theoretical amount of air is: '
print round(Tp,2)
# Part(b)
# For complete combustion of liquid octane with 400% theoretical air, the chemical equation is
# C8H18(l) + 50O2 + 188N2 --------> 8CO2 + 9H2O + 37.5O2 + 188N2
# Proceeding iteratively as part(a)
Tp = 962 # in kelvin
# Result
print '-> The temperature in kelvin using 400 percent theoretical air is: '
print round(Tp,2)
```

In [26]:

```
# Given:-
import math
# Part(a)
Tp = 2395 # in kelvin, from example 13.8
# For combustion of liquid octane with the theoretical amount of air, the chemical equation is
# C8H18(l) + 12.5O2 + 47N2 ----> 8CO2 + 9H2O(g) + 47N2
# From table A-25
sFbar = 360.79 # absolute entropy of liquid octane in kj/kmol.K
# From table A-23
# For reactant side
sbarO2atTref = 205.03 # in kj/kmol.K
sbarN2atTref = 191.5 # in kj/kmol.K
Rbar = 8.314 # universal gas constant in SI units
yO2 = 0.21
yN2 = 0.79
# For product side
yCO2 = 8.0/64.0
yH2O = 9.0/64.0
yN2p = 47.0/64.0
# Calculations
sbarO2 = sbarO2atTref - Rbar*math.log(yO2) # in kj/kmol.K
sbarN2 = sbarN2atTref - Rbar*math.log(yN2) # in kj/kmol.K
# With the help from table A-23
sbarCO2 = 320.173 - Rbar*math.log(yCO2)
sbarH2O = 273.986 - Rbar*math.log(yH2O)
sbarN2p = 258.503 - Rbar*math.log(yN2p)
sigmadot = (8*sbarCO2 + 9*sbarH2O + 47*sbarN2p) - sFbar - (12.5*sbarO2 + 47*sbarN2)
# Result
print '-> The rate of entropy production, in kJ/K per kmol of fuel with theoretical amount of air is: '
print round(sigmadot,2)
# Part(b)
# The complete combustion of liquid octane with 400% theoretical air is described by the following chemical equation:
# C8H18(l) + 50 O2 + 188N2 -----> 8 CO2 + 9H2O(g) + 37.5O2 + 188N2
# For product side
yCO2 = 8.0/242.5
yH2O = 9.0/242.5
yO2 = 37.5/242.5
yN2p = 188.0/242.5
# Calculations
# With help from table A-23
sbarCO2 = 267.12 - Rbar*math.log(yCO2)
sbarH2O = 231.01 - Rbar*math.log(yH2O)
sbarO2p = 242.12 - Rbar*math.log(yO2)
sbarN2p = 226.795 - Rbar*math.log(yN2p)
sigmadot = (8.0*sbarCO2 + 9.0*sbarH2O + 37.5*sbarO2p +188.0*sbarN2p) -sFbar - (50.0*sbarO2 + 188.0*sbarN2)
# Result
print '-> The rate of entropy production, in kJ/K per kmol of fuel with 400 percent theoretical air is: '
print round(sigmadot,2)
```

In [27]:

```
# Given:-
import math
Rbar = 8.314 # universal gas constant in SI units
# The chemical equation for the complete combustion of methane with oxygen is
# CH4 + 2O2 ----> CO2 + 2H2O
yCH4 = 1.0/3.0
yO2 = 2.0/3.0
yCO2 = 1.0/3.0
yH2O = 2.0/3.0
# From table A-25
sbarCH4atTref = 186.16 # in kj/kmol.K
sbarO2atTref = 205.03 # in kj/kmol.K
p2 = 3.02 # in atm
pref = 1.0 # in atm
# Calculations
sbarCH4 = sbarCH4atTref - Rbar*math.log(yCH4)
sbarO2 = sbarO2atTref - Rbar*math.log(yO2)
# With help from table A-23
sbarCO2 = 263.559 - Rbar*math.log(yCO2*p2/pref) # in kj/kmol.K
sbarH2O = 228.321 - Rbar*math.log(yH2O*p2/pref) # in kj/kmol.K
deltaS = sbarCO2 + 2*sbarH2O - sbarCH4 -2*sbarO2 # in kj/K
# Result
print '-> The change in entropy of the system is: ',round(deltaS,2),'kJ/K'
```

In [28]:

```
# Given:-
# Methane is formed from carbon and hydrogen according to
# C + 2H2 ------> CH4
# In the present case, all substances are at the same temperature and pressure, 25C and 1 atm, which correspond to the standard reference state values
hCbar = 0
hH2bar = 0
gRbar = 0
# With enthalpy of formation and absolute entropy data from Table A-25
hfbarCH4 = -74850
sbarCH4 = 186.16
sbarC = 5.74
sbarH2 = 130.57
Tref = 298.15 # in kelvin
# Calculation
gfbarCH4 = hfbarCH4 -Tref*(sbarCH4-sbarC-2*sbarH2) # in kj/kmol
# Result
print '-> The gibbs function of formation of methane at the standard state is: ',gfbarCH4,'kJ/mol'
```

In [29]:

```
# Given:-
# Complete combustion of liquid octane with O2 is described by
# C8H18(l) + 12.5O2 ------> 8CO2 + 9H2O
import math
# Part(a)
Rbar = 8.314 # universal gas constant in SI units
Tnot = 298.15 # in kelvin
# From table A-25
gbarC8H18 = 6610.0
gbarO2 = 0
gbarCO2 = -394380
gbarH2O = -228590
yO2 = 0.2035
yCO2 = 0.0003
yH2O = 0.0312
M = 114.22 # molecular weight of liquid octane
# Calculations
ech = ((gbarC8H18 + 12.5*gbarO2 -8*gbarCO2 -9*gbarH2O) + Rbar*Tnot*math.log(yO2**12.5/(yCO2**8*yH2O**9 )))/M
# Result
print '-> Part(a) the chemical exergy obtained on a unit mass basis is: ',round(ech,2),'kJ/K'
# Part(b)
# With data from Table A-25 and Model II of Table A-26
gbarH2O = -237180.0
ebarCO2 = 19870.0
ebarH2O = 900.0
ebarO2 = 3970.0
# Calculation
ech = ((gbarC8H18 + 12.5*gbarO2 -8*gbarCO2 - 9*gbarH2O) + 8*ebarCO2 + 9*ebarH2O - 12.5*ebarO2)/M
# Result
print '-> Part(b) chemical exergy on a unit mass basis is:',round(ech,3),'kJ/K'
```

In [30]:

```
# Given:-
import math
Rbar = 8.314 # universal gas constant in SI units
Tnot = 298.0 # in kelvin
# With data from the steam tables
h = 2939.9 # in kj/kg
hnot = 104.9 # in kj/kg
s = 7.2307 # in kj/kg
snot = 0.3674 # in kj/kg
# With data from Table A-25
gbarH2Oliq = -237180.0
gbarH2Ogas = -228590.0
yeH2O = 0.0303
M =18.0 # molar mass of steam
# Calculations
ech = (1.0/M)*(gbarH2Oliq-gbarH2Ogas + Rbar*Tnot*math.log(1/yeH2O)) # in kj/kg
ef = h-hnot-Tnot*(s-snot) + ech # in kj/kg
# Result
print '-> The flow exergy of the steam, in kJ/k is: '
print round(ef,2)
```

In [31]:

```
# Given:-
# For 140% theoretical air, the reaction equation for complete combustion of methane is
# CH4 + 2.8(O2 + 3.76N2) -------> CO2 + 2H2O + 10.53N2 + .8O2
# For product side
yCO2p = 1.0/(1.0+2.0+10.53+.8)
yH2Op = 2.0/(1.0+2.0+10.53+.8)
yN2p = 10.53/(1.0+2.0+10.53+.8)
yO2p = 0.8/(1.0+2.0+10.53+.8)
Rbar = 8.314 # universal gas constant in SI units
Tnot = 298.15 # in kelvin
yeN2 = 0.7567
yeO2 = 0.2035
yeH2O = 0.0303
yeCO2 = 0.0003
# Calculations
import math
ebarch = Rbar*Tnot*(math.log(yCO2p/yeCO2) + 2*math.log(yH2Op/yeH2O) + 10.53*math.log(yN2p/yeN2) + .8*math.log(yO2p/yeO2))
# with data from tables A-23 at 480 and 1560 kelvin,the thermomechanical contribution to the flow exergy, per mole of fuel, is
contri480 = 17712.0 # kJ per kmol of fuel
contri1560 = 390853.0 # kJ per kmol of fuel
efbar480 = contri480 + ebarch # kJ per kmol of fuel
efbar1560 = contri1560 + ebarch # kJ per kmol of fuel
# Results
print '-> At T= 480k, the flow exergy of the combustion products, in kJ per kmol of fuel is: '
print round(efbar480,2)
print '-> At T = 1560K, the flow exergy of the combustion products, in kJ per kmol of fuel is: '
print round(efbar1560,2)
```

In [32]:

```
# Given:-
mFdot = 1.8e-3 # fuel mass flow rate in kg/s
ech = 47346.0 # in kj/kg, from example 13.12(a)
Wcvdot = 37.0 # power developed by the engine in kw
# Calculations
Efdot = mFdot*ech # rate at which exergy enters with the fuel in kw
epsilon = Wcvdot/Efdot # exergetic efficiency
# Result
print '-> The exergetic efficiency is: '
print round(epsilon,3)
```

In [33]:

```
# Given:-
Tnot = 298 # in kelvin
# For the case of complete combustion with the theoretical amount of air
sigmadot = 5404.0 # rate of entropy production from example 13.9, in kj/kmol.K
Efdot = 5407843.0 # rate at which exergy enters with the fuel from example 13.12, in kj/kmol
# Calculations:-
Eddot = Tnot*sigmadot # in kj/kmol
epsilon = 1-Eddot/Efdot
# Result
print '-> The exergetic efficiency with theoretical amount of air is: '
print round(epsilon,3)
# For the case of combustion with 400% theoretical air
sigmadot = 9754.0 # rate of entropy production from example 13.9, in kj/kmol.K
# Calculations
Eddot = Tnot*sigmadot # in kj/kmol
epsilon = 1-Eddot/Efdot
# Result
print 'The exergetic efficiency with 400 percent theoretical amount of air is: '
print round(epsilon,3)
```