Skip to content

Restore ThermoPhase state after error setting state#1981

Merged
bryanwweber merged 5 commits intoCantera:mainfrom
speth:restore-thermo-after-error
Sep 19, 2025
Merged

Restore ThermoPhase state after error setting state#1981
bryanwweber merged 5 commits intoCantera:mainfrom
speth:restore-thermo-after-error

Conversation

@speth
Copy link
Copy Markdown
Member

@speth speth commented Sep 18, 2025

Changes proposed in this pull request

  • Add functions for saving/restoring the "partial" thermo state, which excludes the composition variables
  • Reset ThermoPhase objects to their previous (valid) state after an error setting the state. This is particularly important for the iterative two-property setters like setState_HP which repeatedly manipulate the internal state.

One important result of this revised behavior is that it improves the ability to use thermo models where errors in setState_HP or setState_UV are possible in reactor reactor networks. Previously, a bad estimated step by the integrator would lead to repeated failures in the eval function, even after the integrator backs off from the problematic state. Now, it is actually possible for the integrator to proceed after one of these "recoverable" integrator errors.

If applicable, fill in the issue number this pull request is fixing

Resolves an issue identified in a post on the Cantera Users' Group.

If applicable, provide an example illustrating new features this pull request is introducing

Checklist

  • The pull request includes a clear description of this code change
  • Commit messages have short titles and reference relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • Style & formatting of contributed code follows contributing guidelines
  • The pull request is ready for review

@speth speth added the Thermo label Sep 18, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 18, 2025

Codecov Report

❌ Patch coverage is 81.96721% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.58%. Comparing base (72fbf27) to head (19ce9a2).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/thermo/Phase.cpp 73.33% 3 Missing and 5 partials ⚠️
src/thermo/ThermoPhase.cpp 89.28% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1981      +/-   ##
==========================================
+ Coverage   75.47%   75.58%   +0.11%     
==========================================
  Files         450      450              
  Lines       56317    56320       +3     
  Branches     9301     9294       -7     
==========================================
+ Hits        42503    42570      +67     
+ Misses      10680    10613      -67     
- Partials     3134     3137       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@bryanwweber bryanwweber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Ray! Some small suggestions for improving the docs, otherwise looks good to me.

@speth speth force-pushed the restore-thermo-after-error branch from 89767d9 to 19ce9a2 Compare September 18, 2025 17:30
@bryanwweber bryanwweber merged commit c6ca2ca into Cantera:main Sep 19, 2025
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants