Handling of Mixtures in Cantera using Quantity Class
The general combustion equation is as follows:
`C_xH_y+a(O_2+3.76N_2) rightarrow xCO_2+(y/2)H_2O+3.76aN_2`
The air is assumed to be composed of Oxygen and Nitrogen where oxygen is 21% and Nitrogen is 79%. i.e One mole of air has 3.76 moles of Oxygen.
Thus the total moles of air would be 4.76a.
The Air Fuel is defined as `A/F=m_(air)/m_f=(4.76a)/x((MW_(air))/(MW_f))`
In this problem the equivalence ratio is considered as 1.
Equating the coefficients for complete combustion the combustion equation reduces as below:
`CH_4+2(O_2+3.76N_2) rightarrow CO_2+2H_2O+7.52N_2`
Hence the number of moles of fuel=1
number of moles of air=2(1+3.76)=9.52
The above sample code is completed as follows:
import cantera as ct
import matplotlib.pyplot as plt
gas=ct.Solution(\'gri30.cti\')
#Setting the initial conditions for Air
Air=ct.Quantity(gas)
Air.TPX=298.15,ct.one_atm,{\'O2\':0.21,\'N2\':0.79}
Air.moles=9.523 # Total moles of air is calculated
print(\'Air Mass fraction\',Air.mass_fraction_dict())
print(\'\\nThe total mass of Air:\',Air.mass,\'kg\')
#setting the initial conditions of Fuel(Methane)
Fuel=ct.Quantity(gas)
Fuel.TPX=298.5,ct.one_atm,\'CH4:1546\'
Fuel.moles=1
print(\'\\nFuel mass fractions:\',Fuel.mass_fraction_dict())
print(\'\\nFuel Mass\',Fuel.mass,\'kg\')
#Setting up the air-fuel Mixture
Mix=Air+Fuel
Mix.equilibrate(\'HP\',solver=\'auto\')
print (\'\\nThe Adiabatic Flame temperature is:\',Mix.T,\'K\')
print(\'\\nThe Mole fraction of the products is as follows:\\n\',Mix.mole_fraction_dict())
The initial conditions for air are set up.
Air.moles=9.523 sets up the total moles of air. the ratio in which the moles are divided are given in the dictionary in terms of Mole Fractions.
Fuel.TPX=298.5,ct.one_atm,\'CH4:1546\'
Fuel.moles=1
The above lines are used to set up the initial conditions of the fuel. The number 1546 denoted the mole Fraction of Fuel i.e the ratio in which the total moles are divided.But since there is only one component of fuel, or the mole fraction being one any positive number greater than one can be used.
The output of the above code is shown in the below figure:
The first two lines in the output indicate the mole fractions of the reactant components.This is obtained by using:
print(Air.mass_fraction_dict())
The mass of Oxygen in the mixture:63.98kg
The mass of Nitrogen: 210.33kg
the mass of fuel:16.4kg
The adiabatic flame temperature obtained is 2224.286K and the mole fractions of the products obtained are displayed.