Project

Handling mixtures in Cantera

Objective:

To arrive at the adiabatic flame temperature for the combustion of methane in air at stoichiometry under constant pressure by treating methane and air as two separate quantities using the \'Quantity Class\' in Cantera.

Solution:

1. Calculation of moles of air:

When using the \'moles\' function of class \'Quantity\', we get the no. of moles of air as 0.03466156784836224.

Calculation Procedure

Cantera follows the MKS system of units. When the mass of a quantity is not defined, Cantera automatically assumes it as 1 Kg. Therefore, when using the \'moles\' function, it gives the number of kilomoles present per kilogram of the quantity (k-mol/kg), which can also be written as the number of moles per gram of the quantity.

In the above code, the quantity \'air\' has been defined as a mixture of 21% O2 and 79% N2. This composition has been specified in line no. 9 as molar fractions in a dictionary form.

Now, the mass of 1 mole of O2 = 15.9994*2 = 31.9988 g

No. of moles in 1 gram of O2 = 1/31.9988 = 0.03125117191

Similarly, the mass of 1 mole of N2 = 14.00674*2 = 28.01348 g

No. of moles in 1 gram of N2 = 1/28.01348 = 0.03569710011

Now a weighted average is taken since air is a mixture. Therefore, the no. of moles present in 1 gram of air(O2 + N2) = 0.21*0.03125117191 + 0.79*0.03569710011

No. of moles in 1 gram of air = 0.03476345518

The small error is due to round-off.

2. Calculation of Mass fraction

When using the mole_fraction_dict() and mass_fraction_dict() methods, the mole fraction and mass fraction are obtained as follows;

Calculation Procedure

Mole fraction is the volumetric ratio of O2 and N2 in the atmosphere. It appears as specified.

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.9988 g

The mass of 1 mole of N2 = 14.00674*2 = 28.01348

Mass of air(O2 + N2) = 0.21*31.9988 + 0.79*28.01348 = 28.8503972 g

Mass fraction of O2 in air = 0.21*31.9988/28.8503972 = 0.23291700122

Mass fraction of N2 in air = 0.79*28.01348/28.8503972 = 0.76708299877

The values concur with the result given by Cantera.

3. Explanation for lines 15 and 16

The lines 15 and 16 are shown below:

After creating another instance \'B\' of class \'Quantity\' in line 14, we are defining the Temperature, Pressure and the mole fractions. While defining the mole fraction, we must specify all the species involved along with their mole fractions separated by a colon. However, since there is only one species inside this quantity, any positive number greater than 0 can be specified alongside the species. The result does not change.

In line 16, it is necessary to specify the number of moles of CH4 we\'re working with, otherwise, Cantera will again assume per gram value for the number of moles for CH4 which would give wrong results.

4. Necessary changes for correct result

To get the correct value for the adiabatic flame temperature, the number of moles of \'air\' must be specified in line no. 10. This value can be sourced from the combustion reaction of methane at equivalence ratio = 1.

`CH_4 + 2 (O_2 + 3.76 N_2) -> CO_2 + 2 H_2O + 7.52 N_2`

On the reactants side,

Number of moles of CH4 = 1

Number of moles of air = 2 + 2*3.76 = 9.52

Therefore the corerct 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

fuel = ct.Quantity(gas)
fuel.TPX = 298.15, ct.one_atm, \'CH4:0.1\'
fuel.moles = 1

air.constant = fuel.constant = \'HP\'
mix = air + fuel

mix.equilibrate(\'HP\')

print(mix.T)

The correct value for the adiabatic temperature (K) is as shown:

Conclusion

The correct value for temperature has been arrived at using the \'Quantity\' class to create the air-fuel mixture in Cantera.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.