From 61f9a46db39a0ea2112e7df1179f7742c6393548 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Wed, 27 Nov 2024 17:26:23 +0100 Subject: [PATCH] Add RTC on opened branch and associated TUs Signed-off-by: p-arvy --- open-reac/README.md | 18 ++-- .../src/main/resources/openreac/commons.mod | 3 +- .../powsybl/openreac/OpenReacRunnerTest.java | 85 +++++++++---------- 3 files changed, 51 insertions(+), 55 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index a92b1241..53824bc0 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -116,12 +116,12 @@ In addition to the previous parameters, the user can specify which parameters will be variable or fixed in the ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)). This is done using the following files: -| File | Description | Default behavior of modified values | -|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| -| `param_transformers.txt` | Ratio tap changers with a variable transformation ratio (real variable) | Transformation ratios are fixed | -| `param_shunt.txt` | Shunts with a continuous variable susceptance and which can be modified and/or connected (only if possible bus is defined in `ampl_network_shunts.txt`) | Shunt susceptances are fixed | -| `param_generators_reactive.txt` | Generators with a constant reactive power production. If this value is not consistent (> PQmax), the reactive power production stays variable | Coherent reactive power productions (see [4.5](#45-pq-units-domain)) are variable | -| `param_buses_with_reactive_slack.txt` | Buses with attached reactive slacks if configurable parameter buses_with_reactive_slacks = "CONFIGURED" | Only buses with no reactive power production have reactive slacks attached | +| File | Description | Default behavior of modified values | +|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| +| `param_transformers.txt` | Ratio tap changers with a variable transformation ratio (real variable). Note that ratio tap changers on branches with opened side 2 **will not be optimized**. | Transformation ratios are fixed | +| `param_shunt.txt` | Shunts with a continuous variable susceptance and which can be modified and/or connected (only if possible bus is defined in `ampl_network_shunts.txt`) | Shunt susceptances are fixed | +| `param_generators_reactive.txt` | Generators with a constant reactive power production. If this value is not consistent (> PQmax), the reactive power production stays variable | Coherent reactive power productions (see [4.5](#45-pq-units-domain)) are variable | +| `param_buses_with_reactive_slack.txt` | Buses with attached reactive slacks if configurable parameter buses_with_reactive_slacks = "CONFIGURED" | Only buses with no reactive power production have reactive slacks attached | All of these files share the same format: 2 columns #"num" "id". @@ -303,6 +303,7 @@ Please note that: even if the user designates these generators as fixed in the parameter file `param_generators_reactive.txt` (see [3.2](#32-configuration-of-the-run)). Therefore, when the optimization results are exported, **these generators are exported with a reactive power target of $0$**. - **Neither current limits nor power limits** on branches are considered in the optimization. +- Branches with opened side 1 or 2 are taken into account in the optimization. #### 7.2 Constraints @@ -407,8 +408,3 @@ of the DCOPF fails (see [6](#6-direct-current-optimal-power-flow)), the problem is considered as inconsistent. Then, the script `reactiveopfexit.run` is executed and the file `reactiveopf_results_indic.txt` described in [8.1](#81-in-case-of-convergence) is exported, without the information on the calculated angles. - -TODO -Should ratio tap changers on branch with one side opened be optimized? -Clarify if they should be taken into account on branches with side 1 opened -Surement une erreur dans le code AMPL. QUand G1 est non nul alors il y a des problèmes \ No newline at end of file diff --git a/open-reac/src/main/resources/openreac/commons.mod b/open-reac/src/main/resources/openreac/commons.mod index 63092138..000a36a8 100644 --- a/open-reac/src/main/resources/openreac/commons.mod +++ b/open-reac/src/main/resources/openreac/commons.mod @@ -131,7 +131,7 @@ set BUSVV := {n in BUSCC : bus_V0[1,n] >= min_plausible_low_voltage_limit}; # Reactive set SHUNTCC := {(1,s,n) in SHUNT: n in BUSCC or shunt_possiblebus[1,s,n] in BUSCC}; # We want to be able to reconnect shunts -set BRANCHCC_REGL := {(qq,m,n) in BRANCHCC diff BRANCHZNULL: branch_ptrRegl[1,qq,m,n] != -1 }; +set BRANCHCC_REGL := {(qq,m,n) in BRANCHCC union BRANCHCC_WITH_SIDE_2_OPENED diff BRANCHZNULL: branch_ptrRegl[1,qq,m,n] != -1 }; # ratio tap changers have impact on lines with side 1 opened set BRANCHCC_DEPH := {(qq,m,n) in BRANCHCC diff BRANCHZNULL: branch_ptrDeph[1,qq,m,n] != -1 }; set SVCCC := {(1,svc,n) in SVC: n in BUSCC}; @@ -170,6 +170,7 @@ set UNIT_FIXQ := {(g,n) in UNITON: g in PARAM_UNIT_FIXQ and abs(unit_Qc[1,g,n])< set BRANCHCC_REGL_VAR := { (qq,m,n) in BRANCHCC_REGL: qq in PARAM_TRANSFORMERS_RATIO_VARIABLE + and (qq,m,n) not in BRANCHCC_WITH_SIDE_2_OPENED # ratio tap changers on branch with side 2 opened are not optimized and regl_ratio_min[1,branch_ptrRegl[1,qq,m,n]] < regl_ratio_max[1,branch_ptrRegl[1,qq,m,n]] }; set BRANCHCC_REGL_FIX := BRANCHCC_REGL diff BRANCHCC_REGL_VAR; diff --git a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java index 02f12c95..9cc66ff2 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -452,72 +452,69 @@ void testBranchesIndicators() throws IOException { } @Test - void testLinesOpenedSide1OpenReac() throws IOException { + void testOpenLineSide1OpenReac() throws IOException { Network network = VoltageControlNetworkFactory.createWithSimpleRemoteControl(); - network.getLine("l43") - .setG2(0.1f) - .setB2(0.1f) - .getTerminal1().disconnect(); + network.getLine("l43").setG2(0.1f).setB2(0.1f).getTerminal1().disconnect(); setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network testAllModifAndLoadFlow(network, "openreac-output-real-network", new OpenReacParameters(), ReportNode.NO_OP); } - @Test - void testLinesOpenedSide2OpenReac() throws IOException { - Network network = VoltageControlNetworkFactory.createWithSimpleRemoteControl(); - network.getLine("l24") - .setG1(0.1f) - .setB1(0.1f) - .getTerminal2().disconnect(); - setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network - testAllModifAndLoadFlow(network, "openreac-output-real-network", new OpenReacParameters(), ReportNode.NO_OP); - } + + @Test - void testBranchZeroImpedanceSide1OpenedOpenReac() throws IOException { - Network network = VoltageControlNetworkFactory.createWithSimpleRemoteControl(); - network.getLine("l43") - .setX(0.0) - .getTerminal2().disconnect(); + void testZeroImpedanceOpenBranchSide1OpenReac() throws IOException { + Network network = VoltageControlNetworkFactory.createWithTwoVoltageControls(); + network.getLine("l45").setX(1e-8).setB1(1).setG1(0.1).getTerminal2().disconnect(); setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network - testAllModifAndLoadFlow(network, "openreac-output-real-network", new OpenReacParameters(), ReportNode.NO_OP); + + OpenReacResult result = runOpenReac(network, "", new OpenReacParameters(), ReportNode.NO_OP); + // opened branch is considered as non impedant + assertEquals("1", result.getIndicators().get("nb_branch_with_zero_or_small_impedance")); + + assertEquals(OpenReacStatus.OK, result.getStatus()); + result.applyAllModifications(network); + LoadFlowResult loadFlowResult = LoadFlow.run(network); + assertTrue(loadFlowResult.isFullyConverged()); } @Test - void testBranchZeroImpedanceSide2OpenedOpenReac() throws IOException { - Network network = VoltageControlNetworkFactory.createWithSimpleRemoteControl(); - network.getLine("l43") - .setX(0.0) - .getTerminal1().disconnect(); + void testZeroImpedanceOpenBranchSide2OpenReac() throws IOException { + Network network = VoltageControlNetworkFactory.createNetworkWith2T2wt(); + network.getTwoWindingsTransformer("T2wT2").setR(0.0).setX(1e-8).setG(0.01).setB(0.1).getTerminal1().disconnect(); setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network - testAllModifAndLoadFlow(network, "openreac-output-real-network", new OpenReacParameters(), ReportNode.NO_OP); - } - @Test - void testBranchWithRatioTapChangerSide1OpenedOpenReac() { - // TODO - } + OpenReacResult result = runOpenReac(network, "", new OpenReacParameters(), ReportNode.NO_OP); + // opened branch is considered as non impedant + assertEquals("1", result.getIndicators().get("nb_branch_with_zero_or_small_impedance")); - @Test - void testBranchWithPhaseTapChangerSide1OpenedOpenReac() { - // TODO + assertEquals(OpenReacStatus.OK, result.getStatus()); + result.applyAllModifications(network); + LoadFlowResult loadFlowResult = LoadFlow.run(network); + assertTrue(loadFlowResult.isFullyConverged()); } @Test - void testBranchWithRatioTapChangerSide2OpenedOpenReac() { - // TODO + void testRatioTapChangerOpenSide1OpenReac() throws IOException { + Network network = VoltageControlNetworkFactory.createNetworkWithT2wt(); + network.getTwoWindingsTransformer("T2wT").getTerminal2().disconnect(); + setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network + testAllModifAndLoadFlow(network, "", new OpenReacParameters(), ReportNode.NO_OP); } @Test - void testBranchWithPhaseTapChangerSide2OpenedOpenReac() { - // TODO + void testRatioTapChangerOpenSide2OpenReac() throws IOException { + Network network = VoltageControlNetworkFactory.createNetworkWithT2wt(); + network.getTwoWindingsTransformer("T2wT").getTerminal2().disconnect(); + setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network + testAllModifAndLoadFlow(network, "", new OpenReacParameters(), ReportNode.NO_OP); } @Test - // TODO : to be clarified if we take into account the ratio tap changers on branches that are opened... - void testRatioTapChangerNotOptimizedIfOpenSide2() throws IOException { + void testRatioTapChangerNotOptimizedOnOpenBranchSide2() throws IOException { Network network = VoltageControlNetworkFactory.createNetworkWith2T2wt(); network.getTwoWindingsTransformer("T2wT1").getTerminal2().disconnect(); + network.getTwoWindingsTransformer("T2wT2").getRatioTapChanger().setTapPosition(3); setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network OpenReacParameters parameters = new OpenReacParameters(); @@ -528,8 +525,10 @@ void testRatioTapChangerNotOptimizedIfOpenSide2() throws IOException { assertEquals("1", result.getIndicators().get("nb_transformers_with_variable_ratio")); assertEquals("1", result.getIndicators().get("nb_transformers_with_fixed_ratio")); - // verify tap of optimized rtc has changed - assertEquals(); + // verify only tap of optimized rtc has changed + result.applyAllModifications(network); + assertEquals(0, network.getTwoWindingsTransformer("T2wT1").getRatioTapChanger().getTapPosition()); + assertEquals(0, network.getTwoWindingsTransformer("T2wT2").getRatioTapChanger().getTapPosition()); } public static Network create() {