Problems with convergence when trying to obtain equlibrium

48 views
Skip to first unread message

Jędrzej Chrostowski

unread,
Jul 17, 2025, 4:41:00 PM7/17/25
to Cantera Users' Group
Hi, I'm trying to basically create a Python script that could perform calculations simmilar to the ones performed by NASA CEA, but I'm encountering problems when trying to run a very easy script that is presented below.

import cantera as ct
gas = ct.Solution(species=ct.Species.list_from_file('nasa_gas.yaml'),thermo='ideal-gas',kinetics='gas')
gas.TPX = 300, 101325, 'O2:1.0, H2:2.0'
gas.equilibrate('HP',rtol=1e-5,log_level=1)
gas()

When trying to run the script I'm getting an error message such as:

Trying ChemEquil solver
ChemEquil solver failed.

*******************************************************************************
CanteraError thrown by ChemEquil::equilibrate:
no convergence in 1000 iterations.
*******************************************************************************
Trying VCS equilibrium solver
VCS solver failed.

*******************************************************************************
CanteraError thrown by vcs_MultiPhaseEquil::equilibrate_HP:
No convergence for T
*******************************************************************************
Trying MultiPhaseEquil (Gibbs) equilibrium solver
MultiPhaseEquil solver failed.

*******************************************************************************
CanteraError thrown by MultiPhase::equilibrate_MultiPhaseEquil:
No convergence for T
*******************************************************************************
Traceback (most recent call last):
  File "D:\CANTERA_tutorials\T1\trial.py", line 63, in <module>
    gas.equilibrate('HP',rtol=1e-5,log_level=1)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "thermo.pyx", line 449, in cantera.thermo.ThermoPhase.equilibrate
cantera._utils.CanteraError:
*******************************************************************************
CanteraError thrown by MultiPhase::equilibrate_MultiPhaseEquil:
No convergence for T
*******************************************************************************

So my question is - does the yaml library I'm using have to have reactions/kinetics specified to obtain equilibrium with constant pressure and enthalpy? Until now I thought that the Gibbs Energy minimalization does not need those informations but I might be wrong.

Thanks in advance for all the answers

Ray Speth

unread,
Jul 17, 2025, 10:13:16 PM7/17/25
to Cantera Users' Group

Hi,

The example code you posted works fine for me using both the release version (3.1.0) and the latest development version, producing the following output:

Trying ChemEquil solver ChemEquil solver succeeded temperature 3077.2 K pressure 1.0133e+05 Pa density 0.058835 kg/m^3 mean mol. weight 14.856 kg/kmol phase of matter gas 1 kg 1 kmol --------------- --------------- enthalpy 4470.7 66417 J internal energy -1.7177e+06 -2.5519e+07 J entropy 18241 2.7099e+05 J/K Gibbs function -5.6128e+07 -8.3383e+08 J heat capacity c_p 3175.4 47174 J/K heat capacity c_v 2615.7 38860 J/K mass frac. Y mole frac. X chem. pot. / RT --------------- --------------- --------------- Electron 4.4502e-13 1.2051e-08 -24.331 H 0.0052182 0.076906 -11.42 H+ 4.039e-15 5.956e-14 12.911 H- 1.5512e-12 2.2849e-11 -35.751 HO2 9.0356e-05 4.0669e-05 -44.782 H2 0.020274 0.1494 -22.839 H2O 0.70803 0.58388 -39.521 H2O+ 1.0847e-10 8.9454e-11 -15.19 H2O2 5.9784e-06 2.6111e-06 -56.202 H3O+ 1.671e-08 1.305e-08 -26.609 O 0.035616 0.033072 -16.681 O+ 2.3613e-14 2.1927e-14 7.6498 O- 2.0591e-10 1.9119e-10 -41.012 OH 0.1211 0.10579 -28.101 OH+ 2.4639e-12 2.1523e-12 -3.7699 OH- 1.0072e-09 8.7982e-10 -52.432 O2 0.10966 0.050913 -33.362 O2+ 5.0297e-11 2.3352e-11 -9.0314 O2- 4.3152e-11 2.0034e-11 -57.693 O3 5.8177e-08 1.8007e-08 -50.044 [ +728 minor] 6.6668e-16 4.9122e-15

What version of Cantera are you using, on what OS, and how did you install it?

Regards,
Ray

Jędrzej Chrostowski

unread,
Jul 18, 2025, 4:03:01 AM7/18/25
to Cantera Users' Group
Hi,
Cantera ver.: 3.1.0
OS: Windows 11 Enterprise 22H2
Cantera was installed through pip install in cmd

However I think I have located the problem which was causing the errors. 
During my 'test runs' with Cantera I added some species to nasa_gas.yaml library (to test the Shomate compiler) which doubled the already existing species in the library. After they were deleted the code runs without any problems.

For future reference here are the doubled species:

- name: N2H4
  composition: {N: 2, H: 4}
  thermo:
    model: NASA7
    temperature-ranges: [200.0, 1000.0, 6000.0]
    data:
    - [3.83472149, -6.49129555e-04, 3.76848463e-05, -5.00709182e-08, 2.03362064e-11,
      1.00893925e+04, 5.7527203]
    - [4.93957357, 8.75017187e-03, -2.99399058e-06, 4.67278418e-10, -2.73068599e-14,
      9282.65548, -2.69439772]
    note: L 5/90


- name: N2H4(G)
  composition: {N: 2, H: 4}
  thermo:
    model: Shomate
    temperature-ranges: [800.0, 2000.0, 6000.0]
    reference-pressure: 1.0 bar
    data:
      - [35.1824, 96.0526, -40.5013, 6.66807, -0.874233, 77.9915, 249.425]
      - [121.401, 4.81688, -0.763012, 0.043232, -40.7865, -11.3811, 305.344]


- name: H2O2
  composition: {H: 2, O: 2}
  thermo:
    model: NASA7
    temperature-ranges: [200.0, 1000.0, 6000.0]
    data:
    - [4.27611269, -5.42822417e-04, 1.67335701e-05, -2.15770813e-08, 8.62454363e-12,
      -1.77542989e+04, 3.43505074]
    - [4.57333537, 4.0498407e-03, -1.29479479e-06, 1.9728171e-10, -1.13402846e-14,
      -1.80548121e+04, 0.704278488]
    note: L 2/93

  - name: H2O2(G)
    composition: {H: 2, O: 2}
    thermo:
      model: Shomate
      temperature-ranges: [298.0, 1500.0]
      reference-pressure: 1.0 bar
      data:
        - [34.25667, 55.18445, -35.15443, 9.08744, -0.422157, -149.9098,
              257.0604]

Reply all
Reply to author
Forward
0 new messages