Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miss contingency status in DC sensitivity analysis #610

Merged
merged 2 commits into from
Sep 26, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ private static Set<ComputedContingencyElement> getGroupOfElementsBreakingConnect

private static List<ConnectivityAnalysisResult> computeConnectivityData(LfNetwork lfNetwork, SensitivityFactorHolder<DcVariableType, DcEquationType> factorHolder,
Map<Set<ComputedContingencyElement>, List<PropagatedContingency>> contingenciesByGroupOfElementsBreakingConnectivity,
List<PropagatedContingency> nonLosingConnectivityContingencies) {
List<PropagatedContingency> nonLosingConnectivityContingencies, SensitivityResultWriter resultWriter) {
if (contingenciesByGroupOfElementsBreakingConnectivity.isEmpty()) {
return Collections.emptyList();
}
Expand Down Expand Up @@ -606,6 +606,11 @@ private static List<ConnectivityAnalysisResult> computeConnectivityData(LfNetwor
List<LfSensitivityFactor<DcVariableType, DcEquationType>> lfFactors = factorHolder.getFactorsForContingencies(contingenciesIds);
if (!lfFactors.isEmpty()) {
connectivityAnalysisResults.computeIfAbsent(breakingConnectivityElements, branches -> new ConnectivityAnalysisResult(lfFactors, branches, connectivity, lfNetwork)).getContingencies().addAll(contingencyList);
} else {
// write contingency status
for (PropagatedContingency propagatedContingency : contingencyList) {
resultWriter.writeContingencyStatus(propagatedContingency.getIndex(), SensitivityAnalysisResult.Status.SUCCESS);
}
}
}
connectivity.undoTemporaryChanges();
Expand Down Expand Up @@ -931,7 +936,7 @@ public void analyse(Network network, List<PropagatedContingency> contingencies,
// this second method process all contingencies that potentially break connectivity and using graph algorithms
// find remaining contingencies that do not break connectivity
List<ConnectivityAnalysisResult> connectivityAnalysisResults
= computeConnectivityData(lfNetwork, validFactorHolder, contingenciesByGroupOfElementsPotentiallyBreakingConnectivity, nonBreakingConnectivityContingencies);
= computeConnectivityData(lfNetwork, validFactorHolder, contingenciesByGroupOfElementsPotentiallyBreakingConnectivity, nonBreakingConnectivityContingencies, resultWriter);
LOGGER.info("After graph based connectivity analysis, {} contingencies do not break connectivity, {} contingencies break connectivity",
nonBreakingConnectivityContingencies.size(), connectivityAnalysisResults.stream().mapToInt(results -> results.getContingencies().size()).count());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2122,4 +2122,22 @@ void testSwitchContingency() {
assertEquals(300.0, result.getBranchFlow1FunctionReferenceValue("L1"), LoadFlowAssert.DELTA_POWER);
assertEquals(-3.770, result.getBranchFlow1FunctionReferenceValue("C", "L1"), LoadFlowAssert.DELTA_POWER);
}

@Test
void testFunctionDisconnectedBranchBothSidesWithContingency() {
Network network = ConnectedComponentNetworkFactory.createTwoCcLinkedByTwoLines();
Line l45 = network.getLine("l45");
l45.getTerminal1().disconnect();
l45.getTerminal2().disconnect();
runDcLf(network);

SensitivityAnalysisParameters sensiParameters = createParameters(true, "b1_vl_0", true);
sensiParameters.getLoadFlowParameters().setBalanceType(LoadFlowParameters.BalanceType.PROPORTIONAL_TO_LOAD);

List<SensitivityFactor> factors = List.of(createBranchFlowPerInjectionIncrease("l45", "g2"));
List<Contingency> contingencies = List.of(new Contingency("C", List.of(new BranchContingency("l24"), new BranchContingency("l35"))));

SensitivityAnalysisResult result = sensiRunner.run(network, factors, contingencies, Collections.emptyList(), sensiParameters);
assertEquals(SensitivityAnalysisResult.Status.SUCCESS, result.getContingencyStatus("C"));
}
}