From dcdd456f392b26508205e7d29a2fe4322e8a2a70 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Thu, 16 May 2024 12:40:09 +0200 Subject: [PATCH 01/10] Reactive slacks on all buses by default. Signed-off-by: p-arvy --- .../powsybl/openreac/parameters/input/OpenReacParameters.java | 2 +- open-reac/src/main/resources/openreac/reactiveopf.run | 2 +- .../java/com/powsybl/openreac/OpenReacParametersTest.java | 4 ++-- .../test/java/com/powsybl/openreac/OpenReacRunnerTest.java | 2 +- .../test/resources/openreac-input-algo-parameters/default.txt | 2 +- .../openreac-input-algo-parameters/modified_param_algo.txt | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java index 4d945ff4..c509a0ce 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java @@ -58,7 +58,7 @@ public class OpenReacParameters { private double maxPlausibleHighVoltageLimit = 1.5; // in pu - private ReactiveSlackBusesMode reactiveSlackBusesMode = ReactiveSlackBusesMode.NO_GENERATION; + private ReactiveSlackBusesMode reactiveSlackBusesMode = ReactiveSlackBusesMode.ALL; private static final String ACTIVE_POWER_VARIATION_RATE_KEY = "coeff_alpha"; diff --git a/open-reac/src/main/resources/openreac/reactiveopf.run b/open-reac/src/main/resources/openreac/reactiveopf.run index 240b222f..976ac5ab 100644 --- a/open-reac/src/main/resources/openreac/reactiveopf.run +++ b/open-reac/src/main/resources/openreac/reactiveopf.run @@ -316,7 +316,7 @@ if ignore_voltage_bounds >= epsilon_nominal_voltage then printf{LOG_INFO} "Parameter: for all busses with nominal voltage <= ignore_voltage_bounds=%.1f, voltage bounds are ignored and replaced by [%.3f;%.3f]\n",ignore_voltage_bounds,min_plausible_low_voltage_limit,max_plausible_high_voltage_limit; check ignore_voltage_bounds >= 0; -param buses_with_reactive_slacks symbolic default "NO_GENERATION"; +param buses_with_reactive_slacks symbolic default "ALL"; if "buses_with_reactive_slacks" in PARAM_ALGO_KEYS then let buses_with_reactive_slacks := PARAM_ALGO_VALUES["buses_with_reactive_slacks"]; printf{LOG_INFO} "Parameter: choice for buses with reactive slacks in ACOPF := %Q (%s)\n", buses_with_reactive_slacks, if buses_with_reactive_slacks == "ALL" then "every bus in connex component." diff --git a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java index 4b4f3665..6b982122 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java @@ -355,7 +355,7 @@ void testAlgorithmParams() { void testBusesWithReactiveSlackConfigIntegrity() { OpenReacParameters parameters = new OpenReacParameters(); - assertEquals(ReactiveSlackBusesMode.NO_GENERATION, parameters.getReactiveSlackBusesMode()); // default value + assertEquals(ReactiveSlackBusesMode.ALL, parameters.getReactiveSlackBusesMode()); // default value assertThrows(NullPointerException.class, () -> parameters.setReactiveSlackBusesMode(null)); parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED); assertEquals("CONFIGURED", parameters.getReactiveSlackBusesMode().toParam().getValue()); @@ -374,7 +374,7 @@ void testDefaultParametersValuesIntegrity() { assertEquals(OpenReacSolverLogLevel.EVERYTHING, parameters.getLogLevelSolver()); assertEquals(0.5, parameters.getMinPlausibleLowVoltageLimit()); assertEquals(1.5, parameters.getMaxPlausibleHighVoltageLimit()); - assertEquals(ReactiveSlackBusesMode.NO_GENERATION, parameters.getReactiveSlackBusesMode()); + assertEquals(ReactiveSlackBusesMode.ALL, parameters.getReactiveSlackBusesMode()); assertEquals(1., parameters.getActivePowerVariationRate()); assertEquals(0.01, parameters.getMinPlausibleActivePowerThreshold()); assertEquals(1e-4, parameters.getLowImpedanceThreshold()); 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 8be99c84..5f5a5f80 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -104,7 +104,7 @@ void testModifiedParamAlgoExport() throws IOException { .setLogLevelSolver(OpenReacSolverLogLevel.ONLY_RESULTS) .setMinPlausibleLowVoltageLimit(0.7888) .setMaxPlausibleHighVoltageLimit(1.3455) - .setReactiveSlackBusesMode(ReactiveSlackBusesMode.ALL) + .setReactiveSlackBusesMode(ReactiveSlackBusesMode.NO_GENERATION) .setActivePowerVariationRate(0.88) .setMinPlausibleActivePowerThreshold(0.45) .setLowImpedanceThreshold(1e-5) diff --git a/open-reac/src/test/resources/openreac-input-algo-parameters/default.txt b/open-reac/src/test/resources/openreac-input-algo-parameters/default.txt index 73774fb2..3066948e 100644 --- a/open-reac/src/test/resources/openreac-input-algo-parameters/default.txt +++ b/open-reac/src/test/resources/openreac-input-algo-parameters/default.txt @@ -3,7 +3,7 @@ log_level_ampl INFO log_level_knitro 2 min_plausible_low_voltage_limit 0.5 max_plausible_high_voltage_limit 1.5 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL coeff_alpha 1.0 Pnull 0.01 Znull 1.0E-4 diff --git a/open-reac/src/test/resources/openreac-input-algo-parameters/modified_param_algo.txt b/open-reac/src/test/resources/openreac-input-algo-parameters/modified_param_algo.txt index b2af5a2c..d93ef083 100644 --- a/open-reac/src/test/resources/openreac-input-algo-parameters/modified_param_algo.txt +++ b/open-reac/src/test/resources/openreac-input-algo-parameters/modified_param_algo.txt @@ -4,7 +4,7 @@ log_level_ampl WARNING log_level_knitro 1 min_plausible_low_voltage_limit 0.7888 max_plausible_high_voltage_limit 1.3455 -buses_with_reactive_slacks ALL +buses_with_reactive_slacks NO_GENERATION coeff_alpha 0.88 Pnull 0.45 Znull 1.0E-5 From ecb8f118e2dec0d102a37a656e6efe022ab916eb Mon Sep 17 00:00:00 2001 From: p-arvy Date: Thu, 16 May 2024 12:41:26 +0200 Subject: [PATCH 02/10] Update default value in README. Signed-off-by: p-arvy --- open-reac/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open-reac/README.md b/open-reac/README.md index b501e488..5270bc66 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -94,7 +94,7 @@ These are specified in the file `param_algo.txt`: | `min_plausible_low_voltage_limit` | Consistency bound for low voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $0.5$ (p.u.) | $\mathbb{R}^{+}$ | | `max_plausible_high_voltage_limit` | Consistency bound for high voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $1.5$ (p.u.) | [`min_plausible_low_voltage_limit`; $\infty$] | | `ignore_voltage_bounds` | Threshold to replace voltage limits of voltage levels with nominal voltage lower than it, by [min_plausible_low_voltage_limit; max_plausible_high_voltage_limit] | $0$ (p.u.) | $\mathbb{R}^{+}$ | -| `buses_with_reactive_slacks` | Choice of which buses will have reactive slacks attached in ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | NO_GENERATION | {CONFIGURED, NO_GENERATION, ALL} | +| `buses_with_reactive_slacks` | Choice of which buses will have reactive slacks attached in ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | ALL | {CONFIGURED, NO_GENERATION, ALL} | | `PQmax` | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.4](#44-pq-units-domain)) | $9000$ (MW, MVAr) | $\mathbb{R}$ | | `defaultPmax` | Threshold for correction of high active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $1000$ (MW) | $\mathbb{R}$ | | `defaultPmin` | Threshold for correction of low active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $0$ (MW) | $\mathbb{R}$ | From 85912c03ba4c831a6510070b5ab8e2b2b617b364 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Thu, 16 May 2024 12:50:40 +0200 Subject: [PATCH 03/10] Update resources. Signed-off-by: p-arvy --- .../resources/mock_outputs/reactiveopf_results_indic.txt | 6 +++--- .../openreac-output-ieee14/reactiveopf_results_indic.txt | 6 +++--- .../reactiveopf_results_indic.txt | 6 +++--- .../openreac-output-shunt/reactiveopf_results_indic.txt | 6 +++--- .../openreac-output-svc/reactiveopf_results_indic.txt | 6 +++--- .../openreac-output-transfo/reactiveopf_results_indic.txt | 6 +++--- .../openreac-output-vsc/reactiveopf_results_indic.txt | 6 +++--- .../reactiveopf_results_indic.txt | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/open-reac/src/test/resources/mock_outputs/reactiveopf_results_indic.txt b/open-reac/src/test/resources/mock_outputs/reactiveopf_results_indic.txt index 16c3e8dd..13cd1bd0 100644 --- a/open-reac/src/test/resources/mock_outputs/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/mock_outputs/reactiveopf_results_indic.txt @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000 min_plausible_low_voltage_limit 0.500000 max_plausible_high_voltage_limit 1.500000 ignore_voltage_bounds 0.000000 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -44,8 +44,8 @@ nb_bus_in_ACDC_CC 57 nb_bus_in_AC_CC 57 nb_bus_in_ACDC_but_out_AC_CC 0 nb_bus_with_voltage_value 57 -nb_bus_with_reactive_slacks 53 -nb_bus_without_reactive_slacks 4 +nb_bus_with_reactive_slacks 57 +nb_bus_without_reactive_slacks 0 nb_branch_in_data_file 80 nb_branch_in_AC_CC 80 nb_branch_with_nonsmall_impedance 80 diff --git a/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_indic.txt index 4aa3530b..a2ed7a44 100644 --- a/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_indic.txt @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000 min_plausible_low_voltage_limit 0.500000 max_plausible_high_voltage_limit 1.500000 ignore_voltage_bounds 0.000000 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -44,8 +44,8 @@ nb_bus_in_ACDC_CC 14 nb_bus_in_AC_CC 14 nb_bus_in_ACDC_but_out_AC_CC 0 nb_bus_with_voltage_value 14 -nb_bus_with_reactive_slacks 12 -nb_bus_without_reactive_slacks 2 +nb_bus_with_reactive_slacks 14 +nb_bus_without_reactive_slacks 0 nb_branch_in_data_file 20 nb_branch_in_AC_CC 20 nb_branch_with_nonsmall_impedance 20 diff --git a/open-reac/src/test/resources/openreac-output-real-network/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-real-network/reactiveopf_results_indic.txt index a768d155..3ba53f43 100644 --- a/open-reac/src/test/resources/openreac-output-real-network/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-real-network/reactiveopf_results_indic.txt @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000 min_plausible_low_voltage_limit 0.500000 max_plausible_high_voltage_limit 1.500000 ignore_voltage_bounds 0.000000 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -44,8 +44,8 @@ nb_bus_in_ACDC_CC 57 nb_bus_in_AC_CC 57 nb_bus_in_ACDC_but_out_AC_CC 0 nb_bus_with_voltage_value 57 -nb_bus_with_reactive_slacks 53 -nb_bus_without_reactive_slacks 4 +nb_bus_with_reactive_slacks 57 +nb_bus_without_reactive_slacks 0 nb_branch_in_data_file 80 nb_branch_in_AC_CC 80 nb_branch_with_nonsmall_impedance 80 diff --git a/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_indic.txt index cefc036e..50325109 100644 --- a/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_indic.txt @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000 min_plausible_low_voltage_limit 0.500000 max_plausible_high_voltage_limit 1.500000 ignore_voltage_bounds 0.000000 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -44,8 +44,8 @@ nb_bus_in_ACDC_CC 3 nb_bus_in_AC_CC 3 nb_bus_in_ACDC_but_out_AC_CC 0 nb_bus_with_voltage_value 0 -nb_bus_with_reactive_slacks 2 -nb_bus_without_reactive_slacks 1 +nb_bus_with_reactive_slacks 3 +nb_bus_without_reactive_slacks 0 nb_branch_in_data_file 2 nb_branch_in_AC_CC 2 nb_branch_with_nonsmall_impedance 2 diff --git a/open-reac/src/test/resources/openreac-output-svc/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-svc/reactiveopf_results_indic.txt index 4021d0d6..83c540f8 100644 --- a/open-reac/src/test/resources/openreac-output-svc/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-svc/reactiveopf_results_indic.txt @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000 min_plausible_low_voltage_limit 0.500000 max_plausible_high_voltage_limit 1.500000 ignore_voltage_bounds 0.000000 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -44,8 +44,8 @@ nb_bus_in_ACDC_CC 2 nb_bus_in_AC_CC 2 nb_bus_in_ACDC_but_out_AC_CC 0 nb_bus_with_voltage_value 0 -nb_bus_with_reactive_slacks 0 -nb_bus_without_reactive_slacks 2 +nb_bus_with_reactive_slacks 2 +nb_bus_without_reactive_slacks 0 nb_branch_in_data_file 1 nb_branch_in_AC_CC 1 nb_branch_with_nonsmall_impedance 1 diff --git a/open-reac/src/test/resources/openreac-output-transfo/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-transfo/reactiveopf_results_indic.txt index 5f45745f..42b9c65c 100644 --- a/open-reac/src/test/resources/openreac-output-transfo/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-transfo/reactiveopf_results_indic.txt @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000 min_plausible_low_voltage_limit 0.500000 max_plausible_high_voltage_limit 1.500000 ignore_voltage_bounds 0.000000 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -44,8 +44,8 @@ nb_bus_in_ACDC_CC 3 nb_bus_in_AC_CC 3 nb_bus_in_ACDC_but_out_AC_CC 0 nb_bus_with_voltage_value 0 -nb_bus_with_reactive_slacks 2 -nb_bus_without_reactive_slacks 1 +nb_bus_with_reactive_slacks 3 +nb_bus_without_reactive_slacks 0 nb_branch_in_data_file 2 nb_branch_in_AC_CC 2 nb_branch_with_nonsmall_impedance 2 diff --git a/open-reac/src/test/resources/openreac-output-vsc/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-vsc/reactiveopf_results_indic.txt index 0f7fe9a3..a9434106 100644 --- a/open-reac/src/test/resources/openreac-output-vsc/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-vsc/reactiveopf_results_indic.txt @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000 min_plausible_low_voltage_limit 0.500000 max_plausible_high_voltage_limit 1.500000 ignore_voltage_bounds 0.000000 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -44,8 +44,8 @@ nb_bus_in_ACDC_CC 6 nb_bus_in_AC_CC 6 nb_bus_in_ACDC_but_out_AC_CC 0 nb_bus_with_voltage_value 0 -nb_bus_with_reactive_slacks 0 -nb_bus_without_reactive_slacks 6 +nb_bus_with_reactive_slacks 6 +nb_bus_without_reactive_slacks 0 nb_branch_in_data_file 7 nb_branch_in_AC_CC 7 nb_branch_with_nonsmall_impedance 7 diff --git a/open-reac/src/test/resources/openreac-output-warm-start/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-warm-start/reactiveopf_results_indic.txt index e98ac678..64e91ce4 100644 --- a/open-reac/src/test/resources/openreac-output-warm-start/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-warm-start/reactiveopf_results_indic.txt @@ -25,7 +25,7 @@ epsilon_nominal_voltage 1.000000 min_plausible_low_voltage_limit 0.500000 max_plausible_high_voltage_limit 1.500000 ignore_voltage_bounds 0.000000 -buses_with_reactive_slacks NO_GENERATION +buses_with_reactive_slacks ALL PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -44,8 +44,8 @@ nb_bus_in_ACDC_CC 3 nb_bus_in_AC_CC 3 nb_bus_in_ACDC_but_out_AC_CC 0 nb_bus_with_voltage_value 0 -nb_bus_with_reactive_slacks 2 -nb_bus_without_reactive_slacks 1 +nb_bus_with_reactive_slacks 3 +nb_bus_without_reactive_slacks 0 nb_branch_in_data_file 2 nb_branch_in_AC_CC 2 nb_branch_with_nonsmall_impedance 2 From 333e3d61b1724c71a69d275ee01d024073e0f768 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Thu, 20 Jun 2024 09:50:59 +0200 Subject: [PATCH 04/10] Add scaling of shunt variables and modify reactive slacks. Signed-off-by: p-arvy --- .../main/resources/openreac/reactiveopf.mod | 12 ++++----- .../main/resources/openreac/reactiveopf.run | 25 ++++++++++++++----- .../powsybl/openreac/OpenReacRunnerTest.java | 12 ++++----- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/open-reac/src/main/resources/openreac/reactiveopf.mod b/open-reac/src/main/resources/openreac/reactiveopf.mod index 90fd13f4..df57bc3a 100644 --- a/open-reac/src/main/resources/openreac/reactiveopf.mod +++ b/open-reac/src/main/resources/openreac/reactiveopf.mod @@ -954,8 +954,8 @@ subject to ctr_balance_P{PROBLEM_ACOPF,k in BUSCC}: set BUSCC_SLACK := if buses_with_reactive_slacks == "ALL" then BUSCC else if buses_with_reactive_slacks == "NO_GENERATION" then {n in BUSCC: (card{(g,n) in UNITON: (g,n) not in UNIT_FIXQ}==0 and card{(svc,n) in SVCON}==0 and card{(vscconv,n) in VSCCONVON}==0)} else BUSCC inter PARAM_BUSES_WITH_REACTIVE_SLACK; # if = "CONFIGURED", buses given as parameter but in connex component -var slack1_balance_Q{BUSCC_SLACK} >=0; -var slack2_balance_Q{BUSCC_SLACK} >=0; +var slack1_shunt_B{BUSCC_SLACK} >= 0; +var slack2_shunt_B{BUSCC_SLACK} >= 0; #subject to ctr_compl_slack_Q{PROBLEM_ACOPF,k in BUSCC_SLACK}: slack1_balance_Q[k] >= 0 complements slack2_balance_Q[k] >= 0; subject to ctr_balance_Q{PROBLEM_ACOPF,k in BUSCC}: @@ -980,8 +980,8 @@ subject to ctr_balance_Q{PROBLEM_ACOPF,k in BUSCC}: + sum{(l,k) in LCCCONVON} lccconv_Q0[1,l,k] # Fixed value # Slack variables + if k in BUSCC_SLACK then - (- slack1_balance_Q[k] # Homogeneous to a generation of reactive power (condensator) - + slack2_balance_Q[k]) # homogeneous to a reactive load (self) + (- base100MVA * V[k]^2 * slack1_shunt_B[k] # Homogeneous to a generation of reactive power (condensator) + + base100MVA * V[k]^2 * slack2_shunt_B[k]) # homogeneous to a reactive load (self) = 0; @@ -1013,8 +1013,8 @@ param penalty_voltage_target_low := 0.01; minimize problem_acopf_objective: sum{n in BUSCC_SLACK} ( - penalty_invest_rea_pos * slack1_balance_Q[n] - + penalty_invest_rea_neg * slack2_balance_Q[n] + penalty_invest_rea_pos * base100MVA * slack1_shunt_B[n] + + penalty_invest_rea_neg * base100MVA * slack2_shunt_B[n] ) # coeff_alpha == 1 : minimize sum of generation, all generating units vary with 1 unique variable alpha diff --git a/open-reac/src/main/resources/openreac/reactiveopf.run b/open-reac/src/main/resources/openreac/reactiveopf.run index 976ac5ab..d5559804 100644 --- a/open-reac/src/main/resources/openreac/reactiveopf.run +++ b/open-reac/src/main/resources/openreac/reactiveopf.run @@ -369,11 +369,15 @@ if "reactive_slack_variable_scaling_factor" in PARAM_ALGO_KEYS then let reactive printf{LOG_INFO} "Parameter: scaling factor for reactive slack variables := %.3f\n",reactive_slack_variable_scaling_factor; check reactive_slack_variable_scaling_factor > 0; -param transformer_ratio_variable_scaling_factor default 1e-1; +param transformer_ratio_variable_scaling_factor default 1e-3; if "transformer_ratio_variable_scaling_factor" in PARAM_ALGO_KEYS then let transformer_ratio_variable_scaling_factor := num(PARAM_ALGO_VALUES["transformer_ratio_variable_scaling_factor"]); printf{LOG_INFO} "Parameter: scaling factor for tranformer ratio variables := %.3f\n",transformer_ratio_variable_scaling_factor; check transformer_ratio_variable_scaling_factor > 0; +param shunt_variable_scaling_factor default 1e-1; +if "shunt_variable_scaling_factor" in PARAM_ALGO_KEYS then let shunt_variable_scaling_factor := num(PARAM_ALGO_VALUES["shunt_variable_scaling_factor"]); +printf{LOG_INFO} "Parameter: scaling factor for shunt variables := %.3f\n",shunt_variable_scaling_factor; +check shunt_variable_scaling_factor > 0; ############################################################################### # Solver choice and options @@ -971,8 +975,8 @@ let {n in BUSVV} V[n] := bus_V0[1,n]; let {n in BUSCC diff BUSVV} V[n] := voltage_lower_bound[1,bus_substation[1,n]] + 0.8 *(voltage_upper_bound[1,bus_substation[1,n]] - voltage_lower_bound[1,bus_substation[1,n]]); -let {n in BUSCC_SLACK} slack1_balance_Q[n] := 0; -let {n in BUSCC_SLACK} slack2_balance_Q[n] := 0; +let {n in BUSCC_SLACK} slack1_shunt_B[n] := 0; +let {n in BUSCC_SLACK} slack2_shunt_B[n] := 0; let alpha := 0.01; let {(g,n) in UNITON} P_bounded[g,n] := max(P_dcopf[g,n],unit_Pc[1,g,n]); let {(g,n) in UNITON} Q[g,n] := 0.5*(corrected_unit_Qmax[g,n] + corrected_unit_Qmin[g,n]); @@ -989,16 +993,18 @@ let tempstr := ctime(); printf{LOG_KNITRO} "\n######################################################################\n"; printf{LOG_KNITRO} "** ACopf solve: start (%s)\n\n",ctime(); -option knitro_options ("opttol=1 opttolabs=1e-1 feastol=1 feastolabs=1e-3 maxit=200 outlev=3"); +option knitro_options ("opttol=1 opttolabs=1e-1 feastol=1 feastolabs=1e-3 maxit=300 outlev=3"); let {i in 1.._nvars} _var[i].xscalefactor := default_variable_scaling_factor; let {i in 1.._ncons} _con[i].cscalefactor := default_constraint_scaling_factor; -let {n in BUSCC_SLACK} slack1_balance_Q[n].xscalefactor := reactive_slack_variable_scaling_factor; -let {n in BUSCC_SLACK} slack2_balance_Q[n].xscalefactor := reactive_slack_variable_scaling_factor; +let {n in BUSCC_SLACK} slack1_shunt_B[n].xscalefactor := reactive_slack_variable_scaling_factor; +let {n in BUSCC_SLACK} slack2_shunt_B[n].xscalefactor := reactive_slack_variable_scaling_factor; let {(qq,m,n) in BRANCHCC_REGL_VAR} branch_Ror_var[qq,m,n].xscalefactor := transformer_ratio_variable_scaling_factor; +let {(shunt,n) in SHUNT_VAR} shunt_var[shunt,n].xscalefactor := shunt_variable_scaling_factor; + # solve acopf and avoid knitro printing if user asks if (log_level_knitro <= 1) then { solve problem_acopf_objective > (nullDevice); @@ -1013,6 +1019,13 @@ printf{LOG_KNITRO} "\n** ACopf solve: end (%s -> %s)\n",tempstr,ctime(); printf{LOG_KNITRO} "######################################################################\n\n"; +param slack1_balance_Q{n in BUSCC_SLACK}; +param slack2_balance_Q{n in BUSCC_SLACK}; +for {n in BUSCC_SLACK} { + let slack1_balance_Q[n] := base100MVA * V[n]^2 * slack1_shunt_B[n].val; + let slack2_balance_Q[n] := base100MVA * V[n]^2 * slack2_shunt_B[n].val; +} + ############################################################################### # Analysis of solve_result_num ############################################################################### 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 5f5a5f80..5d33bc34 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -248,9 +248,9 @@ void testRunAsync() throws IOException { subFolder + "/reactiveopf_results_vsc_converter_stations.csv", subFolder + "/reactiveopf_results_voltages.csv")); // To really run open reac, use the commented 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())) { + try (ComputationManager computationManager = new LocalComputationManager()) { +// try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), +// localCommandExecutor, ForkJoinPool.commonPool())) { CompletableFuture openReacResults = OpenReacRunner.runAsync(network, network.getVariantManager().getWorkingVariantId(), parameters, new OpenReacConfig(true), computationManager); @@ -370,9 +370,9 @@ private void runAndApplyAllModifications(Network network, String subFolder, Open subFolder + "/reactiveopf_results_vsc_converter_stations.csv", subFolder + "/reactiveopf_results_voltages.csv")); // 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())) { + try (ComputationManager computationManager = new LocalComputationManager()) { +// try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), +// localCommandExecutor, ForkJoinPool.commonPool())) { OpenReacResult openReacResult = OpenReacRunner.run(network, network.getVariantManager().getWorkingVariantId(), parameters, new OpenReacConfig(true), computationManager); From bbae1e0768f9d69d07407053b638db6464f3ec85 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Thu, 20 Jun 2024 18:52:58 +0200 Subject: [PATCH 05/10] Interface shunt scaling factor and add TUs. Signed-off-by: p-arvy --- .../parameters/input/OpenReacParameters.java | 20 +++++++++++++++++++ .../json/OpenReacParametersDeserializer.java | 4 ++++ .../json/OpenReacParametersSerializer.java | 1 + .../resources/openreac/reactiveopfexit.run | 2 +- .../resources/openreac/reactiveopfoutput.run | 1 + .../openreac/OpenReacParametersTest.java | 18 ++++++++++++++--- .../powsybl/openreac/OpenReacRunnerTest.java | 17 ++++++++-------- .../resources/expected_inputs/param_algo.txt | 1 + .../reactiveopf_results_indic.txt | 1 + .../default.txt | 1 + .../modified_param_algo.txt | 1 + .../reactiveopf_results_generators.csv | 4 ++-- .../reactiveopf_results_indic.txt | 13 ++++++------ .../reactiveopf_results_voltages.csv | 2 +- .../reactiveopf_results_indic.txt | 9 +++++---- .../reactiveopf_results_indic.txt | 13 ++++++------ .../reactiveopf_results_shunts.csv | 2 +- .../reactiveopf_results_indic.txt | 7 ++++--- .../reactiveopf_results_indic.txt | 13 ++++++------ .../reactiveopf_results_indic.txt | 13 ++++++------ .../reactiveopf_results_indic.txt | 13 ++++++------ .../src/test/resources/parametersLists.json | 3 ++- .../test/resources/parametersThresholds.json | 3 ++- 23 files changed, 107 insertions(+), 55 deletions(-) diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java index c509a0ce..e1332da0 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java @@ -116,6 +116,10 @@ public class OpenReacParameters { private double twoWindingTransformerRatioVariableScalingFactor = 1e-3; + private static final String SHUNT_VARIABLE_SCALING_FACTOR_KEY = "shunt_variable_scaling_factor"; + + private double shuntVariableScalingFactor = 1e-1; + /** * Override some voltage level limits in the network. This will NOT modify the network object. *

@@ -507,6 +511,21 @@ public OpenReacParameters setTwoWindingTransformerRatioVariableScalingFactor(dou return this; } + /** + * @return the scaling value of shunt variables in ACOPF. + */ + public double getShuntVariableScalingFactor() { + return shuntVariableScalingFactor; + } + + public OpenReacParameters setShuntVariableScalingFactor(double shuntVariableScalingFactor) { + if (shuntVariableScalingFactor <= 0 || Double.isNaN(shuntVariableScalingFactor)) { + throw new IllegalArgumentException("Scaling factor for shunt variables must be > 0 and defined to be consistent."); + } + this.shuntVariableScalingFactor = shuntVariableScalingFactor; + return this; + } + public List getAllAlgorithmParams() { ArrayList allAlgoParams = new ArrayList<>(); allAlgoParams.add(objective.toParam()); @@ -532,6 +551,7 @@ public List getAllAlgorithmParams() { allAlgoParams.add(new OpenReacAlgoParamImpl(DEFAULT_CONSTRAINT_SCALING_FACTOR, Double.toString(defaultConstraintScalingFactor))); allAlgoParams.add(new OpenReacAlgoParamImpl(REACTIVE_SLACK_VARIABLE_SCALING_FACTOR, Double.toString(reactiveSlackVariableScalingFactor))); allAlgoParams.add(new OpenReacAlgoParamImpl(TWO_WINDING_TRANSFORMER_RATIO_VARIABLE_SCALING_FACTOR, Double.toString(twoWindingTransformerRatioVariableScalingFactor))); + allAlgoParams.add(new OpenReacAlgoParamImpl(SHUNT_VARIABLE_SCALING_FACTOR_KEY, Double.toString(shuntVariableScalingFactor))); return allAlgoParams; } diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersDeserializer.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersDeserializer.java index 5a4819f2..f49506a4 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersDeserializer.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersDeserializer.java @@ -147,6 +147,10 @@ public OpenReacParameters deserialize(JsonParser parser, DeserializationContext parser.nextToken(); parameters.setTwoWindingTransformerRatioVariableScalingFactor(parser.readValueAs(Double.class)); } + case "shuntVariableScalingFactor" -> { + parser.nextToken(); + parameters.setShuntVariableScalingFactor(parser.readValueAs(Double.class)); + } default -> throw new IllegalStateException("Unexpected field: " + parser.getCurrentName()); } } diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersSerializer.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersSerializer.java index e78337c7..3225d5b0 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersSerializer.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/json/OpenReacParametersSerializer.java @@ -61,6 +61,7 @@ public void serialize(OpenReacParameters openReacParameters, JsonGenerator jsonG serializerProvider.defaultSerializeField("defaultConstraintScalingFactor", openReacParameters.getDefaultConstraintScalingFactor(), jsonGenerator); serializerProvider.defaultSerializeField("reactiveSlackVariableScalingFactor", openReacParameters.getReactiveSlackVariableScalingFactor(), jsonGenerator); serializerProvider.defaultSerializeField("twoWindingTransformerRatioVariableScalingFactor", openReacParameters.getTwoWindingTransformerRatioVariableScalingFactor(), jsonGenerator); + serializerProvider.defaultSerializeField("shuntVariableScalingFactor", openReacParameters.getShuntVariableScalingFactor(), jsonGenerator); jsonGenerator.writeEndObject(); } } diff --git a/open-reac/src/main/resources/openreac/reactiveopfexit.run b/open-reac/src/main/resources/openreac/reactiveopfexit.run index 1f47ae4f..4e7a8fc3 100644 --- a/open-reac/src/main/resources/openreac/reactiveopfexit.run +++ b/open-reac/src/main/resources/openreac/reactiveopfexit.run @@ -71,7 +71,7 @@ printf "%s %f\n","default_variable_scaling_factor",default_variable_scaling_fact printf "%s %f\n","default_constraint_scaling_factor",default_constraint_scaling_factor > (fileOut); printf "%s %f\n","reactive_slack_variable_scaling_factor",reactive_slack_variable_scaling_factor > (fileOut); printf "%s %f\n","transformer_ratio_variable_scaling_factor",transformer_ratio_variable_scaling_factor > (fileOut); - +printf "%s %f\n","shunt_variable_scaling_factor",shunt_variable_scaling_factor > (fileOut); close (fileOut); printf "\n*** End of file reactiveopfexit.run : %s\n",ctime(); diff --git a/open-reac/src/main/resources/openreac/reactiveopfoutput.run b/open-reac/src/main/resources/openreac/reactiveopfoutput.run index d2b67213..ecfc2bcd 100644 --- a/open-reac/src/main/resources/openreac/reactiveopfoutput.run +++ b/open-reac/src/main/resources/openreac/reactiveopfoutput.run @@ -273,6 +273,7 @@ printf "%s %f\n","default_variable_scaling_factor",default_variable_scaling_fact printf "%s %f\n","default_constraint_scaling_factor",default_constraint_scaling_factor > (fileOut); printf "%s %f\n","reactive_slack_variable_scaling_factor",reactive_slack_variable_scaling_factor > (fileOut); printf "%s %f\n","transformer_ratio_variable_scaling_factor",transformer_ratio_variable_scaling_factor > (fileOut); +printf "%s %f\n","shunt_variable_scaling_factor",shunt_variable_scaling_factor > (fileOut); printf "\n" > (fileOut); printf "%s %i\n","nb_substations",card(SUBSTATIONS) > (fileOut); diff --git a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java index 6b982122..0494d0c1 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java @@ -285,6 +285,17 @@ void testVariablesScalingFactorsIntegrity() { assertEquals("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.", e8.getMessage()); IllegalArgumentException e9 = assertThrows(IllegalArgumentException.class, () -> parameters.setTwoWindingTransformerRatioVariableScalingFactor(Double.NaN)); assertEquals("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.", e9.getMessage()); + + // Consistency of shunt variables scaling factor + assertEquals(1e-1, parameters.getShuntVariableScalingFactor()); // default value + parameters.setShuntVariableScalingFactor(0.011); + assertEquals(0.011, parameters.getShuntVariableScalingFactor()); + IllegalArgumentException e10 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(-0.25)); + assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e10.getMessage()); + IllegalArgumentException e11 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(0)); + assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e11.getMessage()); + IllegalArgumentException e12 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(Double.NaN)); + assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e12.getMessage()); } @Test @@ -325,9 +336,10 @@ void testAlgorithmParams() { parameters.setDefaultConstraintScalingFactor(0.75); parameters.setReactiveSlackVariableScalingFactor(1e-2); parameters.setTwoWindingTransformerRatioVariableScalingFactor(0.0001); + parameters.setShuntVariableScalingFactor(3e-2); List algoParams = parameters.getAllAlgorithmParams(); - assertEquals(21, algoParams.size()); + assertEquals(22, algoParams.size()); assertEquals("2", algoParams.get(0).getValue()); assertEquals("0.4", algoParams.get(1).getValue()); assertEquals("DEBUG", algoParams.get(2).getValue()); @@ -349,6 +361,7 @@ void testAlgorithmParams() { assertEquals("0.75", algoParams.get(18).getValue()); assertEquals("0.01", algoParams.get(19).getValue()); assertEquals("1.0E-4", algoParams.get(20).getValue()); + assertEquals("0.03", algoParams.get(21).getValue()); } @Test @@ -385,7 +398,6 @@ void testDefaultParametersValuesIntegrity() { assertEquals(1000., parameters.getHighActivePowerDefaultLimit()); assertEquals(0.3, parameters.getDefaultQmaxPmaxRatio()); assertEquals(1., parameters.getDefaultMinimalQPRange()); - // TODO : add cases for scaling values assertTrue(parameters.checkAlgorithmParametersIntegrity()); } @@ -398,7 +410,7 @@ void testDefaultParametersListsIntegrity() { assertEquals(0, parameters.getConstantQGenerators().size(), "ConstantQGenerators should be empty when using default OpenReacParameter constructor."); assertEquals(0, parameters.getVariableShuntCompensators().size(), "VariableShuntCompensators should be empty when using default OpenReacParameter constructor."); assertEquals(0, parameters.getConfiguredReactiveSlackBuses().size(), "ConfiguredReactiveSlackBuses should be empty when using default OpenREacParameter constructor."); - assertEquals(20, parameters.getAllAlgorithmParams().size()); + assertEquals(21, parameters.getAllAlgorithmParams().size()); } @Test 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 5d33bc34..858a1d08 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -118,7 +118,8 @@ void testModifiedParamAlgoExport() throws IOException { .setDefaultVariableScalingFactor(1.1222) .setDefaultConstraintScalingFactor(0.7889) .setReactiveSlackVariableScalingFactor(0.2) - .setTwoWindingTransformerRatioVariableScalingFactor(0.0045); + .setTwoWindingTransformerRatioVariableScalingFactor(0.0045) + .setShuntVariableScalingFactor(0.101); LocalCommandExecutor localCommandExecutor = new TestLocalCommandExecutor( List.of("empty_case/reactiveopf_results_indic.txt")); @@ -228,7 +229,7 @@ public void testOutputFileParsing() throws IOException { assertEquals(1, openReacResult.getVscModifications().size()); assertEquals(7, openReacResult.getGeneratorModifications().size()); assertEquals(3, openReacResult.getVoltageProfile().size()); - assertEquals(86, openReacResult.getIndicators().size()); + assertEquals(87, openReacResult.getIndicators().size()); assertTrue(openReacResult.getReactiveSlacks().isEmpty()); } } @@ -248,9 +249,9 @@ void testRunAsync() throws IOException { subFolder + "/reactiveopf_results_vsc_converter_stations.csv", subFolder + "/reactiveopf_results_voltages.csv")); // To really run open reac, use the commented 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())) { +// try (ComputationManager computationManager = new LocalComputationManager()) { + try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), + localCommandExecutor, ForkJoinPool.commonPool())) { CompletableFuture openReacResults = OpenReacRunner.runAsync(network, network.getVariantManager().getWorkingVariantId(), parameters, new OpenReacConfig(true), computationManager); @@ -370,9 +371,9 @@ private void runAndApplyAllModifications(Network network, String subFolder, Open subFolder + "/reactiveopf_results_vsc_converter_stations.csv", subFolder + "/reactiveopf_results_voltages.csv")); // 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())) { +// try (ComputationManager computationManager = new LocalComputationManager()) { + try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), + localCommandExecutor, ForkJoinPool.commonPool())) { OpenReacResult openReacResult = OpenReacRunner.run(network, network.getVariantManager().getWorkingVariantId(), parameters, new OpenReacConfig(true), computationManager); diff --git a/open-reac/src/test/resources/expected_inputs/param_algo.txt b/open-reac/src/test/resources/expected_inputs/param_algo.txt index 07b96927..a0b2e565 100644 --- a/open-reac/src/test/resources/expected_inputs/param_algo.txt +++ b/open-reac/src/test/resources/expected_inputs/param_algo.txt @@ -19,4 +19,5 @@ default_variable_scaling_factor 1.0 default_constraint_scaling_factor 1.0 reactive_slack_variable_scaling_factor 0.1 transformer_ratio_variable_scaling_factor 0.001 +shunt_variable_scaling_factor 0.1 diff --git a/open-reac/src/test/resources/mock_outputs/reactiveopf_results_indic.txt b/open-reac/src/test/resources/mock_outputs/reactiveopf_results_indic.txt index 13cd1bd0..36fe7884 100644 --- a/open-reac/src/test/resources/mock_outputs/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/mock_outputs/reactiveopf_results_indic.txt @@ -37,6 +37,7 @@ default_variable_scaling_factor 1.000000 default_constraint_scaling_factor 1.000000 reactive_slack_variable_scaling_factor 0.100000 transformer_ratio_variable_scaling_factor 0.001000 +shunt_variable_scaling_factor 0.100000 nb_substations 42 nb_bus_in_data_file 58 diff --git a/open-reac/src/test/resources/openreac-input-algo-parameters/default.txt b/open-reac/src/test/resources/openreac-input-algo-parameters/default.txt index 3066948e..f2d2f613 100644 --- a/open-reac/src/test/resources/openreac-input-algo-parameters/default.txt +++ b/open-reac/src/test/resources/openreac-input-algo-parameters/default.txt @@ -18,4 +18,5 @@ default_variable_scaling_factor 1.0 default_constraint_scaling_factor 1.0 reactive_slack_variable_scaling_factor 0.1 transformer_ratio_variable_scaling_factor 0.001 +shunt_variable_scaling_factor 0.1 diff --git a/open-reac/src/test/resources/openreac-input-algo-parameters/modified_param_algo.txt b/open-reac/src/test/resources/openreac-input-algo-parameters/modified_param_algo.txt index d93ef083..686bd1d2 100644 --- a/open-reac/src/test/resources/openreac-input-algo-parameters/modified_param_algo.txt +++ b/open-reac/src/test/resources/openreac-input-algo-parameters/modified_param_algo.txt @@ -19,4 +19,5 @@ default_variable_scaling_factor 1.1222 default_constraint_scaling_factor 0.7889 reactive_slack_variable_scaling_factor 0.2 transformer_ratio_variable_scaling_factor 0.0045 +shunt_variable_scaling_factor 0.101 diff --git a/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_generators.csv b/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_generators.csv index a1706533..8a9b2752 100644 --- a/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_generators.csv +++ b/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_generators.csv @@ -1,6 +1,6 @@ #variant;num;bus;vRegul;V(pu);targetP(MW);targetQ(Mvar);P(MW);Q(MW); -1;1;1;'true';1.083;232.4;48.6;-233.0;-48.6; -1;2;2;'true';1.045;40.0;50.0;-40.7;-50.0; +1;1;1;'true';1.083;232.4;48.7;-233.0;-48.7; +1;2;2;'true';1.045;40.0;49.9;-40.7;-49.9; 1;3;3;'false';0.971;0;0;0;0; 1;4;6;'false';0.973;0;0;0;0; 1;5;8;'false';1.500;0;0;0;0; diff --git a/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_indic.txt index a2ed7a44..cbdccbc7 100644 --- a/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_indic.txt @@ -1,18 +1,18 @@ final_status OK dcopf_status OK -ctime_start 'Mon Apr 01 12:22:19 2024' +ctime_start 'Thu Jun 20 14:34:11 2024' last_solve_result_num 0 nb_iter_last 6 nb_iter_total 6 -_ampl_elapsed_time 0.062000 -_total_solve_time 0.031250 +_ampl_elapsed_time 0.032000 +_total_solve_time 0.000000 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_14143080586829170076' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_15080248147598462242' log_level_ampl INFO log_level_knitro 2 @@ -37,6 +37,7 @@ default_variable_scaling_factor 1.000000 default_constraint_scaling_factor 1.000000 reactive_slack_variable_scaling_factor 0.100000 transformer_ratio_variable_scaling_factor 0.001000 +shunt_variable_scaling_factor 0.100000 nb_substations 14 nb_bus_in_data_file 14 @@ -81,9 +82,9 @@ min_teta_dc -0.12 min_teta_ac -0.11 teta_min -3.12 max_delta_teta_dc 0.159330 -max_delta_teta_ac 0.140571 +max_delta_teta_ac 0.140559 min_delta_teta_dc -0.041368 -min_delta_teta_ac -0.041534 +min_delta_teta_ac -0.041533 nb_reactive_slacks 0 nb_slacks_condensator 0 diff --git a/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_voltages.csv b/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_voltages.csv index 58d56b24..20f1298f 100644 --- a/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_voltages.csv +++ b/open-reac/src/test/resources/openreac-output-ieee14/reactiveopf_results_voltages.csv @@ -1,5 +1,5 @@ #variant;bus;V(pu);theta(rad);id; -1;1;1.083;0.168;"VL1_0"; +1;1;1.083;0.167;"VL1_0"; 1;2;1.045;0.089;"VL2_0"; 1;3;0.971;-0.042;"VL3_0"; 1;4;0.991;0.000;"VL4_0"; diff --git a/open-reac/src/test/resources/openreac-output-real-network/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-real-network/reactiveopf_results_indic.txt index 3ba53f43..ba6544bd 100644 --- a/open-reac/src/test/resources/openreac-output-real-network/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-real-network/reactiveopf_results_indic.txt @@ -1,18 +1,18 @@ final_status OK dcopf_status OK -ctime_start 'Mon Apr 01 12:18:15 2024' +ctime_start 'Thu Jun 20 14:42:54 2024' last_solve_result_num 0 nb_iter_last 7 nb_iter_total 7 -_ampl_elapsed_time 0.032000 -_total_solve_time 0.046875 +_ampl_elapsed_time 0.078000 +_total_solve_time 0.031250 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_14716501820934220752' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_16419245349654459503' log_level_ampl INFO log_level_knitro 2 @@ -37,6 +37,7 @@ default_variable_scaling_factor 1.000000 default_constraint_scaling_factor 1.000000 reactive_slack_variable_scaling_factor 0.100000 transformer_ratio_variable_scaling_factor 0.001000 +shunt_variable_scaling_factor 0.100000 nb_substations 42 nb_bus_in_data_file 57 diff --git a/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_indic.txt index 50325109..4b072890 100644 --- a/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_indic.txt @@ -1,18 +1,18 @@ final_status OK dcopf_status OK -ctime_start 'Mon Apr 01 12:20:13 2024' +ctime_start 'Thu Jun 20 14:41:11 2024' last_solve_result_num 0 -nb_iter_last 20 -nb_iter_total 20 -_ampl_elapsed_time 0.063000 -_total_solve_time 0.046875 +nb_iter_last 35 +nb_iter_total 35 +_ampl_elapsed_time 0.047000 +_total_solve_time 0.031250 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_3013493296207512901' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_10955859460968685093' log_level_ampl INFO log_level_knitro 2 @@ -37,6 +37,7 @@ default_variable_scaling_factor 1.000000 default_constraint_scaling_factor 1.000000 reactive_slack_variable_scaling_factor 0.100000 transformer_ratio_variable_scaling_factor 0.001000 +shunt_variable_scaling_factor 0.100000 nb_substations 3 nb_bus_in_data_file 3 diff --git a/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_shunts.csv b/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_shunts.csv index 7b7a196a..9c032169 100644 --- a/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_shunts.csv +++ b/open-reac/src/test/resources/openreac-output-shunt/reactiveopf_results_shunts.csv @@ -1,2 +1,2 @@ #variant;num;bus;b(pu);Q(Mvar);section; -1;1;3;1.234;136.453;0; +1;1;3;1.234;136.461;0; diff --git a/open-reac/src/test/resources/openreac-output-svc/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-svc/reactiveopf_results_indic.txt index 83c540f8..82d999e8 100644 --- a/open-reac/src/test/resources/openreac-output-svc/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-svc/reactiveopf_results_indic.txt @@ -1,18 +1,18 @@ final_status OK dcopf_status OK -ctime_start 'Mon Apr 01 12:21:04 2024' +ctime_start 'Thu Jun 20 14:40:34 2024' last_solve_result_num 0 nb_iter_last 6 nb_iter_total 6 _ampl_elapsed_time 0.047000 -_total_solve_time 0.046875 +_total_solve_time 0.015625 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_10447832462844756764' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_11839740265781623806' log_level_ampl INFO log_level_knitro 2 @@ -37,6 +37,7 @@ default_variable_scaling_factor 1.000000 default_constraint_scaling_factor 1.000000 reactive_slack_variable_scaling_factor 0.100000 transformer_ratio_variable_scaling_factor 0.001000 +shunt_variable_scaling_factor 0.100000 nb_substations 2 nb_bus_in_data_file 2 diff --git a/open-reac/src/test/resources/openreac-output-transfo/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-transfo/reactiveopf_results_indic.txt index 42b9c65c..8a0fad45 100644 --- a/open-reac/src/test/resources/openreac-output-transfo/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-transfo/reactiveopf_results_indic.txt @@ -1,18 +1,18 @@ final_status OK dcopf_status OK -ctime_start 'Mon Apr 01 12:18:59 2024' +ctime_start 'Thu Jun 20 14:44:47 2024' last_solve_result_num 0 nb_iter_last 5 nb_iter_total 5 -_ampl_elapsed_time 0.063000 -_total_solve_time 0.031250 +_ampl_elapsed_time 0.047000 +_total_solve_time 0.046875 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_6686274912630047225' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_7513458987966328583' log_level_ampl INFO log_level_knitro 2 @@ -37,6 +37,7 @@ default_variable_scaling_factor 1.000000 default_constraint_scaling_factor 1.000000 reactive_slack_variable_scaling_factor 0.100000 transformer_ratio_variable_scaling_factor 0.001000 +shunt_variable_scaling_factor 0.100000 nb_substations 3 nb_bus_in_data_file 3 @@ -81,9 +82,9 @@ min_teta_dc -0.05 min_teta_ac -0.08 teta_min -3.05 max_delta_teta_dc 0.045914 -max_delta_teta_ac 0.081650 +max_delta_teta_ac 0.081636 min_delta_teta_dc 0.009298 -min_delta_teta_ac 0.014294 +min_delta_teta_ac 0.014293 nb_reactive_slacks 0 nb_slacks_condensator 0 diff --git a/open-reac/src/test/resources/openreac-output-vsc/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-vsc/reactiveopf_results_indic.txt index a9434106..e2d6706c 100644 --- a/open-reac/src/test/resources/openreac-output-vsc/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-vsc/reactiveopf_results_indic.txt @@ -1,18 +1,18 @@ final_status OK dcopf_status OK -ctime_start 'Mon Apr 01 12:21:43 2024' +ctime_start 'Thu Jun 20 14:38:57 2024' last_solve_result_num 0 nb_iter_last 6 nb_iter_total 6 -_ampl_elapsed_time 0.063000 -_total_solve_time 0.015625 +_ampl_elapsed_time 0.047000 +_total_solve_time 0.031250 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_8140062921975933350' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_4294773797099927510' log_level_ampl INFO log_level_knitro 2 @@ -37,6 +37,7 @@ default_variable_scaling_factor 1.000000 default_constraint_scaling_factor 1.000000 reactive_slack_variable_scaling_factor 0.100000 transformer_ratio_variable_scaling_factor 0.001000 +shunt_variable_scaling_factor 0.100000 nb_substations 6 nb_bus_in_data_file 6 @@ -81,9 +82,9 @@ min_teta_dc -0.20 min_teta_ac -0.93 teta_min -3.20 max_delta_teta_dc 0.066667 -max_delta_teta_ac 0.220225 +max_delta_teta_ac 0.220224 min_delta_teta_dc -0.200000 -min_delta_teta_ac -0.927212 +min_delta_teta_ac -0.927179 nb_reactive_slacks 0 nb_slacks_condensator 0 diff --git a/open-reac/src/test/resources/openreac-output-warm-start/reactiveopf_results_indic.txt b/open-reac/src/test/resources/openreac-output-warm-start/reactiveopf_results_indic.txt index 64e91ce4..f2caf73d 100644 --- a/open-reac/src/test/resources/openreac-output-warm-start/reactiveopf_results_indic.txt +++ b/open-reac/src/test/resources/openreac-output-warm-start/reactiveopf_results_indic.txt @@ -1,18 +1,18 @@ final_status OK dcopf_status OK -ctime_start 'Mon Apr 01 12:16:18 2024' +ctime_start 'Thu Jun 20 14:43:42 2024' last_solve_result_num 0 nb_iter_last 5 nb_iter_total 5 -_ampl_elapsed_time 0.031000 -_total_solve_time 0.000000 +_ampl_elapsed_time 0.048000 +_total_solve_time 0.031250 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_15875136273009914017' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_8325889982896404457' log_level_ampl INFO log_level_knitro 2 @@ -37,6 +37,7 @@ default_variable_scaling_factor 1.000000 default_constraint_scaling_factor 1.000000 reactive_slack_variable_scaling_factor 0.100000 transformer_ratio_variable_scaling_factor 0.001000 +shunt_variable_scaling_factor 0.100000 nb_substations 3 nb_bus_in_data_file 3 @@ -81,9 +82,9 @@ min_teta_dc -0.05 min_teta_ac -0.08 teta_min -3.05 max_delta_teta_dc 0.045914 -max_delta_teta_ac 0.081650 +max_delta_teta_ac 0.081651 min_delta_teta_dc 0.009298 -min_delta_teta_ac 0.014293 +min_delta_teta_ac 0.014294 nb_reactive_slacks 0 nb_slacks_condensator 0 diff --git a/open-reac/src/test/resources/parametersLists.json b/open-reac/src/test/resources/parametersLists.json index 79ffbc86..69d5e7c3 100644 --- a/open-reac/src/test/resources/parametersLists.json +++ b/open-reac/src/test/resources/parametersLists.json @@ -44,5 +44,6 @@ "defaultVariableScalingFactor" : 1.0, "defaultConstraintScalingFactor" : 1.0, "reactiveSlackVariableScalingFactor" : 0.1, - "twoWindingTransformerRatioVariableScalingFactor" : 0.001 + "twoWindingTransformerRatioVariableScalingFactor" : 0.001, + "shuntVariableScalingFactor" : 0.1 } \ No newline at end of file diff --git a/open-reac/src/test/resources/parametersThresholds.json b/open-reac/src/test/resources/parametersThresholds.json index 1fcece0c..96df9fa8 100644 --- a/open-reac/src/test/resources/parametersThresholds.json +++ b/open-reac/src/test/resources/parametersThresholds.json @@ -24,5 +24,6 @@ "defaultVariableScalingFactor" : 0.756, "defaultConstraintScalingFactor" : 0.888, "reactiveSlackVariableScalingFactor" : 0.01, - "twoWindingTransformerRatioVariableScalingFactor" : 0.005 + "twoWindingTransformerRatioVariableScalingFactor" : 0.005, + "shuntVariableScalingFactor" : 0.1 } \ No newline at end of file From 414301171ef4efdb25fe537c8e147c14fc6b86a9 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Tue, 25 Jun 2024 10:43:23 +0200 Subject: [PATCH 06/10] Wip. Signed-off-by: p-arvy --- open-reac/src/main/resources/openreac/reactiveopf.run | 2 +- .../test/java/com/powsybl/openreac/OpenReacRunnerTest.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/open-reac/src/main/resources/openreac/reactiveopf.run b/open-reac/src/main/resources/openreac/reactiveopf.run index d5559804..4279b371 100644 --- a/open-reac/src/main/resources/openreac/reactiveopf.run +++ b/open-reac/src/main/resources/openreac/reactiveopf.run @@ -369,7 +369,7 @@ if "reactive_slack_variable_scaling_factor" in PARAM_ALGO_KEYS then let reactive printf{LOG_INFO} "Parameter: scaling factor for reactive slack variables := %.3f\n",reactive_slack_variable_scaling_factor; check reactive_slack_variable_scaling_factor > 0; -param transformer_ratio_variable_scaling_factor default 1e-3; +param transformer_ratio_variable_scaling_factor default 1e-1; if "transformer_ratio_variable_scaling_factor" in PARAM_ALGO_KEYS then let transformer_ratio_variable_scaling_factor := num(PARAM_ALGO_VALUES["transformer_ratio_variable_scaling_factor"]); printf{LOG_INFO} "Parameter: scaling factor for tranformer ratio variables := %.3f\n",transformer_ratio_variable_scaling_factor; check transformer_ratio_variable_scaling_factor > 0; 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 777250fd..c7754656 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -413,9 +413,9 @@ private void runAndApplyAllModifications(Network network, String subFolder, Open subFolder + "/reactiveopf_results_vsc_converter_stations.csv", subFolder + "/reactiveopf_results_voltages.csv")); // 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())) { + try (ComputationManager computationManager = new LocalComputationManager()) { +// try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), +// localCommandExecutor, ForkJoinPool.commonPool())) { OpenReacResult openReacResult = OpenReacRunner.run(network, network.getVariantManager().getWorkingVariantId(), parameters, new OpenReacConfig(true), computationManager, reportNode, null); From 8e211a87784af69e5552fcbdf0a13da20c859175 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Wed, 3 Jul 2024 17:02:35 +0200 Subject: [PATCH 07/10] Refactor tests. Signed-off-by: p-arvy --- .../test/java/com/powsybl/openreac/OpenReacRunnerTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 c5d612da..b7051dfe 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -413,9 +413,9 @@ private void runAndApplyAllModifications(Network network, String subFolder, Open subFolder + "/reactiveopf_results_vsc_converter_stations.csv", subFolder + "/reactiveopf_results_voltages.csv")); // 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())) { +// try (ComputationManager computationManager = new LocalComputationManager()) { + try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), + localCommandExecutor, ForkJoinPool.commonPool())) { OpenReacResult openReacResult = OpenReacRunner.run(network, network.getVariantManager().getWorkingVariantId(), parameters, new OpenReacConfig(true), computationManager, reportNode, null); From 126c74f96c7644ab375e5760bd7b337779b9b002 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Wed, 3 Jul 2024 17:24:32 +0200 Subject: [PATCH 08/10] Clean overbrain. Signed-off-by: p-arvy --- .../openreac/OpenReacParametersTest.java | 87 +++++++++++-------- 1 file changed, 51 insertions(+), 36 deletions(-) diff --git a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java index 0494d0c1..b54b1055 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java @@ -249,53 +249,64 @@ void testDefaultMinimalQPRangeIntegrity() { assertEquals("Default minimal QP range must be defined and >= 0 to be consistent.", e2.getMessage()); } + @Test + void testTwoWindingTransformerRatioVariablesScalingFactor() { + OpenReacParameters parameters = new OpenReacParameters(); + + // Consistency of t2wt ratio variables scaling factor + parameters.setTwoWindingTransformerRatioVariableScalingFactor(0.007); + assertEquals(0.007, parameters.getTwoWindingTransformerRatioVariableScalingFactor()); + IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> parameters.setTwoWindingTransformerRatioVariableScalingFactor(-0.25)); + assertEquals("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.", e1.getMessage()); + IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> parameters.setTwoWindingTransformerRatioVariableScalingFactor(0)); + assertEquals("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.", e2.getMessage()); + IllegalArgumentException e3 = assertThrows(IllegalArgumentException.class, () -> parameters.setTwoWindingTransformerRatioVariableScalingFactor(Double.NaN)); + assertEquals("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.", e3.getMessage()); + } + + @Test + void testShuntVariablesScalingFactor() { + OpenReacParameters parameters = new OpenReacParameters(); + + // Consistency of shunt variables scaling factor + parameters.setShuntVariableScalingFactor(0.011); + assertEquals(0.011, parameters.getShuntVariableScalingFactor()); + IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(-0.25)); + assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e1.getMessage()); + IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(0)); + assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e2.getMessage()); + IllegalArgumentException e3 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(Double.NaN)); + assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e3.getMessage()); + } + + @Test + void testReactiveSlackVariablesScalingFactorsIntegrity() { + OpenReacParameters parameters = new OpenReacParameters(); + + // Consistency of reactive slack variables scaling factor + parameters.setReactiveSlackVariableScalingFactor(0.058); + assertEquals(0.058, parameters.getReactiveSlackVariableScalingFactor()); + IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> parameters.setReactiveSlackVariableScalingFactor(-0.25)); + assertEquals("Scaling factor for reactive slack variables must be > 0 and defined to be consistent.", e1.getMessage()); + IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> parameters.setReactiveSlackVariableScalingFactor(0)); + assertEquals("Scaling factor for reactive slack variables must be > 0 and defined to be consistent.", e2.getMessage()); + IllegalArgumentException e3 = assertThrows(IllegalArgumentException.class, () -> parameters.setReactiveSlackVariableScalingFactor(Double.NaN)); + assertEquals("Scaling factor for reactive slack variables must be > 0 and defined to be consistent.", e3.getMessage()); + } + @Test void testVariablesScalingFactorsIntegrity() { OpenReacParameters parameters = new OpenReacParameters(); // Consistency of default scaling factor - assertEquals(1, parameters.getDefaultVariableScalingFactor()); // default value parameters.setDefaultVariableScalingFactor(0.8); assertEquals(0.8, parameters.getDefaultVariableScalingFactor()); - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> parameters.setDefaultVariableScalingFactor(-0.25)); - assertEquals("Default scaling factor for variables must be > 0 and defined to be consistent.", e.getMessage()); + IllegalArgumentException e1 = assertThrows(IllegalArgumentException.class, () -> parameters.setDefaultVariableScalingFactor(-0.25)); + assertEquals("Default scaling factor for variables must be > 0 and defined to be consistent.", e1.getMessage()); IllegalArgumentException e2 = assertThrows(IllegalArgumentException.class, () -> parameters.setDefaultVariableScalingFactor(0)); assertEquals("Default scaling factor for variables must be > 0 and defined to be consistent.", e2.getMessage()); IllegalArgumentException e3 = assertThrows(IllegalArgumentException.class, () -> parameters.setDefaultVariableScalingFactor(Double.NaN)); assertEquals("Default scaling factor for variables must be > 0 and defined to be consistent.", e3.getMessage()); - - // Consistency of reactive slack variables scaling factor - assertEquals(1e-1, parameters.getReactiveSlackVariableScalingFactor()); // default value - parameters.setReactiveSlackVariableScalingFactor(0.058); - assertEquals(0.058, parameters.getReactiveSlackVariableScalingFactor()); - IllegalArgumentException e4 = assertThrows(IllegalArgumentException.class, () -> parameters.setReactiveSlackVariableScalingFactor(-0.25)); - assertEquals("Scaling factor for reactive slack variables must be > 0 and defined to be consistent.", e4.getMessage()); - IllegalArgumentException e5 = assertThrows(IllegalArgumentException.class, () -> parameters.setReactiveSlackVariableScalingFactor(0)); - assertEquals("Scaling factor for reactive slack variables must be > 0 and defined to be consistent.", e5.getMessage()); - IllegalArgumentException e6 = assertThrows(IllegalArgumentException.class, () -> parameters.setReactiveSlackVariableScalingFactor(Double.NaN)); - assertEquals("Scaling factor for reactive slack variables must be > 0 and defined to be consistent.", e6.getMessage()); - - // Consistency of t2wt ratio variables scaling factor - assertEquals(1e-3, parameters.getTwoWindingTransformerRatioVariableScalingFactor()); // default value - parameters.setTwoWindingTransformerRatioVariableScalingFactor(0.007); - assertEquals(0.007, parameters.getTwoWindingTransformerRatioVariableScalingFactor()); - IllegalArgumentException e7 = assertThrows(IllegalArgumentException.class, () -> parameters.setTwoWindingTransformerRatioVariableScalingFactor(-0.25)); - assertEquals("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.", e7.getMessage()); - IllegalArgumentException e8 = assertThrows(IllegalArgumentException.class, () -> parameters.setTwoWindingTransformerRatioVariableScalingFactor(0)); - assertEquals("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.", e8.getMessage()); - IllegalArgumentException e9 = assertThrows(IllegalArgumentException.class, () -> parameters.setTwoWindingTransformerRatioVariableScalingFactor(Double.NaN)); - assertEquals("Scaling factor for transformer ratio variables must be > 0 and defined to be consistent.", e9.getMessage()); - - // Consistency of shunt variables scaling factor - assertEquals(1e-1, parameters.getShuntVariableScalingFactor()); // default value - parameters.setShuntVariableScalingFactor(0.011); - assertEquals(0.011, parameters.getShuntVariableScalingFactor()); - IllegalArgumentException e10 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(-0.25)); - assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e10.getMessage()); - IllegalArgumentException e11 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(0)); - assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e11.getMessage()); - IllegalArgumentException e12 = assertThrows(IllegalArgumentException.class, () -> parameters.setShuntVariableScalingFactor(Double.NaN)); - assertEquals("Scaling factor for shunt variables must be > 0 and defined to be consistent.", e12.getMessage()); } @Test @@ -398,6 +409,10 @@ void testDefaultParametersValuesIntegrity() { assertEquals(1000., parameters.getHighActivePowerDefaultLimit()); assertEquals(0.3, parameters.getDefaultQmaxPmaxRatio()); assertEquals(1., parameters.getDefaultMinimalQPRange()); + assertEquals(1, parameters.getDefaultVariableScalingFactor()); + assertEquals(1e-1, parameters.getReactiveSlackVariableScalingFactor()); + assertEquals(1e-3, parameters.getTwoWindingTransformerRatioVariableScalingFactor()); + assertEquals(1e-1, parameters.getShuntVariableScalingFactor()); assertTrue(parameters.checkAlgorithmParametersIntegrity()); } From d6cfa8dc69235e505bdc02e48789f648acbdd0a1 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Thu, 11 Jul 2024 12:54:10 +0200 Subject: [PATCH 09/10] Small clean Signed-off-by: p-arvy --- open-reac/README.md | 48 +++++++++---------- .../powsybl/openreac/OpenReacRunnerTest.java | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 7db33830..48136249 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -81,30 +81,30 @@ The user can configure the run with the dedicated Java interface Specifically, the user can set various parameters and thresholds used in the preprocessing and modeling of the reactive OPF. These are specified in the file `param_algo.txt`: -| Parameter | Description | Java default value | Domain | -|---------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-----------------------------------------------| -| `log_level_ampl` | Level of display for AMPL prints | INFO | {DEBUG, INFO, WARNING, ERROR} | -| `log_level_knitro` | Level of display for solver prints (see [AMPL documentation](https://dev.ampl.com/ampl/options.html)) | $1$ | {0, 1, 2} | -| `objective_choice` | Choice of the objective function for the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) | $0$ | {0, 1, 2} | -| `ratio_voltage_target` | Ratio to calculate target V of buses when `objective_choice` is set to $1$ (see [7](#7-alternative-current-optimal-power-flow)) | $0.5$ | $\[0; 1\]$ | -| `coeff_alpha` | Weight to favor more/less minimization of active power produced by generators or deviation between them and target values (see [6.2](#62-alternative-current-optimal-power-flow)) | $1$ | $\[0; 1\]$ | -| `Pnull` | Threshold of active and reactive powers considered as null | $0.01$ (MW) | $\[0; 1\]$ | -| `Znull` | Threshold of impedance considered as null (see [4.2](#)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ | - | `epsilon_nominal_voltage` | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathbb{R}^{+}$ | -| `min_plausible_low_voltage_limit` | Consistency bound for low voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $0.5$ (p.u.) | $\mathbb{R}^{+}$ | -| `max_plausible_high_voltage_limit` | Consistency bound for high voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $1.5$ (p.u.) | [`min_plausible_low_voltage_limit`; $\infty$] | -| `ignore_voltage_bounds` | Threshold to replace voltage limits of voltage levels with nominal voltage lower than it, by [min_plausible_low_voltage_limit; max_plausible_high_voltage_limit] | $0$ (p.u.) | $\mathbb{R}^{+}$ | -| `buses_with_reactive_slacks` | Choice of which buses will have reactive slacks attached in ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | ALL | {CONFIGURED, NO_GENERATION, ALL} | -| `PQmax` | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.4](#44-pq-units-domain)) | $9000$ (MW, MVAr) | $\mathbb{R}$ | -| `defaultPmax` | Threshold for correction of high active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $1000$ (MW) | $\mathbb{R}$ | -| `defaultPmin` | Threshold for correction of low active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $0$ (MW) | $\mathbb{R}$ | -| `defaultQmaxPmaxRatio` | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.4](#44-pq-units-domain)) | $0.3$ (MVAr/MW) | $\mathbb{R}$ | -| `minimalQPrange` | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.4](#44-pq-units-domain)) | $1$ (MW, MVAr) | $\mathbb{R}$ | -| `default_variable_scaling_factor` | Default scaling factor applied to all the variables (except reactive slacks and transformer ratios) before ACOPF solving | $1$ | $\mathbb{R}^{*,+}$ | -| `default_constraint_scaling_factor` | Default scaling factor applied to all the constraints before ACOPF solving | $1$ | $\mathbb{R}^{+}$ | -| `reactive_slack_variable_scaling_factor` | Scaling factor applied to all reactive slacks variables before ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | $0.1$ | $\mathbb{R}^{*,+}$ | -| `transformer_ratio_variable_scaling_factor` | Scaling factor applied to all transformer ratio variables before ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | $0.001$ | $\mathbb{R}^{*,+}$ | - +| Parameter | Description | Java default value | Domain | +|---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------|-----------------------------------------------| +| `log_level_ampl` | Level of display for AMPL prints | INFO | {DEBUG, INFO, WARNING, ERROR} | +| `log_level_knitro` | Level of display for solver prints (see [AMPL documentation](https://dev.ampl.com/ampl/options.html)) | $1$ | {0, 1, 2} | +| `objective_choice` | Choice of the objective function for the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) | $0$ | {0, 1, 2} | +| `ratio_voltage_target` | Ratio to calculate target V of buses when `objective_choice` is set to $1$ (see [7](#7-alternative-current-optimal-power-flow)) | $0.5$ | $\[0; 1\]$ | +| `coeff_alpha` | Weight to favor more/less minimization of active power produced by generators or deviation between them and target values (see [6.2](#62-alternative-current-optimal-power-flow)) | $1$ | $\[0; 1\]$ | +| `Pnull` | Threshold of active and reactive powers considered as null | $0.01$ (MW) | $\[0; 1\]$ | +| `Znull` | Threshold of impedance considered as null (see [4.2](#)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ | + | `epsilon_nominal_voltage` | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathbb{R}^{+}$ | +| `min_plausible_low_voltage_limit` | Consistency bound for low voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $0.5$ (p.u.) | $\mathbb{R}^{+}$ | +| `max_plausible_high_voltage_limit` | Consistency bound for high voltage limit of voltage levels (see [4.1](#41-voltage-level-limits-computation)) | $1.5$ (p.u.) | [`min_plausible_low_voltage_limit`; $\infty$] | +| `ignore_voltage_bounds` | Threshold to replace voltage limits of voltage levels with nominal voltage lower than it, by [min_plausible_low_voltage_limit; max_plausible_high_voltage_limit] | $0$ (p.u.) | $\mathbb{R}^{+}$ | +| `buses_with_reactive_slacks` | Choice of which buses will have reactive slacks attached in ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | ALL | {CONFIGURED, NO_GENERATION, ALL} | +| `PQmax` | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.4](#44-pq-units-domain)) | $9000$ (MW, MVAr) | $\mathbb{R}$ | +| `defaultPmax` | Threshold for correction of high active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $1000$ (MW) | $\mathbb{R}$ | +| `defaultPmin` | Threshold for correction of low active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $0$ (MW) | $\mathbb{R}$ | +| `defaultQmaxPmaxRatio` | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.4](#44-pq-units-domain)) | $0.3$ (MVAr/MW) | $\mathbb{R}$ | +| `minimalQPrange` | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.4](#44-pq-units-domain)) | $1$ (MW, MVAr) | $\mathbb{R}$ | +| `default_variable_scaling_factor` | Default scaling factor applied to all the variables (except reactive slacks and transformer ratios) before ACOPF solving | $1$ | $\mathbb{R}^{*,+}$ | +| `default_constraint_scaling_factor` | Default scaling factor applied to all the constraints before ACOPF solving | $1$ | $\mathbb{R}^{+}$ | +| `reactive_slack_variable_scaling_factor` | Scaling factor applied to all reactive slacks variables before ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | $0.1$ | $\mathbb{R}^{*,+}$ | +| `transformer_ratio_variable_scaling_factor` | Scaling factor applied to all transformer ratio variables before ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | $0.001$ | $\mathbb{R}^{*,+}$ | +| `shunt_variable_scaling_factor` | Scaling factor applied to all shunt variables before ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)) | $0.1$ | $\mathbb{R}^{*,+}$ | Please note that for these parameters, the AMPL code defines default values which may be different from those in Java (for example, for the scaling values). This allows a user to use the AMPL code without going through the Java interface, and without providing the file `param_algo.txt`. 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 b7051dfe..923c0ee1 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -252,7 +252,7 @@ void testRunAsync() throws IOException { subFolder + "/reactiveopf_results_vsc_converter_stations.csv", subFolder + "/reactiveopf_results_voltages.csv")); // To really run open reac, use the commented 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()) { try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), localCommandExecutor, ForkJoinPool.commonPool())) { CompletableFuture openReacResults = OpenReacRunner.runAsync(network, From cdf7eae997f49bfbc8049cc6ee59c618841fb877 Mon Sep 17 00:00:00 2001 From: Sophie Frasnedo Date: Thu, 11 Jul 2024 13:53:43 +0200 Subject: [PATCH 10/10] Fix typo Signed-off-by: Sophie Frasnedo --- .../test/java/com/powsybl/openreac/OpenReacParametersTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java index b54b1055..dd3e89a1 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java @@ -424,7 +424,7 @@ void testDefaultParametersListsIntegrity() { assertEquals(0, parameters.getSpecificVoltageLimits().size(), "SpecificVoltageLimits should be empty when using default OpenReacParameter constructor."); assertEquals(0, parameters.getConstantQGenerators().size(), "ConstantQGenerators should be empty when using default OpenReacParameter constructor."); assertEquals(0, parameters.getVariableShuntCompensators().size(), "VariableShuntCompensators should be empty when using default OpenReacParameter constructor."); - assertEquals(0, parameters.getConfiguredReactiveSlackBuses().size(), "ConfiguredReactiveSlackBuses should be empty when using default OpenREacParameter constructor."); + assertEquals(0, parameters.getConfiguredReactiveSlackBuses().size(), "ConfiguredReactiveSlackBuses should be empty when using default OpenReacParameter constructor."); assertEquals(21, parameters.getAllAlgorithmParams().size()); }