In [1]:

```
#Given:
HCV = 46900. #Highest calorific value(HCV) of petrol in kJ/kg
pH2 = 14.4/100 #Composition of Hydrogen in petrol by mass
ufg = 2304.4 #Latent heat of evaporation for water in kJ/kg
#Solution:
# 2[H2] + [O2] = 2[H2O]
H = 1 #Atomic mass of Hydrogen(H)
O = 16 #Atomic mass of Oxygen(O)
#Assume 1 kg of fuel consume
mH2 = 1*pH2 #Mass of Hydrogen in kg/kg of fuel
m_a = 2*(2*H+O)/(2*2*H)*mH2 #Mass of water produced in kg/kg of fuel
LCV = HCV-m_a*ufg #Lowest calorific value in kJ/kg
#Results:
print " The LCV of petrol = %.0f kJ/kg"%(LCV)
```

In [2]:

```
from scipy.optimize import fsolve
import math
#Given:
pCO2 = 13./100 #Composition of Carbon di oxide in dry exhaust gas
#Solution:
p_v = 21./100 #Composition of Oxygen in air by volume
C = 12. #Atomic mass of Carbon(C)
H = 1. #Atomic mass of Hydrogen(H)
O = 16. #Atomic mass of Oxygen(O)
#Combustion equation
# [C8H18] + a[O2] + (1-p_v)/p_v*a[N2] = x[CO2] + y[H2O] + z[O2] + w[N2]
#On balancing the reaction
x = 8.
y = 9. #Coefficients of combustion equation
def f(a): #Defining the function, M of coefficient a for calculation of a
z = a-x-y/2 #On balancing O
w = (1-p_v)/p_v*a #On balancing N
return x/(x+z+w)-pCO2
#Since, Composition of CO2 calculated from the equation must be equal to the given composition of CO2
#Thus, function M solve for zero to get value of a
a = fsolve(f,1)
A_F_act = a/p_v #Air fuel ratio by volume
#For chemically correct mixture
a = x+y/2 #Moles of air required
A_F_cc = a/p_v #Chemically correct air fuel ratio
ratio = (1/A_F_act)/(1/A_F_cc)*100 #Ratio of actual to chemically correct fuel air ratio by volume
#Results:
print " The ratio by volume of fuel to air supplied = 1/%.0f"%(A_F_act)
print " The volume fuel air ratio = %.1f percentage of chemically correct ratio"%(ratio)
```

In [4]:

```
#Given:
pC = 84.
pH2 = 16. #Percentage of Carbon, Hydrogen in fuel
p_v = 20.9 #Percentage of Oxygen in air by volume
#Solution:
C = 12. #Atomic mass of Carbon(C)
H = 1. #Atomic mass of Hydrogen(H)
O = 16. #Atomic mass of Oxygen(O)
N = 14. #Atomic mass of Nitrogen(N)
m_f = 100. #Mass of fuel (assume) in kg
#Combustion equation
#pC/C[C] + pH2/2[H2] + [a[O2] + (100-p_v)/p_v*a[N2]] = b[CO2] + d[O2] + e[N2] + f[H2O]
#Equating coefficients
b = pC/C
f = pH2/2
d = b/6
a = b+d+f/2 #Coefficients of combustion equation
m_a = a*2*O + (100-p_v)/p_v*a*2*N #Mass of air supplied in kg
A_F = m_a/m_f #Air fuel ratio
P_e = d/(a-d)*100 #Percentage excess air
#Results:
print " a)The air fuel ratio by mass, A_F = %.1f/1"%(A_F)
print " b)The percentage excess air supplied = %.1f percent"%(P_e)
```

In [5]:

```
#Given:
MS = 25. #Mixture strength in percent
p = 23.1 #Percentage of oxygen in air by mass
#Solution:
C = 12. #Atomic mass of Carbon(C)
H = 1. #Atomic mass of Hydrogen(H)
O = 16. #Atomic mass of Oxygen(O)
N = 14. #Atomic mass of Nitrogen(N)
m_f = 1. #Mass of fuel(C6H14) in kg
mC = (6*C)/((6*C)+(14*H)) #Mass of Carbon in kg
mH = (14*H)/((6*C)+(14*H)) #Mass of Hydrogen in kg
m_a = (2*O/C*mC+O/(2*H)*mH)*100/p #Mass of air in kg
#For 25 percent rich mixture
m_f = m_f+m_f*MS/100 #Mass of fuel(C6H14) in kg
A_F = m_a/m_f #Air fuel ratio
mO2 = p/100*A_F #Mass of Oxygen available in kg
mO2_1 = O/(2*H)*mH #Oxygen required for combustion of H to H2O in kg
mH2O = mH*(1+O/(2*H)) #Mass of H2O produced in kg
mO2_2 = O/C*mC #Oxygen required for combustion of C to CO in kg
mCO = mC*(1+O/C) #Mass of CO produced in kg
mO2_3 = mO2-(mO2_1+mO2_2) #Mass of Oxygen remaining for combustion of CO to CO2
mCO_b = mO2_3*(C+O)/O #Mass of CO burned to CO2 in kg
mCO2 = mCO_b*(1+O/(C+O)) #Mass of CO2 produced in kg
mCO_ub = mCO-mCO_b #Mass of CO unburned in kg
nH2O = mH2O/(2*H+O) #Moles of H2O
nCO2 = mCO2/(C+2*O) #Moles of CO2
nCO = mCO_ub/(C+O) #Moles of CO
mN2 = A_F*(1-p/100) #Mass of Nitrogen (N2) in kg
nN2 = mN2/(2*N) #Moles of N2
nT = nH2O+nCO2+nCO+nN2 #Total number of moles
pH2O = nH2O/nT
pCO2 = nCO2/nT
pCO = nCO/nT
pN2 = nN2/nT #Composition of products
#Results:
print " The theoretical mass of air required, m_a = %.2f kg"%(m_a)
print " The composition of the products in percent\t H2O = %.2f\t CO2 = %.2f\t CO = %.2f\t N2 = %.2f"%(pH2O*100,pCO2*100,pCO*100,pN2*100)
```

In [6]:

```
import math
from numpy import roots
from sympy import Symbol,solve
#C7H16 in Petrol engine
#Given:
p_v = 21. #Percentage of Oxygen in air by volume
p_e = 50. #Percentage of excess air supplied
#Solution:
m_f = 100. #Mass of fuel (assume) in kg
C = 12. #Atomic mass of Carbon(C)
H = 1. #Atomic mass of Hydrogen(H)
O = 16. #Atomic mass of Oxygen(O)
N = 14. #Atomic mass of Nitrogen(N)
#a = poly(0,'a') #Defining unknown number of moles of stoichiometric oxygen
a = Symbol('a')
#Combustion equation
#m_f/(7*C+16*H)[C7H16] + (1+p_e/100)*[a[O2] + (100-p_v)/p_v*a[N2]] = b[CO2] + d[O2] + e[N2] + f[H2O]
#Equating coefficients
b = m_f/(7*C+16*H)*7 #Moles of CO2 on balancing of C
f = m_f/(7*C+16*H)*16/2 #Moles of H2O on balancing of H
d = p_e/100*a #Excess moles of oxygen
a = solve((1+p_e/100)*a-(b+d+f/2))[0] #Balancing Oxygen of both sides
print a
m_a = a*2*O+(100-p_v)/p_v*a*2*N #Mass of air supplied in kg
A_F = m_a/m_f #Air fuel ratio
d = p_e/100*a #Moles of Oxygen in products of combustion
e = (1+p_e/100)*(100-p_v)/p_v*a #Moles of Nitrogen in products of combustion
nT = b+d+e+f #Total number of moles in product of combustion
pH2O = f/nT*100
pCO2 = b/nT*100
pO2 = d/nT*100
pN2 = e/nT*100 #Percentage volumetric composition of the products of combustion
#Results:
print " a)The stoichiometric air fuel consumption by mass, A_F = %.2f:1"%(A_F)
print " b)The percentage volumetric composition of the products\t CO2 = %.2f\t O2 = %.2f\t N2 = %.1f\t H2O = %.2f"%(pCO2,pO2,pN2,pH2O)
```

In [9]:

```
import math
from numpy.linalg import solve
#Given:
pC = 85.
pH2 = 15. #Percentage of Carbon, Hydrogen in fuel
A_F = 14. #Air fuel ratio by mass
p_m = 23.2 #Percentage of oxygen in air by mass
#Solution:
m_f = 100. #Mass of fuel (assume) in kg
m_a = A_F*m_f #Mass of air in kg
C = 12. #Atomic mass of Carbon(C)
H = 1. #Atomic mass of Hydrogen(H)
O = 16. #Atomic mass of Oxygen(O)
N = 14. #Atomic mass of Nitrogen(N)
p_v = 20.9 #Percentage of Oxygen in air by volume
#Combustion equation
#pC/C[C] + pH2/2[H2] + [a[O2] + (100-p_v)/p_v*a[N2]] = b[CO2] + d[CO] + e[N2] + f[H2O]
#Equating coefficients
f = pH2/2 #Moles of H2O on balancing of H
a = m_a/(2*O+(100-p_v)/p_v*2*N) #Balancing Oxygen of both sides
#On balancing C of both sides we get, b + d = pC/C eq(1)
#On balancing O of both sides we get, b + d/2 + f/2 = a eq(2)
#Solving equations (1) and (2)
A = [[1,1],[1, 1./2]]
B = [[pC/C],[a-f/2]]
SOL = solve(A,B) #Taking matrix A, B to get solution matrix, SOL = [b;d]
b = SOL[0]
d = SOL[1] #Moles of CO2 and CO
e = (100-p_v)/p_v*a #Moles of Nitrogen in products of combustion
mC = b/m_f*C #Mass of carbon burning to CO2 in kg per kg of fuel
mCO2 = b/m_f*(C+2*O) #Mass of CO2 produced in kg
mCO = d/m_f*(C+O) #Mass of CO produced in kg
mN2 = e/m_f*(2*N) #Mass of N2 produced in kg
mH2O = f/m_f*(2*H+O) #Mass of H2O produced in kg
#Results:
print " a)The mass of the carbon burning to CO2 = %.3f kg"%(mC)
print " b)The mass of each of the gases in the exhaust per kg of fuel\t CO2 = %.2f kg\t CO = %.2f kg\t N2 = %.2f kg\t H2O = %.2f kg"%(mCO2,mCO,mN2,mH2O)
```

In [8]:

```
#Given:
pCO2 = 12./100
pCO = 2./100
pCH4 = 4./100
pH2 = 1./100
pO2 = 4.5/100 #Composition of Carbon di oxide(CO2), Carbon mono oxide(CO), Methane(CH4), Hydrogen(H2), Oxygen(O2) in dry exhaust gas
pN2 = 1-(pCO2+pCO+pCH4+pH2+pO2) #Composition of Nitrogen(N2) in dry exhaust gas
#Solution:
C = 12. #Atomic mass of Carbon(C)
H = 1. #Atomic mass of Hydrogen(H)
p_v = 21. #Percentage of Oxygen in air by volume
#Let X be the mass of the fuel per mole dry exhaust gas
#Let Y be the mole of O2 per mole dry exhaust gas
#Let 1 kg of fuel contain p kg of C and q kg of H2
#Combustion equation
#X*(p/C[C] + q/(2*H)[H2]) + Y[O2] + (100-p_v)/p_v*Y[N2] = pCO2[CO2] + pCO[CO] + pCH4[CH4] + pH2[H2] + pO2[O2] + a[H2O] + pN2[N2]
#Equating coefficients
Y = pN2/((100-p_v)/p_v) #Nitrogen(N) balance
a = 2*(Y-(pCO2+pCO/2+pO2)) #Oxygen(O) balance
Xp = C*(pCO2+pCO+pCH4) #Carbon(C) balance; X*p
Xq = (2*H)*(2*pCH4+pH2+a) #Hydrogen(H) balance; X*q
p_q = Xp/Xq #Ratio of C to H2 in fuel
#Results:
print " The proportion by mass of Carbon to Hydrogen in the fuel = %.2f/1"%(p_q)
```

In [11]:

```
#Given:
pCO2 = 7.5
pCO = 1.
pO2 = 9.4 #Percentage of Carbon di oxide(CO2), Carbon mono oxide(CO), Oxygen(O2) in dry exhaust gas
P = 1.02 #Pressure of the exhaust gas in bar
pO_v = 21. #Percentage of Oxygen in air by volume
pN_v = 79. #Percentage of Nitrogen in air by volume
M = 29. #Molecular weight of air
#Solution:
C = 12. #Atomic mass of Carbon(C)
H = 1. #Atomic mass of Hydrogen(H)
#Let 100*x moles of air be used with fuel per 100 mole of dry exhaust products
pN2 = 100-(pCO2+pCO+pO2) #Composition of Nitrogen(N2) in dry exhaust gas
#Combustion equation
# a[C] + b[H2]) + pO_v*x[O2] + pN_v*x[N2] = pCO2[CO2] + pCO[CO] + pO2[O2] d[H2O] + pN2[N2]
#Equating coefficients
a = pCO2+pCO #Carbon(C) balance
x = pN2/pN_v #Nitrogen(N) balance
d = 2*(pO_v*x-(pCO2+pO2+pCO/2)) #Oxygen(O) balance
d = round(10*d)/10
b = d #Hydrogen(H) balance
m_a = 100*x*M #Mass of air in kg
m_f = a*C+b*2*H #Mass of fuel in kg
A_F = m_a/m_f #Air fuel ratio
pC = a*C/m_f*100 #Percentage of Carbon(C) in fuel
pH2 = 100-pC #Percentage of Hydrogen(H2) in fuel
nT = pCO2+pCO+pO2+pN2+d #Total number of moles in product of combustion
CO2 = pCO2/nT*100;O2 = pO2/nT*100;CO = pCO/nT*100;N2 = pN2/nT*100;H2O = d/nT*100 #Percentage volumetric composition of the products of combustion
PP = d/nT*P #Partial pressure of H2O in bar
#From steam tables
if (PP == 0.0825):
T = 42.8 #Saturation temperature in degreeC
#Results:
print " a)The air fuel ratio used, A_F = %.1f"%(A_F)
print " b)The mass analysis of the fuel\t Carbon = %.1f percent\t Hydrogen = %.1f percent"%(pC,pH2)
print " c)The wet products analysis in percent\t CO2 = %.1f\t O2 = %.2f\t CO = %.1f\t N2 = %.2f\t Steam = %.1f"%(CO2,O2,CO,N2,H2O)
print " d)The minimum temperature to which the exhaust may be cooled before condensation occurs = %.1f degreeC"%(T)
```

In [12]:

```
from numpy import sum,array
#Given:
pH2 = 49.4/100
pCO = 18./100
pCH4 = 20./100
pC4H8 = 2./100
pO2 = 0.4/100
pN2 = 6.2/100
pCO2 = 4./100 #Composition of Coal gas
MW = 20. #Mixture weakness in percent
#Solution:
#Combustion equations for determining the moles of Oxygen used
#2[H2] + [O2] ---> 2[H2O] #For Hydrogen
#2[CO] + [O2] ---> 2[CO2] #For Carbon mono oxide
#[CH4] + 2[O] ---> [CO2] + 2[H2O] #For Methane
#[C4H8] + 6[O2] ---> 4[CO2] + 4[H2O] #For C4H8
nO2 = sum([pH2/2, pCO/2, 2*pCH4, 6*pC4H8 ,pO2]) #Moles of O2 required (error)
nCO2 = sum([pCO, pCH4 ,4*pC4H8 ,pCO2]) #Moles of CO2
nH2O = sum([pH2, 2*pCH4, 4*pC4H8]) #Moles of H2O
p_v = 21. #Percentage of Oxygen in air by volume
n_a = nO2/p_v*100 #Moles of air required
n_f = 1. #For 1 mole of fuel
A_F = n_a/n_f #Air fuel ratio
#For weak mixture
A_F_act = A_F*(1+MW/100) #Actual air fuel ratio
nN2 = (1-p_v/100)*A_F_act #Moles of N2
nO2 = p_v/100*A_F_act-nO2 #Excess moles of Oxygen in products
nN2 = nN2+pN2 #Moles of Nitrogen in products
nT_d = nCO2+nO2+nN2 #Total dry moles of product
nT_w = nT_d+nH2O #Total wet moles of product
p_d = array([nCO2, nO2 ,nN2])*100/nT_d #Percentage volumetric composition of the dry products of combustion
p_w = array([nCO2, nH2O, nO2, nN2])*100/nT_w #Percentage volumetric composition of the wet products of combustion
#Results:
print " The stoichiometric air fuel ratio used, A_F = %.1f/1"%(A_F)
print " The wet products analysis in percent\t CO2 = %.0f\t H2O = %.2f\t O2 = %.2f\t N2 = %.2f"%(p_w[0],p_w[1],p_w[2],p_w[3])
print " The dry products analysis in percent\t CO2 = %.2f\t O2 = %.2f\t N2 = %.2f"%(p_d[0],p_d[1],p_d[2])
#Answers in the book are wrong
```