Gas mixture calculator: mole and mass fractions, air and mixing streams

Air taken as 21 % oxygen and 79 % nitrogen by mole has a molar mass of 28.85 kg/kmol and is 23.29 % oxygen by mass. Mixing 9.52 kmol of it with 1 kmol of methane gives 290.70 kg of a stoichiometric mixture that burns at about 2224 K in Cantera with GRI-Mech 3.0.

This calculator converts mole fractions to mass fractions and back (or ppm) for up to six species, compares air models, builds a fuel-air mixture at any equivalence ratio and mixes two gas streams the way Cantera's Quantity class does, with the mixed temperature from NASA polynomials. Free, no sign-up, runs in your browser. The last tab checks a mass, mass fraction or temperature from your report. Built for Skill-Lync's Computational Combustion using Python and Cantera course.

Cantera 3.2.0 element weights (CIAAW 2017) · NASA polynomials (nasa_gas.yaml) · checked against Cantera on 267 cases (4,432 checks at build) · Updated 23 Nov 2026

Presets:

Molar masses from Cantera 3.2.0's element weights (CIAAW 2017: H 1.008, C 12.011, N 14.007, O 15.999, Ar 39.95). Gas fractions by volume are fractions by mole (ideal gas). Density is the ideal-gas value at your T and P.

Mean molar mass28.851 kg/kmol= g/mol
Density1.179 kg/m³ideal gas, 298.15 K, 1 atm
Gas constant R/M288.19 J/(kg K)specific
SpeciesM kg/kmolX moleY massppmvppm masskg / kmol mixkmol / kg mix
O231.9980.210000.232912,10,0002,32,9096.71960.0072789
N228.0140.790000.767097,90,0007,67,09122.1310.027382
Mixture28.85061110,00,00010,00,00028.85060.034661
Air, 21 % O2 by moleby mole (X)O2: 0.2100.210N2: 0.7900.790by mass (Y)O2: 0.2329.233N2: 0.7671.767O2N2
  • Fractions sum to 1.

How do you convert mole fraction to mass fraction?

Weight each mole fraction by its molar mass and divide by the total, which is the mean molar mass of the mixture. Going back, divide each mass fraction by its molar mass and normalise:

For air as 21 % O2 and 79 % N2 by mole, with the molar masses Cantera uses (O2 31.998, N2 28.014 kg/kmol):

Back the other way, YO2 = 0.23291 returns XO2 = 0.21000. For gases, volume % and mole % are the same thing (equal volumes of ideal gases hold equal numbers of molecules), so ppmv is 106 X. ppm by mass is 106 Y and is a different number: 420 ppmv of CO2 in nitrogen is 660 ppm by mass.

Two things go wrong most often. Using rounded molar masses (32 and 28) gives M = 28.84 and YO2 = 0.2330, close but not what a code prints. And fractions that do not add up to 1: Cantera's TPX quietly divides by the sum, so "O2:1, N2:3.76" becomes XO2 = 0.21008, and so does "CH4:1546" become 1. The calculator does the same when "Normalise" is on, and says so.

What is the molar mass of air?

28.97 kg/kmol for dry air with its four main gases, and 28.85 kg/kmol for the 21/79 model that combustion classes and the Cantera challenge use. The difference is argon: real air holds 0.934 % argon (M = 39.95) that the two-species model counts as nitrogen. With the standard dry-air fractions, which add to 100.0052 % and are scaled to 1:

Air modelM (kg/kmol)YO2YN2kmol air per kmol CH4A/F of CH4 (kg/kg)
O2 0.21, N2 0.7928.85060.232910.767099.523817.127
O2 + 3.76 N228.85100.233000.767009.520017.120
Dry air, 4 species28.96650.231370.755129.548917.241

So the mass fraction of oxygen in air is 23.29 % in the 21/79 model and 23.14 % in dry air. Humidity lowers the molar mass further: water vapour is 18.02 kg/kmol. Which model to use is a choice, not a correction: the 4-species air needs 0.7 % more air by mass for methane, small next to the effect of humidity or a few percent of excess air.

How much air does methane need? (air-fuel ratio)

One kmol of methane burns with 2 kmol of O2. Air brings 3.76 kmol of N2 with every kmol of O2, so stoichiometric air is 2 × 4.76 = 9.52 kmol:

By mass that is the air-fuel ratio:

For any fuel and oxidiser the calculator uses the oxygen balance Cantera's set_equivalence_ratio uses, where C, H, O, S are atoms per molecule:

Stoichiometric methane-air is then XCH4 = 0.09502 by mole and YCH4 = 0.05517 by mass. At φ = 0.8 methane takes 11.905 kmol of air and the products keep 0.500 kmol of O2. Propane needs A/F = 15.58 and hydrogen 34.07: hydrogen needs the most air per kg of fuel, because a kg of it holds far more molecules. The natural gas combustion calculator does the same balance as a mixture fraction for Fluent.

What temperature do you get when you mix two gas streams?

With no heat loss, a steady mixer keeps total enthalpy. The mixed temperature is where the mixture's enthalpy, from the NASA polynomials of each species, equals what the two streams brought in:

Air preheated to 600 K and mixed with methane at 298.15 K, in the challenge's 9.52 to 1 ratio, ends at 561.35 K. Averaging the two temperatures by moles would give 571.3 K: methane carries more heat per kelvin than air (cp about 35.7 against 29.1 kJ/(kmol K) at room temperature), so it pulls the mix down further than its share of moles. Burnt, this mix reaches 2349 K instead of 2225 K; what that preheat saves in fuel is the subject of the air preheat fuel savings calculator.

Cantera's Quantity does this sum when you write air + fuel, but by default it holds internal energy and volume constant, like two closed tanks joined into one:

For the 600 K case that gives 557.87 K and 98.942 kPa instead of 561.35 K at 101.325 kPa. When both streams start at the same temperature and pressure, as in the challenge, the two give the same 298.15 K and 1 atm, so the default never shows. For a burner or a duct, create both Quantities with constant="HP"; Cantera then refuses to add them unless their pressures match, because a constant-pressure mix needs one pressure.

How does Cantera's Quantity class handle mixtures?

A Quantity is a Solution state plus an amount. The challenge builds air and methane as separate Quantities, sets 9.52 and 1 in .moles, adds them and calls equilibrate("HP") for the adiabatic flame temperature. Three details decide whether a report's numbers are right:

  • Units. Cantera is SI with kmol: moles is in kmol and mass in kg, so 9.52 kmol of 21/79 air prints 274.65809, which is 274.66 kg, not grams. A Quantity created without a size is 1 kg, not "per gram".
  • 9.52 or 9.5238. 9.52 kmol of 21/79 air holds 1.9992 kmol of O2, a hair short of 2, so the challenge's mix sits at φ = 1.00040. With O2 + 3.76 N2 it is exactly 2. The flame temperature does not notice; a mass balance to five figures does.
  • Mechanism file. Cantera 3 loads gri30.yaml; gri30.cti and gri30.xml are no longer read. The challenge's answer, 2224 K, is what gri30.yaml gives: 2224.4 K.

This script reproduces the calculator's challenge preset with Cantera 3.2.0:

import cantera as ct
gas = ct.Solution("gri30.yaml")
air = ct.Quantity(gas, constant="HP")         # default would be 1 kg, constant UV
air.TPX = 298.15, ct.one_atm, "O2:0.21, N2:0.79"
air.moles = 9.52                              # kmol, not mol
fuel = ct.Quantity(gas, constant="HP")
fuel.TPX = 298.15, ct.one_atm, "CH4:1"
fuel.moles = 1
mix = air + fuel                              # adiabatic mixing at constant H, P
print(air.mass, fuel.mass, mix.mass, mix.moles, mix.T)
print(mix.mole_fraction_dict(), mix.mass_fraction_dict())
mix.equilibrate("HP")
print(mix.T)

It prints 274.658 kg of air, 16.043 kg of methane, 290.701 kg and 10.52 kmol of mixture at 298.15 K, and 2224.4 K after equilibrium. Without constant="HP" the mixing step gives the same state here (both streams are at 298.15 K and 1 atm), and the flame is 2224.4 K. The NASA polynomial calculator shows the enthalpy functions behind both steps, and the ignition delay calculator puts the same mixture in a reactor.

What did student reports do?

Skill-Lync read the text and pasted code of every public report of the Handling Mixtures challenge. As of 23 Nov 2026, n = 91 public reports, none of them image-only; 55 carry screenshots, which are not counted, so these are lower bounds. The challenge hands out starting code with 21/79 air, 'CH4:1546' and no air moles, and asks for the line that gives 2224 K.

  • The fix. 78 set 9.52 kmol of air or an exact equivalent such as 2/0.21; 3 use other values (9.56, 9.2, 8.875), which in Cantera give 2222.4, 2232.6 and 2223.4 K against 2224.4 K. Left unset, the air is Cantera's default 1 kg (0.0347 kmol) and the mix only reaches 374.1 K; 4 reports quote that number first. 61 state a flame temperature within 5 K of 2224.4 K; the other 30 state none in text.
  • Mechanism file. 81 of 91 load gri30.cti (75) or gri30.xml (6), which Cantera 3 refuses; 4 load gri30.yaml. This is mostly the starting code being kept, and it was right for Cantera 2.
  • Units. 7 call the moles kmol. 13 describe Cantera as working "per gram"; for moles per unit mass that reads the same (kmol per kg is mol per g), but 9 of them never say that a Quantity defaults to 1 kg. 5 label the printed mass in grams, which puts 274.66 kg of air at 274.66 g.
  • Air and solver. 85 keep 21/79 air and 4 use O2 + 3.76 N2; 63 call equilibrate('HP') and 20 add 'auto', which gives the same result here. None mixes streams at different temperatures, so none meets Cantera's constant-UV default.

Clear examples: 1 (gri30.yaml, 9.52 kmol, 2224 K), 2 (explains kmol and the mass fractions; loads gri30.xml) and 3 (shows the 374 K result before the fix; loads gri30.cti). Reports that are near copies of each other are counted separately.

How accurate is this calculator?

The fraction algebra is exact; the only data are the molar masses, which use the same element weights as Cantera 3.2.0, so a Cantera script prints the same digits. A separate script (267 cases) compared the calculator with Cantera: conversions against Cantera's own mole and mass fractions, fuel-air mixtures against set_equivalence_ratio for 12 fuels and five oxidisers, and 48 mixing results against Quantity addition, where the temperatures agree to within 0.00001 K. The flame temperature of a mixed stream comes from the site's 11-species equilibrium solver and agreed with Cantera's to 4e-7 K. The page rebuilds only if all 4,432 comparisons pass.

What it assumes: ideal gases (fine below a few tens of bar for these species), no condensation (water stays a vapour in the mixing tab), and adiabatic mixing. Products are given for lean and stoichiometric mixtures only.

What this calculator does not cover

  • Flame temperature and dissociation: one number for the mixed stream; for φ sweeps, preheat and oxygen enrichment use the adiabatic flame temperature calculator.
  • Liquids and humid air with condensation: fuels are vapours here; water does not condense.
  • Real-gas mixing: no compressibility factors or mixing rules for high pressure.
  • Fluent species inputs and NOx: see the natural gas combustion calculator.
Learn combustion modelling

Building mixtures, getting the units right and knowing what Cantera holds constant is the first step of every combustion calculation, from flame temperatures to engine CFD. This challenge is part of Skill-Lync's combustion courses.

Frequently asked questions

How do you convert mole fraction to mass fraction?

Multiply each mole fraction by its species' molar mass, then divide by the sum of those products, which is the mixture's mean molar mass. For air as 21 % O2 and 79 % N2 by mole: 0.21 × 31.998 / 28.851 = 0.2329, so oxygen is 23.29 % of air by mass.

What is the molar mass of air?

About 28.97 kg/kmol (g/mol) for dry air with nitrogen, oxygen, argon and carbon dioxide. The two-species model of 21 % O2 and 79 % N2 gives 28.85 kg/kmol, because it puts the 0.93 % argon in with nitrogen, which is lighter. Combustion calculations and Cantera exercises usually use the two-species value.

What is the mass fraction of oxygen in air?

23.14 % for dry air with argon and carbon dioxide included, and 23.29 % for the 21/79 model. By volume, which is by mole for gases, oxygen is 20.94 % of dry air. Mass fraction is higher than mole fraction because an oxygen molecule is heavier than the mixture's average.

What is the stoichiometric air-fuel ratio of methane?

17.13 kg of air per kg of methane with air as 21 % O2 and 79 % N2, and 17.24 with argon and carbon dioxide in the air. One kmol of methane needs 2 kmol of O2, which comes with 7.52 kmol of N2: 9.52 kmol of air, or 9.5238 if you divide 2 by exactly 0.21.

What temperature do you get when two gas streams mix?

In a steady mixer with no heat loss, the temperature at which the mixture's enthalpy equals what the two streams brought in. Air at 600 K mixed with methane at 298.15 K in the 9.52 to 1 ratio gives 561.3 K. A simple average weighted by moles gives 571.3 K, because methane's heat capacity is higher than air's.

Does Cantera's Quantity use grams or kilograms?

Kilograms and kilomoles. A Quantity created without a size holds 1 kg, its moles are in kmol and its enthalpy in joules. So air.moles = 9.52 is 9.52 kmol and air.mass prints 274.66, which is kilograms. Labelling it grams, or saying Cantera works per gram, is a units slip.

Why does Cantera add Quantities at constant volume?

Because constant='UV' is the default: adding two Quantities models two closed tanks joined into one, keeping internal energy and total volume. For a steady mixing process, create both with constant='HP'. Streams at the same temperature and pressure give the same answer either way, which is why the challenge's case cannot show the difference.

Related on Skill-Lync

Sources

  • Cantera 3.2.0, Python class Quantity (cantera.org API reference and the installed source): moles "Get/Set the number of moles [kmol]", mass set to 1.0 when neither mass nor moles is given, constant='UV' by default ("# combine at constant UV"), and the 'HP' branch that refuses unequal pressures. set_equivalence_ratio: "Considers the oxidation of C to CO2, H to H2O and S to SO2. Other elements are assumed not to participate in oxidation (that is, N ends up as N2)."
  • Cantera source, src/thermo/Elements.cpp: "Values are used from CIAAW. Atomic weights of the elements 2017" (H 1.008, C 12.011, N 14.007, O 15.999, Ar 39.95). NASA 7-coefficient polynomials from Cantera's nasa_gas.yaml (McBride, Gordon and Reno, NASA database).
  • Wikipedia, "Atmosphere of Earth", table of major constituents of dry air by volume: nitrogen 78.084 %, oxygen 20.946 %, argon 0.9340 %, carbon dioxide 412 ppm (the table also lists 423.9 ppm for 2024); average molar mass of dry air "about 28.946" or "28.964" g/mol.
  • The challenge statement of Skill-Lync's Computational Combustion using Python and Cantera course (Week 4.1, Handling Mixtures) as quoted in the public reports: air as O2 0.21, N2 0.79 at 298.15 K and 1 atm, methane as 'CH4:1546', "The right answer is 2224K".
  • scripts/verify/gas_mixture.py recomputes 267 cases another way (own fraction algebra with Cantera's molar masses, Cantera's set_equivalence_ratio, Quantity addition at constant HP and UV, HP equilibrium, the Units tab's script); the page compares its own numbers with them at build time (4,432 checks).
Free counselling

From a gas mixture to combustion simulation.

Combustion and CFD engineers work on engines, gas turbines, furnaces and hydrogen and ammonia burners. A Skill-Lync counsellor can map the course that fits the role you want.

Talk to a combustion course counsellor

Free. We call you back, usually the same day.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

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.