From 4a2c2b6f2656e2faefceb9ef25560cf90ebfdd5c Mon Sep 17 00:00:00 2001 From: Anne Tilloy Date: Wed, 19 Apr 2023 12:49:24 +0200 Subject: [PATCH 1/4] Add unit test and fix. Signed-off-by: Anne Tilloy --- .../ac/equations/AcEquationSystemCreator.java | 2 +- .../network/VoltageControlNetworkFactory.java | 18 ++++++++++++++++++ .../sa/OpenSecurityAnalysisTest.java | 13 +++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java b/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java index c04748e7cb..ca7ca58905 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java @@ -224,7 +224,7 @@ static void updateRemoteVoltageControlEquations(VoltageCon .setActive(false); equationSystem.getEquation(controllerElement.getNum(), ctrlEqType) .orElseThrow() - .setActive(false); + .setActive(!controllerElement.isDisabled()); } } else { if (voltageControl.isHidden()) { diff --git a/src/test/java/com/powsybl/openloadflow/network/VoltageControlNetworkFactory.java b/src/test/java/com/powsybl/openloadflow/network/VoltageControlNetworkFactory.java index 5e0ff0799d..497698999f 100644 --- a/src/test/java/com/powsybl/openloadflow/network/VoltageControlNetworkFactory.java +++ b/src/test/java/com/powsybl/openloadflow/network/VoltageControlNetworkFactory.java @@ -981,4 +981,22 @@ public static Network createWithStaticVarCompensator() { .add(); return network; } + + public static Network createWithSimpleRemoteControl() { + Network network = Network.create("remoteControl", "code"); + Bus b1 = createBus(network, "b1"); + Bus b2 = createBus(network, "b2"); + Bus b3 = createBus(network, "b3"); + Bus b4 = createBus(network, "b4"); + createGenerator(b2, "g2", 2, 1); + createGenerator(b3, "g3", 2, 1); + createGenerator(b4, "g4", 2, 1); + createLoad(b3, "l3", 5, 1); + createLoad(b1, "l1", 1, 1); + createLine(network, b1, b2, "l12", 0.0); + createLine(network, b2, b4, "l24", 0.01); + createLine(network, b4, b3, "l43", 0.01); + createLine(network, b3, b1, "l31", 0.0); + return network; + } } diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java index c43ccccbfd..a3877c1e22 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java @@ -1850,4 +1850,17 @@ void testLoadContingencyNoImpact() { result = runSecurityAnalysis(network, contingencies); assertEquals(2, result.getPostContingencyResults().size()); } + + @Test + void testWithVoltageRemoteControl() { + Network network = VoltageControlNetworkFactory.createWithSimpleRemoteControl(); + network.getGenerator("g4").setRegulatingTerminal(network.getLoad("l1").getTerminal()); // remote control. + List contingencies = List.of(new Contingency("contingency", + List.of(new BranchContingency("l12"), new BranchContingency("l31")))); + LoadFlowParameters lfParameters = new LoadFlowParameters(); + setSlackBusId(lfParameters, "b4_vl"); + SecurityAnalysisParameters securityAnalysisParameters = new SecurityAnalysisParameters(); + securityAnalysisParameters.setLoadFlowParameters(lfParameters); + SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, Collections.emptyList(), securityAnalysisParameters); + } } From 61394b07d95e3698ae7393460ae4b399c00010bf Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Wed, 19 Apr 2023 16:24:04 +0200 Subject: [PATCH 2/4] Fix Signed-off-by: Geoffroy Jamgotchian --- .../openloadflow/ac/equations/AcEquationSystemCreator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java b/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java index ca7ca58905..0acc7ebe31 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java +++ b/src/main/java/com/powsybl/openloadflow/ac/equations/AcEquationSystemCreator.java @@ -215,7 +215,7 @@ static void updateRemoteVoltageControlEquations(VoltageCon .map(vc -> equationSystem.getEquation(vc.getControlledBus().getNum(), AcEquationType.BUS_TARGET_V).orElseThrow()) .collect(Collectors.toList()); - if (voltageControl.isDisabled()) { + if (controlledBus.isDisabled()) { // we disable all voltage control equations vEq.setActive(false); for (T controllerElement : controllerElements) { From 3abd8ed5433e638436b78d2fba2133e11807db17 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Wed, 19 Apr 2023 16:28:08 +0200 Subject: [PATCH 3/4] Fix Signed-off-by: Geoffroy Jamgotchian --- .../powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java index a3877c1e22..c907208343 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java @@ -1851,7 +1851,7 @@ void testLoadContingencyNoImpact() { assertEquals(2, result.getPostContingencyResults().size()); } - @Test + @Test() void testWithVoltageRemoteControl() { Network network = VoltageControlNetworkFactory.createWithSimpleRemoteControl(); network.getGenerator("g4").setRegulatingTerminal(network.getLoad("l1").getTerminal()); // remote control. @@ -1861,6 +1861,8 @@ void testWithVoltageRemoteControl() { setSlackBusId(lfParameters, "b4_vl"); SecurityAnalysisParameters securityAnalysisParameters = new SecurityAnalysisParameters(); securityAnalysisParameters.setLoadFlowParameters(lfParameters); - SecurityAnalysisResult result = runSecurityAnalysis(network, contingencies, Collections.emptyList(), securityAnalysisParameters); + assertDoesNotThrow(() -> { + runSecurityAnalysis(network, contingencies, Collections.emptyList(), securityAnalysisParameters); + }); } } From cbd50bfac6f45fd9cde3b5e9bc87c0d04285d732 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Wed, 19 Apr 2023 16:28:13 +0200 Subject: [PATCH 4/4] Fix Signed-off-by: Geoffroy Jamgotchian --- .../com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java index c907208343..0f65a1b762 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java @@ -1851,7 +1851,7 @@ void testLoadContingencyNoImpact() { assertEquals(2, result.getPostContingencyResults().size()); } - @Test() + @Test void testWithVoltageRemoteControl() { Network network = VoltageControlNetworkFactory.createWithSimpleRemoteControl(); network.getGenerator("g4").setRegulatingTerminal(network.getLoad("l1").getTerminal()); // remote control.