Challenge

Handling Mixtures with Cantera

Answer to the questions -

1. Moles method and its calculation approach

The moles function defines the number of moles of the object A (comprised of the species O2 and N2). By basic chemistry, we arrive at the number of moles of A -

`x_(O_2) = n_(O_2)/(n_(O_2)+n_(N_2)) = n_(O_2)/n_(air)`

At STP, the oxidizer air contains 21% O2 and 79% N2. This has been provided as an input to the TPX method. To calculate the number of moles of air which is needed for mixture handling, we assume that the methane combustion is stoichiometric.

Thus, substituting the values in the above equation, we get

`0.21 = 2/n_(air)`

`rArr n_(air) = 9.52`

This can also be obtained from the balanced equation of stoichiometric methane combustion i.e.

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

2. mole_fraction_dict()/mass_fraction_dict()

This function calculates the mole fraction(mass fraction) of the species.

When used as print(A.mass_fraction_dict()), it calculates the mass fraction of the species in the object A. This is calculated as given in the below table

Species Mole fraction Number of moles Mass Mass fraction
`O_2` 0.21 0.21*9.52 = 1.9992 `~~`2 2*32 = 64 64/(64+210.56)= 0.2331
`N_2` 0.79 0.79*9.52 = 7.52 7.52*28 = 210.56 210.56/(64+210.56) = 0.7668

Thus, the number of moles of air provided as an input is used for calculating the mass fractions.

This is the same we get from cantera

3. Lines 15 and 16

In the line 15, we are assigning the initial conditions of the object B (fuel). The formate for this is temperaure (in Kelvin), pressure(in Pascals), mole fractions.

If there are multiple species to be defined in the object B, we can use dictionary to define them using their mole fractions. However, since we only have considered 1 species (i.e. CH4)

we don't need to use dictionary format. Also, because there is only 1 species the mole fraction of CH4 is 1 by default.

The number 1546 is just an arbitrary number. It must be noted that 0 is not acceptable.

In the line 16, we assign the number of moles of the object B.

4. Right value of AFT

AFT temperature depends on the number of moles of fuel (object B) and oxidizer (object A) which react at constant pressure.

Thus, we need to provide the correct number of moles for both the objects.

The number of moles of the object A is thus defined at line 10 as

A.moles = 9.52

This gives the correct value of AFT for Methane combustion.

IT MUST BE NOTED THAT THE NAMES IN THE CODE PROVIDED BELOW HAVE BEEN MODIFIED TO MAKE THEM MORE READABLE.

"""
This code demonstrates how mixtures can be effectively ahndled with cantera
With the understanding of this, a combustion analysis can be carried out more easily with variable equivalence ratio
"""

import cantera as ct

T_air = 298.15	#defines initial temp for air object
P_air = 101325	#defines initial press for air object

T_fuel =298.15	#defines initial temp for fuel object
P_fuel = 101325	#defines initial press for air object

gas = ct.Solution('gri30.cti')	#gas object inherits the information of the Solution class of cantera library.

air = ct.Quantity(gas)	#Quantity is another class in the cantera library which provides additional properties to control
air.TPX = T_air,P_air,{"O2":0.21,"N2":0.79}	#Reactant side temp, pressure and mole fraction of o2 and n2

"""
n - number of moles
x - mole fraction
n_air = n_o2+n_n2
x_o2 = n_o2/(n_o2+n_air) = n_o2/n_air
For stoichiometric combustion of methane 
n_o2 = 2
=> n_air = 2/0.21 = 9.52
"""
air.moles = 9.52

fuel = ct.Quantity(gas)
fuel.TPX = T_fuel,P_fuel,'CH4:1546'	#1546 makes no sense. Since only one species is defined the default mole fraction is assumed as 1
fuel.moles = 1

mix = air+fuel #This calculates the state of the mixture when the objects defined in the quantity class are added or combined
print('Mole fraction of individual species in oxidizer (air) is n',air.mole_fraction_dict())
print('Mass fraction of individual species in oxidizer (air) is n',air.mass_fraction_dict())
mix.equilibrate('HP','auto')
print('Adiabatic Flame temperature for Constant Pressure Combustion = ',mix.T)
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.