Skip to content

Track phase shifter tap movements in security analysis results - #4066

Open
RiadBRD wants to merge 4 commits into
mainfrom
phase-shifter-results
Open

Track phase shifter tap movements in security analysis results#4066
RiadBRD wants to merge 4 commits into
mainfrom
phase-shifter-results

Conversation

@RiadBRD

@RiadBRD RiadBRD commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • A PR or issue has been opened in all impacted repositories (if any)

What kind of change does this PR introduce?
Feature

Add phase shifter tap position tracking to security analysis results. Both PreContingencyResult and PostContingencyResult now include a map of all phase shifters that were optimized (moved) during the loadflow calculation, capturing their initial and final tap positions.

What is the current behavior?
Phase shifter tap adjustments made during security analysis loadflow computations are not preserved or accessible in the results. Users cannot track which phase shifters were moved or their tap position changes.

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

After a security analysis loadflow, users can now retrieve phase shifter movements via:

  • getPhaseShifterResults() - returns a map of all moved phase shifters keyed by transformer ID
  • getPhaseShifterResult(String transformerId) - retrieves specific phase shifter movement

Each MovedPhaseShifterResult contains:

  • transformerId: The phase shifter identifier
  • initialTap: Tap position before
  • newTap: Tap position after

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

The PostContingencyResult constructor signature changed from 6 to 7 parameters, adding a required phaseShifterResults map as the last parameter. All direct instantiations must pass this parameter; use Collections.emptyMap() when no phase shifter data is available.

The PreContingencyResult maintains backward compatibility via constructor overloading. Existing 4-parameter calls continue to work, but to pass phase shifter data, you must use the new 5-parameter constructor.

JSON deserialization of existing results remains compatible with the new phaseShifterResults field, which is treated as optional and defaults to an empty map.

Applications can now access phase shifter movements through the new getPhaseShifterResults() and getPhaseShifterResult(String) methods on both result classes.

…ingencyResult

  * Add MovedPhaseShifterResult record (transformerId, initialTap, newTap)
  * Add Map<String, MovedPhaseShifterResult> phaseShifterResults to PreContingencyResult and PostContingencyResult
  * Update JSON serialization to handle the new field (only written when non-empty)
  * Update JSON deserialization with version guard (>= 2.0) and empty default for backward compatibility
  * Bump SecurityAnalysisResult version from 1.9 to 2.0
  * Update all call sites to pass Collections.emptyMap() when no phase shifter results
  * Add tests for non-empty phase shifter results

  Signed-off-by: Riad Benradi <riad.benradi_externe@rte-france.com>

Signed-off-by: Riad Benradi <riad.benradi_externe@rte-france.com>
Signed-off-by: Riad Benradi <riad.benradi_externe@rte-france.com>

@olperr1 olperr1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, can you improve the test coverage?
For instance, you have created a single (de)serialization test with tap movements in the results.

Riad Benradi added 2 commits August 31, 2026 14:04
…PreContingencyResult` and `PostContingencyResult`.

- Bump `SecurityAnalysisResult` JSON version to `1.10`, with the `phaseShifterResults` tag gated on `>= 1.10`.
- Share JSON read/write helpers in the new `PhaseShifterResultSerializer` utility.
- Sort serialized entries by `transformerId` for deterministic output.
- Guard constructors against null or empty maps by defaulting to `Collections.emptyMap()`.
- Update the JSON fixture with the new version and `violationLocation`.

Signed-off-by: Riad Benradi <riad.benradi_externe@rte-france.com>
Signed-off-by: Riad Benradi <riad.benradi_externe@rte-france.com>
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants