Extract mole fractions of function "equilibrate"

43 views
Skip to first unread message

Ando

unread,
Feb 10, 2021, 10:46:56 AM2/10/21
to Cantera Users' Group
I would like to calculate the equilibria of a gas mixture at varying temperatures and pressures.
The result should be a table containing the different temperatures, pressures and mole fractions.
Unfortunately I couldn't find a way to extract the mole fraction from the result of the function "equilibrate", as this the result of this function looks like this:

Screenshot_20210210_155748.png

Bryan W. Weber

unread,
Feb 11, 2021, 8:55:32 AM2/11/21
to Cantera Users' Group
Hi,

Cantera is a little bit different from other software that do a similar job. In particular, Cantera has ideas of objects, so the equilibrate function does not return any results. Instead, the results are stored in the object which called the equilibrate function. For instance, if you set the problem up like this (in Python):

gas = ct.Solution('gri30.yaml')
gas.set_equivalence_ratio(1.0, 'CH4', 'O2:1,N2:3.76')
gas.equilibrate('HP')

then the state of the "gas" object will be set to the equilibrium state, and you can use all the methods of the Solution object to retrieve the results. In particular,

gas.X

gives you an array of mole fractions of the species.

Best,
Bryan

Ando

unread,
Feb 15, 2021, 11:46:06 AM2/15/21
to Cantera Users' Group
Dear Bryan,
Thanks a lot, works just fine
Best
Ando
Reply all
Reply to author
Forward
0 new messages