From 32563050633640fe336d49c4a55de43f1b8acad0 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Mon, 1 Mar 2021 14:32:41 +0100 Subject: [PATCH] Increase slack active power distribution threshold (#232) Signed-off-by: Geoffroy Jamgotchian --- .../openloadflow/ac/DistributedSlackOuterLoop.java | 8 ++++++-- .../com/powsybl/openloadflow/NonImpedantBranchTest.java | 2 +- .../openloadflow/ac/AcLoadFlowDanglingLineTest.java | 2 +- .../openloadflow/ac/DistributedSlackOnGenerationTest.java | 2 +- .../openloadflow/ac/DistributedSlackOnLoadTest.java | 8 ++++---- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/ac/DistributedSlackOuterLoop.java b/src/main/java/com/powsybl/openloadflow/ac/DistributedSlackOuterLoop.java index 89e6bfcfa6..39527611b1 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/DistributedSlackOuterLoop.java +++ b/src/main/java/com/powsybl/openloadflow/ac/DistributedSlackOuterLoop.java @@ -7,7 +7,6 @@ package com.powsybl.openloadflow.ac; import com.powsybl.commons.PowsyblException; -import com.powsybl.openloadflow.ac.nr.DefaultNewtonRaphsonStoppingCriteria; import com.powsybl.openloadflow.ac.outerloop.OuterLoop; import com.powsybl.openloadflow.ac.outerloop.OuterLoopContext; import com.powsybl.openloadflow.ac.outerloop.OuterLoopStatus; @@ -25,6 +24,11 @@ public class DistributedSlackOuterLoop implements OuterLoop { private static final Logger LOGGER = LoggerFactory.getLogger(DistributedSlackOuterLoop.class); + /** + * Slack bus maximum active power mismatch: 10^-2 in p.u => 1 Mw + */ + private static final double SLACK_BUS_P_MAX_MISMATCH = Math.pow(10, -2); + private final ActivePowerDistribution activePowerDistribution; private final boolean throwsExceptionInCaseOfFailure; @@ -42,7 +46,7 @@ public String getType() { @Override public OuterLoopStatus check(OuterLoopContext context) { double slackBusActivePowerMismatch = context.getLastNewtonRaphsonResult().getSlackBusActivePowerMismatch(); - if (Math.abs(slackBusActivePowerMismatch) > DefaultNewtonRaphsonStoppingCriteria.CONV_EPS_PER_EQ) { + if (Math.abs(slackBusActivePowerMismatch) > SLACK_BUS_P_MAX_MISMATCH) { ActivePowerDistribution.Result result = activePowerDistribution.run(context.getNetwork(), slackBusActivePowerMismatch); diff --git a/src/test/java/com/powsybl/openloadflow/NonImpedantBranchTest.java b/src/test/java/com/powsybl/openloadflow/NonImpedantBranchTest.java index 2368273240..87f4cf4437 100644 --- a/src/test/java/com/powsybl/openloadflow/NonImpedantBranchTest.java +++ b/src/test/java/com/powsybl/openloadflow/NonImpedantBranchTest.java @@ -75,7 +75,7 @@ void threeBusesTest() { assertVoltageEquals(1, b1); assertVoltageEquals(0.856, b2); assertVoltageEquals(0.856, b3); - assertAngleEquals(13.444857, b1); + assertAngleEquals(13.520904, b1); assertAngleEquals(0, b2); assertAngleEquals(0, b3); diff --git a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowDanglingLineTest.java b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowDanglingLineTest.java index 21b3bd0132..04af2f935e 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowDanglingLineTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/AcLoadFlowDanglingLineTest.java @@ -155,7 +155,7 @@ void testWithVoltageRegulationOn() { assertTrue(result2.isOk()); assertVoltageEquals(390.440, bus1); - assertAngleEquals(0.114259, bus1); + assertAngleEquals(0.114371, bus1); assertVoltageEquals(390.181, bus2); assertAngleEquals(0, bus2); assertActivePowerEquals(101.2, dl1.getTerminal()); diff --git a/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnGenerationTest.java b/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnGenerationTest.java index 49af850b04..9449641d51 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnGenerationTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnGenerationTest.java @@ -145,7 +145,7 @@ void generatorWithNegativeTargetP() { network.getLoad("LOAD").setQ0(-200); LoadFlowResult result = LoadFlow.find("OpenLoadFlow").run(network, parameters); assertTrue(result.isOk()); - assertActivePowerEquals(595.350, network.getGenerator("GEN").getTerminal()); + assertActivePowerEquals(595.328, network.getGenerator("GEN").getTerminal()); } @Test diff --git a/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnLoadTest.java b/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnLoadTest.java index aa75a5f441..992ba54cc3 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnLoadTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/DistributedSlackOnLoadTest.java @@ -127,8 +127,8 @@ void testPowerFactorConstant() { assertPowerFactor(network1); LoadFlowResult loadFlowResultExpected1 = new LoadFlowResultBuilder(true) - .addMetrics("5", "CONVERGED") - .addComponentResult(0, LoadFlowResult.ComponentResult.Status.CONVERGED, 5, "VLHV1_0", -3.06844963660069E-5) + .addMetrics("4", "CONVERGED") + .addComponentResult(0, LoadFlowResult.ComponentResult.Status.CONVERGED, 4, "VLHV1_0", 0.026900149770181514) .build(); assertLoadFlowResultsEquals(loadFlowResultExpected1, loadFlowResult1); @@ -147,8 +147,8 @@ void testPowerFactorConstant() { // then assertPowerFactor(network2); - LoadFlowResult loadFlowResultExpected2 = new LoadFlowResultBuilder(true).addMetrics("5", "CONVERGED") - .addComponentResult(0, LoadFlowResult.ComponentResult.Status.CONVERGED, 5, "VLHV1_0", 1.340823176931849E-5) + LoadFlowResult loadFlowResultExpected2 = new LoadFlowResultBuilder(true).addMetrics("4", "CONVERGED") + .addComponentResult(0, LoadFlowResult.ComponentResult.Status.CONVERGED, 4, "VLHV1_0", 0.026900149770181514) .build(); assertLoadFlowResultsEquals(loadFlowResultExpected2, loadFlowResult2); }