Challenge

Week 4.1- Handling Mixtures with Cantera

Objective: To create various mixture using Quantity class in Cantera.

1. Use the "moles" method/function, calculate the number of moles of the object A and explain how it is calculated analytically. You need to use this after line number 9 by using the predefined function ‘A.moles’

  • Mixture used for the process is methane and air.
    `CH_4+2(O_2+3.76N_2)->CO_2+2H_2O+7.52N_2`
  • Here in this, the mole fraction value is given for Oxygen and Nitrogen
    `O_2=0.21text( & ) N_2=0.79`
  • Summation of both the quantities mole fraction is 1.
  • Mole fraction of any species in a mixture is given by the formula:

    `text(Mole fraction of species i in A)=text(No. of moles of i in mixture A)/text(Total no. of moles in Mixture)`

    here in this case, A represents mixture of `O_2 and N_2` and we have,

    No. of moles of `O_2 = 2`

    No. of moles of `N_2 = 2xx3.76=7.52`

  • Now, calculating the mole fraction for the species.

    `text(Mole fraction of ) A_(O_2)=2/(2+7.52)=0.21`

    `text(Mole fraction of ) A_(N_2)=7.52/(2+7.52)=0.79`
  • Calculating No. of moles

    `text(No. of moles) = text(Total no. of moles)/text(Mole fraction of the species)`

    `text(Moles of )O_2=2/0.21=9.52`

    `text(Moles of )N_2=7.52/0.79=9.52`

  • As the no. of moles of Nitrogen and oxygen are same, we can use them to calculate.

2. Use the method mass_fraction_dict() of the A object and explain it analytically.

After using "A.mass_fraction_doct()" in the code I got the result which is shown above. And this is representing the mass fraction of the species `N_2 and O_2`.

it can be calculated analytically using the formula:

`text(mass fraction of the species i )=text(mass of the species i present in mixture)/text(Total mass of the mixture)`

For methane-air mixture

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

A is the mixture of Nitrogen and oxygen so,

no. of moles of `O_2` in mixture A = 2

no. of moles of `N_2` in mixture A = 7.52

total mass of species i in mixture A is given by the formula:

`text(Total mass of species i in mixture A ) = text(no. of moles of species i in mixture)xxtext(molecular weight of the species)`

Total weight of `O_2` in mixture A= 2x32=64

Total weight of `N_2` in mixture A= 7.52x28 = 210.56

Mass fraction of `O_2 = 64/(64+210.56)=0.232`

Mass fraction of `N_2 = 210.56/(210.56+64)=0.767`

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

  • in line no. 15 TPX command is given that means get Temperature, pressure and mole fraction.
  • in line no. 16 no. of moles of mixture B is assigned as 1.
  • And the number 1546 represents the Mole fraction of the object. since only one compound is given the molar fraction plays no role here.

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

  • Actually, we don't need to change anything in line no. 22. we need to set the no. of moles of mixture A (A.moles) to .52, we calculated this in part 1.

Code

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 = 9.52
print(A.mass_fraction_dict())


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


M=A+B
M.equilibrate('HP')
print(M.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.