From a1298150267f06c5358393a2757f4400ceb8d7c6 Mon Sep 17 00:00:00 2001 From: p-arvy <126792538+p-arvy@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:33:13 +0100 Subject: [PATCH] Add configuration of reactive slacks repartition (#41) Signed-off-by: parvy Co-authored-by: Anne Tilloy --- .../parameters/OpenReacAmplIOFiles.java | 4 +- .../input/AbstractElementsInput.java | 2 +- .../ConfiguredBusesWithReactiveSlack.java | 32 +++++++ .../parameters/input/OpenReacParameters.java | 36 ++++++++ .../input/algo/ReactiveSlackBusesMode.java | 32 +++++++ .../json/OpenReacParametersDeserializer.java | 9 ++ .../json/OpenReacParametersSerializer.java | 5 + .../main/resources/openreac/reactiveopf.dat | 10 +- .../main/resources/openreac/reactiveopf.mod | 27 +++--- .../main/resources/openreac/reactiveopf.run | 36 +++++--- .../resources/openreac/reactiveopfexit.run | 1 + .../resources/openreac/reactiveopfoutput.run | 1 + .../openreac/OpenReacParametersTest.java | 92 ++++++++++++------- .../powsybl/openreac/OpenReacRunnerTest.java | 18 ++-- .../input/json/OpenReacJsonModuleTest.java | 5 + .../resources/expected_inputs/param_algo.txt | 1 + .../param_buses_with_reactive_slack.txt | 3 + .../param_generators_reactive.txt | 2 +- .../expected_inputs/param_shunts.txt | 2 +- .../expected_inputs/param_transformers.txt | 2 +- .../reactiveopf_results_indic.txt | 11 ++- .../default.txt | 1 + .../modified_param_algo.txt | 1 + .../reactiveopf_results_generators.csv | 4 +- .../reactiveopf_results_indic.txt | 15 +-- .../reactiveopf_results_indic.txt | 9 +- .../reactiveopf_results_indic.txt | 13 +-- .../reactiveopf_results_indic.txt | 5 +- .../reactiveopf_results_indic.txt | 7 +- .../reactiveopf_results_indic.txt | 7 +- open-reac/src/test/resources/parameters.json | 4 +- 31 files changed, 295 insertions(+), 102 deletions(-) create mode 100644 open-reac/src/main/java/com/powsybl/openreac/parameters/input/ConfiguredBusesWithReactiveSlack.java create mode 100644 open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/ReactiveSlackBusesMode.java create mode 100644 open-reac/src/test/resources/expected_inputs/param_buses_with_reactive_slack.txt diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/OpenReacAmplIOFiles.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/OpenReacAmplIOFiles.java index 55c4801a..ee3aace5 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/OpenReacAmplIOFiles.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/OpenReacAmplIOFiles.java @@ -38,6 +38,7 @@ public class OpenReacAmplIOFiles implements AmplParameters { private final AlgorithmInput algorithmParams; private final ReactiveSlackOutput reactiveSlackOutput; private final VoltageLevelLimitsOverrideInput voltageLimitsOverride; + private final ConfiguredBusesWithReactiveSlack configuredReactiveSlackBuses; private final NetworkModifications networkModifications; private final boolean debug; @@ -48,6 +49,7 @@ public OpenReacAmplIOFiles(OpenReacParameters params, Network network, boolean d this.variableTwoWindingsTransformers = new VariableTwoWindingsTransformers(params.getVariableTwoWindingsTransformers()); this.algorithmParams = new AlgorithmInput(params.getAllAlgorithmParams()); this.voltageLimitsOverride = new VoltageLevelLimitsOverrideInput(params.getSpecificVoltageLimits(), network); + this.configuredReactiveSlackBuses = new ConfiguredBusesWithReactiveSlack(params.getConfiguredReactiveSlackBuses()); //outputs this.reactiveSlackOutput = new ReactiveSlackOutput(); @@ -67,7 +69,7 @@ public NetworkModifications getNetworkModifications() { @Override public Collection getInputParameters() { return List.of(constantQGenerators, variableShuntCompensators, variableTwoWindingsTransformers, - algorithmParams, voltageLimitsOverride); + algorithmParams, voltageLimitsOverride, configuredReactiveSlackBuses); } @Override diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/AbstractElementsInput.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/AbstractElementsInput.java index 34832d39..3982bafd 100644 --- a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/AbstractElementsInput.java +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/AbstractElementsInput.java @@ -28,7 +28,7 @@ protected AbstractElementsInput(List elementIds) { @Override public void write(BufferedWriter writer, StringToIntMapper stringToIntMapper) throws IOException { - writer.write("#amplId powsyblId\n"); + writer.write("#num id\n"); for (String elementID : elementIds) { int amplId = stringToIntMapper.getInt(getElementAmplSubset(), elementID); String[] tokens = {Integer.toString(amplId), AmplIOUtils.addQuotes(elementID)}; diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/ConfiguredBusesWithReactiveSlack.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/ConfiguredBusesWithReactiveSlack.java new file mode 100644 index 00000000..aeb57846 --- /dev/null +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/ConfiguredBusesWithReactiveSlack.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2023, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package com.powsybl.openreac.parameters.input; + +import com.powsybl.ampl.converter.AmplSubset; + +import java.util.List; + +/** + * @author Pierre Arvy + */ +public class ConfiguredBusesWithReactiveSlack extends AbstractElementsInput { + public static final String PARAM_BUSES_FILE_NAME = "param_buses_with_reactive_slack.txt"; + + public ConfiguredBusesWithReactiveSlack(List elementIds) { + super(elementIds); + } + + @Override + public String getFileName() { + return PARAM_BUSES_FILE_NAME; + } + + @Override + AmplSubset getElementAmplSubset() { + return AmplSubset.BUS; + } +} 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 a2d2cf68..dbcda6d6 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 @@ -20,6 +20,7 @@ * This class stores all inputs parameters specific to the OpenReac optimizer. * * @author Nicolas Pierre + * @author Pierre Arvy */ public class OpenReacParameters { @@ -33,6 +34,8 @@ public class OpenReacParameters { private final List variableTwoWindingsTransformers = new ArrayList<>(); + private final List configuredReactiveSlackBuses = new ArrayList<>(); + // Algo parameters private OpenReacOptimisationObjective objective = OpenReacOptimisationObjective.MIN_GENERATION; @@ -53,6 +56,8 @@ public class OpenReacParameters { private double maxPlausibleHighVoltageLimit = 1.5; // in pu + private ReactiveSlackBusesMode reactiveSlackBusesMode = ReactiveSlackBusesMode.NO_GENERATION; + /** * Override some voltage level limits in the network. This will NOT modify the network object. *

@@ -89,6 +94,14 @@ public OpenReacParameters addVariableTwoWindingsTransformers(List transf return this; } + /** + * A list of buses, to which reactive slacks variable will be attached by the optimizer. + */ + public OpenReacParameters addConfiguredReactiveSlackBuses(List busesIds) { + this.configuredReactiveSlackBuses.addAll(busesIds); + return this; + } + /** * The definition of the objective function for the optimization. */ @@ -190,6 +203,19 @@ public OpenReacParameters setMaxPlausibleHighVoltageLimit(double maxPlausibleHig return this; } + /** + * @return the mode used to select which buses will have reactive slack variables attached in the optimization. + * If mode is CONFIGURED, the buses in configuredReactiveSlackBuses are used. + */ + public ReactiveSlackBusesMode getReactiveSlackBusesMode() { + return reactiveSlackBusesMode; + } + + public OpenReacParameters setReactiveSlackBusesMode(ReactiveSlackBusesMode reactiveSlackBusesMode) { + this.reactiveSlackBusesMode = Objects.requireNonNull(reactiveSlackBusesMode); + return this; + } + public List getVariableShuntCompensators() { return variableShuntCompensators; } @@ -206,6 +232,10 @@ public List getVariableTwoWindingsTransformers() { return variableTwoWindingsTransformers; } + public List getConfiguredReactiveSlackBuses() { + return configuredReactiveSlackBuses; + } + public List getAllAlgorithmParams() { ArrayList allAlgoParams = new ArrayList<>(); allAlgoParams.add(objective.toParam()); @@ -216,6 +246,7 @@ public List getAllAlgorithmParams() { allAlgoParams.add(this.logLevelSolver.toParam()); allAlgoParams.add(new OpenReacAlgoParamImpl(MIN_PLAUSIBLE_LOW_VOLTAGE_LIMIT_KEY, Double.toString(minPlausibleLowVoltageLimit))); allAlgoParams.add(new OpenReacAlgoParamImpl(MAX_PLAUSIBLE_HIGH_VOLTAGE_LIMIT_KEY, Double.toString(maxPlausibleHighVoltageLimit))); + allAlgoParams.add(reactiveSlackBusesMode.toParam()); return allAlgoParams; } @@ -241,6 +272,11 @@ public void checkIntegrity(Network network) throws InvalidParametersException { throw new InvalidParametersException("Two windings transformer " + transformerId + " not found in the network."); } } + for (String busId : getConfiguredReactiveSlackBuses()) { + if (network.getBusView().getBus(busId) == null) { + throw new InvalidParametersException("Bus " + busId + " not found in the network."); + } + } // Check integrity of voltage overrides boolean integrityVoltageLimitOverrides = checkVoltageLimitOverrides(network); diff --git a/open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/ReactiveSlackBusesMode.java b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/ReactiveSlackBusesMode.java new file mode 100644 index 00000000..20ada48e --- /dev/null +++ b/open-reac/src/main/java/com/powsybl/openreac/parameters/input/algo/ReactiveSlackBusesMode.java @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2023, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ +package com.powsybl.openreac.parameters.input.algo; + +/** + * @author Pierre Arvy + */ +public enum ReactiveSlackBusesMode { + CONFIGURED("CONFIGURED"), + NO_GENERATION("NO_GENERATION"), + ALL("ALL"); + + private static final String REACTIVE_SLACK_BUSES_KEY = "buses_with_reactive_slacks"; + + private final String amplKey; + + /** + * @param amplKey value used in param_algo.txt to define the slacks repartition. + */ + ReactiveSlackBusesMode(String amplKey) { + this.amplKey = amplKey; + } + + public OpenReacAlgoParam toParam() { + return new OpenReacAlgoParamImpl(REACTIVE_SLACK_BUSES_KEY, amplKey); + } + +} 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 7b50e988..433a934b 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 @@ -14,6 +14,7 @@ import com.powsybl.openreac.parameters.input.OpenReacParameters; import com.powsybl.openreac.parameters.input.VoltageLimitOverride; import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import com.powsybl.openreac.parameters.input.algo.OpenReacOptimisationObjective; import com.powsybl.openreac.parameters.input.algo.OpenReacSolverLogLevel; @@ -57,6 +58,10 @@ public OpenReacParameters deserialize(JsonParser parser, DeserializationContext parser.nextToken(); parameters.addVariableTwoWindingsTransformers(parser.readValueAs(new TypeReference>() { })); break; + case "configuredReactiveSlackBuses": + parser.nextToken(); + parameters.addConfiguredReactiveSlackBuses(parser.readValueAs(new TypeReference>() { })); + break; case "objective": parser.nextToken(); parameters.setObjective(OpenReacOptimisationObjective.valueOf(parser.getText())); @@ -81,6 +86,10 @@ public OpenReacParameters deserialize(JsonParser parser, DeserializationContext parser.nextToken(); parameters.setMaxPlausibleHighVoltageLimit(parser.readValueAs(Double.class)); break; + case "reactiveSlackBusesMode": + parser.nextToken(); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.valueOf(parser.getText())); + break; 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 4d3b8763..5aa24e56 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 @@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import com.powsybl.openreac.parameters.input.OpenReacParameters; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import java.io.IOException; @@ -34,6 +35,9 @@ public void serialize(OpenReacParameters openReacParameters, JsonGenerator jsonG serializerProvider.defaultSerializeField("constantQGenerators", openReacParameters.getConstantQGenerators(), jsonGenerator); serializerProvider.defaultSerializeField("variableTwoWindingsTransformers", openReacParameters.getVariableTwoWindingsTransformers(), jsonGenerator); serializerProvider.defaultSerializeField("variableShuntCompensators", openReacParameters.getVariableShuntCompensators(), jsonGenerator); + if (openReacParameters.getReactiveSlackBusesMode() == ReactiveSlackBusesMode.CONFIGURED) { + serializerProvider.defaultSerializeField("configuredReactiveSlackBuses", openReacParameters.getConfiguredReactiveSlackBuses(), jsonGenerator); + } serializerProvider.defaultSerializeField("objective", openReacParameters.getObjective().name(), jsonGenerator); if (openReacParameters.getObjectiveDistance() != null) { serializerProvider.defaultSerializeField("objectiveDistance", openReacParameters.getObjectiveDistance(), jsonGenerator); @@ -42,6 +46,7 @@ public void serialize(OpenReacParameters openReacParameters, JsonGenerator jsonG serializerProvider.defaultSerializeField("logLevelSolver", openReacParameters.getLogLevelSolver(), jsonGenerator); serializerProvider.defaultSerializeField("minPlausibleLowVoltageLimit", openReacParameters.getMinPlausibleLowVoltageLimit(), jsonGenerator); serializerProvider.defaultSerializeField("maxPlausibleHighVoltageLimit", openReacParameters.getMaxPlausibleHighVoltageLimit(), jsonGenerator); + serializerProvider.defaultSerializeField("reactiveSlackBusesMode", openReacParameters.getReactiveSlackBusesMode().name(), jsonGenerator); jsonGenerator.writeEndObject(); } } diff --git a/open-reac/src/main/resources/openreac/reactiveopf.dat b/open-reac/src/main/resources/openreac/reactiveopf.dat index 1f20e015..c306f93f 100644 --- a/open-reac/src/main/resources/openreac/reactiveopf.dat +++ b/open-reac/src/main/resources/openreac/reactiveopf.dat @@ -77,13 +77,17 @@ param: BRANCH: branch_3wt branch_subor branch_subex branch_R branch_X branch_Gor param: BOUND_OVERRIDES: substation_new_Vmin, substation_new_Vmax, substation_new_checkId := include ampl_network_substations_override.txt; # param_shunts.txt -#"variant" "num" "bus" "id" +#"num" "id" param: PARAM_SHUNT: param_shunt_id := include param_shunts.txt; # param_generators_reactive.txt -#"variant" "num" "bus" "id" +#"num" "id" param: PARAM_UNIT_FIXQ: param_unit_fixq_id := include param_generators_reactive.txt; # param_transformers.txt -#"variant" "num" "bus1" "bus2" "id" +#"num" "id" param: PARAM_TRANSFORMERS_RATIO_VARIABLE: param_transformers_ratio_variable_id := include param_transformers.txt; + +# param_buses_with_reactive_slack.txt +#"num" "id" +param: PARAM_BUSES_WITH_REACTIVE_SLACK: param_buses_with_reactive_slack_id := include param_buses_with_reactive_slack.txt; diff --git a/open-reac/src/main/resources/openreac/reactiveopf.mod b/open-reac/src/main/resources/openreac/reactiveopf.mod index aa975cd0..9c3d312f 100644 --- a/open-reac/src/main/resources/openreac/reactiveopf.mod +++ b/open-reac/src/main/resources/openreac/reactiveopf.mod @@ -529,6 +529,16 @@ param param_transformers_ratio_variable_id{PARAM_TRANSFORMERS_RATIO_VARIABLE} sy check {(t,qq,m,n) in BRANCH: qq in PARAM_TRANSFORMERS_RATIO_VARIABLE}: branch_id[t,qq,m,n] == param_transformers_ratio_variable_id[qq]; +############################################################################### +# Buses with reactive slacks +############################################################################### +# param_buses_with_reactive_slack.txt +# If buses_with_reactive_slacks == "CONFIGURED" then only buses listed in this file will have reactive slacks attached in ACOPF +#"num" "id" +set PARAM_BUSES_WITH_REACTIVE_SLACK dimen 1 default {}; +param param_buses_with_reactive_slack_id{PARAM_BUSES_WITH_REACTIVE_SLACK} symbolic; +check {(t,n) in BUS: n in PARAM_BUSES_WITH_REACTIVE_SLACK}: bus_id[t,n] == param_buses_with_reactive_slack_id[n]; + ############################################################################### # Additional sets for equipments which are really working @@ -939,17 +949,12 @@ subject to ctr_balance_P{PROBLEM_ACOPF,k in BUSCC}: # Reactive Balance # -# Reactive balance slack variables only if there is a load or a shunt connected -# If there is a unit, or SVC, or VSC, they already have reactive power generation, so no need to add slack variables -set BUSCC_SLACK := {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 - ) - } ; -var slack1_balance_Q{BUSCC_SLACK} >=0, <= 500; # 500 Mvar is already HUGE -var slack2_balance_Q{BUSCC_SLACK} >=0, <= 500; +# Reactive balance slack variables at configured nodes +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; #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}: diff --git a/open-reac/src/main/resources/openreac/reactiveopf.run b/open-reac/src/main/resources/openreac/reactiveopf.run index 19cbf205..a7109f6d 100644 --- a/open-reac/src/main/resources/openreac/reactiveopf.run +++ b/open-reac/src/main/resources/openreac/reactiveopf.run @@ -181,18 +181,20 @@ if length($SHELL) > 0 then { # initialized to empty sets or tables; so the minimum we need is empty file. # Maybe this is not the best way to manage optional parameter files... if operatingSystem == "linux" then { - shell "if [ ! -f param_algo.txt ]; then touch param_algo.txt ;fi"; - shell "if [ ! -f param_shunts.txt ]; then touch param_shunts.txt ;fi"; - shell "if [ ! -f param_generators_reactive.txt ]; then touch param_generators_reactive.txt ;fi"; - shell "if [ ! -f param_transformers.txt ]; then touch param_transformers.txt ;fi"; + shell "if [ ! -f param_algo.txt ]; then touch param_algo.txt ;fi"; + shell "if [ ! -f param_shunts.txt ]; then touch param_shunts.txt ;fi"; + shell "if [ ! -f param_generators_reactive.txt ]; then touch param_generators_reactive.txt ;fi"; + shell "if [ ! -f param_transformers.txt ]; then touch param_transformers.txt ;fi"; + shell "if [ ! -f param_buses_with_reactive_slack.txt ]; then touch param_buses_with_reactive_slack.txt ;fi"; shell "if [ ! -f ampl_network_substations_override.txt ]; then touch ampl_network_substations_override.txt ;fi"; shell "chmod a+rX . * 2>/dev/null"; } if operatingSystem == "windows" then { - shell "if not exist param_algo.txt echo #empty > param_algo.txt"; - shell "if not exist param_shunts.txt echo #empty > param_shunts.txt"; - shell "if not exist param_generators_reactive.txt echo #empty > param_generators_reactive.txt"; - shell "if not exist param_transformers.txt echo #empty > param_transformers.txt"; + shell "if not exist param_algo.txt echo #empty > param_algo.txt"; + shell "if not exist param_shunts.txt echo #empty > param_shunts.txt"; + shell "if not exist param_generators_reactive.txt echo #empty > param_generators_reactive.txt"; + shell "if not exist param_transformers.txt echo #empty > param_transformers.txt"; + shell "if not exist param_buses_with_reactive_slack.txt echo #empty > param_buses_with_reactive_slack.txt"; shell "if not exist ampl_network_substations_override.txt echo #empty > ampl_network_substations_override.txt"; } # If operating system is not linux nor windows, then these optional files are @@ -226,11 +228,11 @@ display PARAM_ALGO_VALUES; # Log level of ampl printing set LOG_LEVELS ordered = {"ERROR", "WARNING", "INFO", "DEBUG"}; # different values of log level for ampl exec -param log_level_ampl symbolic default "INFO"; # default value of log level +param log_level_ampl symbolic default "INFO"; # default value of log level if "log_level_ampl" in PARAM_ALGO_KEYS then let log_level_ampl := PARAM_ALGO_VALUES["log_level_ampl"]; # Sets used to print or not. A void set avoid printing -param log_index := ord0(log_level_ampl, LOG_LEVELS); +param log_index := ord0(log_level_ampl, LOG_LEVELS); set LOG_DEBUG := if log_index >= 4 then{1} else {}; set LOG_INFO := if log_index >= 3 then{1} else {}; set LOG_WARNING := if log_index >= 2 then{1} else {}; @@ -313,6 +315,14 @@ 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"; +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." + else if buses_with_reactive_slacks == "NO_GENERATION" then "buses without generation (no generator, svc or vsc)" + else if buses_with_reactive_slacks == "CONFIGURED" then "buses given as parameters in param_buses_with_reactive_slack.txt"; +check buses_with_reactive_slacks in {"CONFIGURED", "NO_GENERATION", "ALL"}; + # Consistency maximal value for P and Q # Any Pmax Pmin Qmax Qmin of generating unit with abolute value larger than PQmax is discarded # Largest nuclear plant in Europe are less than 2000GW. Value 9000 might be a problem for large hydro dams in the world (22GW) @@ -1073,7 +1083,7 @@ for {(qq,m,n) in BRANCHCC: (teta[m]-teta[n])>temp1*0.99 or (teta[m]-teta[n]) Pnull then { - + if 1 in LOG_INFO then display sum{n in BUSCC_SLACK} slack1_balance_Q[n], @@ -1101,7 +1111,7 @@ include reactiveopfoutput.run; # Write voltage information in debug file let fileOut := "debug_bus.csv"; printf{LOG_DEBUG} "#bus_id;Vnom;V;Vlb;Vub;Vmin_mod;Vmax_mod;Vmin_OK;Vmax_OK;Vmin_ori;Vmax_ori;sQ1;sQ2;\n" > (fileOut); -for {n in BUSCC} +for {n in BUSCC} printf{LOG_DEBUG} "%Q;%i;%.4f;%.4f;%.4f;%.4f;%.4f;%s;%s;%.4f;%.4f;%.2f;%.2f;\n", bus_id[1,n],substation_Vnomi[1,bus_substation[1,n]], V[n],V[n].lb,V[n].ub, @@ -1118,7 +1128,7 @@ close (fileOut); # Write units which are not in uniton (debug only) let fileOut := "reactiveopf_results_generators_Pnull.csv"; printf{LOG_DEBUG} "#variant;num;bus;vRegul;V(pu);targetP(MW);targetQ(Mvar);P(MW);Q(MW);id;bus_id;\n" > (fileOut); -for {(g,n) in UNITCC diff UNITON} +for {(g,n) in UNITCC diff UNITON} printf{LOG_DEBUG} "%i;%i;%i;%Q;%.3f;%.3f;%.3f;%.3f;%.3f;%Q;%Q;\n", 1,g,n, unit_vregul[1,g,n], diff --git a/open-reac/src/main/resources/openreac/reactiveopfexit.run b/open-reac/src/main/resources/openreac/reactiveopfexit.run index db70d245..e8cae7a7 100644 --- a/open-reac/src/main/resources/openreac/reactiveopfexit.run +++ b/open-reac/src/main/resources/openreac/reactiveopfexit.run @@ -58,6 +58,7 @@ printf "%s %f\n","epsilon_nominal_voltage",epsilon_nominal_voltage > (fileOut); printf "%s %f\n","min_plausible_low_voltage_limit",min_plausible_low_voltage_limit > (fileOut); printf "%s %f\n","max_plausible_high_voltage_limit",max_plausible_high_voltage_limit > (fileOut); printf "%s %f\n","ignore_voltage_bounds",ignore_voltage_bounds > (fileOut); +printf "%s %s\n","buses_with_reactive_slacks",buses_with_reactive_slacks > (fileOut); printf "%s %f\n","PQmax",PQmax > (fileOut); printf "%s %f\n","defaultPmax",defaultPmax > (fileOut); printf "%s %f\n","defaultPmin",defaultPmin > (fileOut); diff --git a/open-reac/src/main/resources/openreac/reactiveopfoutput.run b/open-reac/src/main/resources/openreac/reactiveopfoutput.run index f1afba9c..f6130193 100644 --- a/open-reac/src/main/resources/openreac/reactiveopfoutput.run +++ b/open-reac/src/main/resources/openreac/reactiveopfoutput.run @@ -242,6 +242,7 @@ printf "%s %f\n","epsilon_nominal_voltage",epsilon_nominal_voltage > (fileOut); printf "%s %f\n","min_plausible_low_voltage_limit",min_plausible_low_voltage_limit > (fileOut); printf "%s %f\n","max_plausible_high_voltage_limit",max_plausible_high_voltage_limit > (fileOut); printf "%s %f\n","ignore_voltage_bounds",ignore_voltage_bounds > (fileOut); +printf "%s %s\n","buses_with_reactive_slacks",buses_with_reactive_slacks > (fileOut); printf "%s %f\n","PQmax",PQmax > (fileOut); printf "%s %f\n","defaultPmax",defaultPmax > (fileOut); printf "%s %f\n","defaultPmin",defaultPmin > (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 e91760d6..f0d8c99d 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacParametersTest.java @@ -14,6 +14,7 @@ import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; import com.powsybl.openreac.parameters.input.algo.OpenReacOptimisationObjective; import com.powsybl.openreac.parameters.input.algo.OpenReacSolverLogLevel; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import org.junit.jupiter.api.Test; import java.util.List; @@ -123,66 +124,95 @@ void testAlgorithmParams() { parameters.setLogLevelSolver(OpenReacSolverLogLevel.NOTHING); parameters.setMinPlausibleLowVoltageLimit(0.8); parameters.setMaxPlausibleHighVoltageLimit(1.2); - List algoParams = parameters.getAllAlgorithmParams(); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.ALL); - assertEquals(6, algoParams.size()); + List algoParams = parameters.getAllAlgorithmParams(); + assertEquals(7, algoParams.size()); assertEquals("2", algoParams.get(0).getValue()); assertEquals("0.4", algoParams.get(1).getValue()); assertEquals("DEBUG", algoParams.get(2).getValue()); assertEquals("0", algoParams.get(3).getValue()); assertEquals("0.8", algoParams.get(4).getValue()); assertEquals("1.2", algoParams.get(5).getValue()); + assertEquals("ALL", algoParams.get(6).getValue()); } @Test - void testParametersIntegrity() { - Network network = IeeeCdfNetworkFactory.create57(); - setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network - String wrongId = "An id not in 118 cdf network."; + void testBusesWithReactiveSlackConfigIntegrity() { OpenReacParameters parameters = new OpenReacParameters(); + assertEquals(ReactiveSlackBusesMode.NO_GENERATION, parameters.getReactiveSlackBusesMode()); // default value + assertThrows(NullPointerException.class, () -> parameters.setReactiveSlackBusesMode(null)); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED); + assertEquals("CONFIGURED", parameters.getReactiveSlackBusesMode().toParam().getValue()); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.NO_GENERATION); + assertEquals("NO_GENERATION", parameters.getReactiveSlackBusesMode().toParam().getValue()); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.ALL); + assertEquals("ALL", parameters.getReactiveSlackBusesMode().toParam().getValue()); + } + + @Test + void testDefaultListsOfParametersIntegrity() { + // testing default lists of parameters + OpenReacParameters parameters = new OpenReacParameters(); assertEquals(0, parameters.getVariableTwoWindingsTransformers().size(), "VariableTwoWindingsTransformers should be empty when using default OpenReacParameter constructor."); 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(5, parameters.getAllAlgorithmParams().size()); + assertEquals(0, parameters.getConfiguredReactiveSlackBuses().size(), "ConfiguredReactiveSlackBuses should be empty when using default OpenREacParameter constructor."); + assertEquals(6, parameters.getAllAlgorithmParams().size()); + } + + @Test + void testListsOfParametersIntegrity() { + Network network = IeeeCdfNetworkFactory.create57(); + setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network + String wrongId = "An id not in 57 cdf network."; - // adding an objective, to have a valid OpenReacParameter object - parameters.setObjective(OpenReacOptimisationObjective.MIN_GENERATION); - // testing TwoWindingsTransformer + testTwoWindingsTransformersParametersIntegrity(network, wrongId); + testShuntCompensatorParametersIntegrity(network, wrongId); + testConstantQGeneratorsParametersIntegrity(network, wrongId); + testBusesWithReactiveSlacksParametersIntegrity(network, wrongId); + } + + void testTwoWindingsTransformersParametersIntegrity(Network network, String wrongId) { + OpenReacParameters parameters = new OpenReacParameters(); parameters.addVariableTwoWindingsTransformers(network.getTwoWindingsTransformerStream().map(TwoWindingsTransformer::getId).collect(Collectors.toList())); - OpenReacParameters lambdaParams = parameters; // for the lambdas to compile - assertDoesNotThrow(() -> lambdaParams.checkIntegrity(network), "Adding TwoWindingsTransformer network IDs should not throw."); + assertDoesNotThrow(() -> parameters.checkIntegrity(network), "Adding TwoWindingsTransformer network IDs should not throw."); parameters.addVariableTwoWindingsTransformers(List.of(wrongId)); assertNull(network.getTwoWindingsTransformer(wrongId), "Please change wrong ID so it does not match any element in the network."); - InvalidParametersException e = assertThrows(InvalidParametersException.class, () -> lambdaParams.checkIntegrity(network)); + InvalidParametersException e = assertThrows(InvalidParametersException.class, () -> parameters.checkIntegrity(network)); assertEquals("Two windings transformer " + wrongId + " not found in the network.", e.getMessage()); + } - // Reseting parameters - parameters = new OpenReacParameters(); - parameters.setObjective(OpenReacOptimisationObjective.MIN_GENERATION); - - // testing ShuntCompensator + void testShuntCompensatorParametersIntegrity(Network network, String wrongId) { + OpenReacParameters parameters = new OpenReacParameters(); parameters.addVariableShuntCompensators(network.getShuntCompensatorStream().map(ShuntCompensator::getId).collect(Collectors.toList())); - OpenReacParameters lambdaParamsShunts = parameters; // for the lambdas to compile - assertDoesNotThrow(() -> lambdaParamsShunts.checkIntegrity(network), "Adding ShuntCompensator network IDs should not throw."); + assertDoesNotThrow(() -> parameters.checkIntegrity(network), "Adding ShuntCompensator network IDs should not throw."); parameters.addVariableShuntCompensators(List.of(wrongId)); assertNull(network.getShuntCompensator(wrongId), "Please change wrong ID so it does not match any element in the network."); - InvalidParametersException e2 = assertThrows(InvalidParametersException.class, () -> lambdaParamsShunts.checkIntegrity(network)); - assertEquals("Shunt " + wrongId + " not found in the network.", e2.getMessage()); - - // Reseting parameters - parameters = new OpenReacParameters(); - parameters.setObjective(OpenReacOptimisationObjective.MIN_GENERATION); + InvalidParametersException e = assertThrows(InvalidParametersException.class, () -> parameters.checkIntegrity(network)); + assertEquals("Shunt " + wrongId + " not found in the network.", e.getMessage()); + } - // testing Generator + void testConstantQGeneratorsParametersIntegrity(Network network, String wrongId) { + OpenReacParameters parameters = new OpenReacParameters(); parameters.addConstantQGenerators(network.getGeneratorStream().map(Generator::getId).collect(Collectors.toList())); - OpenReacParameters lambdaParamsGenerators = parameters; // for the lambdas to compile - assertDoesNotThrow(() -> lambdaParamsGenerators.checkIntegrity(network), "Adding Generator network IDs should not throw."); + assertDoesNotThrow(() -> parameters.checkIntegrity(network), "Adding Generator network IDs should not throw."); parameters.addConstantQGenerators(List.of(wrongId)); assertNull(network.getGenerator(wrongId), "Please change wrong ID so it does not match any element in the network."); - InvalidParametersException e3 = assertThrows(InvalidParametersException.class, () -> lambdaParamsGenerators.checkIntegrity(network)); - assertEquals("Generator " + wrongId + " not found in the network.", e3.getMessage()); + InvalidParametersException e = assertThrows(InvalidParametersException.class, () -> parameters.checkIntegrity(network)); + assertEquals("Generator " + wrongId + " not found in the network.", e.getMessage()); + } + + void testBusesWithReactiveSlacksParametersIntegrity(Network network, String wrongId) { + OpenReacParameters parameters = new OpenReacParameters(); + parameters.addConfiguredReactiveSlackBuses(network.getBusView().getBusStream().map(Bus::getId).collect(Collectors.toList())); + assertDoesNotThrow(() -> parameters.checkIntegrity(network), "Adding Buses network IDs should not throw."); + parameters.addConfiguredReactiveSlackBuses(List.of(wrongId)); + assertNull(network.getBusView().getBus(wrongId), "Please change wrong ID so it does not match any any element in the network."); + InvalidParametersException e = assertThrows(InvalidParametersException.class, () -> parameters.checkIntegrity(network)); + assertEquals("Bus " + wrongId + " not found in the network.", e.getMessage()); } void setDefaultVoltageLimits(Network network) { 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 65a7a0e4..b16d5993 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/OpenReacRunnerTest.java @@ -21,6 +21,7 @@ import com.powsybl.openreac.network.VoltageControlNetworkFactory; import com.powsybl.openreac.parameters.input.OpenReacParameters; import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import com.powsybl.openreac.parameters.input.algo.OpenReacOptimisationObjective; import com.powsybl.openreac.parameters.input.algo.OpenReacSolverLogLevel; import com.powsybl.openreac.parameters.output.OpenReacResult; @@ -102,7 +103,8 @@ void testParamAlgoExport() throws IOException { .setLogLevelAmpl(OpenReacAmplLogLevel.WARNING) .setLogLevelSolver(OpenReacSolverLogLevel.ONLY_RESULTS) .setMinPlausibleLowVoltageLimit(0.7888) - .setMaxPlausibleHighVoltageLimit(1.3455); + .setMaxPlausibleHighVoltageLimit(1.3455) + .setReactiveSlackBusesMode(ReactiveSlackBusesMode.ALL); LocalCommandExecutor localCommandExecutor = new TestLocalCommandExecutor( List.of("empty_case/reactiveopf_results_indic.txt")); @@ -119,9 +121,11 @@ void testParamAlgoExport() throws IOException { void testInputFile() throws IOException { Network network = IeeeCdfNetworkFactory.create57(); setDefaultVoltageLimits(network); // set default voltage limits to every voltage levels of the network + OpenReacParameters parameters = new OpenReacParameters().setObjective( OpenReacOptimisationObjective.BETWEEN_HIGH_AND_LOW_VOLTAGE_LIMIT) .setObjectiveDistance(70) + .setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED) .addVariableTwoWindingsTransformers(network.getTwoWindingsTransformerStream() .limit(1) .map(TwoWindingsTransformer::getId) @@ -129,7 +133,9 @@ void testInputFile() throws IOException { .addConstantQGenerators( network.getGeneratorStream().limit(1).map(Generator::getId).collect(Collectors.toList())) .addVariableShuntCompensators( - network.getShuntCompensatorStream().limit(1).map(ShuntCompensator::getId).collect(Collectors.toList())); + network.getShuntCompensatorStream().limit(1).map(ShuntCompensator::getId).collect(Collectors.toList())) + .addConfiguredReactiveSlackBuses( + network.getBusView().getBusStream().limit(1).map(Bus::getId).collect(Collectors.toList())); LocalCommandExecutor localCommandExecutor = new TestLocalCommandExecutor( List.of("empty_case/reactiveopf_results_indic.txt")); @@ -139,10 +145,10 @@ void testInputFile() throws IOException { new OpenReacConfig(true), computationManager); Path execFolder = getAmplExecPath(); assertEqualsToRef(execFolder.resolve("param_algo.txt"), "/expected_inputs/param_algo.txt"); - assertEqualsToRef(execFolder.resolve("param_generators_reactive.txt"), - "/expected_inputs/param_generators_reactive.txt"); + assertEqualsToRef(execFolder.resolve("param_generators_reactive.txt"), "/expected_inputs/param_generators_reactive.txt"); assertEqualsToRef(execFolder.resolve("param_shunts.txt"), "/expected_inputs/param_shunts.txt"); assertEqualsToRef(execFolder.resolve("param_transformers.txt"), "/expected_inputs/param_transformers.txt"); + assertEqualsToRef(execFolder.resolve("param_buses_with_reactive_slack.txt"), "/expected_inputs/param_buses_with_reactive_slack.txt"); } } @@ -206,7 +212,7 @@ public void testOutputFileParsing() throws IOException { assertEquals(1, openReacResult.getSvcModifications().size()); assertEquals(1, openReacResult.getVscModifications().size()); assertEquals(7, openReacResult.getGeneratorModifications().size()); - assertEquals(81, openReacResult.getIndicators().size()); + assertEquals(82, openReacResult.getIndicators().size()); assertTrue(openReacResult.getReactiveSlacks().isEmpty()); } } @@ -220,7 +226,7 @@ private void testAllModifAndLoadFlow(Network network, String subFolder, OpenReac subFolder + "/reactiveopf_results_static_var_compensators.csv", subFolder + "/reactiveopf_results_vsc_converter_stations.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()) { try (ComputationManager computationManager = new LocalComputationManager(new LocalComputationConfig(tmpDir), localCommandExecutor, ForkJoinPool.commonPool())) { OpenReacResult openReacResult = OpenReacRunner.run(network, diff --git a/open-reac/src/test/java/com/powsybl/openreac/parameters/input/json/OpenReacJsonModuleTest.java b/open-reac/src/test/java/com/powsybl/openreac/parameters/input/json/OpenReacJsonModuleTest.java index f6729bc8..3823348c 100644 --- a/open-reac/src/test/java/com/powsybl/openreac/parameters/input/json/OpenReacJsonModuleTest.java +++ b/open-reac/src/test/java/com/powsybl/openreac/parameters/input/json/OpenReacJsonModuleTest.java @@ -13,6 +13,7 @@ import com.powsybl.openreac.parameters.input.VoltageLimitOverride; import com.powsybl.openreac.parameters.input.algo.OpenReacAmplLogLevel; import com.powsybl.openreac.parameters.input.algo.OpenReacSolverLogLevel; +import com.powsybl.openreac.parameters.input.algo.ReactiveSlackBusesMode; import org.junit.jupiter.api.Test; import java.io.IOException; @@ -49,6 +50,8 @@ void test() throws IOException { parameters.setLogLevelSolver(OpenReacSolverLogLevel.NOTHING); parameters.setMinPlausibleLowVoltageLimit(0.755); parameters.setMaxPlausibleHighVoltageLimit(1.236); + parameters.setReactiveSlackBusesMode(ReactiveSlackBusesMode.CONFIGURED); + parameters.addConfiguredReactiveSlackBuses(List.of("bus1", "bus2")); String json = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(parameters); ComparisonUtils.compareTxt(Objects.requireNonNull(getClass().getResourceAsStream("/parameters.json")), json); @@ -68,5 +71,7 @@ void test() throws IOException { assertEquals(OpenReacSolverLogLevel.NOTHING, parameters2.getLogLevelSolver()); assertEquals(0.755, parameters2.getMinPlausibleLowVoltageLimit()); assertEquals(1.236, parameters2.getMaxPlausibleHighVoltageLimit()); + assertEquals(ReactiveSlackBusesMode.CONFIGURED, parameters2.getReactiveSlackBusesMode()); + assertEquals(List.of("bus1", "bus2"), parameters2.getConfiguredReactiveSlackBuses()); } } 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 e199a0d1..6a5ddad4 100644 --- a/open-reac/src/test/resources/expected_inputs/param_algo.txt +++ b/open-reac/src/test/resources/expected_inputs/param_algo.txt @@ -4,4 +4,5 @@ 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 CONFIGURED diff --git a/open-reac/src/test/resources/expected_inputs/param_buses_with_reactive_slack.txt b/open-reac/src/test/resources/expected_inputs/param_buses_with_reactive_slack.txt new file mode 100644 index 00000000..0c5fff9f --- /dev/null +++ b/open-reac/src/test/resources/expected_inputs/param_buses_with_reactive_slack.txt @@ -0,0 +1,3 @@ +#num id +1 'VL1_0' + diff --git a/open-reac/src/test/resources/expected_inputs/param_generators_reactive.txt b/open-reac/src/test/resources/expected_inputs/param_generators_reactive.txt index 1c4661e2..32f36c08 100644 --- a/open-reac/src/test/resources/expected_inputs/param_generators_reactive.txt +++ b/open-reac/src/test/resources/expected_inputs/param_generators_reactive.txt @@ -1,3 +1,3 @@ -#amplId powsyblId +#num id 1 'B1-G' diff --git a/open-reac/src/test/resources/expected_inputs/param_shunts.txt b/open-reac/src/test/resources/expected_inputs/param_shunts.txt index b062f94b..fc53b694 100644 --- a/open-reac/src/test/resources/expected_inputs/param_shunts.txt +++ b/open-reac/src/test/resources/expected_inputs/param_shunts.txt @@ -1,3 +1,3 @@ -#amplId powsyblId +#num id 1 'B18-SH' diff --git a/open-reac/src/test/resources/expected_inputs/param_transformers.txt b/open-reac/src/test/resources/expected_inputs/param_transformers.txt index b6d3a78e..c69428a7 100644 --- a/open-reac/src/test/resources/expected_inputs/param_transformers.txt +++ b/open-reac/src/test/resources/expected_inputs/param_transformers.txt @@ -1,3 +1,3 @@ -#amplId powsyblId +#num id 64 'T4-18-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 7f5cc3e4..98bb7b22 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 @@ -1,18 +1,18 @@ final_status OK dcopf_status OK -ctime_start 'Thu Nov 23 14:59:05 2023' +ctime_start 'Fri Nov 24 12:03:37 2023' last_solve_result_num 0 -nb_iter_last 7 -nb_iter_total 7 -_ampl_elapsed_time 0.047000 +nb_iter_last 6 +nb_iter_total 6 +_ampl_elapsed_time 0.077000 _total_solve_time 0.046875 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_7395805484686702830' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_14004834396321580705' log_level_ampl INFO log_level_knitro 2 @@ -25,6 +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 PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 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 eabad3a4..7256e488 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,4 +3,5 @@ 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 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 5b470005..3ec31f6c 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,4 +4,5 @@ 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 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 9d2c8ae3..a1706533 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.084;232.4;48.8;-233.0;-48.8; -1;2;2;'true';1.045;40.0;49.8;-40.7;-49.8; +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;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 451fd03a..46d921f9 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 'Thu Nov 23 14:53:50 2023' +ctime_start 'Fri Nov 24 11:59:34 2023' last_solve_result_num 0 -nb_iter_last 7 -nb_iter_total 7 -_ampl_elapsed_time 0.095000 +nb_iter_last 6 +nb_iter_total 6 +_ampl_elapsed_time 0.125000 _total_solve_time 0.031250 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_5579556502931529884' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_12583331805904096086' log_level_ampl INFO log_level_knitro 2 @@ -25,6 +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 PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 @@ -76,9 +77,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.140548 +max_delta_teta_ac 0.140571 min_delta_teta_dc -0.041368 -min_delta_teta_ac -0.041532 +min_delta_teta_ac -0.041534 nb_reactive_slacks 0 nb_slacks_condensator 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 4cb5ce0b..420331e6 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 'Thu Nov 23 14:58:11 2023' +ctime_start 'Fri Nov 24 12:03:02 2023' last_solve_result_num 0 nb_iter_last 7 nb_iter_total 7 -_ampl_elapsed_time 0.077000 -_total_solve_time 0.046875 +_ampl_elapsed_time 0.110000 +_total_solve_time 0.031250 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_2760859736839254273' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_3114721600970297698' log_level_ampl INFO log_level_knitro 2 @@ -25,6 +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 PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 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 a8ae420a..a205a5f3 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 'Thu Nov 23 14:56:52 2023' +ctime_start 'Fri Nov 24 12:01:56 2023' last_solve_result_num 0 -nb_iter_last 35 -nb_iter_total 35 -_ampl_elapsed_time 0.062000 -_total_solve_time 0.062500 +nb_iter_last 29 +nb_iter_total 29 +_ampl_elapsed_time 0.077000 +_total_solve_time 0.031250 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_12329044319369847398' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_12369045109419234150' log_level_ampl INFO log_level_knitro 2 @@ -25,6 +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 PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 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 7cb0374e..a9224ea0 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,7 +1,7 @@ final_status OK dcopf_status OK -ctime_start 'Thu Nov 23 14:56:01 2023' +ctime_start 'Fri Nov 24 12:01:27 2023' last_solve_result_num 0 nb_iter_last 6 nb_iter_total 6 @@ -12,7 +12,7 @@ total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_9796395416193655574' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_11598000998118468803' log_level_ampl INFO log_level_knitro 2 @@ -25,6 +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 PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 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 7b201352..b898ef32 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 'Thu Nov 23 14:57:46 2023' +ctime_start 'Fri Nov 24 12:02:34 2023' last_solve_result_num 0 nb_iter_last 4 nb_iter_total 4 -_ampl_elapsed_time 0.093000 +_ampl_elapsed_time 0.095000 _total_solve_time 0.031250 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_1042775858349572355' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_7140935963031466466' log_level_ampl INFO log_level_knitro 2 @@ -25,6 +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 PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 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 8ada26e8..07bad8c4 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 'Thu Nov 23 14:55:00 2023' +ctime_start 'Fri Nov 24 12:01:03 2023' last_solve_result_num 0 nb_iter_last 6 nb_iter_total 6 _ampl_elapsed_time 0.110000 -_total_solve_time 0.031250 +_total_solve_time 0.046875 total_time 0 operatingSystem windows OS 'Windows_NT' COMPUTERNAME 'ARTELYS-PC253' -directory 'C:\Users\parvy\AppData\Local\Temp\ampl_4704726281504951464' +directory 'C:\Users\parvy\AppData\Local\Temp\ampl_2514974589581916563' log_level_ampl INFO log_level_knitro 2 @@ -25,6 +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 PQmax 9000.000000 defaultPmax 1000.000000 defaultPmin 0.000000 diff --git a/open-reac/src/test/resources/parameters.json b/open-reac/src/test/resources/parameters.json index a0671e5d..7e58d075 100644 --- a/open-reac/src/test/resources/parameters.json +++ b/open-reac/src/test/resources/parameters.json @@ -24,10 +24,12 @@ "constantQGenerators" : [ "g1", "g2" ], "variableTwoWindingsTransformers" : [ "tr1" ], "variableShuntCompensators" : [ "sc1", "sc2" ], + "configuredReactiveSlackBuses" : [ "bus1", "bus2" ], "objective" : "MIN_GENERATION", "objectiveDistance" : 5.0, "logLevelAmpl" : "WARNING", "logLevelSolver" : "NOTHING", "minPlausibleLowVoltageLimit" : 0.755, - "maxPlausibleHighVoltageLimit" : 1.236 + "maxPlausibleHighVoltageLimit" : 1.236, + "reactiveSlackBusesMode" : "CONFIGURED" } \ No newline at end of file