Week 4.1- Handling Mixtures with Cantera
Calculation of moles of air:
When using the ‘moles’ function of class ‘Quantity’ we get no of moles of air as 0.0346615678
The code is given below
"""
Sample code to vary the temperature of air and oxidizer individually
"""
import cantera as ct
gas= ct.Solution('gri30.cti')
air= ct.Quantity(gas)
air.TPX= 298.15, ct.one_atm,{'O2':0.21,'N2':0.79}
print ('no of moles of air =',air.moles)
Output

Computation of moles of air:
Cantera follows the MKS system of units. When the mass of quantity is not defined. Cantera automatically assumes it as 1 kg. therefore, when using ‘moles’ function, it gives the number of kilomoles present per kg of quantity (K-mole/kg) which can be written as no of moles/gram of the quantity.
In the given code we have defined the quantity ‘air’ as a mixture of 21%O2 and 72%N2. This composition has been specified in line 9 as molar fraction in dictionary format.
Now mass of 1 mole of O2= 15.9994*2 = 31.9988g
No of moles in 1gm O2 = 1/31.9988 = 0.03125117191
Similarly, the mass of 1 mole of N2= 14.00674*2 = 28.01348g
No of moles in 1gm of N2 = 1/28.01348 = 0.0356971
Now a weighted average quantity of air is taken as mixture. Therefore, the no of moles present in 1 gm of air = 0.21*0.03125117191 + 0.79*0.0356971
No of moles in 1gm of air = 0.03476345518
Calculation of mass fraction:
When using the mole fraction_dict() and mass_fraction_dict() methods, the mole fractions and mass fractions are obtained.
The code is given below
"""
Sample code to vary the temperature of air and oxidizer individually
"""
import cantera as ct
gas= ct.Solution('gri30.cti')
air= ct.Quantity(gas)
air.TPX= 298.15, ct.one_atm,{'O2':0.21,'N2':0.79}
print ('no of moles of air =',air.moles)
print('mole fraction in air =',air.mole_fraction_dict())
print('mass fraction in air =',air.mass_fraction_dict())
Output

Computational procedure:
Mole fraction is the volumetric ratio of O2 and N2 in the atmosphere.
Mass fraction is the mass ratio of O2 and N2 in the atmosphere. It is calculated as follows:
We know the mass of 1 mole of O2 = 31.9988g
The mass of 1 mole of N2 = 28.01348
Mass of air (O2+N2) = 0.21*31.9988 + 0.79*28.01348 = 28.8503972
Mass fraction of O2= (0.21*31.9988) / 28.8503972 = 0.23291700122
Mass fraction of N2= (0.79*28.01348) / 28.8503972 = 0.767082998877
Explanation for line 15and 16:
After creating another instance ‘B’ of class ‘Quantity’ in line 14, we are defining temperature, pressure and mole fraction. While defining mole fraction we must define all the species along with mole fraction separated by colon.
However, since there is only one species inside this quantity, any positive number greater than 0 can be specified along side with species. The result does not change.
In line 16 it is necessary to specify the moles of ch4 we were working, otherwise cantera will again assume per gram value for the no of moles for ch4.
The number 1546 is just an arbitrary number. It must be noted that 0 is not acceptable.
Necessary changes for correct results:
To get the correct values of adiabatic flame temperature, the no of moles of air must be specified in line no 10 this values can be sourced from combustion reaction of methane at equilibrium ratio equal to 1.
CH4 + 2 (O2 + 3.76 N2) = CO0 +2H2O + 7.52 N2
On the reactant side
No of moles of CH4 = 1
No of moles of air = 2 + 2*3.76 = 9.52
The corrected program is
"""
Sample code to vary the temperature of air and oxidizer individually
"""
import cantera as ct
gas= ct.Solution('gri30.cti')
air= ct.Quantity(gas)
air.TPX= 298.15, ct.one_atm,{'O2':0.21,'N2':0.79}
air.moles=9.52
print ('no of moles of air =',air.moles)
print('mole fraction in air =',air.mole_fraction_dict())
print('mass fraction in air =',air.mass_fraction_dict())
fuel=ct.Quantity(gas)
fuel.TPX= 298.15, ct.one_atm,'CH4:1'
fuel.moles=1
# The following step is used for right molar balance equations
air.constant=fuel.constant='HP'
mix= air+fuel
mix.equilibrate ('HP')
print(mix.T)
Calculated AFT
