Challenge

Week 4.1- Handling Mixtures with Cantera

1.

Objective :

To calculate the Adiabatic Flame Temparature of Stoichiometric Combustion of Methane by specifying Fuel & Oxidizer as separate Mixtures, using the Quantity Class in Cantera.

Introduction :

General form of Stoichiometric Hydro-Carbon Combustion Reaction with a single Fuel Species :

CxHyOz + (1/phi)*(x + (y/4) - (z/2))(O2 + 3.76N2)
------->
xCO2 + (y/2)H2O + (3.76/phi)*(x + (y/4) - (z/2))N2 + (x + (y/4) - (z/2))*((1/phi)-1)O2
Therefore, in case of Methane, using phi = 1, x = 1, y = 4 & z = 0, the reaction is as follows :
Stoichiometric Combustion : CH4 + 2(O2 + 3.76N2) -> CO2 + 2H2O + 7.52N2
General Calculations :
Mass of 1 O atom = 15.9994 g/mole
Mass of O2 = (15.9994 * 2) g/mole = 31.9988 g/mole
31.9988 g is the weight of 1 mole of O2
1 g is the weight of (1/31.9988) = 0.0312511 moles of O2
Simillarly,
Mass of 1 N atom = 14.0067 g/mole
Mass of N2 = (14.0067 * 2) g/mole = 28.01348 g/mole
28.01348 g is the weight of 1 mole of N2
1 g is the weight of (1/28.01348) = 0.0356971 moles of N2
Now, we must find the total number of Moles that are present in Air, which is defined as a Mixture containing 21% N2 & 79% O2. Therefore,
Total Number of Moles in 1 g of Air = (0.21 * 0.0312511) + (0.79 * 0.0356971) = 0.03476345
Simillarly, Mass Fractions can be calculated as follows :
Mass of 1 mole of Air = (0.21 * 31.9988) + (0.79 * 28.01348) = 28.85039 g
Therefore,
Mass Fraction of O2 : (0.21 * 31.9988) / 28.85039 = 0.232917
Mass Fraction of N2 : (0.79 * 28.01348) / 28.85039 = 0.767083
We do the same in Cantera using the following Code :
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("Total Number of Moles of Air : ", Air.moles)
print("Mole Fraction of Air : ", Air.mole_fraction_dict())
print("Mass Fraction of Air : ", Air.mass_fraction_dict())
The Output being :
We can see that Cantera agrees with our Analytical Calculations.
Calculations for Metane-Air Combustion :
CH4 + 2(O2 + 3.76N2) -> CO2 + 2H2O + 7.52N2
In this case, the reaction clearly indicates the Number of Moles of each reactant species :
Fuel (CH4) = 1
Air (O2 + N2) = 2 + (3.76 * 2) = 9.52
Here, we must specify, rather than calculate (as was in the previous case) the Number of Moles of Air & Fuel in the Reactant Mixture. The code for which is as follows :
# Program to demonestrate Mixtures using Cantera

# In case of Stoichiometric Combustion of Methane at Constant Pressure,

# CH4 + 2(O2 + 3.76N2) -> CO2 + 2H2O + 7.52N2       

import cantera as ct

gas = ct.Solution('gri30.cti')

###############################################################################################

# Creating a mixture Air by passing the gas object to the Quantity Class
Air = ct.Quantity(gas)
# specifying Temparature, Pressure & Mole Fractions of Air
Air.TPX = 298.15, ct.one_atm, {'O2' : 0.21, 'N2' : 0.79} 
# spcifying Total Number of Moles of Air
Air.moles = 9.52  

# This will give Total Mass of 1 mole of Air
print("The Mass of Air is : ", Air.mass, 'g') 
# This will give the Mass Fractions of all the constituents of Air in form of a Dictionary
print("The Mass Fraction of Air is : ", Air.mass_fraction_dict())

###############################################################################################

# Creating a mixture Fuel by passing the gas object to the Quantity Class
Fuel = ct.Quantity(gas)
# specifying Temparature, Pressure & Mole Fraction of Fuel
# Since there is only one Species in the Fuel Mixture, Cantera will take Mole Fraction
# to be Unity, no matter what value we specify. Any Positive Number would suffice
Fuel.TPX = 298.15, ct.one_atm, 'CH4 : 1546'
# spcifying Total Number of Moles of Fuel
Fuel.moles = 1

# This will give Total Mass of 1 mole of Fuel
print("\nThe Mass of Fuel is : ", Fuel.mass, 'g')
# This will give the Mass Fractions of all the constituents of Fuel in form of a Dictionary
print("The Mass Fraction of Fuel is : ", Fuel.mass_fraction_dict())

###############################################################################################

# "+" is an Over-Loaded Operator. 
Mixture = Air + Fuel

# The AUTO solver initially uses the Element Potential Method, & if it fails, automatically
# switches to the Gibbs Solver
Mixture.equilibrate ('HP', 'auto')

# This will print the Adiabatic Flame Temparature
print("\nThe AFT of the Product Mixture is : ", Mixture.T, 'K')
# This will print the Total Mass of the Product Mixture
print("The Mass of the Product Mixture is : ", Mixture.mass, 'g')

# This will print the Mole Fractions of the different constituent species of the Product Mixture
print("\nThe Mole Fraction of the Product Mixture is : ", Mixture.mole_fraction_dict())
# This will print the Mass Fractions of the different constituent species of the Product Mixture
print("\nThe Mass Fraction of the Product Mixture is : ", Mixture.mass_fraction_dict())
The Output being :
In addition to TPX values, one needs to specify the Total Number of Moles of Mixtures using <Mixture_Name>.moles, otherwise Cantera assumes per gram values.
Conclusion :
This demonestrates the usefulness of specifying separate Mixtures 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.