Skip to content

feat(solver): add structured failure events to Solution#1458

Merged
olelod merged 1 commit intomainfrom
feat/solver-failure-status
Mar 26, 2026
Merged

feat(solver): add structured failure events to Solution#1458
olelod merged 1 commit intomainfrom
feat/solver-failure-status

Conversation

@olelod
Copy link
Copy Markdown
Contributor

@olelod olelod commented Mar 25, 2026

Replace bare success=False returns with typed failure events:

  • OutsideCapacityEvent: rate above stonewall or below surge, with actual and boundary values (m3/h) when available
  • TargetNotAchievableEvent: pressure target out of achievable range, with achievable and target values (bara)

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 force-pushed the feat/solver-failure-status branch from 1209514 to 854a522 Compare March 25, 2026 12:55
Comment thread src/libecalc/domain/process/process_solver/solver.py
@olelod olelod force-pushed the feat/solver-failure-status branch 2 times, most recently from 1dcbba5 to ac95db4 Compare March 26, 2026 13:02
@olelod olelod marked this pull request as ready for review March 26, 2026 13:02
@olelod olelod requested a review from a team as a code owner March 26, 2026 13:02
@olelod olelod force-pushed the feat/solver-failure-status branch from ac95db4 to f4c7294 Compare March 26, 2026 13:13

current_inlet = inlet_stream
overall_success = True
failure_event: SolverFailureEvent | None = None
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.

only first failure that occurs

configurations[pressure_control_configuration.simulation_unit_id] = pressure_control_configuration

failure_event = pressure_control_solution.failure_event
if isinstance(failure_event, TargetNotAchievableEvent) and failure_event.source_id is None:
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.

if the failure occurs within common_asv or individual_asv there is no process_system_id available when the failure occurs. add it here.

@tj098895
Copy link
Copy Markdown
Contributor

@olelod dont see any reason to not merge it despite that it is not "complete" :)

Replace bare success=False returns with typed failure events:
- OutsideCapacityEvent: rate above stonewall or below surge, with required
  source_id (ProcessUnitId) and optional actual/boundary values (m3/h)
- TargetNotAchievableEvent: pressure target out of achievable range, with
  achievable/target values (bara) and optional source_id (ProcessSystemId)

Compressor passes its process_unit_id (required) when raising RateTooHighError/
RateTooLowError.

OutletPressureSolver takes a required process_system_id such that
TargetNotAchievableEvent in multi pressure system can trace which segment failed.
@olelod olelod force-pushed the feat/solver-failure-status branch from f4c7294 to e6ee51f Compare March 26, 2026 18:44
@olelod olelod merged commit 7167fa3 into main Mar 26, 2026
24 checks passed
@olelod olelod deleted the feat/solver-failure-status branch March 26, 2026 18:47
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