diff --git a/open-reac/src/main/resources/openreac/acopf_preprocessing.run b/open-reac/src/main/resources/openreac/acopf_preprocessing.run index 59fd08fd..1ddc6dc8 100644 --- a/open-reac/src/main/resources/openreac/acopf_preprocessing.run +++ b/open-reac/src/main/resources/openreac/acopf_preprocessing.run @@ -175,10 +175,17 @@ for {(g,n) in UNITON} { } if abs(unit_qp[1,g,n]) >= PQmax then { - let corrected_unit_qp[g,n] := -defaultQmaxPmaxRatio * corrected_unit_Pmax[g,n]; - printf{LOG_DEBUG} "%Q for %Q is %Q -> corrected to %Q\n","unit_qp",unit_id[1,g,n],unit_qp[1,g,n],corrected_unit_qp[g,n]; - } - else let corrected_unit_qp[g,n] := unit_qp[1,g,n]; + let corrected_unit_qp[g,n] := -defaultQmaxPmaxRatio * corrected_unit_Pmax[g,n]; + printf{LOG_DEBUG} "%Q for %Q is %Q -> corrected to %Q\n","unit_qp",unit_id[1,g,n],unit_qp[1,g,n],corrected_unit_qp[g,n]; + } + else let corrected_unit_qp[g,n] := unit_qp[1,g,n]; + + # TODO : update print + if abs(unit_qp0[1,g,n]) >= PQmax then { + let corrected_unit_q0[g,n] := -defaultQmaxPmaxRatio * corrected_unit_Pmax[g,n]; + printf{LOG_DEBUG} "%Q for %Q is %Q -> corrected to %Q\n","unit_qp",unit_id[1,g,n],unit_qp[1,g,n],corrected_unit_qp[g,n]; + } + else let corrected_unit_q0[g,n] := unit_qp0[1,g,n]; if abs(unit_qP[1,g,n]) >= PQmax then { let corrected_unit_qP[g,n] := -defaultQmaxPmaxRatio * corrected_unit_Pmax[g,n]; @@ -187,10 +194,17 @@ for {(g,n) in UNITON} { else let corrected_unit_qP[g,n] := unit_qP[1,g,n]; if abs(unit_Qp[1,g,n]) >= PQmax then { - let corrected_unit_Qp[g,n] := defaultQmaxPmaxRatio * corrected_unit_Pmax[g,n]; - printf{LOG_DEBUG} "%Q for %Q is %Q -> corrected to %Q\n","unit_Qp",unit_id[1,g,n],unit_Qp[1,g,n],corrected_unit_Qp[g,n]; - } - else let corrected_unit_Qp[g,n] := unit_Qp[1,g,n]; + let corrected_unit_Qp[g,n] := defaultQmaxPmaxRatio * corrected_unit_Pmax[g,n]; + printf{LOG_DEBUG} "%Q for %Q is %Q -> corrected to %Q\n","unit_Qp",unit_id[1,g,n],unit_Qp[1,g,n],corrected_unit_Qp[g,n]; + } + else let corrected_unit_Qp[g,n] := unit_Qp[1,g,n]; + + # TODO : update print + if abs(unit_Qp0[1,g,n]) >= PQmax then { + let corrected_unit_Q0[g,n] := defaultQmaxPmaxRatio * corrected_unit_Pmax[g,n]; + printf{LOG_DEBUG} "%Q for %Q is %Q -> corrected to %Q\n","unit_Qp",unit_id[1,g,n],unit_Qp[1,g,n],corrected_unit_Qp[g,n]; + } + else let corrected_unit_Q0[g,n] := unit_Qp0[1,g,n]; if abs(unit_QP[1,g,n]) >= PQmax then { let corrected_unit_QP[g,n] := defaultQmaxPmaxRatio * corrected_unit_Pmax[g,n]; @@ -206,12 +220,20 @@ for {(g,n) in UNITON} { } if corrected_unit_qP[g,n] > corrected_unit_QP[g,n] then { - printf{LOG_WARNING} "Warning unit %Q : unit_qP > unit_QP -> we invert them",unit_id[1,g,n]; - let tempo := corrected_unit_qP[g,n]; - let corrected_unit_qP[g,n] := corrected_unit_QP[g,n]; - let corrected_unit_QP[g,n] := tempo; - } + printf{LOG_WARNING} "Warning unit %Q : unit_qP > unit_QP -> we invert them",unit_id[1,g,n]; + let tempo := corrected_unit_qP[g,n]; + let corrected_unit_qP[g,n] := corrected_unit_QP[g,n]; + let corrected_unit_QP[g,n] := tempo; + } + + if corrected_unit_q0[g,n] > corrected_unit_Q0[g,n] then { + printf{LOG_WARNING} "Warning unit %Q : unit_qP > unit_QP -> we invert them",unit_id[1,g,n]; + let tempo := corrected_unit_q0[g,n]; + let corrected_unit_q0[g,n] := corrected_unit_Q0[g,n]; + let corrected_unit_Q0[g,n] := tempo; + } + # TODO : add corner cases here if abs(corrected_unit_qP[g,n]-corrected_unit_QP[g,n]) <= minimalQPrange and abs(corrected_unit_qp[g,n]-corrected_unit_Qp[g,n]) <= minimalQPrange and abs(corrected_unit_QP[g,n]-corrected_unit_qp[g,n]) <= minimalQPrange @@ -225,8 +247,28 @@ for {(g,n) in UNITON} { let corrected_unit_Qp[g,n] := tempo; } - let corrected_unit_Qmin[g,n] := min(corrected_unit_qP[g,n],corrected_unit_qp[g,n]); - let corrected_unit_Qmax[g,n] := min(corrected_unit_QP[g,n],corrected_unit_Qp[g,n]); + # cases when Qmin/Qmax are taken between Pmin and Pmax + if (unit_Pc[1,g,n] >= corrected_unit_Pmin[g,n] and unit_Pc[1,g,n] <= corrected_unit_Pmax[g,n] and (corrected_unit_Pmin[g,n] > 0 or corrected_unit_Pmax[g,n] < 0)) then { + let corrected_unit_Qmin[g,n] := corrected_unit_qp[g,n] + (unit_Pc[1,g,n] - corrected_unit_Pmin[g,n]) / (corrected_unit_Pmax[g,n] - corrected_unit_Pmin[g,n]) * (corrected_unit_qP[g,n] - corrected_unit_qp[g,n]); + let corrected_unit_Qmax[g,n] := corrected_unit_Qp[g,n] + (unit_Pc[1,g,n] - corrected_unit_Pmin[g,n]) / (corrected_unit_Pmax[g,n] - corrected_unit_Pmin[g,n]) * (corrected_unit_QP[g,n] - corrected_unit_Qp[g,n]); + + # cases when Qmin/Qmax are taken between 0 and Pmax + } else if ((unit_Pc[1,g,n] >= corrected_unit_Pmin[g,n] and unit_Pc[1,g,n] <= corrected_unit_Pmax[g,n] and unit_Pc[1,g,n] > 0) + or (unit_Pc[1,g,n] < 0 and unit_Pc[1,g,n] >= corrected_unit_Pmax[g,n])) then { + let corrected_unit_Qmin[g,n] := corrected_unit_q0[g,n] + (unit_Pc[1,g,n] - 0) / (corrected_unit_Pmax[g,n] - 0) * (corrected_unit_qP[g,n] - corrected_unit_q0[g,n]); + let corrected_unit_Qmax[g,n] := corrected_unit_Q0[g,n] + (unit_Pc[1,g,n] - 0) / (corrected_unit_Pmax[g,n] - 0) * (corrected_unit_QP[g,n] - corrected_unit_Q0[g,n]); + + # cases when Qmin/Qmax are taken between 0 and Pmin + } else if ((unit_Pc[1,g,n] >= corrected_unit_Pmin[g,n] and unit_Pc[1,g,n] <= corrected_unit_Pmax[g,n] and unit_Pc[1,g,n] < 0) + or (unit_Pc[1,g,n] > 0 and unit_Pc[1,g,n] <= corrected_unit_Pmin[g,n])) then { + let corrected_unit_Qmin[g,n] := corrected_unit_qp[g,n] + (unit_Pc[1,g,n] - corrected_unit_Pmin[g,n]) / (0 - corrected_unit_Pmin[g,n]) * (corrected_unit_q0[g,n] - corrected_unit_qp[g,n]); + let corrected_unit_Qmax[g,n] := corrected_unit_Qp[g,n] + (unit_Pc[1,g,n] - corrected_unit_Pmin[g,n]) / (0 - corrected_unit_Pmin[g,n]) * (corrected_unit_Q0[g,n] - corrected_unit_Qp[g,n]); + } else { + # TODO : add case when P_t is not in ramp up/down or in the diagram + # TODO : same when diagram has only 4 points... + let corrected_unit_Qmin[g,n] := min(corrected_unit_qP[g,n],corrected_unit_qp[g,n]); + let corrected_unit_Qmax[g,n] := min(corrected_unit_QP[g,n],corrected_unit_Qp[g,n]); + } if unit_Pc[1,g,n] > corrected_unit_Pmax[g,n] or unit_Pc[1,g,n] < corrected_unit_Pmin[g,n] then printf{LOG_WARNING} "Warning unit %Q Pc=%Q not in bounds [ Pmin=%Q ; Pmax=%Q ]\n", diff --git a/open-reac/src/main/resources/openreac/commons.mod b/open-reac/src/main/resources/openreac/commons.mod index e90a63b0..098f4079 100644 --- a/open-reac/src/main/resources/openreac/commons.mod +++ b/open-reac/src/main/resources/openreac/commons.mod @@ -228,7 +228,9 @@ param corrected_unit_Pmin{UNITON} default defaultPmin; param corrected_unit_Pmax{UNITON} default defaultPmax; param corrected_unit_qP {UNITON} default defaultQmin; param corrected_unit_qp {UNITON} default defaultQmin; +param corrected_unit_q0 {UNITON} default defaultQmin; param corrected_unit_QP {UNITON} default defaultQmax; param corrected_unit_Qp {UNITON} default defaultQmax; +param corrected_unit_Q0 {UNITON} default defaultQmax; param corrected_unit_Qmin{UNITON} default defaultQmin; param corrected_unit_Qmax{UNITON} default defaultQmax; \ No newline at end of file diff --git a/open-reac/src/main/resources/openreac/iidm_importer.mod b/open-reac/src/main/resources/openreac/iidm_importer.mod index eb902755..c1a4bb59 100644 --- a/open-reac/src/main/resources/openreac/iidm_importer.mod +++ b/open-reac/src/main/resources/openreac/iidm_importer.mod @@ -124,7 +124,7 @@ check {(t,g,n) in UNIT}: t in TIME; check {(t,g,n) in UNIT}: (t,n) in BUS or n==-1; check {(t,g,n) in UNIT}: (t,unit_substation[t,g,n]) in SUBSTATIONS; check {(t,g,n) in UNIT}: (t,unit_vregul_bus[t,g,n]) in BUS or unit_vregul_bus[t,g,n] == -1; -check {(t,g,n) in UNIT}: unit_Pmax[t,g,n] >= -Pnull; +#check {(t,g,n) in UNIT}: unit_Pmax[t,g,n] >= -Pnull; check {(t,g,n) in UNIT}: unit_Pmax[t,g,n] >= unit_Pmin[t,g,n]; # Checks below are useless since values will be corrected for units in UNITON #check {(t,g,n) in UNIT}: unit_Qp[t,g,n] >= unit_qp[t,g,n]; diff --git a/open-reac/src/test/java/com/powsybl/openreac/network/AbstractLoadFlowNetworkFactory.java b/open-reac/src/test/java/com/powsybl/openreac/network/AbstractLoadFlowNetworkFactory.java index 4baf9161..a266874d 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/network/AbstractLoadFlowNetworkFactory.java +++ b/open-reac/src/test/java/com/powsybl/openreac/network/AbstractLoadFlowNetworkFactory.java @@ -62,7 +62,7 @@ protected static Generator createGenerator(Bus b, String id, double p, double v) .setConnectableBus(b.getId()) .setEnergySource(EnergySource.OTHER) .setMinP(0) - .setMaxP(p) + .setMaxP(2) .setTargetP(p) .setTargetV(v) .setVoltageRegulatorOn(true) diff --git a/open-reac/src/test/java/com/powsybl/openreac/network/VoltageControlNetworkFactory.java b/open-reac/src/test/java/com/powsybl/openreac/network/VoltageControlNetworkFactory.java index f93c5337..1c038cc3 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/network/VoltageControlNetworkFactory.java +++ b/open-reac/src/test/java/com/powsybl/openreac/network/VoltageControlNetworkFactory.java @@ -915,15 +915,12 @@ public static Network createWithShuntSharedRemoteControl() { } /** - * SVC test case. - * * g1 ld1 * | | * b1---------b2 - * l1 | - * svc1 + * l1 */ - public static Network createWithStaticVarCompensator() { + public static Network createWithTwoBuses() { Network network = Network.create("svc", "test"); Substation s1 = network.newSubstation() .setId("S1") @@ -964,14 +961,6 @@ public static Network createWithStaticVarCompensator() { .setP0(101) .setQ0(150) .add(); - vl2.newStaticVarCompensator() - .setId("svc1") - .setConnectableBus("b2") - .setBus("b2") - .setRegulationMode(StaticVarCompensator.RegulationMode.OFF) - .setBmin(-0.008) - .setBmax(0.008) - .add(); network.newLine() .setId("l1") .setBus1("b1") @@ -982,6 +971,28 @@ public static Network createWithStaticVarCompensator() { return network; } + /** + * SVC test case. + * + * g1 ld1 + * | | + * b1---------b2 + * l1 | + * svc1 + */ + public static Network createWithStaticVarCompensator() { + Network network = createWithTwoBuses(); + network.getVoltageLevel("vl2").newStaticVarCompensator() + .setId("svc1") + .setConnectableBus("b2") + .setBus("b2") + .setRegulationMode(StaticVarCompensator.RegulationMode.OFF) + .setBmin(-0.008) + .setBmax(0.008) + .add(); + return network; + } + /** * l1 - b1 ================ b2 - g2 * || | diff --git a/open-reac/src/test/java/com/powsybl/openreac/optimization/AbstractOpenReacRunnerTest.java b/open-reac/src/test/java/com/powsybl/openreac/optimization/AbstractOpenReacRunnerTest.java index d6fb60fe..2c3158c2 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/optimization/AbstractOpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/optimization/AbstractOpenReacRunnerTest.java @@ -12,7 +12,6 @@ import com.powsybl.commons.test.ComparisonUtils; import com.powsybl.computation.ComputationManager; import com.powsybl.computation.local.LocalCommandExecutor; -import com.powsybl.computation.local.LocalComputationConfig; import com.powsybl.computation.local.LocalComputationManager; import com.powsybl.iidm.network.*; import com.powsybl.loadflow.LoadFlow; @@ -20,6 +19,7 @@ import com.powsybl.openreac.OpenReacConfig; import com.powsybl.openreac.OpenReacRunner; import com.powsybl.openreac.parameters.input.OpenReacParameters; +import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; import com.powsybl.openreac.parameters.output.OpenReacResult; import com.powsybl.openreac.parameters.output.OpenReacStatus; import org.junit.jupiter.api.AfterEach; @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.concurrent.ForkJoinPool; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -135,11 +134,14 @@ protected OpenReacResult runOpenReac(Network network, String subFolder, OpenReac } LocalCommandExecutor localCommandExecutor = new TestLocalCommandExecutor(outputFileNames); // To really run open reac, use the commentede line below. Be sure that open-reac/src/test/resources/com/powsybl/config/test/config.yml contains your ampl path -// try (ComputationManager computationManager = new LocalComputationManager()) { - try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), - localCommandExecutor, ForkJoinPool.commonPool())) { - return OpenReacRunner.run(network, network.getVariantManager().getWorkingVariantId(), parameters, + try (ComputationManager computationManager = new LocalComputationManager()) { +// try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), +// localCommandExecutor, ForkJoinPool.commonPool())) { + parameters.setLogLevelAmpl(OpenReacAmplLogLevel.DEBUG); + OpenReacResult result = OpenReacRunner.run(network, network.getVariantManager().getWorkingVariantId(), parameters, new OpenReacConfig(true), computationManager, reportNode, null); + System.out.println(result.getIndicators().get("directory")); + return result; } } diff --git a/open-reac/src/test/java/com/powsybl/openreac/optimization/OpecReacOptimizationBoundsTest.java b/open-reac/src/test/java/com/powsybl/openreac/optimization/OpecReacOptimizationBoundsTest.java index 33c27b80..ceb3619a 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/optimization/OpecReacOptimizationBoundsTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/optimization/OpecReacOptimizationBoundsTest.java @@ -7,9 +7,12 @@ */ package com.powsybl.openreac.optimization; -import com.powsybl.iidm.network.Network; +import com.powsybl.iidm.network.*; +import com.powsybl.loadflow.LoadFlow; +import com.powsybl.loadflow.LoadFlowResult; import com.powsybl.openreac.network.VoltageControlNetworkFactory; import com.powsybl.openreac.parameters.input.OpenReacParameters; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import com.powsybl.openreac.parameters.output.OpenReacResult; import com.powsybl.openreac.parameters.output.OpenReacStatus; import org.junit.jupiter.api.Test; @@ -67,61 +70,171 @@ void testGeneratorsMinPBounds() throws IOException { assertEquals(OpenReacStatus.OK, result.getStatus()); } +// @Test +// void testGeneratorQmaxPmaxRatioBounds() throws IOException { +// Network network = VoltageControlNetworkFactory.createWithTwoVoltageControls(); +// network.getLine("l45").disconnect(); +// network.getLoad("l4").setP0(4).setQ0(2); +// +// OpenReacParameters parameters = new OpenReacParameters(); +// OpenReacResult result = runOpenReac(network, "optimization/bounds/qmax-pmax-default-ratio", parameters, true); +// assertEquals(OpenReacStatus.OK, result.getStatus()); +// // there are slacks as Q bounds are not large enough +// assertTrue(Integer.parseInt(result.getIndicators().get("nb_reactive_slacks")) > 0); +// +// parameters.setDefaultQmaxPmaxRatio(1); +// result = runOpenReac(network, "optimization/bounds/same-qmax-pmax", parameters, true); +// assertEquals(OpenReacStatus.OK, result.getStatus()); +// // Q bounds are large enough to remove reactive slacks in optimization +// assertEquals(0, Integer.parseInt(result.getIndicators().get("nb_reactive_slacks"))); +// } + @Test - void testGeneratorRectangularQBounds() throws IOException { - Network network = VoltageControlNetworkFactory.createWithTwoVoltageControls(); - network.getLine("l45").disconnect(); - network.getLoad("l4").setP0(4).setQ0(2); + void testGeneratorQBoundsTargetPInsidePminPmax() throws IOException { + Network network = createWithTwoBuses(101, 50, 150, 0, -100, 100, 150, -200, 200, 150); + assertConvergence(network); + network = createWithTwoBuses(101, 50, 150, 0, -100, 100, 150, -150, 150, 150); + assertDivergence(network); + } - // set reactive limits to both generators - network.getGenerator("g2").newReactiveCapabilityCurve() - .beginPoint() - .setP(0) - .setMinQ(-0.25) - .setMaxQ(0.25) - .endPoint() - .beginPoint() - .setP(2) - .setMinQ(-2) - .setMaxQ(2) - .endPoint() - .add(); - network.getGenerator("g3").newReactiveCapabilityCurve() - .beginPoint() - .setP(0) - .setMinQ(-0.25) - .setMaxQ(0.25) - .endPoint() - .beginPoint() - .setP(2) - .setMinQ(-2) - .setMaxQ(2) - .endPoint() - .add(); + @Test + void testGeneratorQBoundsTargetPInsidePminPmax2() throws IOException { + Network network = createWithTwoBuses(-10, -20, -5, -20, -30, 30, -5, -5, 5, -10); + assertConvergence(network); + network = createWithTwoBuses(-10, -20, -5, -20, -18, 18, -5, -5, 5, -10); + assertDivergence(network); + } - OpenReacResult result = runOpenReac(network, "optimization/bounds/generator-rectangular-bounds", true); - assertEquals(OpenReacStatus.OK, result.getStatus()); - // rectangular bounds in ACOPF implies Q bounds are not large enough to remove reactive slacks in optimization - assertTrue(Integer.parseInt(result.getIndicators().get("nb_reactive_slacks")) > 0); + @Test + void testGeneratorQBoundsTargetPInside0Pmax() throws IOException { + Network network = createWithTwoBuses(101, -50, 150, 0, -0, 0, 150, -300, 300, 150); + assertConvergence(network); + network = createWithTwoBuses(101, -50, 150, 0, -0, 0, 150, -100, 100, 150); + assertDivergence(network); } @Test - void testGeneratorQmaxPmaxRatioBounds() throws IOException { - Network network = VoltageControlNetworkFactory.createWithTwoVoltageControls(); - network.getLine("l45").disconnect(); - network.getLoad("l4").setP0(4).setQ0(2); + void testGeneratorQBoundsTargetPInside0Pmax2() throws IOException { + Network network = createWithTwoBuses(-4, -20, -5, -5, -5, 5, 0, -1, 1, -4); + assertConvergence(network); + network = createWithTwoBuses(-4, -20, -5, -5, -4.25, 4.25, 0, -1, 1, -4); + assertDivergence(network); + } + + @Test + void testGeneratorQBoundsTargetPInside0Pmin() throws IOException { + Network network = createWithTwoBuses(101, 150, 200, + 0, -0, 0, + 150, -150, 150, 100); + assertConvergence(network); + network = createWithTwoBuses(101, 150, 200, + 0, -0, 0, + 150, -140, 140, 100); + assertDivergence(network); + } + @Test + void testGeneratorQBoundsTargetPInside0Pmin2() throws IOException { + Network network = createWithTwoBuses(-5.1, -10, 10, + 0, -0, 0, + -10, -4, 4, + -2); + assertConvergence(network); + network = createWithTwoBuses(-5.1, -10, 10, + 0, -0, 0, + -10, -3.8, 3.8, + -2); + assertDivergence(network); + } + + void assertConvergence(Network network) throws IOException { OpenReacParameters parameters = new OpenReacParameters(); - OpenReacResult result = runOpenReac(network, "optimization/bounds/qmax-pmax-default-ratio", parameters, true); + parameters.setMinPlausibleLowVoltageLimit(0.4); + parameters.setMaxPlausibleHighVoltageLimit(1.6); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED); + OpenReacResult result = runOpenReac(network, "", parameters, false); assertEquals(OpenReacStatus.OK, result.getStatus()); - // there are slacks as Q bounds are not large enough - assertTrue(Integer.parseInt(result.getIndicators().get("nb_reactive_slacks")) > 0); + LoadFlowResult loadFlowResult = LoadFlow.run(network); + assertTrue(loadFlowResult.isFullyConverged()); + } - parameters.setDefaultQmaxPmaxRatio(1); - result = runOpenReac(network, "optimization/bounds/same-qmax-pmax", parameters, true); - assertEquals(OpenReacStatus.OK, result.getStatus()); - // Q bounds are large enough to remove reactive slacks in optimization - assertEquals(0, Integer.parseInt(result.getIndicators().get("nb_reactive_slacks"))); + void assertDivergence(Network network) throws IOException { + OpenReacParameters parameters = new OpenReacParameters(); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED); + OpenReacResult result = runOpenReac(network, "", parameters, false); + assertEquals(OpenReacStatus.NOT_OK, result.getStatus()); + } + + /** + * g1 ld1 + * | | + * b1---------b2 + * l1 + */ + public static Network createWithTwoBuses(double g1TargetP, double g1PMin, double g1PMax, + double pValue1, double g1QMin1, double g1QMax1, + double pValue2, double g1QMin2, double g1QMax2, + double ld1TargetQ) { + Network network = Network.create("q-bounds", "test"); + Substation s1 = network.newSubstation() + .setId("S1") + .add(); + Substation s2 = network.newSubstation() + .setId("S2") + .add(); + VoltageLevel vl1 = s1.newVoltageLevel() + .setId("vl1") + .setNominalV(400) + .setTopologyKind(TopologyKind.BUS_BREAKER) + .add(); + vl1.getBusBreakerView().newBus() + .setId("b1") + .add(); + vl1.newGenerator() + .setId("g1") + .setConnectableBus("b1") + .setBus("b1") + .setTargetP(g1TargetP) + .setTargetV(390) + .setMinP(g1PMin) + .setMaxP(g1PMax) + .setVoltageRegulatorOn(true) + .add(); + network.getGenerator("g1").newReactiveCapabilityCurve() + .beginPoint() + .setP(pValue1) + .setMinQ(g1QMin1) + .setMaxQ(g1QMax1) + .endPoint() + .beginPoint() + .setP(pValue2) + .setMinQ(g1QMin2) + .setMaxQ(g1QMax2) + .endPoint() + .add(); + VoltageLevel vl2 = s2.newVoltageLevel() + .setId("vl2") + .setNominalV(400) + .setTopologyKind(TopologyKind.BUS_BREAKER) + .add(); + vl2.getBusBreakerView().newBus() + .setId("b2") + .add(); + vl2.newLoad() + .setId("ld1") + .setConnectableBus("b2") + .setBus("b2") + .setP0(g1TargetP) + .setQ0(ld1TargetQ) + .add(); + network.newLine() + .setId("l1") + .setBus1("b1") + .setBus2("b2") + .setR(0.1) + .setX(3) + .add(); + return network; } } diff --git a/open-reac/src/test/resources/com/powsybl/config/test/config.yml b/open-reac/src/test/resources/com/powsybl/config/test/config.yml index 1acd4f0d..9d797384 100644 --- a/open-reac/src/test/resources/com/powsybl/config/test/config.yml +++ b/open-reac/src/test/resources/com/powsybl/config/test/config.yml @@ -1,2 +1,2 @@ ampl: - homeDir: ??? + homeDir: D:\AMPL-13.1.20220703-Win-64