Updates to make HP queries return values instead of failing for higher pressures#2087
Updates to make HP queries return values instead of failing for higher pressures#2087wandadars wants to merge 2 commits intoCantera:mainfrom
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2087 +/- ##
==========================================
- Coverage 77.53% 77.49% -0.05%
==========================================
Files 451 451
Lines 52810 52928 +118
Branches 8828 8859 +31
==========================================
+ Hits 40947 41016 +69
- Misses 8888 8924 +36
- Partials 2975 2988 +13 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I think this may be partially on the right track, but I'd suggest focusing on a narrower definition of the problem. The equilibrium solver here is acting as a way of "finding" conditions that cause trouble for the equation of state solver, but isn't itself part of the problem. The equations of the P-R model do not like the case where import cantera as ct
def partial_lookup_peng_robinson_phase():
"""Build a mixed-parameter Peng-Robinson phase used by the original test."""
species = ct.Species.list_from_file("test/data/co2_PR_example.yaml")
phase_species = []
for sp in species:
data = dict(sp.input_data)
if data["name"] in {"CH4", "O2"}:
data.pop("equation-of-state", None)
else:
data["equation-of-state"] = {
"model": "Peng-Robinson",
"a": 0,
"b": 0,
"acentric-factor": 0.0,
}
phase_species.append(ct.Species.from_dict(data))
return ct.Solution(
thermo="Peng-Robinson",
kinetics="bulk",
species=phase_species,
reactions=[],
name="partial-lookup-pr",
)
gas = partial_lookup_peng_robinson_phase()
gas.TPX = 500, 1e6, 'CO2:0.333, H2O:0.666'
gas()which outputs: So it's pretty clear why the equilibrium solver can't do anything with such a mixture. If you want to pick out specific cases where the cubic solver is causing trouble, I'd put a |
|
Good catch @speth . We have checks that watch for a=0, b=0 and use ideal-gas fallbacks for those quantities. Also those fallback were moved up to the base class since this is a common issue in both PREOS and RK cubic equations of state. |
…gas fallback methods when degenerate case happens
432eb0a to
2901fd9
Compare
I was running a test case for a 1D counterflow diffusion flame at very high pressures using the Peng-Robinson equation of state, and the initial condition that used the HP equilibrate call return EoS failures. Codex 5.3 identified this as a possible reason for why the real/ideal gas mixed PREOS might be failing, and it did resolve the EoS that was happening for high pressure H-P equilibrate calls.
AI Statement (required)
Significant portions of code or documentation were generated with AI, including
logic and implementation decisions. All generated code and documentation were
reviewed and understood by the contributor. Examples: Output from agentic coding
tools and/or substantial refactoring by LLMs (web-based or local).
For additional information on Cantera's AI policy, see
https://github.com/Cantera/cantera/blob/main/CONTRIBUTING.md#restrictions-on-generative-ai-usage -->