Skip to content

fix: non controllable psts diverging loadflows#619

Open
LeonHilf wants to merge 6 commits into
mainfrom
fix/loadflow_mismatch_pst_noncontrollable
Open

fix: non controllable psts diverging loadflows#619
LeonHilf wants to merge 6 commits into
mainfrom
fix/loadflow_mismatch_pst_noncontrollable

Conversation

@LeonHilf

@LeonHilf LeonHilf commented Jul 9, 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 psts being excluded from the preprocessing if they are outside the control area leading to a loadflow mismatch since they are not considered in the PSDF.

Updated the complex grid to have the DE region connected with another PST and a load. New unconnected region FR. This way we have more diversity in branches being outside and inside the zones

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

Does this PR introduce a breaking change?

  • Yes
  • No

LeonHilf added 3 commits July 9, 2026 12:47
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
@LeonHilf LeonHilf marked this pull request as ready for review July 9, 2026 13:41

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 updates the preprocessing + backend masking around PST controllability to prevent running optimization/loadflows on PSTs that should not be controlled, and refreshes the example/test grids to include additional PST scenarios (including isolated islands).

Changes:

  • Replace the previous PST-related mask outputs (trafo_pst_linear, trafo_has_pst_tap, pst_group_labels) with a single trafo_controllable mask and propagate it through backends.
  • Move/refresh parallel-PST grouping logic into the DC-solver Powsybl preprocessing helpers (used to populate pst_group on the trafo dataframe).
  • Expand the complex Powsybl example grid with additional substations/voltage-levels/PSTs and adjust affected tests/fixtures.

Reviewed changes

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

Show a summary per file
File Description
packages/topology_optimizer_pkg/tests/test_ac_dc_integration.py Updates complex-grid fixture setup to match new PST configuration/flags.
packages/topology_optimizer_pkg/tests/conftest.py Updates fixture grid initialization to pass the updated linear_pst flag shape.
packages/interfaces_pkg/src/toop_engine_interfaces/folder_structure.py Adds trafo_controllable mask filename and removes deprecated PST mask filenames.
packages/importer_pkg/tests/pypowsybl_import/test_powsybl_masks.py Updates mask expectations and removes tests for removed PST grouping outputs.
packages/importer_pkg/tests/network_graph/test_powsybl_station_to_graph.py Updates expected relevant voltage-level IDs due to expanded complex grid topology.
packages/importer_pkg/src/toop_engine_importer/pypowsybl_import/powsybl_masks.py Replaces PST mask outputs with trafo_controllable in the importer’s mask dataclass + update logic.
packages/grid_helpers_pkg/src/toop_engine_grid_helpers/powsybl/example_grids.py Extends complex example grid (DE/FR stations, internal PSTs, extra lines/loads) and adjusts linear_pst default handling.
packages/dc_solver_pkg/tests/preprocessing/test_powsybl_helpers.py Adds unit tests for PST grouping helpers moved into DC-solver preprocessing.
packages/dc_solver_pkg/tests/conftest.py Updates complex-grid preprocessing fixtures to the new linear_pst vector length.
packages/dc_solver_pkg/src/toop_engine_dc_solver/preprocess/powsybl/powsybl_helpers.py Adds PST parallel-group labeling based on step-table equivalence and exposes helper functions.
packages/dc_solver_pkg/src/toop_engine_dc_solver/preprocess/powsybl/powsybl_backend.py Switches controllable-PST selection to use the new controllability mask (but currently has a column mismatch bug).
packages/dc_solver_pkg/src/toop_engine_dc_solver/preprocess/pandapower/pandapower_backend.py Updates Pandapower backend to load trafo_controllable instead of the removed mask name.
packages/dc_solver_pkg/src/toop_engine_dc_solver/example_grids.py Updates saved mask files to trafo_controllable and adjusts complex-grid preprocessing parameters.

Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
@BenjPetr

Copy link
Copy Markdown
Collaborator

works for me, documentation needs to be adjusted

LeonHilf and others added 2 commits July 10, 2026 11:20
Signed-off-by: Leonard Hilfrich <Leonard.Hilfrich@50Hertz.com>
…n the dc-solver

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

Copy link
Copy Markdown

if not allclose(n_0, n_0_solver):
error = np.abs(n_0 - n_0_solver)
messages.append(f"N-0 does not match, mean error: {error.mean()}, max error: {error.max()}")
raise AssertionError(f"N-0 does not match, mean error: {error.mean()}, max error: {error.max()}")

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.

Why do we raise in all cases now? Should we introduce the logger to this file and log the error?

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.

4 participants