Challenge

Week 4.1- Handling Mixtures with Cantera

AIM:

The aim of this study is to understand the mole fraction and the mass fraction of the given mixture using Python and Cantera.

Introduction:

Mass fraction and mole fraction are important parameters in the context of any chemical reaction. Mass fraction of a species in a mixture denotes the fraction of mass of that species present inside a particular mixture. Similarly, the mole fraction of a species in a mixture indicates the fraction of moles of the species present in the given mixture.

Mass fraction is calculated as:

Mass Fraction (Yi) = Mass of the particular species in a mixture ÷ Total mass of the mixture

Sum of mass fraction values for all the species inside a mixture = 1.

Mole fraction is calculated as:

Mole Fraction (Xi) = number of moles of a particular species in a mixture ÷ Total number of moles inside a mixture

Sum of mole fraction values for all the species inside a mixture = 1.

Mass and mole fraction values are important not only in the chemical calculations but also in the calculation of several thermodynamic properties like heat transfer, adiabatic flame temperature, etc.

Coding Approach:

  1. The Cantera module is imported as ‘ct’.
  2. Using the ‘Solution’ class, a ‘gas’ object is created.
  3. ‘A’ object is created, which is an instance of the ‘Quantity’ class. This class inherits from a ‘gas’ object.
  4. Using the ‘.TPX’ method, temperature, pressure, and molar composition are set. Temperature is set at 298.15K, and pressure at 1 atmosphere. The molar composition of oxygen (O2) and nitrogen (N2) is defined.
  5. Using the ‘.moles’ method, a number of moles of O2 and N2 are set.
  6. Similarly, the ‘B’ object is created and temperature, pressure, and molar composition are set for methane (CH4).
  7. A mixture of air and fuel is created using a simple addition method from the Quantity class.
  8. Using the ‘.equilibrate’ method, constant pressure is set.
  9. Using the ‘.T’ method, the temperature is calculated.

Answer for Question 1:

‘A.moles’ method is used to set the number of moles of oxygen (O2) and nitrogen (N2).

For this problem statement, using A.moles, a number of moles of O2 and N2 are set to 9.52.

Initially, the number of moles of O2 was set to 0.21. After using ‘A.moles’ it becomes 1.9992 ≈2. Also, the number of moles of N2 was set to 0.79. After ‘A.moles’ it becomes 7.52.

Hence, the ‘A.moles’ method is used to change/set the number of moles of a particular species.

Answer for Question 2:

As per question 1, we get the number of moles of O2 and N2 to be 2 and 7.52 respectively.

Using the mole fraction formula, mentioned above,

Mole fraction of O2 = 2/(2+7.52) = 0.210084 ≈ 0.21.

Mole fraction of N2 = 7.52/(2+7.52) = 0.789915 ≈ 0.79.

The same results are obtained after using the ‘A.mole_fraction_dict()’ method. The result consists of a dictionary with species name as the key and mole fraction as the value of the dictionary as follows:

{‘O2’ : 0.21, ‘N2’ : 0.79}

Answer for Question 3:

In line 15, using the ‘.TPX’ method, temperature, pressure and the molar composition of the methane is being set. In line 16, using the ‘.moles’ method, the number of moles of methane are set to 1. The number 1546 is irrelevant as any number set instead of 1546, gives the same molar composition for methane. Hence, to set the number of moles properly, the ‘.moles’ method is used.

Using ‘.TPX’ method, the molar composition of O2 and N2 are set properly but the same is not happening with CH4. This can be attributed to the fact that O2 and N2 are elements and the CH4 is a compound.

Answer for Question 4:

To get the right value of AFT in line 22, in line 10, the number of moles of O2 and N2 should be 2 and 7.52 respectively. This can be done by setting the number of moles to 9.52 using the ‘A.moles’ method.

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.