Challenge

Week 4.1- Handling Mixtures with Cantera

Objective : To work with the Quantity class of Cantera to create various mixtures and to explain how the mixture calculations are performed.

1. Use the "moles" method/function of the A object and explain how it was calculated.

Solution is a class and quantity is also a class which adds extra function to the solution.

The stoichiometric reaction of methane and air is given by :

For balanced stoichiometric reaction,

Number of moles of CH4 = 1

Number of moles of O2 = 2

Number of moles of N2 = 7.52

Mole fraction of O2 in air = (Number of moles of O2/ (Number of moles of O2 + Number of moles of N2)) = (2/(2+7.52)) = 0.21

Mole fraction of N2 in air = (Number of moles of N2/ (Number of moles of O2 + Number of moles of N2)) = (7.52/(2+7.52)) = 0.79

2. Use the method mole_fraction_dict() of the A object and explain the result.

Print(A.mass_fraction_dict()) is used calculate and display the mass fraction of the species as shown below

Mole fraction of O2 = 0.21

Mole fraction of N2 = 0.79

Molecular weight of O2 = 32

Molecular weight of N2 = 28

Mass fraction of O2 = (0.21*32/(0.21*32 + 0.79*28)) = 0.233

Mass fraction of N2 = (0.79*28/(0.21*32 + 0.79*28)) = 0.767

3. What is happening in lines 15 and 16? Make sure to explain what 1546 means? Is that reasonable?

TPX command is used to get temperature, pressure and mole fraction.

The number 1546 represents the number of moles of CH4.

Since CH4 is the only species in variable B, the mole fraction will always be 1 irrespective of the number of moles of CH4.

Hence, there can be any number of moles of CH4 other than zero.

4. What changes do need to be put in place to get the right value of AFT in line 22?

Mole fraction of O2 = 0.21

Mole fraction of N2 = 0.79

To calculate mole

Moles of (O2+N2) = 2/0.21 = 9.52

Moles of (O2+N2) = 7.52/0.79 = 9.52

We know that 1 mole of CH4 is present. Species A is composed of O2 and N2. From the balanced stoichiometric reaction, we need to give 9.52 moles for species A (O2+N2) in order to get the correct value of AFT.

Program

"""
Sample code to vary the temperature of air and oxidizer individually
"""
import cantera as ct 

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

A = ct.Quantity(gas)
A.TPX = 298.15, ct.one_atm, {'O2':0.21, 'N2':0.79}
A.moles = 2/0.21
print(A.mass_fraction_dict())



B = ct.Quantity(gas)
B.TPX = 298.15, ct.one_atm, 'CH4:1546' 
B.moles = 1
print(B.mass_fraction_dict())


# The following step is used to apply the right molar balance
M = A + B
M.equilibrate('HP')
print(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.