From 560d0acbc90a2e604e27b88f75988c91b9cbb75c Mon Sep 17 00:00:00 2001 From: PRABAKARAN Sylvestre Date: Fri, 27 Dec 2024 15:38:02 +0100 Subject: [PATCH 1/3] Modified Slack Bus result in OpenLoadFlowProvider Signed-off-by: PRABAKARAN Sylvestre --- .../openloadflow/OpenLoadFlowProvider.java | 4 +-- .../ac/MultipleSlackBusesTest.java | 25 ++++++++++--------- .../openloadflow/dc/DcLoadFlowTest.java | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java index 7e100a3305..a4fd7bc9b0 100644 --- a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java +++ b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java @@ -191,13 +191,13 @@ private LoadFlowResult runAc(Network network, LoadFlowParameters parameters, Ope private static ReferenceBusAndSlackBusesResults buildReferenceBusAndSlackBusesResults(AbstractLoadFlowResult result) { String referenceBusId = null; List slackBusResultList = new ArrayList<>(); - double slackBusActivePowerMismatch = result.getSlackBusActivePowerMismatch() * PerUnit.SB; + //double slackBusActivePowerMismatch = result.getSlackBusActivePowerMismatch() * PerUnit.SB; if (result.getNetwork().getValidity() == LfNetwork.Validity.VALID) { referenceBusId = result.getNetwork().getReferenceBus().getId(); List slackBuses = result.getNetwork().getSlackBuses(); slackBusResultList = slackBuses.stream().map( b -> (LoadFlowResult.SlackBusResult) new LoadFlowResultImpl.SlackBusResultImpl(b.getId(), - slackBusActivePowerMismatch / slackBuses.size())).toList(); + b.getMismatchP() * PerUnit.SB)).toList(); } return new ReferenceBusAndSlackBusesResults(referenceBusId, slackBusResultList); } diff --git a/src/test/java/com/powsybl/openloadflow/ac/MultipleSlackBusesTest.java b/src/test/java/com/powsybl/openloadflow/ac/MultipleSlackBusesTest.java index ee57d97d40..08aebbaced 100644 --- a/src/test/java/com/powsybl/openloadflow/ac/MultipleSlackBusesTest.java +++ b/src/test/java/com/powsybl/openloadflow/ac/MultipleSlackBusesTest.java @@ -95,8 +95,8 @@ void multiSlackTest(boolean ac, NewtonRaphsonStoppingCriteriaType stoppingCriter assertEquals(expectedIterationCount, componentResult.getIterationCount()); List slackBusResults = componentResult.getSlackBusResults(); - double expectedSlackBusMismatch = ac ? -0.7164 : -3.5; - assertSlackBusResults(slackBusResults, expectedSlackBusMismatch, 2); + List expectedSlackBusMismatches = ac ? List.of(-0.7150, -0.7178) : List.of(-3.5, -3.5); // Mismatch values are not exactly the same between both slack buses + assertSlackBusResults(slackBusResults, expectedSlackBusMismatches, 2); if (ac) { assertActivePowerValues(302.807, 302.807, 600.868); @@ -111,8 +111,8 @@ void multiSlackTest(boolean ac, NewtonRaphsonStoppingCriteriaType stoppingCriter slackBusResults = componentResult.getSlackBusResults(); expectedIterationCount = ac ? 4 : 0; assertEquals(expectedIterationCount, componentResult.getIterationCount()); - expectedSlackBusMismatch = ac ? -0.005 : 0; - assertSlackBusResults(slackBusResults, expectedSlackBusMismatch, 2); + expectedSlackBusMismatches = ac ? List.of(-0.00576, -0.00572) : List.of(0d, 0d); + assertSlackBusResults(slackBusResults, expectedSlackBusMismatches, 2); } @ParameterizedTest(name = "ac : {0}") @@ -128,8 +128,8 @@ void nonImpedantBranchTest(boolean ac) { int expectedIterationCount = ac ? 3 : 0; assertEquals(expectedIterationCount, componentResult.getIterationCount()); List slackBusResults = componentResult.getSlackBusResults(); - double expectedSlackBusMismatch = ac ? -2.755 : -3.5; - assertSlackBusResults(slackBusResults, expectedSlackBusMismatch, 2); + List expectedSlackBusMismatches = ac ? List.of(-2.7551, -2.7547) : List.of(-3.5, -3.5); + assertSlackBusResults(slackBusResults, expectedSlackBusMismatches, 2); if (ac) { assertActivePowerValues(603.567, 0.0, 600.812); @@ -144,8 +144,8 @@ void nonImpedantBranchTest(boolean ac) { slackBusResults = componentResult.getSlackBusResults(); expectedIterationCount = ac ? 4 : 0; assertEquals(expectedIterationCount, componentResult.getIterationCount()); - expectedSlackBusMismatch = ac ? -0.005 : 0; - assertSlackBusResults(slackBusResults, expectedSlackBusMismatch, 2); + expectedSlackBusMismatches = ac ? List.of(-0.0054, -0.0056) : List.of(0d, 0d); + assertSlackBusResults(slackBusResults, expectedSlackBusMismatches, 2); } @ParameterizedTest(name = "ac : {0}") @@ -162,8 +162,8 @@ void loadOnSlackBusTest(boolean ac) { List slackBusResults = componentResult.getSlackBusResults(); assertEquals(List.of("VLHV2_0", "VLLOAD_0"), slackBusResults.stream().map(LoadFlowResult.SlackBusResult::getId).toList()); - double expectedSlackBusMismatch = ac ? -0.711 : -3.5; - assertSlackBusResults(slackBusResults, expectedSlackBusMismatch, 2); + List expectedSlackBusMismatches = ac ? List.of(-0.7118, -0.7108) : List.of(-3.5, -3.5); + assertSlackBusResults(slackBusResults, expectedSlackBusMismatches, 2); if (ac) { assertActivePowerValues(303.165, 303.165, 601.58); @@ -180,10 +180,11 @@ void assertActivePowerValues(double line1P1, double line2P1, double loadT2wtP1) assertActivePowerEquals(-607, generator.getTerminal()); } - void assertSlackBusResults(List slackBusResults, double expectedMismatch, int slackBusCount) { + void assertSlackBusResults(List slackBusResults, List expectedMismatches, int slackBusCount) { assertEquals(slackBusCount, slackBusResults.size()); + int i = 0; for (LoadFlowResult.SlackBusResult slackBusResult : slackBusResults) { - assertEquals(expectedMismatch, slackBusResult.getActivePowerMismatch(), LoadFlowAssert.DELTA_POWER); + assertEquals(expectedMismatches.get(i++), slackBusResult.getActivePowerMismatch(), LoadFlowAssert.DELTA_POWER); } } } diff --git a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java index 6f4cc679b6..b456c28e70 100644 --- a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java +++ b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java @@ -553,7 +553,7 @@ void testDcSlackDistributionFailureBehavior() { assertEquals(1, result.getComponentResults().size()); assertEquals(LoadFlowResult.ComponentResult.Status.FAILED, result.getComponentResults().get(0).getStatus()); assertEquals("Outer loop failed: Failed to distribute slack bus active power mismatch, 321.90 MW remains", result.getComponentResults().get(0).getStatusText()); - assertEquals(321.9, result.getComponentResults().get(0).getSlackBusResults().get(0).getActivePowerMismatch(), 0.01); + assertEquals(-73.9, result.getComponentResults().get(0).getSlackBusResults().get(0).getActivePowerMismatch(), 0.01); // The actual slack bus mismatch is the initial mismatch since distribution has failed assertEquals(0, result.getComponentResults().get(0).getDistributedActivePower(), 0.01); assertReportContains("Failed to distribute slack bus active power mismatch, [-+]?321\\.\\d* MW remains", reportNode); From af6220db3fe1a51f0c5bc725ed41efceacbce892 Mon Sep 17 00:00:00 2001 From: PRABAKARAN Sylvestre Date: Mon, 6 Jan 2025 18:11:34 +0100 Subject: [PATCH 2/3] Modified LoadFlowResult interface Signed-off-by: PRABAKARAN Sylvestre --- .../openloadflow/AcLoadFlowFromCache.java | 3 ++- .../openloadflow/OpenLoadFlowProvider.java | 6 +---- .../openloadflow/ac/AcLoadFlowResult.java | 15 ++++++++---- .../openloadflow/ac/AcloadFlowEngine.java | 23 +++++++++++++++---- .../openloadflow/dc/DcLoadFlowEngine.java | 21 +++++++++++------ .../openloadflow/dc/DcLoadFlowResult.java | 16 +++++++++---- .../lf/AbstractLoadFlowResult.java | 19 +++++++++++---- .../openloadflow/lf/LoadFlowResult.java | 4 +++- 8 files changed, 75 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/powsybl/openloadflow/AcLoadFlowFromCache.java b/src/main/java/com/powsybl/openloadflow/AcLoadFlowFromCache.java index 175174aa95..1d71c0ff1c 100644 --- a/src/main/java/com/powsybl/openloadflow/AcLoadFlowFromCache.java +++ b/src/main/java/com/powsybl/openloadflow/AcLoadFlowFromCache.java @@ -24,6 +24,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -120,7 +121,7 @@ private static AcLoadFlowResult run(AcLoadFlowContext context) { context.setNetworkUpdated(false); return result; } - return new AcLoadFlowResult(context.getNetwork(), 0, 0, AcSolverStatus.CONVERGED, OuterLoopResult.stable(), 0d, 0d); + return new AcLoadFlowResult(context.getNetwork(), 0, 0, AcSolverStatus.CONVERGED, OuterLoopResult.stable(), Collections.EMPTY_LIST, 0d); } public List run() { diff --git a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java index a4fd7bc9b0..b746695723 100644 --- a/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java +++ b/src/main/java/com/powsybl/openloadflow/OpenLoadFlowProvider.java @@ -191,13 +191,9 @@ private LoadFlowResult runAc(Network network, LoadFlowParameters parameters, Ope private static ReferenceBusAndSlackBusesResults buildReferenceBusAndSlackBusesResults(AbstractLoadFlowResult result) { String referenceBusId = null; List slackBusResultList = new ArrayList<>(); - //double slackBusActivePowerMismatch = result.getSlackBusActivePowerMismatch() * PerUnit.SB; if (result.getNetwork().getValidity() == LfNetwork.Validity.VALID) { referenceBusId = result.getNetwork().getReferenceBus().getId(); - List slackBuses = result.getNetwork().getSlackBuses(); - slackBusResultList = slackBuses.stream().map( - b -> (LoadFlowResult.SlackBusResult) new LoadFlowResultImpl.SlackBusResultImpl(b.getId(), - b.getMismatchP() * PerUnit.SB)).toList(); + slackBusResultList = result.getSlackBusResults(); } return new ReferenceBusAndSlackBusesResults(referenceBusId, slackBusResultList); } diff --git a/src/main/java/com/powsybl/openloadflow/ac/AcLoadFlowResult.java b/src/main/java/com/powsybl/openloadflow/ac/AcLoadFlowResult.java index 370839c919..2f157717d7 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/AcLoadFlowResult.java +++ b/src/main/java/com/powsybl/openloadflow/ac/AcLoadFlowResult.java @@ -15,7 +15,10 @@ import com.powsybl.openloadflow.network.LfNetwork; import com.powsybl.openloadflow.util.PerUnit; +import java.util.Collections; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * @author Geoffroy Jamgotchian {@literal } @@ -23,7 +26,7 @@ public class AcLoadFlowResult extends AbstractLoadFlowResult { public static AcLoadFlowResult createNoCalculationResult(LfNetwork network) { - return new AcLoadFlowResult(network, 0, 0, AcSolverStatus.NO_CALCULATION, OuterLoopResult.stable(), Double.NaN, Double.NaN); + return new AcLoadFlowResult(network, 0, 0, AcSolverStatus.NO_CALCULATION, OuterLoopResult.stable(), Collections.EMPTY_LIST, Double.NaN); } private final int solverIterations; @@ -32,8 +35,8 @@ public static AcLoadFlowResult createNoCalculationResult(LfNetwork network) { public AcLoadFlowResult(LfNetwork network, int outerLoopIterations, int solverIterations, AcSolverStatus solverStatus, OuterLoopResult outerLoopResult, - double slackBusActivePowerMismatch, double distributedActivePower) { - super(network, slackBusActivePowerMismatch, outerLoopIterations, outerLoopResult, distributedActivePower); + List slackBusResults, double distributedActivePower) { + super(network, slackBusResults, outerLoopIterations, outerLoopResult, distributedActivePower); this.solverIterations = solverIterations; this.solverStatus = Objects.requireNonNull(solverStatus); } @@ -85,7 +88,11 @@ public String toString() { + ", newtonRaphsonIterations=" + solverIterations + ", solverStatus=" + solverStatus + ", outerLoopStatus=" + outerLoopResult.status() - + ", slackBusActivePowerMismatch=" + slackBusActivePowerMismatch * PerUnit.SB + + ", slackBusResults=SlackBusResult(" + + slackBusResults.stream() + .map(s -> "(id=" + s.getId() + ", activePowerMismatch=" + s.getActivePowerMismatch() + ")") + .collect(Collectors.joining("")) + + ")" + ", distributedActivePower=" + distributedActivePower * PerUnit.SB + ")"; } diff --git a/src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java b/src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java index 2afcd6f13b..9ebe5a4fac 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java +++ b/src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java @@ -9,6 +9,8 @@ import com.google.common.collect.Lists; import com.powsybl.commons.report.ReportNode; +import com.powsybl.loadflow.LoadFlowResult; +import com.powsybl.loadflow.LoadFlowResultImpl; import com.powsybl.openloadflow.ac.equations.AcEquationType; import com.powsybl.openloadflow.ac.equations.AcVariableType; import com.powsybl.openloadflow.ac.outerloop.AcActivePowerDistributionOuterLoop; @@ -20,6 +22,7 @@ import com.powsybl.openloadflow.network.LfNetwork; import com.powsybl.openloadflow.network.util.PreviousValueVoltageInitializer; import com.powsybl.openloadflow.network.util.VoltageInitializer; +import com.powsybl.openloadflow.util.PerUnit; import com.powsybl.openloadflow.util.Reports; import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.tuple.Pair; @@ -63,6 +66,8 @@ private static class RunningContext { private final MutableInt nrTotalIterations = new MutableInt(); private OuterLoopResult lastOuterLoopResult = OuterLoopResult.stable(); + + private List slackBusResults; } private void runOuterLoop(AcOuterLoop outerLoop, AcOuterLoopContext outerLoopContext, AcSolver solver, RunningContext runningContext) { @@ -113,7 +118,7 @@ private void runOuterLoop(AcOuterLoop outerLoop, AcOuterLoopContext outerLoopCon @Override public AcLoadFlowResult run() { - LOGGER.info("Start AC loadflow on network {}", context.getNetwork()); + LOGGER.info("Start ACslackBusResults loadflow on network {}", context.getNetwork()); VoltageInitializer voltageInitializer = context.getParameters().getVoltageInitializer(); // in case of a DC voltage initializer, an DC equation system in created and equations are attached @@ -138,7 +143,8 @@ public AcLoadFlowResult run() { LOGGER.info("Network must have at least one bus with generator voltage control enabled"); Reports.reportNetworkMustHaveAtLeastOneBusGeneratorVoltageControlEnabled(reportNode); runningContext.lastSolverResult = new AcSolverResult(AcSolverStatus.SOLVER_FAILED, 0, Double.NaN); - return buildAcLoadFlowResult(runningContext, OuterLoopResult.stable(), distributedActivePower); + List slackBusResults = getSlackBusResults(context.getNetwork()); + return buildAcLoadFlowResult(runningContext, OuterLoopResult.stable(), slackBusResults, distributedActivePower); } AcSolver solver = solverFactory.create(context.getNetwork(), @@ -217,17 +223,24 @@ public AcLoadFlowResult run() { ? new OuterLoopResult(runningContext.lastOuterLoopResult.outerLoopName(), OuterLoopStatus.STABLE, runningContext.lastOuterLoopResult.statusText()) : new OuterLoopResult(runningContext.lastOuterLoopResult.outerLoopName(), OuterLoopStatus.UNSTABLE, runningContext.lastOuterLoopResult.statusText()); } + List slackBusResults = getSlackBusResults(context.getNetwork()); + + return buildAcLoadFlowResult(runningContext, outerLoopFinalResult, slackBusResults, distributedActivePower); + } - return buildAcLoadFlowResult(runningContext, outerLoopFinalResult, distributedActivePower); + public static List getSlackBusResults(LfNetwork network) { + return network.getSlackBuses().stream().map( + b -> (LoadFlowResult.SlackBusResult) new LoadFlowResultImpl.SlackBusResultImpl(b.getId(), + b.getMismatchP() * PerUnit.SB)).toList(); } - private AcLoadFlowResult buildAcLoadFlowResult(RunningContext runningContext, OuterLoopResult outerLoopFinalResult, double distributedActivePower) { + private AcLoadFlowResult buildAcLoadFlowResult(RunningContext runningContext, OuterLoopResult outerLoopFinalResult, List slackBusResults, double distributedActivePower) { AcLoadFlowResult result = new AcLoadFlowResult(context.getNetwork(), runningContext.outerLoopTotalIterations, runningContext.nrTotalIterations.getValue(), runningContext.lastSolverResult.getStatus(), outerLoopFinalResult, - runningContext.lastSolverResult.getSlackBusActivePowerMismatch(), + slackBusResults, distributedActivePower ); diff --git a/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowEngine.java b/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowEngine.java index da3c9fc7b4..629cff28d6 100644 --- a/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowEngine.java +++ b/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowEngine.java @@ -10,6 +10,8 @@ import com.google.common.collect.Lists; import com.powsybl.commons.report.ReportNode; import com.powsybl.loadflow.LoadFlowParameters; +import com.powsybl.loadflow.LoadFlowResult; +import com.powsybl.loadflow.LoadFlowResultImpl; import com.powsybl.math.matrix.MatrixException; import com.powsybl.openloadflow.OpenLoadFlowParameters; import com.powsybl.openloadflow.dc.equations.DcEquationType; @@ -80,6 +82,12 @@ public static double getActivePowerMismatch(Collection buses) { return -mismatch; } + public static List getSlackBusResults(LfNetwork network) { + return network.getSlackBuses().stream().map( + b -> (LoadFlowResult.SlackBusResult) new LoadFlowResultImpl.SlackBusResultImpl(b.getId(), + b.getMismatchP() * PerUnit.SB)).toList(); + } + public static void initStateVector(LfNetwork network, EquationSystem equationSystem, VoltageInitializer initializer) { double[] x = new double[equationSystem.getIndex().getSortedVariablesToFind().size()]; for (Variable v : equationSystem.getIndex().getSortedVariablesToFind()) { @@ -241,7 +249,7 @@ public DcLoadFlowResult run() { runningContext.lastSolverSuccess = false; runningContext.lastOuterLoopResult = new OuterLoopResult("DistributedSlack", OuterLoopStatus.FAILED, resultWbh.failedMessage()); Reports.reportDcLfComplete(reportNode, runningContext.lastSolverSuccess, runningContext.lastOuterLoopResult.status().name()); - return buildDcLoadFlowResult(network, runningContext, initialSlackBusActivePowerMismatch, distributedActivePower); + return buildDcLoadFlowResult(network, runningContext, distributedActivePower); } } @@ -299,20 +307,19 @@ public DcLoadFlowResult run() { Reports.reportDcLfComplete(reportNode, runningContext.lastSolverSuccess, runningContext.lastOuterLoopResult.status().name()); - return buildDcLoadFlowResult(network, runningContext, initialSlackBusActivePowerMismatch, distributedActivePower); + return buildDcLoadFlowResult(network, runningContext, distributedActivePower); } - DcLoadFlowResult buildDcLoadFlowResult(LfNetwork network, RunningContext runningContext, double initialSlackBusActivePowerMismatch, double finalDistributedActivePower) { - double slackBusActivePowerMismatch; + DcLoadFlowResult buildDcLoadFlowResult(LfNetwork network, RunningContext runningContext, double finalDistributedActivePower) { + List slackBusResults; double distributedActivePower; if (runningContext.lastSolverSuccess && runningContext.lastOuterLoopResult.status() == OuterLoopStatus.STABLE) { - slackBusActivePowerMismatch = getActivePowerMismatch(network.getBuses()); distributedActivePower = finalDistributedActivePower; } else { - slackBusActivePowerMismatch = initialSlackBusActivePowerMismatch; distributedActivePower = 0.0; } - DcLoadFlowResult result = new DcLoadFlowResult(network, runningContext.outerLoopTotalIterations, runningContext.lastSolverSuccess, runningContext.lastOuterLoopResult, slackBusActivePowerMismatch, distributedActivePower); + slackBusResults = getSlackBusResults(network); + DcLoadFlowResult result = new DcLoadFlowResult(network, runningContext.outerLoopTotalIterations, runningContext.lastSolverSuccess, runningContext.lastOuterLoopResult, slackBusResults, distributedActivePower); LOGGER.info("DC loadflow complete on network {} (result={})", context.getNetwork(), result); return result; } diff --git a/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowResult.java b/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowResult.java index f301942f2e..536e18766e 100644 --- a/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowResult.java +++ b/src/main/java/com/powsybl/openloadflow/dc/DcLoadFlowResult.java @@ -14,6 +14,10 @@ import com.powsybl.openloadflow.network.LfNetwork; import com.powsybl.openloadflow.util.PerUnit; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + /** * @author Geoffroy Jamgotchian {@literal } */ @@ -22,11 +26,11 @@ public class DcLoadFlowResult extends AbstractLoadFlowResult { private final boolean solverSuccess; public static DcLoadFlowResult createNoCalculationResult(LfNetwork network) { - return new DcLoadFlowResult(network, 0, false, OuterLoopResult.stable(), Double.NaN, Double.NaN); + return new DcLoadFlowResult(network, 0, false, OuterLoopResult.stable(), Collections.EMPTY_LIST, Double.NaN); } - public DcLoadFlowResult(LfNetwork network, int outerLoopIterations, boolean solverSuccess, OuterLoopResult outerLoopResult, double slackBusActivePowerMismatch, double distributedActivePower) { - super(network, slackBusActivePowerMismatch, outerLoopIterations, outerLoopResult, distributedActivePower); + public DcLoadFlowResult(LfNetwork network, int outerLoopIterations, boolean solverSuccess, OuterLoopResult outerLoopResult, List slackBusResults, double distributedActivePower) { + super(network, slackBusResults, outerLoopIterations, outerLoopResult, distributedActivePower); this.solverSuccess = solverSuccess; } @@ -56,7 +60,11 @@ public String toString() { return "DcLoadFlowResult(outerLoopIterations=" + outerLoopIterations + ", solverSuccess=" + solverSuccess + ", outerLoopStatus=" + outerLoopResult.status() - + ", slackBusActivePowerMismatch=" + slackBusActivePowerMismatch * PerUnit.SB + + ", slackBusResults=SlackBusResult(" + + slackBusResults.stream() + .map(s -> "(id=" + s.getId() + ", activePowerMismatch=" + s.getActivePowerMismatch() + ")") + .collect(Collectors.joining("")) + + ")" + ", distributedActivePower=" + distributedActivePower * PerUnit.SB + ")"; } diff --git a/src/main/java/com/powsybl/openloadflow/lf/AbstractLoadFlowResult.java b/src/main/java/com/powsybl/openloadflow/lf/AbstractLoadFlowResult.java index 19c42285e0..7c8317850e 100644 --- a/src/main/java/com/powsybl/openloadflow/lf/AbstractLoadFlowResult.java +++ b/src/main/java/com/powsybl/openloadflow/lf/AbstractLoadFlowResult.java @@ -10,6 +10,7 @@ import com.powsybl.openloadflow.lf.outerloop.OuterLoopResult; import com.powsybl.openloadflow.network.LfNetwork; +import java.util.List; import java.util.Objects; /** @@ -18,15 +19,18 @@ public abstract class AbstractLoadFlowResult implements LoadFlowResult { protected final LfNetwork network; - - protected final double slackBusActivePowerMismatch; + protected final List slackBusResults; protected final int outerLoopIterations; protected final OuterLoopResult outerLoopResult; protected final double distributedActivePower; - protected AbstractLoadFlowResult(LfNetwork network, double slackBusActivePowerMismatch, int outerLoopIterations, OuterLoopResult outerLoopResult, double distributedActivePower) { + protected AbstractLoadFlowResult(LfNetwork network, + List slackBusResults, + int outerLoopIterations, + OuterLoopResult outerLoopResult, + double distributedActivePower) { this.network = Objects.requireNonNull(network); - this.slackBusActivePowerMismatch = slackBusActivePowerMismatch; + this.slackBusResults = slackBusResults; this.outerLoopIterations = outerLoopIterations; this.outerLoopResult = Objects.requireNonNull(outerLoopResult); this.distributedActivePower = distributedActivePower; @@ -37,9 +41,14 @@ public LfNetwork getNetwork() { return network; } - @Override + /*@Override public double getSlackBusActivePowerMismatch() { return slackBusActivePowerMismatch; + }*/ + + @Override + public List getSlackBusResults() { + return slackBusResults; } public int getOuterLoopIterations() { diff --git a/src/main/java/com/powsybl/openloadflow/lf/LoadFlowResult.java b/src/main/java/com/powsybl/openloadflow/lf/LoadFlowResult.java index df29b73103..b7287efe03 100644 --- a/src/main/java/com/powsybl/openloadflow/lf/LoadFlowResult.java +++ b/src/main/java/com/powsybl/openloadflow/lf/LoadFlowResult.java @@ -9,6 +9,8 @@ import com.powsybl.openloadflow.network.LfNetwork; +import java.util.List; + /** * @author Geoffroy Jamgotchian {@literal } */ @@ -21,7 +23,7 @@ record Status(com.powsybl.loadflow.LoadFlowResult.ComponentResult.Status status, LfNetwork getNetwork(); - double getSlackBusActivePowerMismatch(); + List getSlackBusResults(); Status toComponentResultStatus(); } From 607e871b24e99d5e8b40f92060fa48d53d22d534 Mon Sep 17 00:00:00 2001 From: PRABAKARAN Sylvestre Date: Mon, 6 Jan 2025 18:14:45 +0100 Subject: [PATCH 3/3] typo Signed-off-by: PRABAKARAN Sylvestre --- src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java b/src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java index 9ebe5a4fac..7892bdfcf5 100644 --- a/src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java +++ b/src/main/java/com/powsybl/openloadflow/ac/AcloadFlowEngine.java @@ -118,7 +118,7 @@ private void runOuterLoop(AcOuterLoop outerLoop, AcOuterLoopContext outerLoopCon @Override public AcLoadFlowResult run() { - LOGGER.info("Start ACslackBusResults loadflow on network {}", context.getNetwork()); + LOGGER.info("Start AC loadflow on network {}", context.getNetwork()); VoltageInitializer voltageInitializer = context.getParameters().getVoltageInitializer(); // in case of a DC voltage initializer, an DC equation system in created and equations are attached