Skip to content

fix(individual_asv): stable recirculation boundary and correct succes…#1451

Merged
olelod merged 1 commit intomainfrom
fix/individual-asv-boundary-collapse
Mar 20, 2026
Merged

fix(individual_asv): stable recirculation boundary and correct succes…#1451
olelod merged 1 commit intomainfrom
fix/individual-asv-boundary-collapse

Conversation

@olelod
Copy link
Copy Markdown
Contributor

@olelod olelod commented Mar 20, 2026

…s flag

Two bugs fixed in IndividualASVRateControlStrategy

  1. 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.

  2. 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

  • Patch: X.Y.Z+1. NEGLIGIBLE visible changes, does not change input or output - OR changes behaviour. Use chore:, refactor: etc
  • Minor: X.Y+1.Z. Minor changes, might ADD new input (YAML), or other backwards-compatible changes. Use feat:, fix:
  • Major: X+1.Y.Z. Major and most likely BREAKING changes, wo. backwards compatibility, or removing temporary backwards compatibility functionality. Use ! or BREAKING:.

See here (internal): https://github.com/equinor/ecalc-internal/discussions/1044

Have you remembered and considered?

  • IF FEAT: I have remembered to update documentation
  • IF FIX OR FEAT: I have remembered to update manual changelog (docs/drafts/next.draft.md)
  • IF BREAKING: I have remembered to update migration guide (docs/docs/migration_guides/)
  • IF BREAKING: I have committed with BREAKING: in footer or ! in header
  • I have added tests (if not, comment why)
  • I have used conventional commits syntax (if you squash, make sure that conventional commit is used)
  • I have included the Github issue nr in the footer!

What is this PR all about?

What else did you consider?

Between the lines?

@olelod olelod requested a review from a team as a code owner March 20, 2026 12:30
inlet_stream=inlet_stream,
asv_rate_fraction=result_fraction,
)
self._simulator.apply_configurations(configurations)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There can be cases where recirculation does not bring the pressure low enough

…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.
@olelod olelod force-pushed the fix/individual-asv-boundary-collapse branch from 9bbc05d to 6f9517d Compare March 20, 2026 13:32
@olelod olelod merged commit 9ad1cce into main Mar 20, 2026
24 checks passed
@olelod olelod deleted the fix/individual-asv-boundary-collapse branch March 20, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants