Skip to content

Commit ff57cbd

Browse files
Fix SA Exception not same number of equations and variables (#1321)
Signed-off-by: Damien Jeandemange <[email protected]> Co-authored-by: PRABAKARAN Sylvestre <[email protected]>
1 parent d6d38ce commit ff57cbd

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

src/main/java/com/powsybl/openloadflow/equations/EquationSystemIndex.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,11 @@ public void onEquationArrayChange(EquationArray<V, E> equationArray, int element
326326
addVariables(variables);
327327
}
328328
}
329-
for (var singleTerm : equationArray.getSingleEquationTerms(elementNum)) {
330-
if (singleTerm.isActive()) {
331-
List<Variable<V>> variables = singleTerm.getVariables();
332-
addVariables(variables);
333-
}
329+
}
330+
for (var singleTerm : equationArray.getSingleEquationTerms(elementNum)) {
331+
if (singleTerm.isActive()) {
332+
List<Variable<V>> variables = singleTerm.getVariables();
333+
addVariables(variables);
334334
}
335335
}
336336
equationsIndexValid = false;

src/test/java/com/powsybl/openloadflow/network/VoltageControlNetworkFactory.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,4 +1523,23 @@ public static Network createFourBusNetworkWithSharedVoltageControl() {
15231523
.setTargetV(1.2);
15241524
return network;
15251525
}
1526+
1527+
public static Network createThreeBuses() {
1528+
Network network = Network.create("three-buses", "code");
1529+
1530+
Bus b1 = createBus(network, "B1", 400.);
1531+
Bus b2 = createBus(network, "B2", 400.);
1532+
Bus b3 = createBus(network, "B3", 400.);
1533+
createGenerator(b1, "GEN1", 150., 400.);
1534+
createGenerator(b3, "GEN3", 150., 400.)
1535+
.newMinMaxReactiveLimits().setMinQ(-1).setMaxQ(1).add();
1536+
createLoad(b1, "LOAD1", 100., 30.);
1537+
createLoad(b2, "LOAD2", 100., 30.);
1538+
createLoad(b3, "LOAD3", 100., 30.);
1539+
createFixedShuntCompensator(b3, "SC3", 1e-8, 1e-5);
1540+
createLine(network, b1, b2, "l12", 3.00);
1541+
createLine(network, b2, b3, "l23", 3.00);
1542+
1543+
return network;
1544+
}
15261545
}

src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4737,4 +4737,18 @@ void testDoubleBus() {
47374737
});
47384738

47394739
}
4740+
4741+
@Test
4742+
void testContingencyDisconnectingPqBlockedBus() {
4743+
Network network = VoltageControlNetworkFactory.createThreeBuses();
4744+
4745+
// Contingency disconnects/isolates B3 with 1 load, 1 gen blocked PQ, and one fixed shunt.
4746+
List<Contingency> contingencies = List.of(new Contingency("l23", new LineContingency("l23")));
4747+
4748+
List<StateMonitor> monitors = List.of(new StateMonitor(ContingencyContext.all(), Set.of("l12"), Collections.emptySet(), Collections.emptySet()));
4749+
4750+
SecurityAnalysisResult result = assertDoesNotThrow(() -> runSecurityAnalysis(network, contingencies, monitors));
4751+
assertEquals(50., result.getPreContingencyResult().getNetworkResult().getBranchResult("l12").getP1(), DELTA_POWER);
4752+
assertEquals(100., result.getPostContingencyResults().getFirst().getNetworkResult().getBranchResult("l12").getP1(), DELTA_POWER);
4753+
}
47404754
}

0 commit comments

Comments
 (0)