From 4e4c5e8d359fbbcb84f877d5395b994768a72cc3 Mon Sep 17 00:00:00 2001 From: Caio Luke <31912369+caioluke@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:02:07 +0200 Subject: [PATCH] Fix flow decomposition loss compensation when dangling lines have shunt susceptance (#160) * fix losses compensation when dangling lines have shunt susceptance Signed-off-by: Caio Luke --- .../algorithm-description.md | 3 +- .../flow_decomposition/LossesCompensator.java | 15 ++++---- .../LossesCompensationTests.java | 36 ++++++++++++++++--- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/docs/flow_decomposition/algorithm-description.md b/docs/flow_decomposition/algorithm-description.md index 7e66c3c0..b2fc74a5 100644 --- a/docs/flow_decomposition/algorithm-description.md +++ b/docs/flow_decomposition/algorithm-description.md @@ -27,7 +27,8 @@ These losses are then compensated on the sending side of each network element. ![Losses compensation on lines](/_static/img/flow_decomposition/lossesCompensationOnLine.svg) A special treatment is done on tie lines, where instead of compensating the losses on the sending terminal, losses are -compensated at both sides proportionally to the resistance of each half line. +compensated at both sides. Losses are calculated for each half line individually by adding its terminal and boundary flows. +If the half lines have no shunt susceptance, this corresponds to split tie line losses proportionally to the resistance of each half line. ![Losses compensation on tie lines](/_static/img/flow_decomposition/lossesCompensationOnTieLine.svg) diff --git a/flow-decomposition/src/main/java/com/powsybl/flow_decomposition/LossesCompensator.java b/flow-decomposition/src/main/java/com/powsybl/flow_decomposition/LossesCompensator.java index 874541f8..d716e03c 100644 --- a/flow-decomposition/src/main/java/com/powsybl/flow_decomposition/LossesCompensator.java +++ b/flow-decomposition/src/main/java/com/powsybl/flow_decomposition/LossesCompensator.java @@ -112,15 +112,12 @@ private void compensateLossesOnBranch(Network network, Branch branch) { } private void compensateLossesOnTieLine(Network network, TieLine tieLine) { - double r1 = tieLine.getDanglingLine1().getR(); - double r2 = tieLine.getDanglingLine2().getR(); - double r = r1 + r2; - Terminal terminal1 = tieLine.getDanglingLine1().getTerminal(); - Terminal terminal2 = tieLine.getDanglingLine2().getTerminal(); - double losses = terminal1.getP() + terminal2.getP(); - double lossesSide1 = losses * r1 / r; - double lossesSide2 = losses * r2 / r; - + DanglingLine danglingLine1 = tieLine.getDanglingLine1(); + DanglingLine danglingLine2 = tieLine.getDanglingLine2(); + Terminal terminal1 = danglingLine1.getTerminal(); + Terminal terminal2 = danglingLine2.getTerminal(); + double lossesSide1 = terminal1.getP() + danglingLine1.getBoundary().getP(); + double lossesSide2 = terminal2.getP() + danglingLine2.getBoundary().getP(); updateLoadForLossesOnTerminal(network, terminal1, lossesSide1); updateLoadForLossesOnTerminal(network, terminal2, lossesSide2); } diff --git a/flow-decomposition/src/test/java/com/powsybl/flow_decomposition/LossesCompensationTests.java b/flow-decomposition/src/test/java/com/powsybl/flow_decomposition/LossesCompensationTests.java index 779e3dc2..5e108b1b 100644 --- a/flow-decomposition/src/test/java/com/powsybl/flow_decomposition/LossesCompensationTests.java +++ b/flow-decomposition/src/test/java/com/powsybl/flow_decomposition/LossesCompensationTests.java @@ -7,10 +7,7 @@ package com.powsybl.flow_decomposition; import com.powsybl.flow_decomposition.xnec_provider.XnecProviderByIds; -import com.powsybl.iidm.network.Bus; -import com.powsybl.iidm.network.Country; -import com.powsybl.iidm.network.Load; -import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.*; import com.powsybl.loadflow.LoadFlow; import com.powsybl.loadflow.LoadFlowParameters; import org.junit.jupiter.api.Test; @@ -106,6 +103,10 @@ void checkThatLossesCompensationOnTieLineDoesDispatchLossesProportionallyToEachS LossesCompensator lossesCompensator = new LossesCompensator(FlowDecompositionParameters.DISABLE_LOSSES_COMPENSATION_EPSILON); lossesCompensator.run(network); + TieLine tieLine = network.getTieLine("FGEN1 11 X 11 1 + X 11 BLOAD 11 1"); + assertEquals(0.0, tieLine.getDanglingLine1().getB(), EPSILON); + assertEquals(0.0, tieLine.getDanglingLine2().getB(), EPSILON); + Load lossesFgenBload = network.getLoad("LOSSES FGEN1 11 X 11 1 + X 11 BLOAD 11 1"); assertNull(lossesFgenBload); @@ -119,6 +120,33 @@ void checkThatLossesCompensationOnTieLineDoesDispatchLossesProportionallyToEachS assertEquals(0.046875, lossesBloadX.getP0(), EPSILON); } + @Test + void checkThatLossesCompensationOnTieLineDoesDispatchLossesProportionallyToEachSideResistanceWithB() { + String networkFileName = "NETWORK_SINGLE_LOAD_TWO_GENERATORS_WITH_XNODE.uct"; + + Network network = importNetwork(networkFileName); + TieLine tieLine = network.getTieLine("FGEN1 11 X 11 1 + X 11 BLOAD 11 1"); + tieLine.getDanglingLine1().setB(1E-3); + tieLine.getDanglingLine2().setB(1E-3); + LoadFlowParameters loadFlowParameters = new LoadFlowParameters(); + loadFlowParameters.setDc(AC_LOAD_FLOW); + LoadFlow.run(network, loadFlowParameters); + LossesCompensator lossesCompensator = new LossesCompensator(FlowDecompositionParameters.DISABLE_LOSSES_COMPENSATION_EPSILON); + lossesCompensator.run(network); + + Load lossesFgenBload = network.getLoad("LOSSES FGEN1 11 X 11 1 + X 11 BLOAD 11 1"); + assertNull(lossesFgenBload); + + Load lossesFgenX = network.getLoad("LOSSES FGEN1 11"); + assertNotNull(lossesFgenX); + assertEquals("FGEN1 1", lossesFgenX.getTerminal().getVoltageLevel().getId()); + assertEquals(0.044098, lossesFgenX.getP0(), EPSILON); + Load lossesBloadX = network.getLoad("LOSSES BLOAD 11"); + assertNotNull(lossesBloadX); + assertEquals("BLOAD 1", lossesBloadX.getTerminal().getVoltageLevel().getId()); + assertEquals(0.050000, lossesBloadX.getP0(), EPSILON); + } + @Test void checkThatDefaultFlowDecompositionDoesNotCompensateLosses() { String networkFileName = "NETWORK_SINGLE_LOAD_TWO_GENERATORS_WITH_COUNTRIES_EXTRA_SUBSTATION.uct";