fix(individual_asv): stable recirculation boundary and correct succes…#1451
Merged
fix(individual_asv): stable recirculation boundary and correct succes…#1451
Conversation
olelod
commented
Mar 20, 2026
| inlet_stream=inlet_stream, | ||
| asv_rate_fraction=result_fraction, | ||
| ) | ||
| self._simulator.apply_configurations(configurations) |
Contributor
Author
There was a problem hiding this comment.
There can be cases where recirculation does not bring the pressure low enough
jsolaas
approved these changes
Mar 20, 2026
…s flag Reset each loop's recirculation to zero before computing the boundary, so the stream seen at the compressor inlet is independent of any prior state. Without the reset, the boundary collapsed after _minimum_achievable_pressure set maximum recirculation, causing DidNotConvergeError. Fix success flag in IndividualASVRateControlStrategy (was unconditional True) and IndividualASVPressureControlStrategy (was comparing FluidStream == FloatConstraint, always False). Add regression tests for both strategies.
9bbc05d to
6f9517d
Compare
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.
…s flag
Two bugs fixed in IndividualASVRateControlStrategy
Boundary collapse: _get_configurations_from_fraction and _minimum_achievable_pressure used run(to_id=compressor_id), which traverses through the RecirculationLoop mixer and returns the stream AFTER mixing in the current recirculation. This made boundary.max = max_std_rate - (inlet + recirc), which shrinks with each root-finding iteration — a circular dependency that causes Brent's method to converge to the wrong recirculation rate. Fix: use run(to_id=recirculation_loop_id) to stop at the loop inlet (before the mixer), giving a stable boundary = max_std_rate - inlet.
Unconditional success=True: IndividualASVRateControlStrategy.apply ended with return Solution(success=True, ...) regardless of whether the target was actually reached. Fixed to compare outlet_stream.pressure_bara to target_pressure via FloatConstraint equality (isclose, abs_tol=1e-3). Also fixed the same issue in IndividualASVPressureControlStrategy.apply (wrong type comparison: outlet_stream == target_pressure instead of .pressure_bara ==).
Add regression test that fails on main (boundary collapse causes RateTooLowError via collapsed boundary in Brent's method) and passes with the fix.
Type of Work
See here (internal): https://github.com/equinor/ecalc-internal/discussions/1044
Have you remembered and considered?
docs/drafts/next.draft.md)docs/docs/migration_guides/)BREAKING:in footer or!in headerWhat is this PR all about?
What else did you consider?
Between the lines?