Challenge

Handling Mixtures with Cantera

OBJECTIVE:

To understand and work with various attributes of class 'Quantity' and to calculate the Adiabatic Flame Temperature of CH4.

1: When using the 'moles' function of class 'Quantity' we get the number of moles of air.

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('number of moles of air is ',air.moles)

OUTPUT:

Calculation of number of moles of air:

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

Within the code, it is defined that air has a composition of 21% of O2 and 79% of N2.

Mass of 1 mole of O2 = 15.9994*2 =31.9988g

Number of moles in 1g O2 = 1/31.9988 = 0.0312511 moles

Mass of 1 mole of N2 = 14.00674*2 = 28.01348g

Number of moles in 1g N2 = 1/28.01348 = 0.0356971 moles

Hence, the number of moles present in 1 gram of air is 0.21*0.0312511 + 0.79*0.0356971 = 0.0347634

2: When using the moles/mass_fraction_dict(), we get the mole and mass fraction respectively.

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('number of moles of air is ',air.moles)
print('mole fraction of air is ',air.mole_fraction_dict())
print('mass fraction of air is ',air.mass_fraction_dict())

OUTPUT

Mole fraction is the volumetric ratio of O2 nad N2 in atmosphere, whereas mass fraction is the mass ratio of the same.

We know that mass of 1 mole of O2 is 31.9988g and mass of 1 mole of N2 as 28.01348g

Mass of air (mixture) = 0.21* 31.9988 + 0.79*28.01348 = 28.8503972

Mass fraction of O2 = (0.21* 31.9988)/28.8503972 = 0.23290921

Mass fraction of N2 = (0.79* 28.01348)/28.8503972 = 0.76709078

3: Explanation of lines 15 and 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 alongside that the species. The result does not change.

In line 16, it is necessary to specify the moles of CH4 we were using, otherwise, Cantera will again assume per gram value for the number of moles of CH4. The number 1546 is just an arbitrary number. it must be noted that 0 is not acceptable.

4: Changing the program to get the correct results

To get the correct values of adiabatic flame temperature, the number of moles of air must be specified in line number 10.

The balanced equation for complete combustion of methane is

CH4 +2*(O2 + 3.76*N2) = CO2 + 2H2O + 7.52*N2

Here, the number of moles of CH4 (fuel) =1

and the number of moles of oxidiser (O2 + N2) = 2+ 2*3.76 =9.52

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}

fuel= ct.Quantity(gas)
fuel.TPX = 298.15,ct.one_atm,'CH4:1546'


"""Maintain the molar balance"""
air.moles =9.52
fuel.moles=1

"""creating the mixture"""
M=air+fuel

""" calculating AFT"""
M.equilibrate('HP')
print('The AFT of the mixture is ',M.T)

OUTPUT

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.