diff --git a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java index d885d96480..2698700d0e 100644 --- a/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java +++ b/src/test/java/com/powsybl/openloadflow/dc/DcLoadFlowTest.java @@ -272,7 +272,7 @@ void testDisabledNonImpedantBranch() { LoadFlowParameters parameters = new LoadFlowParameters() .setDc(true); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertActivePowerEquals(400.0, network.getLine("L1").getTerminal1()); assertActivePowerEquals(100.0, network.getLine("L2").getTerminal1()); diff --git a/src/test/java/com/powsybl/openloadflow/sa/AbstractOpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/AbstractOpenSecurityAnalysisTest.java index f62b3cee23..e7c6312e89 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/AbstractOpenSecurityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/AbstractOpenSecurityAnalysisTest.java @@ -10,11 +10,15 @@ import com.powsybl.computation.ComputationManager; import com.powsybl.contingency.*; import com.powsybl.iidm.network.*; +import com.powsybl.loadflow.LoadFlow; import com.powsybl.loadflow.LoadFlowParameters; import com.powsybl.loadflow.LoadFlowResult; +import com.powsybl.math.matrix.DenseMatrixFactory; import com.powsybl.math.matrix.MatrixFactory; import com.powsybl.openloadflow.OpenLoadFlowParameters; import com.powsybl.openloadflow.OpenLoadFlowProvider; +import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivityFactory; +import com.powsybl.openloadflow.graph.GraphConnectivityFactory; import com.powsybl.openloadflow.network.*; import com.powsybl.security.*; import com.powsybl.security.action.Action; @@ -22,8 +26,11 @@ import com.powsybl.security.monitor.StateMonitor; import com.powsybl.security.results.*; import com.powsybl.security.strategy.OperatorStrategy; +import org.junit.jupiter.api.BeforeEach; +import org.mockito.Mockito; import java.util.*; +import java.util.concurrent.ForkJoinPool; import java.util.stream.Collectors; import static org.junit.jupiter.api.Assertions.*; @@ -41,6 +48,19 @@ public abstract class AbstractOpenSecurityAnalysisTest { protected OpenLoadFlowProvider loadFlowProvider; + protected LoadFlow.Runner loadFlowRunner; + + @BeforeEach + void setUp() { + computationManager = Mockito.mock(ComputationManager.class); + Mockito.when(computationManager.getExecutor()).thenReturn(ForkJoinPool.commonPool()); + matrixFactory = new DenseMatrixFactory(); + GraphConnectivityFactory connectivityFactory = new EvenShiloachGraphDecrementalConnectivityFactory<>(); + securityAnalysisProvider = new OpenSecurityAnalysisProvider(matrixFactory, connectivityFactory); + loadFlowProvider = new OpenLoadFlowProvider(matrixFactory, connectivityFactory); + loadFlowRunner = new LoadFlow.Runner(loadFlowProvider); + } + protected static Network createNodeBreakerNetwork() { Network network = NodeBreakerNetworkFactory.create(); diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java index 713842fca7..bd842bd1a5 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisTest.java @@ -10,7 +10,6 @@ import com.powsybl.commons.PowsyblException; import com.powsybl.commons.reporter.Reporter; import com.powsybl.commons.reporter.ReporterModel; -import com.powsybl.computation.ComputationManager; import com.powsybl.contingency.*; import com.powsybl.ieeecdf.converter.IeeeCdfNetworkFactory; import com.powsybl.iidm.network.*; @@ -20,29 +19,21 @@ import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; import com.powsybl.iidm.network.test.FourSubstationsNodeBreakerFactory; import com.powsybl.iidm.network.test.SecurityAnalysisTestNetworkFactory; -import com.powsybl.loadflow.LoadFlow; import com.powsybl.loadflow.LoadFlowParameters; import com.powsybl.loadflow.LoadFlowResult; -import com.powsybl.math.matrix.DenseMatrixFactory; import com.powsybl.openloadflow.OpenLoadFlowParameters; -import com.powsybl.openloadflow.OpenLoadFlowProvider; import com.powsybl.openloadflow.ac.nr.NewtonRaphsonStatus; -import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivityFactory; -import com.powsybl.openloadflow.graph.GraphConnectivityFactory; import com.powsybl.openloadflow.network.*; import com.powsybl.openloadflow.network.impl.OlfBranchResult; import com.powsybl.openloadflow.util.LoadFlowAssert; import com.powsybl.security.*; import com.powsybl.security.monitor.StateMonitor; import com.powsybl.security.results.*; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; import java.io.IOException; import java.util.*; import java.util.concurrent.CompletionException; -import java.util.concurrent.ForkJoinPool; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -56,16 +47,6 @@ */ class OpenSecurityAnalysisTest extends AbstractOpenSecurityAnalysisTest { - @BeforeEach - void setUp() { - computationManager = Mockito.mock(ComputationManager.class); - Mockito.when(computationManager.getExecutor()).thenReturn(ForkJoinPool.commonPool()); - matrixFactory = new DenseMatrixFactory(); - GraphConnectivityFactory connectivityFactory = new EvenShiloachGraphDecrementalConnectivityFactory<>(); - securityAnalysisProvider = new OpenSecurityAnalysisProvider(matrixFactory, connectivityFactory); - loadFlowProvider = new OpenLoadFlowProvider(matrixFactory, connectivityFactory); - } - @Test void testCurrentLimitViolations() { Network network = createNodeBreakerNetwork(); @@ -1586,7 +1567,7 @@ void testThreeWindingsTransformerContingency() { network.getThreeWindingsTransformer("T3wT").getLeg2().getTerminal().disconnect(); network.getThreeWindingsTransformer("T3wT").getLeg3().getTerminal().disconnect(); setSlackBusId(parameters, "VL_1"); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); PostContingencyResult contingencyResult = getPostContingencyResult(result, "T3wT"); assertEquals(network.getLine("LINE_12").getTerminal2().getP(), contingencyResult.getNetworkResult().getBranchResult("LINE_12").getP2(), LoadFlowAssert.DELTA_POWER); @@ -1753,7 +1734,7 @@ void testStaticVarCompensatorContingency() { // compare with a simple load low network.getStaticVarCompensator("svc1").getTerminal().disconnect(); - LoadFlow.run(network, parameters.getLoadFlowParameters()); + loadFlowRunner.run(network, parameters.getLoadFlowParameters()); PostContingencyResult postContingencyResult = getPostContingencyResult(result, "svc1"); assertEquals(network.getLine("l1").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l1").getP1(), LoadFlowAssert.DELTA_POWER); @@ -1785,7 +1766,7 @@ void testStaticVarCompensatorContingencyWithStandByAutomaton() { // compare with a simple load low network.getStaticVarCompensator("svc1").getTerminal().disconnect(); - LoadFlow.run(network); + loadFlowRunner.run(network); PostContingencyResult postContingencyResult = getPostContingencyResult(result, "svc1"); assertEquals(network.getLine("l1").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l1").getP1(), LoadFlowAssert.DELTA_POWER); @@ -1796,7 +1777,7 @@ void testStaticVarCompensatorContingencyWithStandByAutomaton() { // test restore. network.getStaticVarCompensator("svc1").getTerminal().connect(); network.getLoad("ld1").getTerminal().disconnect(); - LoadFlow.run(network); + loadFlowRunner.run(network); PostContingencyResult postContingencyResult2 = getPostContingencyResult(result, "ld1"); assertEquals(network.getLine("l1").getTerminal1().getP(), postContingencyResult2.getNetworkResult().getBranchResult("l1").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l1").getTerminal2().getP(), postContingencyResult2.getNetworkResult().getBranchResult("l1").getP2(), LoadFlowAssert.DELTA_POWER); diff --git a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java index 3bffb6fa88..f8dae17b4b 100644 --- a/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java +++ b/src/test/java/com/powsybl/openloadflow/sa/OpenSecurityAnalysisWithActionsTest.java @@ -8,38 +8,40 @@ import com.powsybl.commons.reporter.Reporter; import com.powsybl.commons.reporter.ReporterModel; -import com.powsybl.computation.ComputationManager; import com.powsybl.contingency.*; -import com.powsybl.iidm.network.*; +import com.powsybl.iidm.network.HvdcLine; +import com.powsybl.iidm.network.Network; import com.powsybl.iidm.network.extensions.HvdcAngleDroopActivePowerControlAdder; import com.powsybl.iidm.xml.test.MetrixTutorialSixBusesFactory; -import com.powsybl.loadflow.LoadFlow; import com.powsybl.loadflow.LoadFlowParameters; -import com.powsybl.math.matrix.DenseMatrixFactory; import com.powsybl.openloadflow.OpenLoadFlowParameters; -import com.powsybl.openloadflow.OpenLoadFlowProvider; -import com.powsybl.openloadflow.graph.EvenShiloachGraphDecrementalConnectivityFactory; import com.powsybl.openloadflow.graph.GraphConnectivityFactory; import com.powsybl.openloadflow.graph.NaiveGraphConnectivityFactory; import com.powsybl.openloadflow.network.*; import com.powsybl.openloadflow.util.LoadFlowAssert; -import com.powsybl.security.*; +import com.powsybl.security.LimitViolation; +import com.powsybl.security.LimitViolationType; +import com.powsybl.security.SecurityAnalysisParameters; +import com.powsybl.security.SecurityAnalysisResult; import com.powsybl.security.action.*; import com.powsybl.security.condition.AllViolationCondition; import com.powsybl.security.condition.AnyViolationCondition; import com.powsybl.security.condition.AtLeastOneViolationCondition; import com.powsybl.security.condition.TrueCondition; import com.powsybl.security.monitor.StateMonitor; -import com.powsybl.security.results.*; +import com.powsybl.security.results.BranchResult; +import com.powsybl.security.results.OperatorStrategyResult; +import com.powsybl.security.results.PostContingencyResult; +import com.powsybl.security.results.PreContingencyResult; import com.powsybl.security.strategy.OperatorStrategy; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.Mockito; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; import java.util.concurrent.CompletionException; -import java.util.concurrent.ForkJoinPool; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -52,16 +54,6 @@ */ class OpenSecurityAnalysisWithActionsTest extends AbstractOpenSecurityAnalysisTest { - @BeforeEach - void setUp() { - computationManager = Mockito.mock(ComputationManager.class); - Mockito.when(computationManager.getExecutor()).thenReturn(ForkJoinPool.commonPool()); - matrixFactory = new DenseMatrixFactory(); - GraphConnectivityFactory connectivityFactory = new EvenShiloachGraphDecrementalConnectivityFactory<>(); - securityAnalysisProvider = new OpenSecurityAnalysisProvider(matrixFactory, connectivityFactory); - loadFlowProvider = new OpenLoadFlowProvider(matrixFactory, connectivityFactory); - } - @Test void testDcEquationSystemUpdater() { Network network = VoltageControlNetworkFactory.createWithShuntSharedRemoteControl(); @@ -159,19 +151,19 @@ void testSecurityAnalysisWithOperatorStrategy() { assertEquals(441.539, getOperatorStrategyResult(result, "strategyL2").getNetworkResult().getBranchResult("L3").getI1(), LoadFlowAssert.DELTA_I); // re-run with loadflows - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(578.740, network.getLine("L1").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(0.0, network.getLine("L2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(292.708, network.getLine("L3").getTerminal1().getI(), LoadFlowAssert.DELTA_I); network.getLine("L1").getTerminal1().disconnect(); network.getLine("L1").getTerminal2().disconnect(); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(0.002, network.getLine("L2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(318.284, network.getLine("L3").getTerminal1().getI(), LoadFlowAssert.DELTA_I); network.getSwitch("C1").setOpen(false); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(583.624, network.getLine("L2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(303.513, network.getLine("L3").getTerminal1().getI(), LoadFlowAssert.DELTA_I); @@ -180,12 +172,12 @@ void testSecurityAnalysisWithOperatorStrategy() { network.getLine("L3").getTerminal1().disconnect(); network.getLine("L3").getTerminal2().disconnect(); network.getSwitch("C1").setOpen(true); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(602.965, network.getLine("L1").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(0.0, network.getLine("L2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); network.getSwitch("C2").setOpen(false); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(583.624, network.getLine("L1").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(303.513, network.getLine("L2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); @@ -194,13 +186,13 @@ void testSecurityAnalysisWithOperatorStrategy() { network.getLine("L2").getTerminal1().disconnect(); network.getLine("L2").getTerminal2().disconnect(); network.getSwitch("C2").setOpen(true); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(583.624, network.getLine("L1").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(303.513, network.getLine("L3").getTerminal1().getI(), LoadFlowAssert.DELTA_I); network.getSwitch("C1").setOpen(false); network.getSwitch("C2").setOpen(false); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(441.539, network.getLine("L1").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(89.429, network.getLine("L2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); assertEquals(441.539, network.getLine("L3").getTerminal1().getI(), LoadFlowAssert.DELTA_I); @@ -370,23 +362,23 @@ void testMetrixTutorial() { assertEquals(639.268, getOperatorStrategyResult(result, "strategy3").getNetworkResult().getBranchResult("S_SO_2").getI1(), LoadFlowAssert.DELTA_I); assertEquals(639.268, getOperatorStrategyResult(result, "strategy4").getNetworkResult().getBranchResult("S_SO_2").getI1(), LoadFlowAssert.DELTA_I); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(346.296, network.getLine("S_SO_2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); network.getLine("S_SO_1").getTerminal1().disconnect(); network.getLine("S_SO_1").getTerminal2().disconnect(); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(642.805, network.getLine("S_SO_2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); network.getSwitch("SOO1_SOO1_DJ_OMN").setOpen(true); OpenLoadFlowParameters.create(parameters) .setMaxOuterLoopIterations(50); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(240.523, network.getLine("S_SO_2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); network.getSwitch("SOO1_SOO1_DJ_OMN").setOpen(false); network.getTwoWindingsTransformer("NE_NO_1").getPhaseTapChanger().setTapPosition(1); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(639.268, network.getLine("S_SO_2").getTerminal1().getI(), LoadFlowAssert.DELTA_I); } @@ -761,14 +753,14 @@ void testSaDcPhaseTapChangerTapPositionAction() { // Apply remedial action int originalTapPosition = network.getTwoWindingsTransformer("NE_NO_1").getPhaseTapChanger().getTapPosition(); network.getTwoWindingsTransformer("NE_NO_1").getPhaseTapChanger().setTapPosition(1); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); // Compare results assertEquals(network.getLine("S_SO_2").getTerminal1().getP(), brAbs.getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getBranch("S_SO_2").getTerminal2().getP(), brAbs.getP2(), LoadFlowAssert.DELTA_POWER); // Check the second operator strategy: relative change network.getTwoWindingsTransformer("NE_NO_1").getPhaseTapChanger().setTapPosition(originalTapPosition - 1); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); // Compare results assertEquals(network.getLine("S_SO_2").getTerminal1().getP(), brRel.getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getBranch("S_SO_2").getTerminal2().getP(), brRel.getP2(), LoadFlowAssert.DELTA_POWER); @@ -805,7 +797,7 @@ private void testLoadAction(boolean dc) { operatorStrategies, actions, Reporter.NO_OP); network.getLoad("l2").getTerminal().disconnect(); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); PostContingencyResult postContingencyResult = getPostContingencyResult(result, "l2"); assertEquals(network.getLine("l24").getTerminal1().getP(), postContingencyResult.getNetworkResult().getBranchResult("l24").getP1(), LoadFlowAssert.DELTA_POWER); @@ -820,7 +812,7 @@ private void testLoadAction(boolean dc) { network.getLoad("l4").setP0(90 + postContingencyL4 - initialL4); network.getLoad("l1").setP0(postContingencyL1 + 50); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); OperatorStrategyResult operatorStrategyResult = getOperatorStrategyResult(result, "strategy1"); assertEquals(network.getLine("l24").getTerminal1().getP(), operatorStrategyResult.getNetworkResult().getBranchResult("l24").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l14").getTerminal1().getP(), operatorStrategyResult.getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER); @@ -829,7 +821,7 @@ private void testLoadAction(boolean dc) { network.getLoad("l1").setP0(postContingencyL1); network.getLoad("l2").setP0(postContingencyL2); // because in contingency network.getLoad("l4").setP0(postContingencyL4); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); OperatorStrategyResult operatorStrategyResult2 = getOperatorStrategyResult(result, "strategy2"); assertEquals(network.getLine("l24").getTerminal1().getP(), operatorStrategyResult2.getNetworkResult().getBranchResult("l24").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l14").getTerminal1().getP(), operatorStrategyResult2.getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER); @@ -886,7 +878,7 @@ private void testGeneratorAction(boolean dc, LoadFlowParameters.BalanceType bala // apply contingency network.getLine(lineInContingencyId).getTerminal1().disconnect(); network.getLine(lineInContingencyId).getTerminal2().disconnect(); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(network.getLine("l12").getTerminal1().getP(), getPostContingencyResult(result, lineInContingencyId).getNetworkResult().getBranchResult("l12").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l14").getTerminal1().getP(), getPostContingencyResult(result, lineInContingencyId).getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l23").getTerminal1().getP(), getPostContingencyResult(result, lineInContingencyId).getNetworkResult().getBranchResult("l23").getP1(), LoadFlowAssert.DELTA_POWER); @@ -900,7 +892,7 @@ private void testGeneratorAction(boolean dc, LoadFlowParameters.BalanceType bala // apply remedial action network.getGenerator(g1).setTargetP(g1PostContingencyTargetP + deltaG1); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(network.getLine("l12").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG1").getNetworkResult().getBranchResult("l12").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l14").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG1").getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l23").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG1").getNetworkResult().getBranchResult("l23").getP1(), LoadFlowAssert.DELTA_POWER); @@ -909,7 +901,7 @@ private void testGeneratorAction(boolean dc, LoadFlowParameters.BalanceType bala // reverse action and apply second remedial action network.getGenerator(g1).setTargetP(g1PostContingencyTargetP); network.getGenerator(g2).setTargetP(g2PostContingencyTargetP + deltaG2); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(network.getLine("l12").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG2").getNetworkResult().getBranchResult("l12").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l14").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG2").getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l23").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG2").getNetworkResult().getBranchResult("l23").getP1(), LoadFlowAssert.DELTA_POWER); @@ -918,7 +910,7 @@ private void testGeneratorAction(boolean dc, LoadFlowParameters.BalanceType bala // reverse action and apply third remedial action network.getGenerator(g2).setTargetP(g2PostContingencyTargetP); network.getGenerator(g4).setTargetP(targetPG4 + g4PostContingencyTargetP - g4InitialTargetP); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(network.getLine("l12").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG3").getNetworkResult().getBranchResult("l12").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l14").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG3").getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l23").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG3").getNetworkResult().getBranchResult("l23").getP1(), LoadFlowAssert.DELTA_POWER); @@ -927,7 +919,7 @@ private void testGeneratorAction(boolean dc, LoadFlowParameters.BalanceType bala // reverse action and apply fourth remedial action network.getGenerator(g2).setTargetP(g2PostContingencyTargetP + deltaG2); network.getGenerator(g1).setTargetP(g1PostContingencyTargetP + deltaG1); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); assertEquals(network.getLine("l12").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG4").getNetworkResult().getBranchResult("l12").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l14").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG4").getNetworkResult().getBranchResult("l14").getP1(), LoadFlowAssert.DELTA_POWER); assertEquals(network.getLine("l23").getTerminal1().getP(), getOperatorStrategyResult(result, "strategyG4").getNetworkResult().getBranchResult("l23").getP1(), LoadFlowAssert.DELTA_POWER); @@ -1031,11 +1023,11 @@ void testHvdcAction() { // compare with a loadflow. network.getGenerator("g5").getTerminal().disconnect(); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); network.getHvdcLine("hvdc34").setActivePowerSetpoint(Math.abs(Math.abs(network.getVscConverterStation("cs3").getTerminal().getP()))); network.getHvdcLine("hvdc34").setConvertersMode(HvdcLine.ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER); parameters.setHvdcAcEmulation(false); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); OperatorStrategyResult operatorStrategyResult1 = getOperatorStrategyResult(result, "strategy1"); assertEquals(network.getLine("l13").getTerminal1().getP(), operatorStrategyResult1.getNetworkResult().getBranchResult("l13").getP1(), LoadFlowAssert.DELTA_POWER); @@ -1044,7 +1036,7 @@ void testHvdcAction() { parameters.setHvdcAcEmulation(true); network.getLoad("d2").setP0(network.getLoad("d2").getP0() - 2); - LoadFlow.run(network, parameters); + loadFlowRunner.run(network, parameters); OperatorStrategyResult operatorStrategyResult2 = getOperatorStrategyResult(result, "strategy2"); assertEquals(network.getLine("l13").getTerminal1().getP(), operatorStrategyResult2.getNetworkResult().getBranchResult("l13").getP1(), LoadFlowAssert.DELTA_POWER); diff --git a/src/test/java/com/powsybl/openloadflow/sensi/AbstractSensitivityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sensi/AbstractSensitivityAnalysisTest.java index 3c073a99e3..4395681bba 100644 --- a/src/test/java/com/powsybl/openloadflow/sensi/AbstractSensitivityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sensi/AbstractSensitivityAnalysisTest.java @@ -49,7 +49,7 @@ public abstract class AbstractSensitivityAnalysisTest extends AbstractConverterT protected final OpenLoadFlowProvider loadFlowProvider = new OpenLoadFlowProvider(matrixFactory); - protected final LoadFlow.Runner runner = new LoadFlow.Runner(loadFlowProvider); + protected final LoadFlow.Runner loadFlowRunner = new LoadFlow.Runner(loadFlowProvider); protected static SensitivityAnalysisParameters createParameters(boolean dc, String slackBusId, boolean distributedSlack) { return createParameters(dc, List.of(slackBusId), distributedSlack); diff --git a/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisTest.java b/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisTest.java index f568daa3e0..2ea68c1b20 100644 --- a/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisTest.java +++ b/src/test/java/com/powsybl/openloadflow/sensi/AcSensitivityAnalysisTest.java @@ -13,7 +13,6 @@ import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.HvdcAngleDroopActivePowerControlAdder; import com.powsybl.iidm.network.test.EurostagTutorialExample1Factory; -import com.powsybl.loadflow.LoadFlow; import com.powsybl.loadflow.LoadFlowParameters; import com.powsybl.openloadflow.OpenLoadFlowParameters; import com.powsybl.openloadflow.network.*; @@ -1012,7 +1011,7 @@ void testWithPhaseControlOn() { .setRegulationValue(83); SensitivityAnalysisParameters sensiParameters = createParameters(false); sensiParameters.getLoadFlowParameters().setPhaseShifterRegulationOn(true); - LoadFlow.run(network, sensiParameters.getLoadFlowParameters()); + loadFlowRunner.run(network, sensiParameters.getLoadFlowParameters()); List factors = SensitivityFactor.createMatrix(SensitivityFunctionType.BRANCH_ACTIVE_POWER_1, List.of("L1", "L2", "PS1"), SensitivityVariableType.INJECTION_ACTIVE_POWER, List.of("G1"), false, ContingencyContext.none()); SensitivityAnalysisResult result = sensiRunner.run(network, factors, Collections.emptyList(), Collections.emptyList(), sensiParameters); diff --git a/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java b/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java index 66cdd90a06..fab4f89354 100644 --- a/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java +++ b/src/test/java/com/powsybl/openloadflow/sensi/DcSensitivityAnalysisContingenciesTest.java @@ -2324,7 +2324,7 @@ private void testDcUseTransformerRatioIssue(boolean dcUseTransformerRatio) { double l1011p1ContPs56 = result.getBranchFlow1FunctionReferenceValue(ps56.getId(), l1011.getId()); double l1011p1ContPs49And56 = result.getBranchFlow1FunctionReferenceValue(cont49And56.getId(), l1011.getId()); - runner.run(network, sensiParameters.getLoadFlowParameters()); + loadFlowRunner.run(network, sensiParameters.getLoadFlowParameters()); assertActivePowerEquals(l1011p1, l1011.getTerminal1()); double epsSensiCompLf = 1E-13; @@ -2334,7 +2334,7 @@ private void testDcUseTransformerRatioIssue(boolean dcUseTransformerRatio) { ps49.getTerminal1().disconnect(); ps49.getTerminal2().disconnect(); - runner.run(network, sensiParameters.getLoadFlowParameters()); + loadFlowRunner.run(network, sensiParameters.getLoadFlowParameters()); assertActivePowerEquals(l1011p1ContPs49, l1011.getTerminal1()); assertEquals(calculateSensiFromLf(network, g1, l1011, sensiParameters.getLoadFlowParameters()), @@ -2345,7 +2345,7 @@ private void testDcUseTransformerRatioIssue(boolean dcUseTransformerRatio) { ps49.getTerminal2().connect(); ps56.getTerminal1().disconnect(); ps56.getTerminal2().disconnect(); - runner.run(network, sensiParameters.getLoadFlowParameters()); + loadFlowRunner.run(network, sensiParameters.getLoadFlowParameters()); assertActivePowerEquals(l1011p1ContPs56, l1011.getTerminal1()); assertEquals(calculateSensiFromLf(network, g1, l1011, sensiParameters.getLoadFlowParameters()), @@ -2354,7 +2354,7 @@ private void testDcUseTransformerRatioIssue(boolean dcUseTransformerRatio) { ps49.getTerminal1().disconnect(); ps49.getTerminal2().disconnect(); - runner.run(network, sensiParameters.getLoadFlowParameters()); + loadFlowRunner.run(network, sensiParameters.getLoadFlowParameters()); assertActivePowerEquals(l1011p1ContPs49And56, l1011.getTerminal1()); assertEquals(calculateSensiFromLf(network, g1, l1011, sensiParameters.getLoadFlowParameters()), @@ -2365,7 +2365,7 @@ private void testDcUseTransformerRatioIssue(boolean dcUseTransformerRatio) { private double calculateSensiFromLf(Network network, Generator g, Line l, LoadFlowParameters parameters) { double p1Before = l.getTerminal1().getP(); g.setTargetP(g.getTargetP() + 1); - runner.run(network, parameters); + loadFlowRunner.run(network, parameters); g.setTargetP(g.getTargetP() - 1); return l.getTerminal1().getP() - p1Before; }