Skip to content

VCS equilibrium solver jumps between different solutions for mixtures with binary-solution-tabulated phase #1928

@spinnau

Description

@spinnau

Problem description

Calling the equilibrate method on mixtures containing a `binary-solution-tabulated phase using the VCS solver can give strange results. I have noticed that there are jumps between different solutions when the solver is called several times.

This is not a general problem of the VCS solver. It works fine even with other more complex models e.g. containing HMW-electrolyte phases. When changing the binary-solution-tabulated phase to ideal-condensed, this problem doesn't occur.

Steps to reproduce

yaml = """
phases:
- name: Li(s)
  thermo: fixed-stoichiometry
  elements: [Li]
  species: [Li(cr)]
  state: {T: 298.15, P: 1.0e+5 Pa}

species:
- name: Li(cr)
  composition: {Li: 1}
  thermo:
    model: NASA7
    temperature-ranges: [200.0, 453.69]
    data:
    - [0.610909942, 0.0141041217, -1.7495817e-05, -3.33741023e-08, 7.76629665e-11,
      -625.121208, -3.26449947]
    note: TPIS82
"""

p1 = ct.Solution('lithium_ion_battery.yaml', 'anode')
p2 = ct.Solution(yaml=yaml, name='Li(s)')
mix = ct.Mixture([p1, p2])

mix.T = 293
mix.P = 1e5
mix.species_moles = [1.0, 1.0, 0.0]

mix.equilibrate('TP', solver='vcs', log_level=1)
print(mix.species_moles)

mix.equilibrate('TP', solver='vcs')
print(mix.species_moles)

mix.equilibrate('TP', solver='vcs')
print(mix.species_moles)

mix.equilibrate('TP', solver='vcs')
print(mix.species_moles)

mix.equilibrate('TP', solver='vcs')
print(mix.species_moles)

Behavior

The successive calls to the equilibrate method produce different results. Without changing Temperature, pressure or composition the results should be the same:

Trying VCS equilibrium solver
VCS solver succeeded
[0.04620062 1.95379938 0.95379938]
[1. 1. 0.]
[0.04620062 1.95379938 0.95379938]
[1. 1. 0.]
[0.04620062 1.95379938 0.95379938]

I've also changed the rtol and estimate_equil parameters, but the problem remains the same.

System information

  • Cantera version: 3.1.0
  • OS: Arch Linux
  • Python 3.13.5

Additional context

The solution of the VCS solver is also different from the Gibbs solver. And for this example, the VCS solver gives the same result if the equilibrate method is called again after using the Gibbs solver:

mix.equilibrate('TP', solver='gibbs')
print(mix.species_moles)

mix.equilibrate('TP', solver='vcs')
print(mix.species_moles)

mix.equilibrate('TP', solver='vcs')
print(mix.species_moles)
[0.2347416 1.7652584 0.7652584]
[0.2347416 1.7652584 0.7652584]
[0.2347416 1.7652584 0.7652584]

In principle this looks like I could just use the Gibbs solver, but that very often gives errors like in #1023.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions