Challenge

Handling Mixtures with Cantera

AIM

The aim of this challenge is to work on Quantity class in Cantera

OBJECTIVE

The calculation of Adiabatic Flame Temperature of gas mixture using the Quantity class

PYTHON CODE FOR CALCULATION OF MASS AND MOLE FRACTIONS 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 = ',air.moles)
print('mole fraction of air = ', air.mole_fraction_dict())
print('mass fraction = ', air.mass_fraction_dict())

The gas object is created for solving the problems related to combustion. Air is the created with quantity class defined at STP conditions. Then in the print statements we tell Cantera to execute the code.

Output of the code

If we take the one mole of oxygen we can say that

mass of one mole of di-atomic oxygen (O2) = 32 grams

mass of one mole of di-atomic nitrogen (N2) = 28 grams

Using the above information we can derive the mass of air as follows

mass of air = mass of (O2+N2) = 0.21*32 + 0.79*28 = 28.84 grams

mass of oxygen = 0.21*32/28.84 = 0.2333

mass of nitrogen = 0.79*28/28.84 = 0.76699

CODE SAMPLE

Now in the given sample code from line number 15 and 16 we are defining a gas known as B with quantity class. In Cantera we have to define the temperature, pressure and the number of moles of the given gas which is defined in line number 15.

And in line number 16, we are saying that the gas B should have only one mole for the reaction to take place. Now in the line number 15 we see that the CH4 has 1546 moles, this has been mentioned because Cantera would take the usual values which would give wrong results.

CHANGES IN THE 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}
air.moles = 9.52

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

Mixture = air + fuel
air.constant = 'HP'
fuel.constant = 'HP'
Mixture.equilibrate('HP')
print (Mixture.T)


Lets review the chemical reaction of methane for combustion

`CH_4+2(O_2+3.76N_2)rightarrowCO_2+H_2O+7.52N_2`

Then we see that there is 2 moles of air and 1 mole of methane and then we balance the above chemical reaction.

CODE OUTPUT

Now according to the question we have the adiabatic flame temperature of 2224 Kelvin.

CONCLUSION

  1. The concepts of object oriented programming were reviewed
  2. Mole and mass fractions concepts were applied to the cantera program
  3. The Adiabatic Flame Temperature was accurately predicted using "quantity" class
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.