Fix convergence failures in VCS constant TP solver#2124
Open
speth wants to merge 3 commits into
Open
Conversation
The VCS solver's main loop checked the iteration limit at the top of the MAIN stage but only set the failure flag (iconv = -1) without exiting the loop, relying on the subsequent equilibrium-check stage to act on the limit. That stage is not always reached: a component-basis swap oscillation can keep the solver cycling through the MAIN stage indefinitely, forcing a new component calculation on every iteration and never advancing to the equilibrium check. Fixed by routing the over-iteration case directly to the cleanup-and-return block. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The optimum-basis check at the end of each VCS iteration can disagree with the basis that vcs_basopt actually selects: the check ranks a noncomponent against a component by mole number alone, while vcs_basopt additionally enforces linear independence and uses slightly different size weighting. When they disagree, the check forces a component recalculation that re-selects the same basis, which immediately trips the check again. The solver cycles through its main loop forcing a new basis every iteration and never reaches the equilibrium check, so it cannot converge. Fixed by counting consecutive recalculations forced by this check and stopping forcing once they clearly exceed what a real basis improvement requires. The convergence criterion is the same for any equivalent basis, so suppressing an oscillating swap is safe: it affects only conditioning, not the result. Add a regression test covering a representative spread of the affected compositions. Fixes Cantera#266. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2124 +/- ##
=======================================
Coverage 77.78% 77.78%
=======================================
Files 452 452
Lines 53602 53611 +9
Branches 8958 8959 +1
=======================================
+ Hits 41693 41701 +8
- Misses 8883 8885 +2
+ Partials 3026 3025 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes proposed in this pull request
If applicable, fill in the issue number this pull request is fixing
AI Statement (required)
Checklist
scons build&scons test) and unit tests address code coverage