Skip to content

fix: name input N-1 elements and single outages as the DC solver does - #891

Merged
spetznick-elia merged 4 commits into
mainfrom
fix/nminus1-dc-solver-names
Nov 6, 2026
Merged

spetznick-elia merged 4 commits into
mainfrom
fix/nminus1-dc-solver-names

Conversation

@spetznick-elia

@spetznick-elia spetznick-elia commented Nov 6, 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?

No linked issue. Follow-up to #889.

What is the new behavior and why?

The N-1 definition that the DC solver preprocessing builds and the input N-1 definition that the importer validates named the same UCTE elements differently:

  • The DC solver names a UCTE line or transformer <id>: <elementName>, and a single-outage contingency of it the same way.
  • The importer used the bare elementName for the element and kept the contingency name of the input file. That name follows a business naming scheme, with underscores between shortened node names and a type suffix such as :line or :trf.

The importer now uses the DC solver's naming:

  • UCTE lines and two-winding transformers are named <id>: <elementName>, and UCTE tie lines by their id. Other UCTE elements keep their elementName, and CGMES elements their Powsybl name.
  • A contingency that the DC solver outages as a single element takes that element's grid name. That is a contingency with exactly one line, two-winding transformer or tie line connected at both sides, or with no such branch and exactly one injection; isolating switches do not count. A contingency with a three-winding transformer is never a single outage, because the transformer becomes three DC branches. Multi-outages, and contingencies whose element has no name in the grid, keep their input name.
  • Each renamed contingency is logged as nminus1_contingency_name_corrected.

Known difference: for pure UCTE grids, the DC solver's get_lines joins id and elementName without the ": " separator (<id><elementName>), unlike its transformers and its UCTE/CGMES-merged ("hybrid") grids. The importer always uses ": ", which matches the DC solver's transformers and hybrid grids.

Does this PR introduce a breaking change?

  • Yes, because
  • No

UCTE lines and transformers are now named '<id>: <elementName>' and UCTE
tie lines by their id, matching the branch names of the DC solver
preprocessing. Contingencies that the DC solver outages as a single
element take that element's grid name instead of the input name, so names
such as 'D4EICH2_D4GURT2_EICRTGUR:line' no longer reach the saved N-1
definition.

Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Move the per-source-format naming of lines, transformers and tie lines
from the DC solver preprocessing into get_branch_names in grid_helpers,
together with get_cgmes_ids. The DC solver and, for UCTE, CGMES and
hybrid grids, the input N-1 validation of the importer both use it.

Pure UCTE lines are now named '<id>: <elementName>' in the DC solver as
well, like its transformers and hybrid grids; before, the separator was
missing. get_cgmes_ids no longer raises an AttributeError when a merged
grid has several CGMES sub-networks.

Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
…dation"

This reverts commit f84b97a.

Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
@spetznick-elia
spetznick-elia marked this pull request as ready for review November 6, 2026 12:21
Copilot AI balanced review requested due to automatic review settings November 6, 2026 12:21

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.

🟡 Changes recommended

Contingency renaming can assign incorrect single-outage names because it counts branches excluded by the DC backend and ignores unconverted three-winding transformers.

2 open issues
What changed in this PR

This follow-up to #889 aligns importer N-1 element and single-outage contingency names more closely with DC solver preprocessing.

Changes:

  • Formats UCTE branch names using IDs and grid names, with tie lines named by ID.
  • Renames detected single-outage contingencies and logs name corrections.
  • Updates regression tests and importer documentation.
File Description
packages/​importer_pkg/​tests/​pypowsybl_import/​test_nminus1_definition_input.py Tests grid-derived names, correction logs, and multi-outage name preservation.
packages/​importer_pkg/​src/​toop_engine_importer/​pypowsybl_import/​contingency_from_file/​nminus1_definition_input.py Adds DC-style element naming and single-outage contingency renaming.
docs/​importer/​pypowsybl/​index.md Documents the updated naming behavior.

Review effort: Balanced

A contingency with a three-winding transformer is never a DC single
outage, because the transformer becomes three DC branches, so it keeps
its input name. Branches that are not connected at both sides do not
count as DC branches, as in the DC solver's projection of contingencies.

Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
@sonarqube-mccs

sonarqube-mccs Bot commented Nov 6, 2026

Copy link
Copy Markdown

@spetznick-elia
spetznick-elia merged commit 33d836e into main Nov 6, 2026
21 checks passed
@spetznick-elia
spetznick-elia deleted the fix/nminus1-dc-solver-names branch November 6, 2026 13:09
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