Repository navigation
feat: take N-1 element names from the grid during input N-1 validation - #889
Merged
Merged
Conversation
When validating the input N-1 definition against the grid, the name of every monitored and contingency element is overwritten by the grid element's name (UCTE elementName if set, else the Powsybl name). Elements without a grid name keep their input name. Each change is logged as nminus1_element_name_corrected. Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Loop over the N-1 element types and read each with network.get_elements instead of listing one getter per element type. The name check now runs before the unchanged type/kind correction. Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
GridElementType now lives next to GridElement in nminus1_definition and types the element-type keys of the input N-1 definition validation. power_factory_data_class imports it from there, so existing imports keep working. Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Iterate over GridElementType instead of the keys of KIND_BY_ELEMENT_TYPE when reading names, and parametrize the name test over a UCTE and a CGMES grid. Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the standalone validator’s grid-name alignment changes.
No open issues 🎉
What changed in this PR
Updates the standalone input N-1 validator introduced in #722 to align monitored and contingency element names with the grid. This does not wire the validator into the production import pipeline.
Changes:
- Prefer UCTE
elementName, then Powsyblname; preserve input names when neither is available and log corrections. - Centralize
GridElementTypein the shared interfaces package. - Add name-alignment tests and document the fallback behavior.
| File | Description |
|---|---|
packages/interfaces_pkg/src/toop_engine_interfaces/nminus1_definition.py |
Defines the shared GridElementType alias. |
packages/importer_pkg/tests/pypowsybl_import/test_nminus1_definition_input.py |
Tests UCTE and CGMES names, correction logging, and unnamed-grid fallback. |
packages/importer_pkg/src/toop_engine_importer/pypowsybl_import/contingency_from_file/nminus1_definition_input.py |
Retrieves grid names and applies them during N-1 validation. |
packages/importer_pkg/src/toop_engine_importer/contingency_from_power_factory/power_factory_data_class.py |
Reuses the shared element-type alias. |
docs/importer/pypowsybl/index.md |
Documents name precedence and preservation of input names. |
Review effort: Balanced
|
5 of 6 tasks
spetznick-elia
added a commit
that referenced
this pull request
Nov 6, 2026
…#891) ## Checklist Please check if the PR fulfills these requirements: - [x] PR Title follows conventional commit messages - [x] Tests for the changes have been added (for bug fixes / features) - [x] Docs have been added / updated (for bug fixes / features) - [x] 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 - [x] No --------- Signed-off-by: Sascha Petznick <229719644+spetznick-elia@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Checklist
Please check if the PR fulfills these requirements:
Does this PR already have an issue describing the problem?
No linked issue. Follow-up to #722, which added grid validation of the input N-1 definition.
What is the new behavior and why?
The importer validates an input N-1 definition against the grid file. Until now, that validation corrected the type and kind of each element from the grid, matched by id, but kept the element name from the input file. Monitored and contingency elements could then carry stale or missing names that do not match the grid they refer to.
Now the grid also decides the name. Each monitored element and contingency element takes the name of the grid element with the same id:
elementNameif it is set, because UCTE grids leave the Powsyblnameempty;name;Each overwritten name is logged as a warning (
nminus1_element_name_corrected) with the input and the grid name, in the same way as type corrections. Element ids and every other part of the definition stay as they are.Open point: in UCTE grids, tie lines fall back to the Powsybl
name(both half-line ids joined with+). The new name is not built from their per-sideelementName_1andelementName_2values.Does this PR introduce a breaking change?