Skip to content

fix: bb outages - #625

Merged
BenjPetr merged 18 commits into
mainfrom
fix/bb_outage_ben
Jul 23, 2026
Merged

fix: bb outages#625
BenjPetr merged 18 commits into
mainfrom
fix/bb_outage_ben

Conversation

@BenjPetr

@BenjPetr BenjPetr commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Checklist

Please check if the PR fulfills these requirements:

  • PR Title follows conventional commit messages
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • All commits in this PR are DCO signed-off (see CONTRIBUTING.md)

Does this PR already have an issue describing the problem?

Fixes busbar outages:

  • order issue
  • list(set()) deduplication issue
  • flow still on line for outaged stub -> now zero

What is the new behavior (if this is a feature change)?

Does this PR introduce a breaking change?

  • Yes
  • No

BenjPetr added 5 commits July 17, 2026 15:49
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
…ge and keep order

Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 20, 2026 08:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes incorrect busbar outage handling across preprocessing and the JAX outage execution path, addressing case ordering/deduplication and ensuring physically disconnected stub subtrees yield zero monitored flow instead of residual flow. It also adds regression grids and tests to prevent reintroducing these issues.

Changes:

  • Extend busbar-outage preprocessing to preserve branch order during deduplication and to track “zero-flow” branches for bridge-fed stub subtrees.
  • Propagate the new busbar-outage metadata through NetworkDataconvert_to_jax → HDF5 persistence → JAX outage execution, including filtering padded/always-articulation busbar slots.
  • Add a dedicated node-breaker regression grid plus end-to-end tests validating DC solver results against reference loadflows for busbar contingencies.

Reviewed changes

Copilot reviewed 19 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/interfaces_pkg/src/toop_engine_interfaces/loadflow_result_helpers_polars.py Fix empty-return arrays to be well-formed and filled with NaN instead of relying on invalid np.full usage.
packages/importer_pkg/src/toop_engine_importer/network_graph/powsybl_station_to_graph.py Adjust connected-component in-service mask evaluation for branches/injections.
packages/grid_helpers_pkg/tests/powsybl/test_powsybl_example_grids.py Add convergence test for the new always-articulation busbar outage regression grid.
packages/grid_helpers_pkg/src/toop_engine_grid_helpers/powsybl/example_grids.py Introduce create_busbar_outage_always_articulation_grid() regression grid builder.
packages/dc_solver_pkg/tests/test_example_grids.py Add preprocessing-path test coverage for the new regression grid.
packages/dc_solver_pkg/tests/preprocessing/test_preprocess_bb_outage.py Update tests for new return values (zero-flow branches) + add ordering and stub-compensation regression tests.
packages/dc_solver_pkg/tests/preprocessing/test_convert_to_jax.py Assert correct N-1 case counting and persistence of new rel-busbar validity metadata.
packages/dc_solver_pkg/tests/postprocessing/test_postprocess_powsybl.py Add reference-matching tests comparing solver busbar-outage results to Powsybl DC loadflow per contingency.
packages/dc_solver_pkg/tests/jax/test_busbar_outage.py Add unit tests for padded-slot filtering and extend dummy rel-bb outage data with new fields.
packages/dc_solver_pkg/tests/conftest.py Add fixtures to generate/copy the new regression grid preprocessing folder for tests.
packages/dc_solver_pkg/src/toop_engine_dc_solver/preprocess/preprocess_bb_outage.py Refactor busbar-outage extraction: stable deduplication, connected-busbar propagation logic, and “zero-flow branch” tracking.
packages/dc_solver_pkg/src/toop_engine_dc_solver/preprocess/network_data.py Extend OutageData/NetworkData with *_zero_flow_br_indices fields for busbar outages.
packages/dc_solver_pkg/src/toop_engine_dc_solver/preprocess/convert_to_jax.py Convert/pad new outage metadata for JAX, compute valid busbar masks/flat indices, and carry zero-flow branch sets.
packages/dc_solver_pkg/src/toop_engine_dc_solver/jax/types.py Add new RelBBOutageData / NonRelBBOutageData fields and update outage counts to use valid busbar indices.
packages/dc_solver_pkg/src/toop_engine_dc_solver/jax/inputs.py Persist/load new busbar-outage datasets in HDF5 with backward-compatible defaults.
packages/dc_solver_pkg/src/toop_engine_dc_solver/jax/busbar_outage.py Apply zero-flow forcing post-outage, improve retry outage selection, and filter valid busbar slots in rel-bb execution.
packages/dc_solver_pkg/src/toop_engine_dc_solver/jax/branch_action_set.py Merge new rel-bb outage fields when combining action sets.
packages/dc_solver_pkg/src/toop_engine_dc_solver/example_grids.py Provide a preprocessing-folder generator for the new always-articulation regression grid.
notebooks/example3_e2e_pipeline.ipynb Update notebook pipeline configuration and optionally generate demo grids from helpers.
.gitignore Ignore new notebook demo data folder.

BenjPetr added 4 commits July 20, 2026 13:40
…sbar_outages

Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
@BenjPetr BenjPetr changed the title fix: bb outage ben fix: bb outages Jul 21, 2026
## Checklist

Please check if the PR fulfills these requirements:

- [ ] PR Title follows conventional commit messages
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ] All commits in this PR are DCO signed-off (see CONTRIBUTING.md)

## Does this PR already have an issue describing the problem?

Fixes #

## What is the new behavior (if this is a feature change)?

<!-- Describe the new behavior and the motivation/context for the
change. -->

## Does this PR introduce a breaking change?

- [ ] Yes
- [ ] No

---------

Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
@BenjPetr
BenjPetr force-pushed the fix/bb_outage_ben branch from 5b459c9 to f46e3d1 Compare July 21, 2026 08:24
BenjPetr added 8 commits July 21, 2026 11:28
… rebalance power in create_complex_grid_battery_hvdc_svc_3w_trafo()

Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
…_trafos

Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
…s_breaker_bus_id() has been replaced by test_get_bus_contingency_expansions_uses_busbar_propagation_map_on_complex_grid()

Signed-off-by: Benjamin Petrick <170433522+BenjPetr@users.noreply.github.com>
@sonarqube-mccs

Copy link
Copy Markdown

@LeonHilf LeonHilf left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@BenjPetr
BenjPetr merged commit 81860cf into main Jul 23, 2026
22 checks passed
@BenjPetr
BenjPetr deleted the fix/bb_outage_ben branch July 23, 2026 06:05
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.

3 participants