Skip to content

Mixed security analysis#3871

Open
RiadBRD wants to merge 3 commits intomainfrom
mixed_security_analysis
Open

Mixed security analysis#3871
RiadBRD wants to merge 3 commits intomainfrom
mixed_security_analysis

Conversation

@RiadBRD
Copy link
Copy Markdown
Collaborator

@RiadBRD RiadBRD commented Apr 13, 2026

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

What is the new behavior (if this is a feature change)?
This PR introduces a new Mixed-Mode Security Analysis feature. It adds a new SecurityAnalysisProvider that orchestrates a two-pass workflow:

1.Static Analysis : It first runs a fast, static analysis (e.g., using OpenLoadFlow) on all specified contingencies.

2.Criteria Evaluation : It then evaluates the results of the static pass against a configurable set of criteria (e.g.,NOT_CONVERGED, SPS_TRIGGERED, LIMIT_VIOLATIONS).

3.Dynamic Analysis Pass : For any contingencies that meet the switch criteria, it automatically triggers a more detailed dynamic analysis (e.g., using DynaFlow).

4.Result Merging : Finally, it merges the results from both passes, prioritizing the results from the dynamic analysis for any contingencies that were re-analyzed.

This allows for a more efficient and targeted security analysis, where computationally expensive dynamic simulations are only used when necessary.

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

  • Yes
  • No

Riad Benradi added 2 commits April 13, 2026 07:45
Adds a new provider that orchestrates a two-pass security analysis.

It first runs a static analysis on all contingencies. Based on configurable criteria (e.g., `NOT_CONVERGED`, `SPS_TRIGGERED`), it can then run a dynamic analysis on a subset of contingencies that require further investigation.

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>
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@RiadBRD RiadBRD requested a review from geofjamg April 13, 2026 07:45
*
* @author Riad Benradi {@literal <riad.benradi at rte-france.com>}
*/
public class MixedSecurityAnalysis {
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.

HybridSecurityAnalysis would be better

MixedModeParametersExtension ext = new MixedModeParametersExtension();

// Default values — used if the key is absent from the config file
ext.setStaticSimulator("load-flow");
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.

Maybe not a good idea to have a default value, as in powsybl core we don't know anything about OLF and DynaFlow


// Override with values from config file if the section exists
// Reads from a YAML block named "mixed-mode-analysis"
config.getOptionalModuleConfig(MixedModeParametersExtension.NAME).ifPresent(module -> {
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.

What are you doing here, you set to the extension what you read in the extension???

// Default values — used if the key is absent from the config file
ext.setStaticSimulator("load-flow");
ext.setDynamicSimulator("dynaflow");
ext.setSwitchCriteria(List.of("NOT_CONVERGED"));
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.

Use a Constant from the criteria class


/** @return the provider version */
@Override
public String getVersion() {
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.

We would expect here either:

  • the core version ?
  • the version of found simulators ?

* @author Riad Benradi {@literal <riad.benradi at rte-france.com>}
*/

public class AnalysisSwitchCriteria {
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.

My advice here: before trying to create an abstraction on static / dynamic simulation contingency selection, try to code it simple and make it working with a simple processing: from static analysis, get contingencies from which an automaton has been triggered or a divergence and the re-run the dynamic one. It could be coded in a very simple way.

/**
* The name of the static simulator to use for the first pass.
*/
private String staticSimulator;
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.

The right term for a SecurityAnalysis is provider so here you need the name of the static security analysis provider and the name of the dynamic security analysis provider.

/**
* The name of the dynamic simulator to use for the second pass (for complex cases).
*/
private String dynamicSimulator;
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.

Maybe also another question from myself: could dynamic term here be a little bit confusing as we also have a DynamicSecurityAnalysis API (impl for dynawaltz)? But here we a looking for the classical implementation of SecurityAnalysis but implemented by DynaFlow which is is also a dynamic simulator... this is very confusing.

<groupId>com.powsybl</groupId>
<artifactId>powsybl-security-analysis-api</artifactId>
</dependency>
<dependency>
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.

You are creating a cycling dependency! We cannot have a dependency on OLF in powsybl core

FAILED,
NO_IMPACT
NO_IMPACT,
SPS_TRIGGERED
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.

There is probably something to do like this, but for me it should be done in another PR before with everything regarding upgrading the security analysis result API to store automation systems triggering.

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