Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion docs/security-analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Each example follows a brief and straightforward workflow, using input data that
Network + contingency --> Security Analysis
Network + contingency + operators strategy --> Security Analysis
Network + contingency + limit reduction --> Security Analysis
Network + contingency + state monitor --> Security Analysis
```


Expand All @@ -27,7 +28,7 @@ Loading the network is a common step for all workflows. Then:
1. Define a contingency and run the security analysis.
2. Add operator strategies and reference the associated actions.
3. Configure limit reduction parameters.

4. Add state monitor parameters.

### Import the network from an XML IIDM file

Expand Down Expand Up @@ -156,4 +157,39 @@ Post contingency results
Violation Value: 1008.9287882269946 MW/°
Violation Limit: 460.0 MW/°
Operator strategy results
````

### Create a state Monitor

A state Monitor provides information about the state of elements of the network such as branch, bus and three-winding transformers

As an example, we are going to add state monitor parameter, we will add branch and voltage levels ids that we want information about.

```java

Contingency contingency = Contingency.line("NHV1_NHV2_2");
SecurityAnalysisRunParameters parameters = new SecurityAnalysisRunParameters();
// State Monitor
StateMonitor stateMonitor = new StateMonitor(new ContingencyContext(contingency.getId(), SPECIFIC),
Set.of("NHV1_NHV2_1"), // <= branch id
Set.of("VLGEN", "VLHV1", "VLHV2", "VLLOAD"), // <= Voltage Levels id
Set.of());
parameters.addMonitor(stateMonitor);

// Run security analysis
SecurityAnalysis.run(network, List.of(contingency), parameters);
```

Here are the corresponding prints in the tutorial:
````
:: SecurityAnalysis :: network, contingency and state Monitor
Pre contingency results
Post contingency results
Contingency : NHV1_NHV2_2
branchResult: BranchResult{branchId='NHV1_NHV2_1', p1=610.56215354332, q1=334.0562715296571, i1=1008.9287882269946, p2=-600.9961559564288, q2=-285.3791465506596, i2=1047.8257691455576, flowTransfer=NaN}
busResult: BusResults{voltageLevelId='VLGEN', busId='NGEN', v=24.5, angle=2.3579552596552684}
busResult: BusResults{voltageLevelId='VLHV1', busId='NHV1', v=398.26472467308224, angle=0.0}
busResult: BusResults{voltageLevelId='VLHV2', busId='NHV2', v=366.58481145130054, angle=-7.499211315976122}
busResult: BusResults{voltageLevelId='VLLOAD', busId='NLOAD', v=137.74213838955504, angle=-14.464666247602445}
Operator strategy results
````
1 change: 1 addition & 0 deletions security-analysis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ This tutorial aims to compute security analysis on a network, loading a network
- [x] Make a contingency on a line and compute a security analysis.
- [x] Add operator strategies which contains references for actions
- [x] Add limit reduction parameters
- [x] Add state monitor parameters

The complete tutorial is described in the [security analysis](https://powsybl.readthedocs.io/projects/powsybl-tutorials/en/latest/security-analysis.html) powsybl-tutorials documentation.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
import com.powsybl.security.SecurityAnalysisRunParameters;
import com.powsybl.security.condition.TrueCondition;
import com.powsybl.security.limitreduction.LimitReduction;
import com.powsybl.security.monitor.StateMonitor;
import com.powsybl.security.strategy.ConditionalActions;
import com.powsybl.security.strategy.OperatorStrategy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Set;

import static com.powsybl.contingency.ContingencyContextType.SPECIFIC;

/**
* @author Samir Romdhani {@literal <samir.romdhani_externe at rte-france.com>}
Expand All @@ -39,6 +43,8 @@ public static void main(String[] args) {
log(runSecurityAnalysisWithOperatorStrategyAndActions());
// Network, Contingency, and Limit Reductions
log(runSecurityAnalysisWithLimitReduction());
// Network, Contingency, and State Monitor
log(runSecurityAnalysisWithStateMonitor());
}

public static SecurityAnalysisResult runSecurityAnalysisWithContingency() {
Expand Down Expand Up @@ -109,13 +115,33 @@ public static SecurityAnalysisResult runSecurityAnalysisWithLimitReduction() {
return SecurityAnalysis.run(network, List.of(contingency), parameters).getResult();
}

public static SecurityAnalysisResult runSecurityAnalysisWithStateMonitor() {
Network network = Network.read("network.xml", SecurityAnalysisTutorials.class.getResourceAsStream("/network.xiidm"));
LOGGER.info(":: SecurityAnalysis :: network, contingency and state Monitor");
Contingency contingency = Contingency.line("NHV1_NHV2_2");
SecurityAnalysisRunParameters parameters = new SecurityAnalysisRunParameters();
StateMonitor stateMonitor = new StateMonitor(new ContingencyContext(contingency.getId(), SPECIFIC),
Set.of("NHV1_NHV2_1"), // <= branch id
Set.of("VLGEN", "VLHV1", "VLHV2", "VLLOAD"), // <= Voltage Levels id
Set.of());
parameters.addMonitor(stateMonitor);
return SecurityAnalysis.run(network, List.of(contingency), parameters).getResult();
}

private static void log(SecurityAnalysisResult result) {
LOGGER.info("\t Pre contingency results");
result.getPreContingencyLimitViolationsResult().getLimitViolations()
.forEach(value -> {
LOGGER.info("\t\t Value: {} MW/°", value.getValue());
LOGGER.info("\t\t Limit: {} MW/°", value.getLimit());
result.getPreContingencyResult().getLimitViolationsResult().getLimitViolations()
.forEach(limitViolation -> {
LOGGER.info("\t\t Value: {} MW/°", limitViolation.getValue());
LOGGER.info("\t\t Limit: {} MW/°", limitViolation.getLimit());
});
result.getPreContingencyResult().getNetworkResult().getBranchResults()
.forEach(branchResult -> LOGGER.info("\t\t branchResult: {}", branchResult.toString()));
result.getPreContingencyResult().getNetworkResult().getBusResults()
.forEach(busResult -> LOGGER.info("\t\t busResult: {}", busResult.toString()));
result.getPreContingencyResult().getNetworkResult().getThreeWindingsTransformerResults()
.forEach(transformerResult -> LOGGER.info("\t\t TWT Result: {}", transformerResult.toString()));

LOGGER.info("\t Post contingency results");
result.getPostContingencyResults().forEach(postContingencyResult -> {
LOGGER.info("\t\t Contingency : {}", postContingencyResult.getContingency().getId());
Expand All @@ -124,7 +150,14 @@ private static void log(SecurityAnalysisResult result) {
LOGGER.info("\t\t\t Violation Value: {} MW/°", value.getValue());
LOGGER.info("\t\t\t Violation Limit: {} MW/°", value.getLimit());
});
postContingencyResult.getNetworkResult().getBranchResults()
.forEach(branchResult -> LOGGER.info("\t\t branchResult: {}", branchResult.toString()));
postContingencyResult.getNetworkResult().getBusResults()
.forEach(busResult -> LOGGER.info("\t\t busResult: {}", busResult.toString()));
postContingencyResult.getNetworkResult().getThreeWindingsTransformerResults()
.forEach(transformerResult -> LOGGER.info("\t\t TWT Result: {}", transformerResult.toString()));
});

LOGGER.info("\t Operator strategy results");
result.getOperatorStrategyResults().forEach(operatorStrategyResult -> {
LOGGER.info("\t\t OperatorStrategy : {}", operatorStrategyResult.getOperatorStrategy().getId());
Expand All @@ -133,6 +166,12 @@ private static void log(SecurityAnalysisResult result) {
LOGGER.info("\t\t\t Violation Value: {} MW/°", value.getValue());
LOGGER.info("\t\t\t Violation Limit: {} MW/°", value.getLimit());
});
operatorStrategyResult.getNetworkResult().getBranchResults()
.forEach(branchResult -> LOGGER.info("\t\t branchResult: {}", branchResult.toString()));
operatorStrategyResult.getNetworkResult().getBusResults()
.forEach(busResult -> LOGGER.info("\t\t busResult: {}", busResult.toString()));
operatorStrategyResult.getNetworkResult().getThreeWindingsTransformerResults()
.forEach(transformerResult -> LOGGER.info("\t\t TWT Result: {}", transformerResult.toString()));
});
}
}