From 93a7cb853148b78eba4e3aeffaacd32854a2720d Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 18 Oct 2023 16:41:42 +0200 Subject: [PATCH 01/51] Enrich readme with explanation of AMPL code. Signed-off-by: parvy --- open-reac/README.md | 273 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 263 insertions(+), 10 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 92bf36ae..74863efa 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -1,36 +1,53 @@ # OpenReac -OpenReac is a reactive optimal power flow that gives a set of hypotheses for voltage and reactive controls by network equipments such as generators, shunt compensators and transformers. OpenReac can be used for network planning or in operation as well. + +OpenReac is a reactive optimal power flow that gives a set of hypotheses +for voltage and reactive controls by network equipments such as +generators, shunt compensators and transformers. OpenReac can be used +for network planning or in operation as well. + +--- ## Getting started + ### Knitro -To run this model, in addition of AMPL you'll need Knitro. Knitro is a proprietary non-linear solver. -Artelys is the company developping Knitro. It is distributing keys [here](https://www.artelys.com/solvers/knitro/). +To run this model, in addition of AMPL you'll need Knitro. Knitro is a +proprietary non-linear solver. -After the installation is done and that you got a valid licence, you must have `knitroampl` in your path. +Artelys is the company developping Knitro. It is distributing keys +[here](https://www.artelys.com/solvers/knitro/). + +After the installation is done and that you got a valid licence, you +must have `knitroampl` in your path. To check, start a bash and run : + ```bash knitroampl stub ``` + +--- ## Itools + This project also provides an utilty to run OpenReac with Itools. 1. Run OpenReac on the provided network. 2. Run LoadFlow on the result. 3. Run another OpenReac on the loadflow result. -You will have the running OpenReac folders next to your working directory. +You will have the running OpenReac folders next to your working +directory. ### Syntax -```` bash +````bash itools open-reac --case-file NETWORK [--open-reac-params PARAM_FILE] ```` -You can customize OpenReac parameters directly with the option `--open-reac-params params.json`. -Here are the specific mappings. -``` json +You can customize OpenReac parameters directly with the option +`--open-reac-params params.json`. Here are the specific mappings. + +```json { "obj_min_gen" : null, # list of shunt with variable Q @@ -50,7 +67,10 @@ Here are the specific mappings. # All other key or key value mapping will be passed as algorithm parameters } ``` -Here is a quick description for each objective and how to put them in the json. + +Here is a quick description for each objective and how to put them in +the json. + ``` # =============== Objectives ================ # Minimum power generation (default) @@ -60,3 +80,236 @@ Here is a quick description for each objective and how to put them in the json. # Use the target voltage provided in the network file "obj_provided_target_v" : null ``` + +--- + +## Reactive Optimal Power Flow + +### 1 Overview + +The reactive Optimal Power Flow (OPF) is implemented with AMPL. Its goal is to propose values +for all voltage and reactive equipment and controllers of the grid +(voltage set point of generating units, shunts, transformers ratios...). + +In a grid development study, you decide new equipments, new generating units, +new substations, new loads, you set values for active and reactive loads, +you set values for active power generation and HVDC flows. +Then if you wish to do AC powerflow simulations with N-1 analysis, you need +all voltage and reactive set points and this reactive OPF is your solution. + +Please notice that this reactive OPF: +- does **not** decide active power of generating units and HVDC branches, +- does **not** take into account current nor power limits on branches, +- **use** upper and lower limits for voltage, so be careful with them. + + +### 2 Division of the code + +The code of the reactive OPF is divided into several files, +each serving a specific function: +- `reactiveopf.dat` defines the network data files imported (with + prefix *ampl_*), and the files used to configure the run (with prefix *param_*). +Refer to section 3 for more information. +- `reactiveopf.mod` defines the sets, parameters and optimization problems (CC, DCOPF, ACOPF). +Refer to section 4,5, and 6 for more information. +- `reactiveopfoutput.mod` exports result files if + the solving of optimization problems converges. +Refer to section 7.1 for more information. +- `reactiveopfexit.run` contains the code executed when the AMPL run fails. +Refer to section 7.2 for more information. +- `reactiveopf.run` executes the AMPL process of OpenReac, calling the previous scripts. + + +### 3 Input + +#### 3.1 Network data + + +Text files with the prefix `ampl_` contain the +data/parameters of the network on which the OPF is executed. +These files can be obtained by using the [AMPL export](https://github.com/powsybl/powsybl-core/tree/main/ampl-converter) +of [powsybl-core](https://github.com/powsybl/powsybl-core/). + +TODO : more details on the content of the files ? + +#### 3.2 Fixed VS Variable values + +TODO : which elements are fixed, which are variables + +TODO : what control has the user (which elements can be fixed or put as variables), with which files + +#### 3.3 Checks and special handling + +TODO : add comments on transformation ratios/voltage level checks + +TODO : add comments on voltage level limits handling + +TODO : add comments on correction of P/Q units' domain + +--- +### 4 Reference bus and main connex component + + +A _reference bus_ (`null_phase_bus` parameter) is determined to enforce the zero-phase constraint of the OPFs. +This reference bus corresponds to the bus in the network with the most AC branches connected, +among those belonging to the main connected component (`bus_CC = 0`). +If multiple buses have the same maximum cardinality, the one with the highest `num` is selected. +If no bus is found meeting these criteria, the bus with the lowest `num` in the network is chosen. + +The DCOPF and ACOPF are executed on buses connected to the reference bus by AC branches. +Then, buses connected to the reference bus by HVDC lines are excluded in OPF computation. +These buses are determined by solving the `PROBLEM_CCOMP` optimization problem. +After the optimization, buses connected by AC branches are determined by verifying +that the associated variable `teta_ccomputation` is set to 0. + +### 5 Direct Current Optimal Power Flow + +Before solving the reactive ACOPF, a DCOPF is solved for two main reasons: +- If the DCOPF resolution fails, it provides a strong indication that the ACOPF resolution will also fail. +Therefore, the DCOPF serves as a formal consistency check on the data. +- The phases computed during the DCOPF resolution +will be used as initial points for the ACOPF resolution. + +The DCOPF involves the following constraints: +- `ctr_null_phase_bus_dc`, which sets the phase of the reference bus to 0. +- `ctr_activeflow`, which defines the active power flowing through the network's branches. +- `ctr_balance`, which enforces the active power balance at each network node. +This balance takes into account the active powers generated/consumed +by various devices connected to the nodes. +Within this balance, the following elements are considered as variables: + - The active power generated by the generating units (`UNITON` set). + - The slack variables `balance_pos` and `balance_neg`, which represent + the excess or shortfall of active power produced at each node. + +And the objective function `problem_dcopf_objective`, which minimizes the following summations: +- The sum of squared deviations between the calculated +active power generation for each generator and its target active power (`unit_Pc` parameter). +This sum is normalized by the target active power, +which helps homogenize the deviations among different generators. +- The sum of the variables `balance_pos` and `balance_neg`, penalized by a high coefficient. +The goal is to drive these variables towards 0, ensuring an active power balance at each node. + +### 6 Alternative Current Optimal Power Flow + +After solving the DCOPF, the calculated phases are used +to initialize the phases in the reactive ACOPF. + +This OPF depends on specific user-selected parameters, +including the OPF objective function (see Section 1.2) +and the equipment with variable or fixed values (see Section 1.2). + +The reactive ACOPF involves the following constraints : +- `ctr_null_phase_bus`, which sets the phase of the reference bus to 0. +- `ctr_balance_P`, which enforces the active power balance at each node of the network. +It takes into account the active powers generated/consumed by various devices connected +to the nodes. +- `ctr_balance_Q` enforces the reactive power balance at each node of the network. +It considers the reactive powers generated/consumed by various devices connected to the nodes. +Within this balance, the following elements are considered as variables: + - The transformation ratios of transformers defined as variables by the user (`BRANCHCC_REGL_VAR` set). + - The reactive power generated by the generating units defined as variables by the user +(`UNITON diff UNIT_FIXQ` set). + - The susceptance of shunts defined as variables by the user (`SHUNT_VAR` set). + - The reactive power generated by SVCs (`SVCON` set, containing SVCs with `svc_vregul = true`). + - The reactive power generated by VSCs (`VSCCONVON` set). + - The slack variables `slack1_balance_Q` and `slack2_balance_Q`, +which represent the excess or shortfall of active power produced at each node. +This applies to nodes with a load or a shunt but no unit, +SVC, or VSC (where the reactive power is already defined). + +And the objective function `problem_acopf_objective` which minimizes the following sums +(with certain coefficients that determine their relative importance): + - The sum of `slack1_balance_Q` and `slack2_balance_Q` variables, penalized by a high coefficient. +The objective is to drive these variables towards 0, ensuring a balance in reactive power at each node. + - The sum of squared barycenter between the active power generated by each generator and +the difference between this active power and the generator's target P. +This sum is penalized with a significant coefficient only when `objective_choice = 0`. +This barycenter depends on the `coeff_alpha` weight, which can be chosen by the user. +The closer this coefficient is to 1, the more important the first term of the barycenter, +thus emphasizing the minimization of generated active power. +A coefficient closer to 1 increases the deviation between this active power and the generator's target P +(`unit_Pc` parameter). + - The sum of squared deviations between the calculated voltage values at each node and a +barycenter between the lower and upper voltage limits of the associated voltage level. +This sum is penalized with a significant coefficient only when `objective_choice = 1`. +This barycenter depends on the `ratio_voltage_target` weight, +which can be chosen by the user. + - The sum of squared deviations between the calculated voltage values and their initial values at each node. + This sum is penalized with a significant coefficient only when `objective_choice = 2`. + - The sum of squared deviations of variable transformation ratios from their initial values. +This sum is penalized by a small coefficient. The goal is to limit this deviation without overly restricting it. + - The sum of squared ratios of reactive powers generated by generating units at +their maximal reactive power bounds. +This sum is penalized by a small coefficient. The goal is to limit this deviation without overly restricting it. + +TODO : add comments on results treatment by Knitro (what kind of solutions are considered as good...) + +### 7 Output + +#### 7.1 In case of convergence + +If the solving of DCOPF and reactive ACOPF is successful, +the following files are exported (containing variables calculated values): + +- `reactiveopf_results_indic.txt`, which contains various indicators to provide an overview of the + run. It includes: + - General information (system OS, computation time, etc.). + - The thresholds/parameters used (minimum impedance of lines + considered as impedances, chosen objective function, etc.). + - The cardinality of various sets (number of non-impedance branches, + number of shunts with fixed values, etc.). + - Information about calculated angles (maximum/minimum theta, maximum + difference between neighboring buses, etc.). + + +- `reactiveopf_results_static_var_compensators.csv`, which contains calculated +voltage and reactive power values for the SVC that regulate voltage : + + Format : 6 columns #"variant" "num" "bus" "vRegul" "V(pu)" "Q(Mvar)" + + +- `reactiveopf_results_shunts.csv`, which contains calculated reactive power (and susceptance) values +for shunts that were either connected or modified after the optimization problems were resolved. + + Format : 6 columns #"variant" "num" "bus" "b(pu)" "Q(Mvar)" "section" + + +- `reactiveopf_results_generators.csv`, which contains +calculated active and reactive power values for generating units. + + Format : 9 columns #"variant" "num" "bus" "vRegul" "V(pu)" + "targetP(MW)" "targetQ(Mvar)" "P(MW)" "Q(MW)" + + +- `reactiveopf_results_vsc_converter_stations.csv`, which contains +calculated reactive power values for VSC converter stations. + + Format : 8 columns #"variant" "num" "bus" "vRegul" "targetV(pu)" + "targetQ(Mvar)" "P(MW)" "Q(Mvar)" + + +- `reactiveopf_results_rtc.csv`, which contains the RTCs and their associated taps, +with the transformation ratio closest to the one calculated after +the optimization. + + Format : 3 columns #"variant" "num" "tap" + + +- `reactiveopf_results_reactive_slacks.csv`, which contains the calculated +reactive slack variables `slack1_balance_Q` and `slack2_balance_Q`. + + Format : 6 columns #"variant" "bus" "slack_condensator(Mvar)" "slack_self(Mvar)" "id" "substation" + +#### 7.2 In case of error + +If for any reason the execution of the file *reactiveopf.run* fails, +the file *reactiveopfexit.run* is executed. Then, the following +file is exported: + +- `reactiveopf_results_indic.txt`, which contains various indicators to +provide an overview of the run. It includes: + - The error message(s) returned by AMPL. + - General information (system OS, computation time, etc.). + - The thresholds/parameters used (minimum impedance of lines + considered as impedances, chosen objective function, etc.). + From d576fc6d0d736df12dd43043fb7e4b083ceeba05 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 5 Dec 2023 17:10:24 +0100 Subject: [PATCH 02/51] Remove Itools comments. Signed-off-by: parvy --- open-reac/README.md | 55 --------------------------------------------- 1 file changed, 55 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 74863efa..549691f9 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -26,61 +26,6 @@ To check, start a bash and run : knitroampl stub ``` ---- -## Itools - -This project also provides an utilty to run OpenReac with Itools. - -1. Run OpenReac on the provided network. -2. Run LoadFlow on the result. -3. Run another OpenReac on the loadflow result. - -You will have the running OpenReac folders next to your working -directory. - -### Syntax - -````bash -itools open-reac --case-file NETWORK [--open-reac-params PARAM_FILE] -```` - -You can customize OpenReac parameters directly with the option -`--open-reac-params params.json`. Here are the specific mappings. - -```json -{ - "obj_min_gen" : null, - # list of shunt with variable Q - "variable-shunts-list" : ["var-shunt", "var-shunt-2"], - # list of generators with constant Q - "fixed-generators-list" : ["constant-q-gen"], - # list of transformers with variable ratio - "variable-transformers-list" : ["2-winding-transfo"], - # list of voltage limit override (delta from nominal voltage) - "voltage-level-override" : [ - { - "id": "voltageLevelId", - "lower": "-5", - "upper": "5" - } - ] - # All other key or key value mapping will be passed as algorithm parameters -} -``` - -Here is a quick description for each objective and how to put them in -the json. - -``` -# =============== Objectives ================ -# Minimum power generation (default) -"obj_min_gen" : null -# Target low_voltage_limit + (high_voltage_limit - low_voltage_limit) * RATIO for each equipement -"obj_target_ratio": RATIO -# Use the target voltage provided in the network file -"obj_provided_target_v" : null -``` - --- ## Reactive Optimal Power Flow From de401f4c5eb2b64b8ccf43643b0a0df1317f8145 Mon Sep 17 00:00:00 2001 From: parvy Date: Thu, 7 Dec 2023 09:57:21 +0100 Subject: [PATCH 03/51] WIP. --- open-reac/README.md | 154 ++++++++++++++++++++++++++++++++------------ 1 file changed, 112 insertions(+), 42 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 549691f9..12d25441 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -32,7 +32,7 @@ knitroampl stub ### 1 Overview -The reactive Optimal Power Flow (OPF) is implemented with AMPL. Its goal is to propose values +The reactive optimal power flow (OPF) is implemented with AMPL. Its goal is to propose values for all voltage and reactive equipment and controllers of the grid (voltage set point of generating units, shunts, transformers ratios...). @@ -52,8 +52,8 @@ Please notice that this reactive OPF: The code of the reactive OPF is divided into several files, each serving a specific function: -- `reactiveopf.dat` defines the network data files imported (with - prefix *ampl_*), and the files used to configure the run (with prefix *param_*). +- `reactiveopf.dat` defines the network data files imported (files with + *ampl_* prefix), and the files used to configure the run (files with *param_* prefix). Refer to section 3 for more information. - `reactiveopf.mod` defines the sets, parameters and optimization problems (CC, DCOPF, ACOPF). Refer to section 4,5, and 6 for more information. @@ -69,37 +69,107 @@ Refer to section 7.2 for more information. #### 3.1 Network data +Files with the prefix `ampl_` contain the +data and the parameters of the network on which the reactive OPF is executed. +These files are obtained by using this [AMPL export](https://github.com/powsybl/powsybl-core/tree/main/ampl-converter). -Text files with the prefix `ampl_` contain the -data/parameters of the network on which the OPF is executed. -These files can be obtained by using the [AMPL export](https://github.com/powsybl/powsybl-core/tree/main/ampl-converter) -of [powsybl-core](https://github.com/powsybl/powsybl-core/). +#### 3.2 Configuration of the run -TODO : more details on the content of the files ? +L'utilisateur peut également configurer certains éléments du run, à l'aide de l'interface +Java prévue à cet effet (see X). -#### 3.2 Fixed VS Variable values +Il peut notamment configurer certains paramètres/seuils utilisés dans l'exécution, à +l'aide du fichier `param_algo.txt`. On compte: +- `log_level_ampl`, le paramètre définissant le niveau d'affichage des prints AMPL. La valeur spécifiée +par l'utilisateur doit être "DEBUG", "INFO", "WARNING" ou "ERROR". Ce paramètre vaut "INFO" par défaut. +- `log_level_knitro`, le paramètre définissant le niveau d'affichage des prints Knitro. La valeur spécifiée +par l'utilisateur doit être 0,1 ou 2, comme spécifié dans la documentation AMPL. Ce paramètre vaut 1 par défaut. +- `objective_choice`, le paramètre définissant le choix de la fonction objectif de l'ACOPF décrit section X: + - Si la valeur spécifiée est 0, la minimization de la puissance active produite par les générateurs est privilégiée. + - Si la valeur spécifiée est 1, la minimization de l'écart entre la valeur de tension et la target X des bus est privilégiée. + - Si la valeur spécifiée est 2, la minimization de l'écart entre la valeur de tension et la target X des bus est privilégiée. +- `ratio_voltage_target`, le paramètre utilisé pour calculer la target des bus si le paramètre `objective_choice` +a une valeur de 1. Ce paramètre vaut 0.5 par défaut, et doit être compris entre 0 et 1. +- `coeff_alpha`, le paramètre utilisée dans la fonction objectif de l'ACOPF pour plus ou moins +privilégier la minimization de la génération de puissance active des générateurs +(`coeff_alpha`=1) ou des écarts entre les puissances actives calculées par l'ACOPF et +la target value (`coeff_alpha`=0). Ce paramètre vaut 1 par défaut, et doit être compris +entre 0 et 1. +- `Pnull` le paramètre définissant les puissances actives et réactives considérées comme nulles. +Ce paramètre vaut 0.01 (MW) par défaut, et doit être compris entre 0 et 1 strictement. +- `Znull` le paramètre utilisé pour déterminer quelles branches du réseau sont non-impédantes. +Ce paramètre vaut 1e-4 (pu) par défaut, et doit être compris entre 0 et 0.1 strictement. +- `epsilon_nominal_voltage` le paramètre utilisée comme seuil de consistances pour la tension +nominal des bus du réseau. Les bus ayant une tension nominale inférieure à ce paramètre seront ignorés. +Ce paramètre vaut 1 (kV) par défaut, et doit être supérieur à 0 strictement. +- `min_plausible_low_voltage_limit` le paramètre utilisé comme borne de consistence pour les tensions +minimales des différents voltage levels (voir section X). Ce paramètre vaut 0.5 par défaut, et doit +être supérieur à 0 strictement. +- `max_plausible_high_voltage_limit` le paramètre utilisé comme borne de consistence pour les tensions +maximales des différents voltage levels (voir section X). Ce paramètre vaut 1.5 par défaut, et doit +être supérieur à `min_plausible_low_voltage_limit` strictement. +- `ignore_voltage_bounds` le paramètre utilisé comme seuil de consistances pour prendre en considération +les bornes inférieures et supérieures en tension des bus. Les bus ayant une tension nominale inférieure à +ce paramètre auront leurs bornes remplacées par [`min_plausible_low_voltage_limit`; `max_plausible_high_voltage_limit`]. +- `buses_with_reactive_slacks` le paramètre déterminant quels bus auront des slacks réactifs attachés dans la résolution +de l'ACOPF. Ces paramètres peut prendre les valeurs suivantes: + - "ALL", pour indiquer que tous les bus ont des reactive slack variables attached. + - "NO_GENERATION" pour indiquer que tous les bus ne produisant pas de réactif auront des reactive slacks variables attached. + - "CONFIGURED" pour indiquer -TODO : which elements are fixed, which are variables -TODO : what control has the user (which elements can be fixed or put as variables), with which files +Ces éléments sont dans les fichiers ayant comme prefix +`param_`, et on compte : -#### 3.3 Checks and special handling +- `param_transformers.txt`, defining which ratio tap changers have a variable ratio. + By default, no ratio is variable. -TODO : add comments on transformation ratios/voltage level checks + Format : 2 columns #"num" "id" -TODO : add comments on voltage level limits handling -TODO : add comments on correction of P/Q units' domain +- `param_shunts.txt`, defining which shunts have a variable susceptance value and which can be modified/connected. + By default, all susceptance shunts are constant, fixed to the values defined in `ampl_network_shunts.txt`. + Among the variable shunts, if one is not connected (`bus=-1`) + but parameter `bus_possible` is well defined, then this shunt may be connected by the OPF. + + Format : 2 columns #"num" "id" + + +- `param_generators_reactive.txt`, defining which generators have a constant reactive power value + (defined by `unit_Qc` in `ampl_network_generators.txt`) in the OPFs. This value is used even if it + falls out of bounds (`Qmin`/`Qmax`). However, if it is + not consistent (> `PQmax`), then reactive power becomes a variable. + By default, the reactive power of all generating units are variable. + User is invited to note that it is also possible to fix reactive power by setting the minimum and maximum reactive + power bounds to same value in `ampl_network_generators.txt`. + + Format : 2 columns #"num" "id" + + +- `param_buses_with_reactive_slack.txt`, defining which buses will have reactive slacks attached + in the solving of the ACOPF, if `buses_with_reactive_slacks="CONFIGURED"`. + + Format : 2 columns #"num" "id" + + +### 4 Checks and special handling + +#### 4.X Voltage level limits + +#### 4.X Computation of reference bus + +#### 4.X Transformer consistency + +#### 4.X P/Q units' domain ---- ### 4 Reference bus and main connex component -A _reference bus_ (`null_phase_bus` parameter) is determined to enforce the zero-phase constraint of the OPFs. +A _reference bus_ (`null_phase_bus` AMPL parameter) is determined to enforce the zero-phase constraint of the OPFs. This reference bus corresponds to the bus in the network with the most AC branches connected, among those belonging to the main connected component (`bus_CC = 0`). If multiple buses have the same maximum cardinality, the one with the highest `num` is selected. -If no bus is found meeting these criteria, the bus with the lowest `num` in the network is chosen. +If no bus is found meeting these criteria, the first bus defined in the file `ampl_network_buses.txt` is chosen. The DCOPF and ACOPF are executed on buses connected to the reference bus by AC branches. Then, buses connected to the reference bus by HVDC lines are excluded in OPF computation. @@ -107,7 +177,9 @@ These buses are determined by solving the `PROBLEM_CCOMP` optimization problem. After the optimization, buses connected by AC branches are determined by verifying that the associated variable `teta_ccomputation` is set to 0. -### 5 Direct Current Optimal Power Flow +### 5 Optimal Power Flows + +#### 5.1 Direct Current Optimal Power Flow Before solving the reactive ACOPF, a DCOPF is solved for two main reasons: - If the DCOPF resolution fails, it provides a strong indication that the ACOPF resolution will also fail. @@ -134,7 +206,7 @@ which helps homogenize the deviations among different generators. - The sum of the variables `balance_pos` and `balance_neg`, penalized by a high coefficient. The goal is to drive these variables towards 0, ensuring an active power balance at each node. -### 6 Alternative Current Optimal Power Flow +#### 5.2 Alternative Current Optimal Power Flow After solving the DCOPF, the calculated phases are used to initialize the phases in the reactive ACOPF. @@ -189,26 +261,37 @@ This sum is penalized by a small coefficient. The goal is to limit this deviatio TODO : add comments on results treatment by Knitro (what kind of solutions are considered as good...) -### 7 Output +### X Output + +#### X.1 In case of inconsistency + +If the computation of the main connex component or of the DCOPF fails (Knitro diverges +or the problem is solved with too much slack), the problem is considered as inconsistent. +Then, the script `reactiveopfexit.run` is executed and the following file is exported: + +- `reactiveopf_results_indic.txt`, which contains various indicators to + provide an overview of the run. It includes: + - The error message(s) returned by AMPL. + - General information (system OS, computation time, etc.). + - The configurable thresholds/parameters used in the run (see section X). -#### 7.1 In case of convergence +#### X.2 In case of convergence -If the solving of DCOPF and reactive ACOPF is successful, -the following files are exported (containing variables calculated values): +If the AMPL process defined in `reactiveopf.run` is successful, the script `reactiveopfoutput.run` is executed +(even if the solving of ACOPF failed) and the following files are exported: - `reactiveopf_results_indic.txt`, which contains various indicators to provide an overview of the run. It includes: - General information (system OS, computation time, etc.). - - The thresholds/parameters used (minimum impedance of lines - considered as impedances, chosen objective function, etc.). - - The cardinality of various sets (number of non-impedance branches, - number of shunts with fixed values, etc.). + - The configurable thresholds/parameters used in the run (see section X). + - The cardinality of the sets used in the optimization problems (number of non-impedance branches, + number of buses with slack variables, etc.). - Information about calculated angles (maximum/minimum theta, maximum difference between neighboring buses, etc.). - `reactiveopf_results_static_var_compensators.csv`, which contains calculated -voltage and reactive power values for the SVC that regulate voltage : +voltage and reactive power values for the SVC that regulate voltage. Format : 6 columns #"variant" "num" "bus" "vRegul" "V(pu)" "Q(Mvar)" @@ -245,16 +328,3 @@ reactive slack variables `slack1_balance_Q` and `slack2_balance_Q`. Format : 6 columns #"variant" "bus" "slack_condensator(Mvar)" "slack_self(Mvar)" "id" "substation" -#### 7.2 In case of error - -If for any reason the execution of the file *reactiveopf.run* fails, -the file *reactiveopfexit.run* is executed. Then, the following -file is exported: - -- `reactiveopf_results_indic.txt`, which contains various indicators to -provide an overview of the run. It includes: - - The error message(s) returned by AMPL. - - General information (system OS, computation time, etc.). - - The thresholds/parameters used (minimum impedance of lines - considered as impedances, chosen objective function, etc.). - From d6ce739c4950576031945bee797f6822fce403b4 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 11 Dec 2023 18:43:31 +0100 Subject: [PATCH 04/51] WIP. Signed-off-by: parvy --- open-reac/README.md | 279 +++++++++++++++++++++++++++----------------- 1 file changed, 171 insertions(+), 108 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 12d25441..68d5efde 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -9,6 +9,19 @@ for network planning or in operation as well. ## Getting started +### AMPL +For this project, you must have [AMPL](https://ampl.com/) installed. +AMPL is a proprietary tool that works as an optimization modelling language. It can be interfaced with many solvers. + +AMPL is sold by many companies including Artelys, you can find keys [here](https://www.artelys.com/solvers/ampl/). + +You must add in your `~/.itools/config.yml` an ampl section like this: +```yaml +ampl: + # Change to the ampl folder path that contains the ampl executable + homeDir: /home/user/ampl +``` + ### Knitro To run this model, in addition of AMPL you'll need Knitro. Knitro is a @@ -54,32 +67,32 @@ The code of the reactive OPF is divided into several files, each serving a specific function: - `reactiveopf.dat` defines the network data files imported (files with *ampl_* prefix), and the files used to configure the run (files with *param_* prefix). -Refer to section 3 for more information. -- `reactiveopf.mod` defines the sets, parameters and optimization problems (CC, DCOPF, ACOPF). -Refer to section 4,5, and 6 for more information. -- `reactiveopfoutput.mod` exports result files if - the solving of optimization problems converges. -Refer to section 7.1 for more information. -- `reactiveopfexit.run` contains the code executed when the AMPL run fails. -Refer to section 7.2 for more information. + Refer to section [3](#3-input). +- `reactiveopf.mod` defines the sets, parameters and optimization problems (CC, DCOPF, ACOPF) solved in `reactiveopf.run`. + Refer to section [5](#5-reference-bus--main-connex-component) and [6](#6-optimal-power-flow-problems). +- `reactiveopfoutput.mod` exports result files if the execution of `reactiveopf.run` is successful. + Refer to section [7.1](#72-in-case-of-convergence). +- `reactiveopfexit.run` contains the code executed when the problem is inconsistent. + Refer to section [7.2](#71-in-case-of-inconsistency). - `reactiveopf.run` executes the AMPL process of OpenReac, calling the previous scripts. - ### 3 Input #### 3.1 Network data Files with the prefix `ampl_` contain the data and the parameters of the network on which the reactive OPF is executed. -These files are obtained by using this [AMPL export](https://github.com/powsybl/powsybl-core/tree/main/ampl-converter). +These files are obtained by using the +[AMPL export of PowSyBl](https://github.com/powsybl/powsybl-core/blob/main/ampl-converter/src/main/java/com/powsybl/ampl/converter/AmplNetworkWriter.java). #### 3.2 Configuration of the run -L'utilisateur peut également configurer certains éléments du run, à l'aide de l'interface -Java prévue à cet effet (see X). +L'utilisateur peut configurer certains éléments du run, à l'aide de l'interface +Java prévue à cet effet (see [OpenReacParameters](src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java) +java class). -Il peut notamment configurer certains paramètres/seuils utilisés dans l'exécution, à -l'aide du fichier `param_algo.txt`. On compte: +Il peut notamment configurer certains paramètres et seuils utilisés dans les pré-traitements et modélisations de l'OPF. +Ces paramètres sont spécifiés dans le fichier d'import `param_algo.txt` : - `log_level_ampl`, le paramètre définissant le niveau d'affichage des prints AMPL. La valeur spécifiée par l'utilisateur doit être "DEBUG", "INFO", "WARNING" ou "ERROR". Ce paramètre vaut "INFO" par défaut. - `log_level_knitro`, le paramètre définissant le niveau d'affichage des prints Knitro. La valeur spécifiée @@ -89,8 +102,9 @@ par l'utilisateur doit être 0,1 ou 2, comme spécifié dans la documentation AM - Si la valeur spécifiée est 1, la minimization de l'écart entre la valeur de tension et la target X des bus est privilégiée. - Si la valeur spécifiée est 2, la minimization de l'écart entre la valeur de tension et la target X des bus est privilégiée. - `ratio_voltage_target`, le paramètre utilisé pour calculer la target des bus si le paramètre `objective_choice` -a une valeur de 1. Ce paramètre vaut 0.5 par défaut, et doit être compris entre 0 et 1. -- `coeff_alpha`, le paramètre utilisée dans la fonction objectif de l'ACOPF pour plus ou moins +vaut 1. Il doit être compris entre 0 et 1, pour orienter la target des bus entre les limites inférieures et supérieures +des voltage levels auxquels les bus sont rattachés. Par défaut, ce paramètre vaut 0.5 (donc la target est entre ces deux limites). +- `coeff_alpha`, le paramètre utilisé dans la fonction objectif de l'ACOPF pour plus ou moins privilégier la minimization de la génération de puissance active des générateurs (`coeff_alpha`=1) ou des écarts entre les puissances actives calculées par l'ACOPF et la target value (`coeff_alpha`=0). Ce paramètre vaut 1 par défaut, et doit être compris @@ -103,10 +117,10 @@ Ce paramètre vaut 1e-4 (pu) par défaut, et doit être compris entre 0 et 0.1 s nominal des bus du réseau. Les bus ayant une tension nominale inférieure à ce paramètre seront ignorés. Ce paramètre vaut 1 (kV) par défaut, et doit être supérieur à 0 strictement. - `min_plausible_low_voltage_limit` le paramètre utilisé comme borne de consistence pour les tensions -minimales des différents voltage levels (voir section X). Ce paramètre vaut 0.5 par défaut, et doit +minimales des différents voltage levels (voir section X). Par défaut, ce paramètre vaut 0.5 (p.u.), et il doit être supérieur à 0 strictement. - `max_plausible_high_voltage_limit` le paramètre utilisé comme borne de consistence pour les tensions -maximales des différents voltage levels (voir section X). Ce paramètre vaut 1.5 par défaut, et doit +maximales des différents voltage levels (voir section X). Par défaut, ce paramètre vaut 1.5 (p.u.), et il doit être supérieur à `min_plausible_low_voltage_limit` strictement. - `ignore_voltage_bounds` le paramètre utilisé comme seuil de consistances pour prendre en considération les bornes inférieures et supérieures en tension des bus. Les bus ayant une tension nominale inférieure à @@ -115,175 +129,224 @@ ce paramètre auront leurs bornes remplacées par [`min_plausible_low_voltage_li de l'ACOPF. Ces paramètres peut prendre les valeurs suivantes: - "ALL", pour indiquer que tous les bus ont des reactive slack variables attached. - "NO_GENERATION" pour indiquer que tous les bus ne produisant pas de réactif auront des reactive slacks variables attached. - - "CONFIGURED" pour indiquer - - -Ces éléments sont dans les fichiers ayant comme prefix -`param_`, et on compte : - -- `param_transformers.txt`, defining which ratio tap changers have a variable ratio. - By default, no ratio is variable. - + - "CONFIGURED" pour indiquer que seuls les bus spécifiés dans le fichier `param_buses_with_` auront des reactive slacks variables attached. +- `PQmax` le seuil de puissance active et réactive maximale utilisé dans la correction des +limites des générateurs (voir section X). Par défaut, ce paramètre vaut 9000 (MW). +- `defaultPmax` le seuil utilisé pour corriger la puissance active maximale produite par les +générateurs (voir section X). Par défaut, ce paramètre vaut 1000 (MW). +- `defaultPmin` le seuil utilisé pour corriger la puissance active minimale produite par les +générateurs (voir section X). Par défaut, ce paramètre vaut 0 (MW). +- `defaultQmaxPmaxRatio` le paramètre utilisé pour calculer `defaultQmin` et `defaultQmax`, +les seuils utilisés pour corriger les puissances réactives minimale et maximale +produites par les générateurs (voir section X). Par défaut, ce paramètre vaut 0.3 (MVar/MW), +et les seuils sont calculés comme suit : + - `defaultQmin` = - `defaultPmin` x `defaultQmaxPmaxRatio` + - `defaultQmax` = `defaultPmax` x `defaultQmaxPmaxRatio` +- `minimalQPrange` le seuil utilisé pour fixer les puissances actives (resp. réactives) des +générateurs ayant des limites de puissances actives (resp. réactives Q) trop proches. Par défaut, +ce paramètre vaut 1 (MW ou Mvar). + +En plus des éléments précédents, l'utilisateur peut spécifier une partie des éléments qui seront +variables ou fixes dans la résolution de l'ACOPF (see section X). Cela se fait à l'aide des +fichiers suivants : + +- `param_transformers.txt`, defining which ratio tap changers have a variable transformation ratio. + By default, no ratio is variable in the network. Format : 2 columns #"num" "id" - `param_shunts.txt`, defining which shunts have a variable susceptance value and which can be modified/connected. - By default, all susceptance shunts are constant, fixed to the values defined in `ampl_network_shunts.txt`. + By default, all susceptance shunts are constant, fixed to the values `b (pu)` defined in `ampl_network_shunts.txt`. Among the variable shunts, if one is not connected (`bus=-1`) but parameter `bus_possible` is well defined, then this shunt may be connected by the OPF. - Format : 2 columns #"num" "id" -- `param_generators_reactive.txt`, defining which generators have a constant reactive power value - (defined by `unit_Qc` in `ampl_network_generators.txt`) in the OPFs. This value is used even if it +- `param_generators_reactive.txt`, defining which generators have a constant reactive power value, fixed + to the values `targetQ (MVar)` defined in `ampl_network_generators.txt`. This value is used even if it falls out of bounds (`Qmin`/`Qmax`). However, if it is - not consistent (> `PQmax`), then reactive power becomes a variable. + not consistent (> `PQmax`, defined in `param_algo.txt`), then the reactive power becomes a variable. By default, the reactive power of all generating units are variable. User is invited to note that it is also possible to fix reactive power by setting the minimum and maximum reactive power bounds to same value in `ampl_network_generators.txt`. - Format : 2 columns #"num" "id" - `param_buses_with_reactive_slack.txt`, defining which buses will have reactive slacks attached - in the solving of the ACOPF, if `buses_with_reactive_slacks="CONFIGURED"`. - + in the solving of the ACOPF, if the parameter `buses_with_reactive_slacks` equals "CONFIGURED"`. Format : 2 columns #"num" "id" +#### 3.3 Voltage limits overrides + + +In addition to the elements specified in section [3.2](#32-configuration-of-the-run), the user may choose to override +some voltage limits of specified voltage levels. +These values must be defined in the file ampl_network_substations_override.txt and +are employed to establish the voltage limits of the voltage levels, as specified in section +[4.1](#41-voltage-level-limits-computation). +Format : 4 columns #"num" "minV (pu)" "maxV (pu)" "id" ### 4 Checks and special handling -#### 4.X Voltage level limits +Before solving the optimization problems described in [6](#6-optimal-power-flow-problems), +the following special handling procedures are executed to ensure the consistency +of the values used in the solving. +These specific treatments use values specified by the user (see [3.2](#32-configuration-of-the-run)). + +#### 4.1 Voltage level limits computation -#### 4.X Computation of reference bus +In order to ensure consistent voltage level limits in the optimization of the ACOPF (see [6.2](#62-alternative-current-optimal-power-flow)), +the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. They are initialized as follows: +- `minimal_voltage_lower_bound` is set equal to the maximum value between the configurable threshold `min_plausible_low_voltage_limit` (see [3.2](#32-configuration-of-the-run)) +and the minimum voltage limit across the entire network (considering all voltage levels). +- `maximal_voltage_upper_bound` is set equal to the minimum value between the configurable threshold `max_plausible_high_voltage_limit` (see [3.2](#32-configuration-of-the-run)) +and the maximum voltage limit across the entire network (considering all voltage levels). + +As a result, the lower voltage bound chosen is equal to the maximum value between +`minimal_voltage_lower_bound` +and the specified `minV (pu)` value in `ampl_network_substations.txt`. +If an override value is specified by the user (see [3.3](#33-voltage-limits-overrides)), it replaces `minV (pu)`. + +The upper voltage bound chosen is equal to the minimum value between `maximal_voltage_upper_bound` +and the specified `maxV (pu)` value in `ampl_network_substations.txt`. +If an override value is specified by the user (see [3.3](#33-voltage-limits-overrides)) and it is higher than +the previously calculated lower voltage bound, then the override value replaces `maxV (pu)`. #### 4.X Transformer consistency #### 4.X P/Q units' domain -### 4 Reference bus and main connex component - +### 5 Reference bus & main connex component -A _reference bus_ (`null_phase_bus` AMPL parameter) is determined to enforce the zero-phase constraint of the OPFs. +A _reference bus_ (`null_phase_bus` parameter) is determined to enforce the zero-phase constraint of the OPFs. This reference bus corresponds to the bus in the network with the most AC branches connected, -among those belonging to the main connected component (`bus_CC = 0`). +among those belonging to the main connected component (`bus_CC` equals 0). If multiple buses have the same maximum cardinality, the one with the highest `num` is selected. -If no bus is found meeting these criteria, the first bus defined in the file `ampl_network_buses.txt` is chosen. +If no bus is found meeting these criteria, the first bus defined in the file `ampl_network_buses.txt` is chosen +as reference bus. The DCOPF and ACOPF are executed on buses connected to the reference bus by AC branches. Then, buses connected to the reference bus by HVDC lines are excluded in OPF computation. -These buses are determined by solving the `PROBLEM_CCOMP` optimization problem. -After the optimization, buses connected by AC branches are determined by verifying -that the associated variable `teta_ccomputation` is set to 0. +These buses are determined by solving the `PROBLEM_CCOMP` optimization problem +defined in `reactiveopf.mod`. After the optimization, buses connected by AC branches +are determined by verifying that the associated variable `teta_ccomputation` is set to 0. -### 5 Optimal Power Flows +### 6 Optimal power flow problems -#### 5.1 Direct Current Optimal Power Flow +Deux OPFs sont résolus de manière successive. D'abord un Direct Current Optimal Power Flow (DCOPF), +décrit en section [6.1](#61-direct-current-optimal-power-flow) +puis un Alternative Current Optimal Power Flow (ACOPF), décrit en section [6.2](#62-alternative-current-optimal-power-flow). This is done for +two main reasons: +- If the DCOPF resolution fails (see [6.1](#61-direct-current-optimal-power-flow)), it provides a strong indication that the ACOPF resolution will also fail. + The DCOPF serves as a formal consistency check on the data. +- The phases computed during the DCOPF resolution will be used as initial points for the ACOPF resolution. -Before solving the reactive ACOPF, a DCOPF is solved for two main reasons: -- If the DCOPF resolution fails, it provides a strong indication that the ACOPF resolution will also fail. -Therefore, the DCOPF serves as a formal consistency check on the data. -- The phases computed during the DCOPF resolution -will be used as initial points for the ACOPF resolution. +#### 6.1 Direct current optimal power flow The DCOPF involves the following constraints: -- `ctr_null_phase_bus_dc`, which sets the phase of the reference bus to 0. -- `ctr_activeflow`, which defines the active power flowing through the network's branches. +- `ctr_null_phase_bus_dc`, which sets the phase of the reference (refer to [5](#5-reference-bus--main-connex-component)) to 0. +- `ctr_activeflow`, which defines the active power flowing through the branches of the network. - `ctr_balance`, which enforces the active power balance at each network node. -This balance takes into account the active powers generated/consumed -by various devices connected to the nodes. -Within this balance, the following elements are considered as variables: - - The active power generated by the generating units (`UNITON` set). - - The slack variables `balance_pos` and `balance_neg`, which represent +This balance takes into account the active power produced by generators and batteries, as well as the power consumed +by loads, VSC stations and LCC stations connected to each bus (in addition to what enters and exits the bus). +Within this balance, the following are variables: + - The active power `P_dcopf` generated by the generating units. + - The slack variables `balance_pos` and `balance_neg` (both positive), which represent the excess or shortfall of active power produced at each node. And the objective function `problem_dcopf_objective`, which minimizes the following summations: - The sum of squared deviations between the calculated -active power generation for each generator and its target active power (`unit_Pc` parameter). +active power generation for each generator and its +target active power (`targetP (MW)` defined in `ampl_network_generators.txt`). This sum is normalized by the target active power, which helps homogenize the deviations among different generators. -- The sum of the variables `balance_pos` and `balance_neg`, penalized by a high coefficient. +- The sum of the variables `balance_pos` and `balance_neg`, penalized by a high coefficient (`penalty_balance`). The goal is to drive these variables towards 0, ensuring an active power balance at each node. -#### 5.2 Alternative Current Optimal Power Flow - -After solving the DCOPF, the calculated phases are used -to initialize the phases in the reactive ACOPF. - -This OPF depends on specific user-selected parameters, -including the OPF objective function (see Section 1.2) -and the equipment with variable or fixed values (see Section 1.2). - -The reactive ACOPF involves the following constraints : -- `ctr_null_phase_bus`, which sets the phase of the reference bus to 0. -- `ctr_balance_P`, which enforces the active power balance at each node of the network. -It takes into account the active powers generated/consumed by various devices connected -to the nodes. -- `ctr_balance_Q` enforces the reactive power balance at each node of the network. -It considers the reactive powers generated/consumed by various devices connected to the nodes. +The resolution of this DCOPF is considered as successful if the solver identifies a feasible solution without reaching +a pre-defined limit, and if the sum of all balance variables (`balance_pos` and `balance_neg`) does not exceed the configurable threshold `Pnull` +(see section [3.2](#32-configuration-of-the-run)). In cases where these conditions are not met, +the solving is considered unsuccessful. + +#### 6.2 Alternative current optimal power flow + +This ACOPF relies on specific parameters selected by the user, +as thresholds and equipment of the power network which will be treated as variable or fixed (refer to [3.2](#32-configuration-of-the-run)). +LThe voltage variables utilized in the ACOPF are initialized as follows: +- The phase angles are set equal to those calculated by solving the DCOPF. +- The voltages of buses without reactive slacks (and with nominal voltage greater than `min_plausible_low_voltage_limit`) +are set equal to the specified `v (pu)` values in `ampl_network_buses.txt`. +- The voltages of buses with reactive slacks are initialized to the midpoint of the voltage level limits to which they are connected. + +The ACOPF involves the following constraints : +- `ctr_null_phase_bus`, which sets the phase of the reference bus (refer to [5](#5-reference-bus--main-connex-component)) to 0. +- `ctr_balance_P`, which enforces the active power balance at each node of the network. + This balance takes into account the active power produced by generators and batteries, as well as the power consumed + by loads, VSC stations and LCC stations connected to each bus (in addition to what enters and exits the bus). +Within this balance, the active power produced by units and the flows on the branches are considered as variables. +- `ctr_balance_Q` enforces the reactive power balance at each node of the network. + This balance takes into account the reactive power produced by generators, batteries, shunts, static var compensators, VSC stations, +as well as the power consumed by loads and LCC stations connected to each bus (in addition to what enters and exits the bus). Within this balance, the following elements are considered as variables: - - The transformation ratios of transformers defined as variables by the user (`BRANCHCC_REGL_VAR` set). - - The reactive power generated by the generating units defined as variables by the user -(`UNITON diff UNIT_FIXQ` set). - - The susceptance of shunts defined as variables by the user (`SHUNT_VAR` set). - - The reactive power generated by SVCs (`SVCON` set, containing SVCs with `svc_vregul = true`). - - The reactive power generated by VSCs (`VSCCONVON` set). + - The flows on the branches (tensions, phases and transformation ratios of transformers defined as variables by the user). + - The reactive power generated by the units defined as variables. + - The susceptance of shunts defined as variables by the user. + - The reactive power generated by SVCs (only the one with `svc_vregul` value equals to `true` in `ampl_network_static_var_compensators.txt`). + - The reactive power generated by VSC stations (all consistent ones defined in `ampl_network_vsc_converter_stations.txt`). - The slack variables `slack1_balance_Q` and `slack2_balance_Q`, -which represent the excess or shortfall of active power produced at each node. -This applies to nodes with a load or a shunt but no unit, -SVC, or VSC (where the reactive power is already defined). +which represent the excess or shortfall of active power produced at the buses chosen by the user. -And the objective function `problem_acopf_objective` which minimizes the following sums -(with certain coefficients that determine their relative importance): - - The sum of `slack1_balance_Q` and `slack2_balance_Q` variables, penalized by a high coefficient. +And the objective function `problem_acopf_objective` which minimizes the following sums: + - The sum of `slack1_balance_Q` and `slack2_balance_Q` variables, penalized by a very high coefficient (`penalty_invest_rea_pos`). The objective is to drive these variables towards 0, ensuring a balance in reactive power at each node. - - The sum of squared barycenter between the active power generated by each generator and -the difference between this active power and the generator's target P. + - The sum of squared barycenter between the two values. +The first is the active power produced by each generator. The second is +the difference between this power and the unit's target P (`unit_Pc` parameter), divided by this target. This sum is penalized with a significant coefficient only when `objective_choice = 0`. -This barycenter depends on the `coeff_alpha` weight, which can be chosen by the user. +This barycenter depends on the configurable parameter `coeff_alpha`. The closer this coefficient is to 1, the more important the first term of the barycenter, thus emphasizing the minimization of generated active power. A coefficient closer to 1 increases the deviation between this active power and the generator's target P -(`unit_Pc` parameter). +(`targetP (MW)` defined in `ampl_network_generators.txt`). - The sum of squared deviations between the calculated voltage values at each node and a barycenter between the lower and upper voltage limits of the associated voltage level. This sum is penalized with a significant coefficient only when `objective_choice = 1`. -This barycenter depends on the `ratio_voltage_target` weight, -which can be chosen by the user. - - The sum of squared deviations between the calculated voltage values and their initial values at each node. - This sum is penalized with a significant coefficient only when `objective_choice = 2`. +This barycenter depends on the configurable parameter `ratio_voltage_target`. + - The sum of squared deviations between the calculated voltage values and their initial values (`v (pu)` in `ampl_network_buses.txt`) at each node. +This sum is penalized with a significant coefficient only when `objective_choice = 2`. - The sum of squared deviations of variable transformation ratios from their initial values. This sum is penalized by a small coefficient. The goal is to limit this deviation without overly restricting it. - - The sum of squared ratios of reactive powers generated by generating units at + - The sum of squared ratios of reactive powers generated by units over their maximal reactive power bounds. This sum is penalized by a small coefficient. The goal is to limit this deviation without overly restricting it. +TODO : expliciter le fait qu'on fasse plusieurs optimisations à la suite en jouant sur alpha si besoin. + TODO : add comments on results treatment by Knitro (what kind of solutions are considered as good...) -### X Output +### 7 Output -#### X.1 In case of inconsistency +#### 7.1 In case of inconsistency -If the computation of the main connex component or of the DCOPF fails (Knitro diverges -or the problem is solved with too much slack), the problem is considered as inconsistent. +If the computation of the main connex component or of the DCOPF fails (see [6.1](#61-direct-current-optimal-power-flow)), +the problem is considered as inconsistent. Then, the script `reactiveopfexit.run` is executed and the following file is exported: -- `reactiveopf_results_indic.txt`, which contains various indicators to +`reactiveopf_results_indic.txt`, which contains various indicators to provide an overview of the run. It includes: - - The error message(s) returned by AMPL. + - The error message(s) returned by the execution. - General information (system OS, computation time, etc.). - - The configurable thresholds/parameters used in the run (see section X). + - The configurable thresholds/parameters used in the run (see section [3.2](#32-configuration-of-the-run)). -#### X.2 In case of convergence +#### 7.2 In case of convergence If the AMPL process defined in `reactiveopf.run` is successful, the script `reactiveopfoutput.run` is executed -(even if the solving of ACOPF failed) and the following files are exported: +(even if the solving of ACOPF did not reached a feasible point) and the following files are exported: - `reactiveopf_results_indic.txt`, which contains various indicators to provide an overview of the run. It includes: - General information (system OS, computation time, etc.). - - The configurable thresholds/parameters used in the run (see section X). + - The configurable thresholds/parameters used in the run (see section [3.2](#32-configuration-of-the-run)). - The cardinality of the sets used in the optimization problems (number of non-impedance branches, number of buses with slack variables, etc.). - Information about calculated angles (maximum/minimum theta, maximum From 8f154647255661c6d144a6e90409e86b087a6a72 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 10:05:34 +0100 Subject: [PATCH 05/51] Some traduction/references. Signed-off-by: parvy --- open-reac/README.md | 141 ++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 65 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 68d5efde..2845ebd1 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -87,82 +87,89 @@ These files are obtained by using the #### 3.2 Configuration of the run -L'utilisateur peut configurer certains éléments du run, à l'aide de l'interface -Java prévue à cet effet (see [OpenReacParameters](src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java) -java class). - -Il peut notamment configurer certains paramètres et seuils utilisés dans les pré-traitements et modélisations de l'OPF. -Ces paramètres sont spécifiés dans le fichier d'import `param_algo.txt` : -- `log_level_ampl`, le paramètre définissant le niveau d'affichage des prints AMPL. La valeur spécifiée -par l'utilisateur doit être "DEBUG", "INFO", "WARNING" ou "ERROR". Ce paramètre vaut "INFO" par défaut. -- `log_level_knitro`, le paramètre définissant le niveau d'affichage des prints Knitro. La valeur spécifiée -par l'utilisateur doit être 0,1 ou 2, comme spécifié dans la documentation AMPL. Ce paramètre vaut 1 par défaut. -- `objective_choice`, le paramètre définissant le choix de la fonction objectif de l'ACOPF décrit section X: - - Si la valeur spécifiée est 0, la minimization de la puissance active produite par les générateurs est privilégiée. - - Si la valeur spécifiée est 1, la minimization de l'écart entre la valeur de tension et la target X des bus est privilégiée. - - Si la valeur spécifiée est 2, la minimization de l'écart entre la valeur de tension et la target X des bus est privilégiée. -- `ratio_voltage_target`, le paramètre utilisé pour calculer la target des bus si le paramètre `objective_choice` -vaut 1. Il doit être compris entre 0 et 1, pour orienter la target des bus entre les limites inférieures et supérieures -des voltage levels auxquels les bus sont rattachés. Par défaut, ce paramètre vaut 0.5 (donc la target est entre ces deux limites). -- `coeff_alpha`, le paramètre utilisé dans la fonction objectif de l'ACOPF pour plus ou moins -privilégier la minimization de la génération de puissance active des générateurs -(`coeff_alpha`=1) ou des écarts entre les puissances actives calculées par l'ACOPF et -la target value (`coeff_alpha`=0). Ce paramètre vaut 1 par défaut, et doit être compris -entre 0 et 1. -- `Pnull` le paramètre définissant les puissances actives et réactives considérées comme nulles. -Ce paramètre vaut 0.01 (MW) par défaut, et doit être compris entre 0 et 1 strictement. -- `Znull` le paramètre utilisé pour déterminer quelles branches du réseau sont non-impédantes. -Ce paramètre vaut 1e-4 (pu) par défaut, et doit être compris entre 0 et 0.1 strictement. -- `epsilon_nominal_voltage` le paramètre utilisée comme seuil de consistances pour la tension -nominal des bus du réseau. Les bus ayant une tension nominale inférieure à ce paramètre seront ignorés. -Ce paramètre vaut 1 (kV) par défaut, et doit être supérieur à 0 strictement. -- `min_plausible_low_voltage_limit` le paramètre utilisé comme borne de consistence pour les tensions -minimales des différents voltage levels (voir section X). Par défaut, ce paramètre vaut 0.5 (p.u.), et il doit -être supérieur à 0 strictement. -- `max_plausible_high_voltage_limit` le paramètre utilisé comme borne de consistence pour les tensions -maximales des différents voltage levels (voir section X). Par défaut, ce paramètre vaut 1.5 (p.u.), et il doit -être supérieur à `min_plausible_low_voltage_limit` strictement. -- `ignore_voltage_bounds` le paramètre utilisé comme seuil de consistances pour prendre en considération -les bornes inférieures et supérieures en tension des bus. Les bus ayant une tension nominale inférieure à -ce paramètre auront leurs bornes remplacées par [`min_plausible_low_voltage_limit`; `max_plausible_high_voltage_limit`]. -- `buses_with_reactive_slacks` le paramètre déterminant quels bus auront des slacks réactifs attachés dans la résolution -de l'ACOPF. Ces paramètres peut prendre les valeurs suivantes: - - "ALL", pour indiquer que tous les bus ont des reactive slack variables attached. - - "NO_GENERATION" pour indiquer que tous les bus ne produisant pas de réactif auront des reactive slacks variables attached. - - "CONFIGURED" pour indiquer que seuls les bus spécifiés dans le fichier `param_buses_with_` auront des reactive slacks variables attached. -- `PQmax` le seuil de puissance active et réactive maximale utilisé dans la correction des -limites des générateurs (voir section X). Par défaut, ce paramètre vaut 9000 (MW). -- `defaultPmax` le seuil utilisé pour corriger la puissance active maximale produite par les -générateurs (voir section X). Par défaut, ce paramètre vaut 1000 (MW). -- `defaultPmin` le seuil utilisé pour corriger la puissance active minimale produite par les -générateurs (voir section X). Par défaut, ce paramètre vaut 0 (MW). -- `defaultQmaxPmaxRatio` le paramètre utilisé pour calculer `defaultQmin` et `defaultQmax`, -les seuils utilisés pour corriger les puissances réactives minimale et maximale -produites par les générateurs (voir section X). Par défaut, ce paramètre vaut 0.3 (MVar/MW), -et les seuils sont calculés comme suit : +The user can configure certain aspects of the run with the dedicated Java interface +(see [OpenReacParameters](src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java) java class). + +Specifically, the user can set various parameters and thresholds used in the preprocessing and modeling of the OPF. +These parameters are specified in the import file `param_algo.txt`: + +- `log_level_ampl`: The parameter defining the level of display for AMPL prints. +The user-specified value must be "DEBUG," "INFO," "WARNING," or "ERROR". The default value for this parameter is "INFO." +- `log_level_knitro`: The parameter determining the level of display for Knitro prints. +The user-specified value must be 0, 1, or 2, as specified in the [AMPL documentation](https://dev.ampl.com/ampl/options.html). +The default value for this parameter is 1. +- `objective_choice`: The parameter defining the choice of the objective function for the ACOPF described in section [6.2](#62-alternative-current-optimal-power-flow): + - If the specified value is 0, prioritization is given to the minimization of active power produced by generators. + - If the specified value is 1, prioritization is given to the minimization of the deviation between the voltage value and the computed target of the buses. + This target lies between the upper and lower voltage limits of the level voltages to which the buses are connected, and is calculated using + configurable parameter `ratio_voltage_target`. + - If the specified value is 2, prioritization is given to the minimization of the deviation between the voltage value of the buses and the target V specified in `ampl_network_buses.txt`. +- `ratio_voltage_target`: The arameter is used to calculate the target of buses if the `objective_choice` +parameter is set to 1. It must be between 0 and 1 to guide the target of buses between the lower and upper +limits of the voltage levels to which the buses are connected. +By default, this parameter is set to 0.5 (resulting in the target being the mean of these two limits). +- `coeff_alpha`: The parameter is used in the objective function of the ACOPF (see [6.2](#62-alternative-current-optimal-power-flow)) to more or less favor +the minimization of active power generation by generators (`coeff_alpha`=1) or the deviations between the active powers calculated +by the ACOPF and the target value (`coeff_alpha`=0). The default value for this parameter is 1, and it must lies between 0 and 1. +- `Pnull`: This parameter defines the active and reactive powers considered as null. +The default value for this parameter is 0.01 (MW), and it must be strictly between 0 and 1. +- `Znull`: The threshold to determine which branches of the network are non-impedant (see [4.2](#42-zero-impedance-lines). +The default value for this parameter is 1e-4 (pu), and it must be strictly between 0 and 0.1. +- `epsilon_nominal_voltage`: The consistency threshold for the nominal voltage +of network buses. Buses with a nominal voltage lower than this parameter will be ignored. +The default value for this parameter is 1 (kV), and it must be strictly greater than 0. +- `min_plausible_low_voltage_limit`: The consistency bound for the minimum voltages of different +voltage levels (see section [4.1](#41-voltage-level-limits-computation)). By default, this parameter +is set to 0.5 (p.u.), and it must be strictly greater than 0. +- `max_plausible_high_voltage_limit`: The consistency bound for the maximum +voltages of different voltage levels (see section [4.1](#41-voltage-level-limits-computation)). By default, +this parameter is set to 1.5 (p.u.), and it must be strictly greater than `min_plausible_low_voltage_limit`. +- `ignore_voltage_bounds`: This parameter is used as the consistency threshold to consider the lower and upper +voltage bounds of buses. Buses with a nominal voltage lower than this parameter will +have their bounds replaced by [`min_plausible_low_voltage_limit`; `max_plausible_high_voltage_limit`]. +- `buses_with_reactive_slacks`: This parameter determines which buses will have reactive slacks attached in the resolution of the ACOPF +(see [6.2](#62-alternative-current-optimal-power-flow)). +This parameter can take the following values: + - "ALL" indicates that all buses have reactive slack variables attached. + - "NO_GENERATION" indicates that only buses not producing reactive power will have reactive slack variables attached. + - "CONFIGURED" indicates that only buses specified in the `param_buses_with_reactive_slack.txt` file will have reactive slack variables attached. +- `PQmax` : The threshold for maximum active and reactive power considered in +the correction of the generator limits (see section [4.4](#44-pq-units-domain)). +The default value for this parameter is 9000 (MW). +- `defaultPmax`: Threshold used to correct the maximum active power produced by generators +(see section [4.4](#44-pq-units-domain)). +The default value for this parameter is 1000 (MW). +- `defaultPmin`: Threshold used to correct the minimum active power produced by generators +(see section [4.4](#44-pq-units-domain)). +The default value for this parameter is 0 (MW). +- `defaultQmaxPmaxRatio`: Parameter used to calculate `defaultQmin` and `defaultQmax`, +the thresholds used to correct the minimum and maximum reactive powers produced by generators +(see section [4.4](#44-pq-units-domain)). +The default value for this parameter is 0.3 (MVar/MW), and the thresholds are calculated as follows: - `defaultQmin` = - `defaultPmin` x `defaultQmaxPmaxRatio` - `defaultQmax` = `defaultPmax` x `defaultQmaxPmaxRatio` -- `minimalQPrange` le seuil utilisé pour fixer les puissances actives (resp. réactives) des -générateurs ayant des limites de puissances actives (resp. réactives Q) trop proches. Par défaut, -ce paramètre vaut 1 (MW ou Mvar). +- `minimalQPrange`: The threshold used to fix the active (resp. reactive) power of +generators with active (resp. reactive) power limits that are closer than its value. +By default, this parameter is set to 1 (MW or MVar). -En plus des éléments précédents, l'utilisateur peut spécifier une partie des éléments qui seront -variables ou fixes dans la résolution de l'ACOPF (see section X). Cela se fait à l'aide des -fichiers suivants : -- `param_transformers.txt`, defining which ratio tap changers have a variable transformation ratio. +In addition to the previous parameters and thresholds, the user can specify which +parameters will be variable or fixed in the resolution of +the ACOPF (see section [6.2](#62-alternative-current-optimal-power-flow)). This is done using the following files: + +- `param_transformers.txt`: Defining which ratio tap changers have a variable transformation ratio. By default, no ratio is variable in the network. Format : 2 columns #"num" "id" -- `param_shunts.txt`, defining which shunts have a variable susceptance value and which can be modified/connected. +- `param_shunts.txt`: Defining which shunts have a variable susceptance value and which can be modified/connected. By default, all susceptance shunts are constant, fixed to the values `b (pu)` defined in `ampl_network_shunts.txt`. Among the variable shunts, if one is not connected (`bus=-1`) but parameter `bus_possible` is well defined, then this shunt may be connected by the OPF. Format : 2 columns #"num" "id" -- `param_generators_reactive.txt`, defining which generators have a constant reactive power value, fixed +- `param_generators_reactive.txt`: Defining which generators have a constant reactive power value, fixed to the values `targetQ (MVar)` defined in `ampl_network_generators.txt`. This value is used even if it falls out of bounds (`Qmin`/`Qmax`). However, if it is not consistent (> `PQmax`, defined in `param_algo.txt`), then the reactive power becomes a variable. @@ -172,7 +179,7 @@ fichiers suivants : Format : 2 columns #"num" "id" -- `param_buses_with_reactive_slack.txt`, defining which buses will have reactive slacks attached +- `param_buses_with_reactive_slack.txt`: Defining which buses will have reactive slacks attached in the solving of the ACOPF, if the parameter `buses_with_reactive_slacks` equals "CONFIGURED"`. Format : 2 columns #"num" "id" @@ -191,7 +198,7 @@ Format : 4 columns #"num" "minV (pu)" "maxV (pu)" "id" Before solving the optimization problems described in [6](#6-optimal-power-flow-problems), the following special handling procedures are executed to ensure the consistency of the values used in the solving. -These specific treatments use values specified by the user (see [3.2](#32-configuration-of-the-run)). +These specific treatments use user-configurable parameters (see [3.2](#32-configuration-of-the-run)). #### 4.1 Voltage level limits computation @@ -212,9 +219,13 @@ and the specified `maxV (pu)` value in `ampl_network_substations.txt`. If an override value is specified by the user (see [3.3](#33-voltage-limits-overrides)) and it is higher than the previously calculated lower voltage bound, then the override value replaces `maxV (pu)`. +#### 4.2 Zero impedance lines + + + #### 4.X Transformer consistency -#### 4.X P/Q units' domain +#### 4.4 P/Q units' domain ### 5 Reference bus & main connex component From 3fecd4ed360fc2a05d1c99e80fa9ce4135118e61 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 10:41:33 +0100 Subject: [PATCH 06/51] Add impedance handling. Signed-off-by: parvy --- open-reac/README.md | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 2845ebd1..038157b1 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -134,17 +134,17 @@ This parameter can take the following values: - "NO_GENERATION" indicates that only buses not producing reactive power will have reactive slack variables attached. - "CONFIGURED" indicates that only buses specified in the `param_buses_with_reactive_slack.txt` file will have reactive slack variables attached. - `PQmax` : The threshold for maximum active and reactive power considered in -the correction of the generator limits (see section [4.4](#44-pq-units-domain)). +the correction of the generator limits (see section [4.5](#45-pq-units-domain)). The default value for this parameter is 9000 (MW). - `defaultPmax`: Threshold used to correct the maximum active power produced by generators -(see section [4.4](#44-pq-units-domain)). +(see section [4.5](#45-pq-units-domain)). The default value for this parameter is 1000 (MW). - `defaultPmin`: Threshold used to correct the minimum active power produced by generators -(see section [4.4](#44-pq-units-domain)). +(see section [4.5](#45-pq-units-domain)). The default value for this parameter is 0 (MW). - `defaultQmaxPmaxRatio`: Parameter used to calculate `defaultQmin` and `defaultQmax`, the thresholds used to correct the minimum and maximum reactive powers produced by generators -(see section [4.4](#44-pq-units-domain)). +(see section [4.5](#45-pq-units-domain)). The default value for this parameter is 0.3 (MVar/MW), and the thresholds are calculated as follows: - `defaultQmin` = - `defaultPmin` x `defaultQmaxPmaxRatio` - `defaultQmax` = `defaultPmax` x `defaultQmaxPmaxRatio` @@ -222,16 +222,43 @@ the previously calculated lower voltage bound, then the override value replaces #### 4.2 Zero impedance lines +To determine the non-impedant lines of the network, the configurable threshold `Znull` (p.u.) is used +(see section [3.2](#32-configuration-of-the-run)). +These lines are identified as those with an impedance magnitude (calculated in p.u.) lower than `Znull`. +These lines will have their reactance replaced by `Znull`. -#### 4.X Transformer consistency +Les transformateurs ayant une impédance considérée comme nulle ne sont considérés dans les calculs, +et sont remplacés par des lignes. De plus, les lignes considérés comme non impédantes auront +une réactance remplacée par Znull. -#### 4.4 P/Q units' domain +#### 4.3 Impedance of transformers + +In the calculations of the ACOPF (see section [6.2](#62-alternative-current-optimal-power-flow)), +the ratio tap changers (RTC) with an impedance (specified in `ampl_network_branches.txt`) +considered as null (see [4.2](#42-zero-impedance-lines)) are treated as lines (the transformation ratio is ignored). +This is also the case with phase tap changers (PST), where the phase shift is consequently ignored (as well as +the impedance specified in the tap changer table `ampl_network_tct.txt`). + +For PSTs considered as having impedance, the reactance values from the tap changer table (in `ampl_network_tct.txt`) +replace the reactance specified in `ampl_network_branches.txt`. The resistance is calculated proportionally to this reactance. +The impedances of RTCs remain as specified in `ampl_network_branches.txt`. + +Please notice that there is no specific handling for cases where +resistances/reactances are negative or if there is both an RTC and a PST on the same branch. + +#### 4.4 Transformer consistency + +TODO + +#### 4.5 P/Q units' domain + +TODO ### 5 Reference bus & main connex component -A _reference bus_ (`null_phase_bus` parameter) is determined to enforce the zero-phase constraint of the OPFs. +A reference bus (`null_phase_bus` AMPL parameter) is determined to enforce the zero-phase constraint of the OPFs. This reference bus corresponds to the bus in the network with the most AC branches connected, -among those belonging to the main connected component (`bus_CC` equals 0). +among those belonging to the main connected component (0 in `ampl_network_buses.txt`). If multiple buses have the same maximum cardinality, the one with the highest `num` is selected. If no bus is found meeting these criteria, the first bus defined in the file `ampl_network_buses.txt` is chosen as reference bus. From 7a1518dcb7f221c758e7efda9713162d468912ee Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 11:37:47 +0100 Subject: [PATCH 07/51] Remove french. Signed-off-by: parvy --- open-reac/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 038157b1..ba086664 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -271,9 +271,8 @@ are determined by verifying that the associated variable `teta_ccomputation` is ### 6 Optimal power flow problems -Deux OPFs sont résolus de manière successive. D'abord un Direct Current Optimal Power Flow (DCOPF), -décrit en section [6.1](#61-direct-current-optimal-power-flow) -puis un Alternative Current Optimal Power Flow (ACOPF), décrit en section [6.2](#62-alternative-current-optimal-power-flow). This is done for +Two OPFs are successively solved. First, a Direct Current Optimal Power Flow (DCOPF) as described in section [6.1](#61-direct-current-optimal-power-flow), +followed by an Alternating Current Optimal Power Flow (ACOPF) described in section [6.2](#62-alternative-current-optimal-power-flow). This is done for two main reasons: - If the DCOPF resolution fails (see [6.1](#61-direct-current-optimal-power-flow)), it provides a strong indication that the ACOPF resolution will also fail. The DCOPF serves as a formal consistency check on the data. From 0da9789809f351c8a7d18658fd55e94c9feabc93 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 16:12:03 +0100 Subject: [PATCH 08/51] Test equation. Signed-off-by: parvy --- 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 ba086664..514baa99 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -252,7 +252,7 @@ TODO #### 4.5 P/Q units' domain -TODO +$$x=\frac{1}{\mathcal{R}}$$ ### 5 Reference bus & main connex component From dff8a0069fe138a98a74eb18ba13821d2032c256 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 17:16:54 +0100 Subject: [PATCH 09/51] Refactor Input. Signed-off-by: parvy --- open-reac/README.md | 162 ++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 97 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 514baa99..cb7f3df7 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -87,105 +87,47 @@ These files are obtained by using the #### 3.2 Configuration of the run -The user can configure certain aspects of the run with the dedicated Java interface -(see [OpenReacParameters](src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java) java class). - -Specifically, the user can set various parameters and thresholds used in the preprocessing and modeling of the OPF. -These parameters are specified in the import file `param_algo.txt`: - -- `log_level_ampl`: The parameter defining the level of display for AMPL prints. -The user-specified value must be "DEBUG," "INFO," "WARNING," or "ERROR". The default value for this parameter is "INFO." -- `log_level_knitro`: The parameter determining the level of display for Knitro prints. -The user-specified value must be 0, 1, or 2, as specified in the [AMPL documentation](https://dev.ampl.com/ampl/options.html). -The default value for this parameter is 1. -- `objective_choice`: The parameter defining the choice of the objective function for the ACOPF described in section [6.2](#62-alternative-current-optimal-power-flow): - - If the specified value is 0, prioritization is given to the minimization of active power produced by generators. - - If the specified value is 1, prioritization is given to the minimization of the deviation between the voltage value and the computed target of the buses. - This target lies between the upper and lower voltage limits of the level voltages to which the buses are connected, and is calculated using - configurable parameter `ratio_voltage_target`. - - If the specified value is 2, prioritization is given to the minimization of the deviation between the voltage value of the buses and the target V specified in `ampl_network_buses.txt`. -- `ratio_voltage_target`: The arameter is used to calculate the target of buses if the `objective_choice` -parameter is set to 1. It must be between 0 and 1 to guide the target of buses between the lower and upper -limits of the voltage levels to which the buses are connected. -By default, this parameter is set to 0.5 (resulting in the target being the mean of these two limits). -- `coeff_alpha`: The parameter is used in the objective function of the ACOPF (see [6.2](#62-alternative-current-optimal-power-flow)) to more or less favor -the minimization of active power generation by generators (`coeff_alpha`=1) or the deviations between the active powers calculated -by the ACOPF and the target value (`coeff_alpha`=0). The default value for this parameter is 1, and it must lies between 0 and 1. -- `Pnull`: This parameter defines the active and reactive powers considered as null. -The default value for this parameter is 0.01 (MW), and it must be strictly between 0 and 1. -- `Znull`: The threshold to determine which branches of the network are non-impedant (see [4.2](#42-zero-impedance-lines). -The default value for this parameter is 1e-4 (pu), and it must be strictly between 0 and 0.1. -- `epsilon_nominal_voltage`: The consistency threshold for the nominal voltage -of network buses. Buses with a nominal voltage lower than this parameter will be ignored. -The default value for this parameter is 1 (kV), and it must be strictly greater than 0. -- `min_plausible_low_voltage_limit`: The consistency bound for the minimum voltages of different -voltage levels (see section [4.1](#41-voltage-level-limits-computation)). By default, this parameter -is set to 0.5 (p.u.), and it must be strictly greater than 0. -- `max_plausible_high_voltage_limit`: The consistency bound for the maximum -voltages of different voltage levels (see section [4.1](#41-voltage-level-limits-computation)). By default, -this parameter is set to 1.5 (p.u.), and it must be strictly greater than `min_plausible_low_voltage_limit`. -- `ignore_voltage_bounds`: This parameter is used as the consistency threshold to consider the lower and upper -voltage bounds of buses. Buses with a nominal voltage lower than this parameter will -have their bounds replaced by [`min_plausible_low_voltage_limit`; `max_plausible_high_voltage_limit`]. -- `buses_with_reactive_slacks`: This parameter determines which buses will have reactive slacks attached in the resolution of the ACOPF -(see [6.2](#62-alternative-current-optimal-power-flow)). -This parameter can take the following values: - - "ALL" indicates that all buses have reactive slack variables attached. - - "NO_GENERATION" indicates that only buses not producing reactive power will have reactive slack variables attached. - - "CONFIGURED" indicates that only buses specified in the `param_buses_with_reactive_slack.txt` file will have reactive slack variables attached. -- `PQmax` : The threshold for maximum active and reactive power considered in -the correction of the generator limits (see section [4.5](#45-pq-units-domain)). -The default value for this parameter is 9000 (MW). -- `defaultPmax`: Threshold used to correct the maximum active power produced by generators -(see section [4.5](#45-pq-units-domain)). -The default value for this parameter is 1000 (MW). -- `defaultPmin`: Threshold used to correct the minimum active power produced by generators -(see section [4.5](#45-pq-units-domain)). -The default value for this parameter is 0 (MW). -- `defaultQmaxPmaxRatio`: Parameter used to calculate `defaultQmin` and `defaultQmax`, -the thresholds used to correct the minimum and maximum reactive powers produced by generators -(see section [4.5](#45-pq-units-domain)). -The default value for this parameter is 0.3 (MVar/MW), and the thresholds are calculated as follows: - - `defaultQmin` = - `defaultPmin` x `defaultQmaxPmaxRatio` - - `defaultQmax` = `defaultPmax` x `defaultQmaxPmaxRatio` -- `minimalQPrange`: The threshold used to fix the active (resp. reactive) power of -generators with active (resp. reactive) power limits that are closer than its value. -By default, this parameter is set to 1 (MW or MVar). - - -In addition to the previous parameters and thresholds, the user can specify which -parameters will be variable or fixed in the resolution of -the ACOPF (see section [6.2](#62-alternative-current-optimal-power-flow)). This is done using the following files: - -- `param_transformers.txt`: Defining which ratio tap changers have a variable transformation ratio. - By default, no ratio is variable in the network. - Format : 2 columns #"num" "id" - - -- `param_shunts.txt`: Defining which shunts have a variable susceptance value and which can be modified/connected. - By default, all susceptance shunts are constant, fixed to the values `b (pu)` defined in `ampl_network_shunts.txt`. - Among the variable shunts, if one is not connected (`bus=-1`) - but parameter `bus_possible` is well defined, then this shunt may be connected by the OPF. - Format : 2 columns #"num" "id" - - -- `param_generators_reactive.txt`: Defining which generators have a constant reactive power value, fixed - to the values `targetQ (MVar)` defined in `ampl_network_generators.txt`. This value is used even if it - falls out of bounds (`Qmin`/`Qmax`). However, if it is - not consistent (> `PQmax`, defined in `param_algo.txt`), then the reactive power becomes a variable. - By default, the reactive power of all generating units are variable. - User is invited to note that it is also possible to fix reactive power by setting the minimum and maximum reactive - power bounds to same value in `ampl_network_generators.txt`. - Format : 2 columns #"num" "id" - - -- `param_buses_with_reactive_slack.txt`: Defining which buses will have reactive slacks attached - in the solving of the ACOPF, if the parameter `buses_with_reactive_slacks` equals "CONFIGURED"`. - Format : 2 columns #"num" "id" +The user can configure the run with the dedicated Java interface +(see [OpenReacParameters](src/main/java/com/powsybl/openreac/parameters/input/OpenReacParameters.java)). +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 | Default value | Possible value | +|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|------------------------------------------------------| +| 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 [6.2](#62-alternative-current-optimal-power-flow)) | $0$ | $\{0, 1, 2\}$ | +| ratio_voltage_target | Ratio to calculate target V of buses when objective_choice = 1 | $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](#42-zero-impedance-lines)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ | + | epsilon_nominal_voltage | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathcal{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.) | $\mathcal{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.) | $\[{\rm 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.) | $\mathcal{R}^{+}$ | +| buses_with_reactive_slacks | Choice of which buses will have reactive slacks attached in ACOPF solving (see [6.2](#62-alternative-current-optimal-power-flow)) | $NO_GENERATION$ | $\{CONFIGURED, NO_GENERATION, ALL\}$ | +| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, Mvar) | | +| defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $1000$ (MW) | | +| defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $0$ (MW) | | +| defaultQmaxPmaxRatio | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.5](#45-pq-units-domain)) | $0.3$ (Mvar/MW) | | +| minimalQPrange | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.5](#45-pq-units-domain)) | $1$ (MW, MVar) | | + + +In addition to the previous parameters, the user can specify which +parameters will be variable or fixed in the ACOPF solving (see section [6.2](#62-alternative-current-optimal-power-flow)). +This is done using the following files: + +| File | Description | Default behavior of modified values | +|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| +| param_transformers.txt | Ratio tap changers with a variable transformation ratio (real variable) | Transformation ratios are fixed | +| param_shunt.txt | Shunts with a continuous variable susceptance and which can be modified and/or connected (only if possible bus is defined in `ampl_network_shunts.txt` | Shunt susceptances are fixed | +| param_generators_reactive.txt | Generators with a constant reactive power production. If this value is not consistent (> PQmax), the reactive power production stays variable | Coherent reactive power productions (see [4.5](#45-pq-units-domain)) are variable | +| param_buses_with_reactive_slack.txt | Buses with attached reactive slacks if configurable parameter buses_with_reactive_slacks = "CONFIGURED" | Only buses with no reactive power production have reactive slacks attached | + +All of these files share the same format: 2 columns #"num" "id". #### 3.3 Voltage limits overrides - In addition to the elements specified in section [3.2](#32-configuration-of-the-run), the user may choose to override some voltage limits of specified voltage levels. These values must be defined in the file ampl_network_substations_override.txt and @@ -252,7 +194,13 @@ TODO #### 4.5 P/Q units' domain -$$x=\frac{1}{\mathcal{R}}$$ +TODO : add +- `defaultQmaxPmaxRatio`: Parameter used to calculate `defaultQmin` and `defaultQmax`, + the thresholds used to correct the minimum and maximum reactive powers produced by generators + (see section [4.5](#45-pq-units-domain)). + The default value for this parameter is 0.3 (MVar/MW), and the thresholds are calculated as follows: + - `defaultQmin` = - `defaultPmin` x `defaultQmaxPmaxRatio` + - `defaultQmax` = `defaultPmax` x `defaultQmaxPmaxRatio` ### 5 Reference bus & main connex component @@ -307,6 +255,26 @@ the solving is considered unsuccessful. #### 6.2 Alternative current optimal power flow +TODO : +add +- `buses_with_reactive_slacks`: The parameter determining which buses will have reactive slacks attached in the resolution of the ACOPF +(see [6.2](#62-alternative-current-optimal-power-flow)). +It can take the following values: +- "ALL": all buses have reactive slack variables attached. +- "NO_GENERATION": only buses not producing reactive power will have reactive slack variables attached. +- "CONFIGURED": only buses specified in `param_buses_with_reactive_slack.txt` will have reactive slack variables attached. + +TODO : add +- `objective_choice` defining the choice of the objective function for the ACOPF (see [6.2](#62-alternative-current-optimal-power-flow)): +The minimization priority depends on the value of the parameter: +- If $0$, the active power produced by generators. +- If $1$, the deviation between the voltage value and the calculated target of the buses. +- If $2$, the deviation between the voltage value of the buses and the target V specified in `ampl_network_buses.txt`. + +TODO : add +This target lies between the upper and lower voltage limits of the level voltages to which the buses are connected, and is calculated using +configurable parameter `ratio_voltage_target`. + This ACOPF relies on specific parameters selected by the user, as thresholds and equipment of the power network which will be treated as variable or fixed (refer to [3.2](#32-configuration-of-the-run)). LThe voltage variables utilized in the ACOPF are initialized as follows: From edc821561715198e8aa44f84a9a3fd5c3b9a6b6a Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 18:02:50 +0100 Subject: [PATCH 10/51] WIP. Signed-off-by: parvy --- open-reac/README.md | 69 +++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index cb7f3df7..475cf87e 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -5,10 +5,11 @@ for voltage and reactive controls by network equipments such as generators, shunt compensators and transformers. OpenReac can be used for network planning or in operation as well. ---- ## Getting started +--- + ### AMPL For this project, you must have [AMPL](https://ampl.com/) installed. AMPL is a proprietary tool that works as an optimization modelling language. It can be interfaced with many solvers. @@ -39,10 +40,11 @@ To check, start a bash and run : knitroampl stub ``` ---- ## Reactive Optimal Power Flow +--- + ### 1 Overview The reactive optimal power flow (OPF) is implemented with AMPL. Its goal is to propose values @@ -92,25 +94,25 @@ 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 | Default value | Possible value | -|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|------------------------------------------------------| -| 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 [6.2](#62-alternative-current-optimal-power-flow)) | $0$ | $\{0, 1, 2\}$ | -| ratio_voltage_target | Ratio to calculate target V of buses when objective_choice = 1 | $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](#42-zero-impedance-lines)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ | - | epsilon_nominal_voltage | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathcal{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.) | $\mathcal{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.) | $\[{\rm 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.) | $\mathcal{R}^{+}$ | -| buses_with_reactive_slacks | Choice of which buses will have reactive slacks attached in ACOPF solving (see [6.2](#62-alternative-current-optimal-power-flow)) | $NO_GENERATION$ | $\{CONFIGURED, NO_GENERATION, ALL\}$ | -| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, Mvar) | | -| defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $1000$ (MW) | | -| defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $0$ (MW) | | -| defaultQmaxPmaxRatio | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.5](#45-pq-units-domain)) | $0.3$ (Mvar/MW) | | -| minimalQPrange | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.5](#45-pq-units-domain)) | $1$ (MW, MVar) | | +| Parameter | Description | Default value | Possible value | +|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|--------------------------------------------------| +| 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 [6.2](#62-alternative-current-optimal-power-flow)) | $0$ | ${0, 1, 2}$ | +| ratio_voltage_target | Ratio to calculate target V of buses when objective_choice = 1 | $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](#42-zero-impedance-lines)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ | + | epsilon_nominal_voltage | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathcal{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.) | $\mathcal{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.) | $\mathcal{R}^{+}$ | +| buses_with_reactive_slacks | Choice of which buses will have reactive slacks attached in ACOPF solving (see [6.2](#62-alternative-current-optimal-power-flow)) | NO_GENERATION | {CONFIGURED, NO_GENERATION, ALL} | +| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, Mvar) | | +| defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $1000$ (MW) | | +| defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $0$ (MW) | | +| defaultQmaxPmaxRatio | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.5](#45-pq-units-domain)) | $0.3$ (Mvar/MW) | | +| minimalQPrange | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.5](#45-pq-units-domain)) | $1$ (MW, MVar) | | In addition to the previous parameters, the user can specify which @@ -126,26 +128,26 @@ This is done using the following files: All of these files share the same format: 2 columns #"num" "id". -#### 3.3 Voltage limits overrides +#### 3.3 New voltage limits In addition to the elements specified in section [3.2](#32-configuration-of-the-run), the user may choose to override -some voltage limits of specified voltage levels. -These values must be defined in the file ampl_network_substations_override.txt and -are employed to establish the voltage limits of the voltage levels, as specified in section +the voltage limits of specified voltage levels. These values are defined in `ampl_network_substations_override.txt` and +are employed to establish the new voltage limits as specified in section [4.1](#41-voltage-level-limits-computation). Format : 4 columns #"num" "minV (pu)" "maxV (pu)" "id" -### 4 Checks and special handling +### 4 Pre-processing -Before solving the optimization problems described in [6](#6-optimal-power-flow-problems), -the following special handling procedures are executed to ensure the consistency -of the values used in the solving. -These specific treatments use user-configurable parameters (see [3.2](#32-configuration-of-the-run)). +Before solving the reactive OPF described in [6](#6-optimal-power-flow-problems), +the following pre-processing blocks are executed to ensure the consistency of the values. -#### 4.1 Voltage level limits computation +#### 4.1 Voltage level limits overrides -In order to ensure consistent voltage level limits in the optimization of the ACOPF (see [6.2](#62-alternative-current-optimal-power-flow)), -the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. They are initialized as follows: +In order to ensure consistent voltage level limits, +the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. +They are initialized as follows: +- minimal_voltage_lower_bound = ${\rm max}({\rm min_{vl\in SUBSTATIONS}}(V_{min}^{vl}), $ min_plausible_low_voltage_limit$)$ +- maximal_voltage_upper_bound = ${\rm min}({\rm max_{vl\in SUBSTATIONS}}(V_{max}^{vl}), $ max_plausible_high_voltage_limit$)$ - `minimal_voltage_lower_bound` is set equal to the maximum value between the configurable threshold `min_plausible_low_voltage_limit` (see [3.2](#32-configuration-of-the-run)) and the minimum voltage limit across the entire network (considering all voltage levels). - `maximal_voltage_upper_bound` is set equal to the minimum value between the configurable threshold `max_plausible_high_voltage_limit` (see [3.2](#32-configuration-of-the-run)) @@ -163,7 +165,6 @@ the previously calculated lower voltage bound, then the override value replaces #### 4.2 Zero impedance lines - To determine the non-impedant lines of the network, the configurable threshold `Znull` (p.u.) is used (see section [3.2](#32-configuration-of-the-run)). These lines are identified as those with an impedance magnitude (calculated in p.u.) lower than `Znull`. From bed666ae6c2cab8c42588afa6ee3cb7c183e1fb6 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 18:04:52 +0100 Subject: [PATCH 11/51] wip. Signed-off-by: parvy --- open-reac/README.md | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 475cf87e..84bbcf20 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -94,25 +94,25 @@ 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 | Default value | Possible value | -|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|--------------------------------------------------| -| 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 [6.2](#62-alternative-current-optimal-power-flow)) | $0$ | ${0, 1, 2}$ | -| ratio_voltage_target | Ratio to calculate target V of buses when objective_choice = 1 | $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](#42-zero-impedance-lines)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ | - | epsilon_nominal_voltage | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathcal{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.) | $\mathcal{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.) | $\mathcal{R}^{+}$ | -| buses_with_reactive_slacks | Choice of which buses will have reactive slacks attached in ACOPF solving (see [6.2](#62-alternative-current-optimal-power-flow)) | NO_GENERATION | {CONFIGURED, NO_GENERATION, ALL} | -| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, Mvar) | | -| defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $1000$ (MW) | | -| defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $0$ (MW) | | -| defaultQmaxPmaxRatio | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.5](#45-pq-units-domain)) | $0.3$ (Mvar/MW) | | -| minimalQPrange | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.5](#45-pq-units-domain)) | $1$ (MW, MVar) | | +| Parameter | Description | Default value | Possible value | +|----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|---------------------------------------------| +| 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 [6.2](#62-alternative-current-optimal-power-flow)) | $0$ | ${0, 1, 2}$ | +| ratio_voltage_target | Ratio to calculate target V of buses when objective_choice = 1 | $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](#42-zero-impedance-lines)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ | + | epsilon_nominal_voltage | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathcal{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.) | $\mathcal{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.) | $\mathcal{R}^{+}$ | +| buses_with_reactive_slacks | Choice of which buses will have reactive slacks attached in ACOPF solving (see [6.2](#62-alternative-current-optimal-power-flow)) | NO_GENERATION | {CONFIGURED, NO_GENERATION, ALL} | +| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, Mvar) | | +| defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $1000$ (MW) | | +| defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $0$ (MW) | | +| defaultQmaxPmaxRatio | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.5](#45-pq-units-domain)) | $0.3$ (Mvar/MW) | | +| minimalQPrange | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.5](#45-pq-units-domain)) | $1$ (MW, MVar) | | In addition to the previous parameters, the user can specify which @@ -146,7 +146,7 @@ the following pre-processing blocks are executed to ensure the consistency of th In order to ensure consistent voltage level limits, the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. They are initialized as follows: -- minimal_voltage_lower_bound = ${\rm max}({\rm min_{vl\in SUBSTATIONS}}(V_{min}^{vl}), $ min_plausible_low_voltage_limit$)$ +- minimal_voltage_lower_bound = max($min_{vl\in SUBSTATIONS}}(V_{min}^{vl})$,min_plausible_low_voltage_limit) - maximal_voltage_upper_bound = ${\rm min}({\rm max_{vl\in SUBSTATIONS}}(V_{max}^{vl}), $ max_plausible_high_voltage_limit$)$ - `minimal_voltage_lower_bound` is set equal to the maximum value between the configurable threshold `min_plausible_low_voltage_limit` (see [3.2](#32-configuration-of-the-run)) and the minimum voltage limit across the entire network (considering all voltage levels). From 9e2a5ef6e7e1e761314cdc31d9f9db39dfcc3d4a Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 18:05:47 +0100 Subject: [PATCH 12/51] wip. Signed-off-by: parvy --- 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 84bbcf20..a820bf83 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -146,7 +146,7 @@ the following pre-processing blocks are executed to ensure the consistency of th In order to ensure consistent voltage level limits, the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. They are initialized as follows: -- minimal_voltage_lower_bound = max($min_{vl\in SUBSTATIONS}}(V_{min}^{vl})$,min_plausible_low_voltage_limit) +- minimal_voltage_lower_bound = max(${\rm min}_{vl\in SUBSTATIONS}(V_{min}^{vl})$,min_plausible_low_voltage_limit) - maximal_voltage_upper_bound = ${\rm min}({\rm max_{vl\in SUBSTATIONS}}(V_{max}^{vl}), $ max_plausible_high_voltage_limit$)$ - `minimal_voltage_lower_bound` is set equal to the maximum value between the configurable threshold `min_plausible_low_voltage_limit` (see [3.2](#32-configuration-of-the-run)) and the minimum voltage limit across the entire network (considering all voltage levels). From 85026f8247888df3ee445371ea1d7ff449f28a60 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 18:06:35 +0100 Subject: [PATCH 13/51] wip. Signed-off-by: parvy --- 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 a820bf83..411c0ee2 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -146,7 +146,7 @@ the following pre-processing blocks are executed to ensure the consistency of th In order to ensure consistent voltage level limits, the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. They are initialized as follows: -- minimal_voltage_lower_bound = max(${\rm min}_{vl\in SUBSTATIONS}(V_{min}^{vl})$,min_plausible_low_voltage_limit) +- minimal_voltage_lower_bound = max($min_{vl\in SUBSTATIONS}(V_{min}^{vl})$,min_plausible_low_voltage_limit) - maximal_voltage_upper_bound = ${\rm min}({\rm max_{vl\in SUBSTATIONS}}(V_{max}^{vl}), $ max_plausible_high_voltage_limit$)$ - `minimal_voltage_lower_bound` is set equal to the maximum value between the configurable threshold `min_plausible_low_voltage_limit` (see [3.2](#32-configuration-of-the-run)) and the minimum voltage limit across the entire network (considering all voltage levels). From 0115e54a4762b534fb5d094432fd1e8f12ab1155 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 18:09:46 +0100 Subject: [PATCH 14/51] wip. Signed-off-by: parvy --- open-reac/README.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 411c0ee2..05f4f51f 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -146,12 +146,9 @@ the following pre-processing blocks are executed to ensure the consistency of th In order to ensure consistent voltage level limits, the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. They are initialized as follows: -- minimal_voltage_lower_bound = max($min_{vl\in SUBSTATIONS}(V_{min}^{vl})$,min_plausible_low_voltage_limit) -- maximal_voltage_upper_bound = ${\rm min}({\rm max_{vl\in SUBSTATIONS}}(V_{max}^{vl}), $ max_plausible_high_voltage_limit$)$ -- `minimal_voltage_lower_bound` is set equal to the maximum value between the configurable threshold `min_plausible_low_voltage_limit` (see [3.2](#32-configuration-of-the-run)) -and the minimum voltage limit across the entire network (considering all voltage levels). -- `maximal_voltage_upper_bound` is set equal to the minimum value between the configurable threshold `max_plausible_high_voltage_limit` (see [3.2](#32-configuration-of-the-run)) -and the maximum voltage limit across the entire network (considering all voltage levels). +- minimal_voltage_lower_bound = $max(min\limits_{s\in SUBSTATIONS}(V_{min}^{s})$, min_plausible_low_voltage_limit) +- maximal_voltage_upper_bound = $min(max\limits_{s\in SUBSTATIONS}(V_{max}^{s})$, max_plausible_high_voltage_limit) +where $V_min$ (resp. $V_max$) is the low (resp. high) voltage limit of voltage level $s\in SUBSTATIONS$. As a result, the lower voltage bound chosen is equal to the maximum value between `minimal_voltage_lower_bound` From f663db378948a24f6495703d33d7800c49cd391b Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 12 Dec 2023 18:10:19 +0100 Subject: [PATCH 15/51] wip. Signed-off-by: parvy --- open-reac/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 05f4f51f..055a776b 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -146,8 +146,8 @@ the following pre-processing blocks are executed to ensure the consistency of th In order to ensure consistent voltage level limits, the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. They are initialized as follows: -- minimal_voltage_lower_bound = $max(min\limits_{s\in SUBSTATIONS}(V_{min}^{s})$, min_plausible_low_voltage_limit) -- maximal_voltage_upper_bound = $min(max\limits_{s\in SUBSTATIONS}(V_{max}^{s})$, max_plausible_high_voltage_limit) +- minimal_voltage_lower_bound = $\max(\min\limits_{s\in SUBSTATIONS}(V_{min}^{s})$, min_plausible_low_voltage_limit) +- maximal_voltage_upper_bound = $\min(\max\limits_{s\in SUBSTATIONS}(V_{max}^{s})$, max_plausible_high_voltage_limit) where $V_min$ (resp. $V_max$) is the low (resp. high) voltage limit of voltage level $s\in SUBSTATIONS$. As a result, the lower voltage bound chosen is equal to the maximum value between From a27172df468b5a890110c0aaaf3551427eebf999 Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 19 Dec 2023 12:10:50 +0100 Subject: [PATCH 16/51] wip. Signed-off-by: parvy --- open-reac/README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 055a776b..815e3085 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -106,7 +106,7 @@ These are specified in the file `param_algo.txt`: | epsilon_nominal_voltage | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathcal{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.) | $\mathcal{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.) | $\mathcal{R}^{+}$ | +| 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.) | $\mathcal{R}^{+}$ | | buses_with_reactive_slacks | Choice of which buses will have reactive slacks attached in ACOPF solving (see [6.2](#62-alternative-current-optimal-power-flow)) | NO_GENERATION | {CONFIGURED, NO_GENERATION, ALL} | | PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, Mvar) | | | defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $1000$ (MW) | | @@ -144,11 +144,14 @@ the following pre-processing blocks are executed to ensure the consistency of th #### 4.1 Voltage level limits overrides In order to ensure consistent voltage level limits, -the consistency thresholds `minimal_voltage_lower_bound` and `maximal_voltage_upper_bound` are employed. +the consistency thresholds *minimal_voltage_lower_bound* and *maximal_voltage_upper_bound* are employed. They are initialized as follows: -- minimal_voltage_lower_bound = $\max(\min\limits_{s\in SUBSTATIONS}(V_{min}^{s})$, min_plausible_low_voltage_limit) -- maximal_voltage_upper_bound = $\min(\max\limits_{s\in SUBSTATIONS}(V_{max}^{s})$, max_plausible_high_voltage_limit) -where $V_min$ (resp. $V_max$) is the low (resp. high) voltage limit of voltage level $s\in SUBSTATIONS$. +- $\text{minimal_voltage_lower_bound} = \max(\min\limits_{s\in \text{SUBSTATIONS}}(V_{min}^{s}), \text{min_plausible_low_voltage_limit})$ +- $\text{maximal_voltage_upper_bound} = \min(\max\limits_{s\in \text{SUBSTATIONS}}(V_{max}^{s}), \text{max_plausible_high_voltage_limit})$ + +where $V_{min}$ (resp. $V_{max}$) is the low (resp. high) voltage limit of voltage level $s\in \text{SUBSTATIONS}$. + +TODO : refactor As a result, the lower voltage bound chosen is equal to the maximum value between `minimal_voltage_lower_bound` From a5c66fed8c661ece4475f04445c461a3339e17f6 Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 11:59:52 +0100 Subject: [PATCH 17/51] wip. Signed-off-by: parvy --- open-reac/README.md | 190 +++++++++++++++----------------------------- 1 file changed, 65 insertions(+), 125 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 815e3085..11841b04 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -71,11 +71,11 @@ each serving a specific function: *ampl_* prefix), and the files used to configure the run (files with *param_* prefix). Refer to section [3](#3-input). - `reactiveopf.mod` defines the sets, parameters and optimization problems (CC, DCOPF, ACOPF) solved in `reactiveopf.run`. - Refer to section [5](#5-reference-bus--main-connex-component) and [6](#6-optimal-power-flow-problems). + Refer to sections [5](#5-reference-bus--main-connex-component), [6](#6-direct-current-optimal-power-flow) and [7](#7-alternative-current-optimal-power-flow). - `reactiveopfoutput.mod` exports result files if the execution of `reactiveopf.run` is successful. - Refer to section [7.1](#72-in-case-of-convergence). + Refer to section [8.1](#81-in-case-of-convergence). - `reactiveopfexit.run` contains the code executed when the problem is inconsistent. - Refer to section [7.2](#71-in-case-of-inconsistency). + Refer to section [8.2](#82-in-case-of-inconsistency). - `reactiveopf.run` executes the AMPL process of OpenReac, calling the previous scripts. ### 3 Input @@ -98,25 +98,25 @@ These are specified in the file `param_algo.txt`: |----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|---------------------------------------------| | 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 [6.2](#62-alternative-current-optimal-power-flow)) | $0$ | ${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 = 1 | $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](#42-zero-impedance-lines)) | $10^{-5}$ (p.u.) | $\[0; 0.1\]$ | - | epsilon_nominal_voltage | Threshold to ignore voltage levels with nominal voltage lower than it | $1$ (kV) | $\mathcal{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.) | $\mathcal{R}^{+}$ | + | 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.) | $\mathcal{R}^{+}$ | -| buses_with_reactive_slacks | Choice of which buses will have reactive slacks attached in ACOPF solving (see [6.2](#62-alternative-current-optimal-power-flow)) | NO_GENERATION | {CONFIGURED, NO_GENERATION, ALL} | -| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, Mvar) | | +| 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} | +| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, MVAr) | | | defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $1000$ (MW) | | | defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $0$ (MW) | | -| defaultQmaxPmaxRatio | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.5](#45-pq-units-domain)) | $0.3$ (Mvar/MW) | | -| minimalQPrange | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.5](#45-pq-units-domain)) | $1$ (MW, MVar) | | +| defaultQmaxPmaxRatio | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.5](#45-pq-units-domain)) | $0.3$ (MVAr/MW) | | +| minimalQPrange | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.5](#45-pq-units-domain)) | $1$ (MW, MVAr) | | In addition to the previous parameters, the user can specify which -parameters will be variable or fixed in the ACOPF solving (see section [6.2](#62-alternative-current-optimal-power-flow)). +parameters will be variable or fixed in the ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)). This is done using the following files: | File | Description | Default behavior of modified values | @@ -133,17 +133,17 @@ All of these files share the same format: 2 columns #"num" "id". In addition to the elements specified in section [3.2](#32-configuration-of-the-run), the user may choose to override the voltage limits of specified voltage levels. These values are defined in `ampl_network_substations_override.txt` and are employed to establish the new voltage limits as specified in section -[4.1](#41-voltage-level-limits-computation). +[4.1](#41-voltage-level-limits-overrides). Format : 4 columns #"num" "minV (pu)" "maxV (pu)" "id" ### 4 Pre-processing -Before solving the reactive OPF described in [6](#6-optimal-power-flow-problems), +Before solving the reactive OPF described in [7](#7-alternative-current-optimal-power-flow), the following pre-processing blocks are executed to ensure the consistency of the values. #### 4.1 Voltage level limits overrides -In order to ensure consistent voltage level limits, +In order to ensure consistent voltage level limits for the voltage levels, the consistency thresholds *minimal_voltage_lower_bound* and *maximal_voltage_upper_bound* are employed. They are initialized as follows: - $\text{minimal_voltage_lower_bound} = \max(\min\limits_{s\in \text{SUBSTATIONS}}(V_{min}^{s}), \text{min_plausible_low_voltage_limit})$ @@ -151,7 +151,7 @@ They are initialized as follows: where $V_{min}$ (resp. $V_{max}$) is the low (resp. high) voltage limit of voltage level $s\in \text{SUBSTATIONS}$. -TODO : refactor + As a result, the lower voltage bound chosen is equal to the maximum value between `minimal_voltage_lower_bound` @@ -163,35 +163,26 @@ and the specified `maxV (pu)` value in `ampl_network_substations.txt`. If an override value is specified by the user (see [3.3](#33-voltage-limits-overrides)) and it is higher than the previously calculated lower voltage bound, then the override value replaces `maxV (pu)`. -#### 4.2 Zero impedance lines - -To determine the non-impedant lines of the network, the configurable threshold `Znull` (p.u.) is used -(see section [3.2](#32-configuration-of-the-run)). -These lines are identified as those with an impedance magnitude (calculated in p.u.) lower than `Znull`. -These lines will have their reactance replaced by `Znull`. +#### 4.2 Zero-impedance branches -Les transformateurs ayant une impédance considérée comme nulle ne sont considérés dans les calculs, -et sont remplacés par des lignes. De plus, les lignes considérés comme non impédantes auront -une réactance remplacée par Znull. +Branches with an impedance magnitude (calculated in p.u.) +below the configurable threshold `Znull` (see section [3.2](#32-configuration-of-runtime)) +are considered as non-impedant. +These branches will have their reactance replaced by the threshold `Znull` (in p.u.). #### 4.3 Impedance of transformers -In the calculations of the ACOPF (see section [6.2](#62-alternative-current-optimal-power-flow)), -the ratio tap changers (RTC) with an impedance (specified in `ampl_network_branches.txt`) -considered as null (see [4.2](#42-zero-impedance-lines)) are treated as lines (the transformation ratio is ignored). -This is also the case with phase tap changers (PST), where the phase shift is consequently ignored (as well as -the impedance specified in the tap changer table `ampl_network_tct.txt`). - -For PSTs considered as having impedance, the reactance values from the tap changer table (in `ampl_network_tct.txt`) -replace the reactance specified in `ampl_network_branches.txt`. The resistance is calculated proportionally to this reactance. -The impedances of RTCs remain as specified in `ampl_network_branches.txt`. - -Please notice that there is no specific handling for cases where -resistances/reactances are negative or if there is both an RTC and a PST on the same branch. +In the calculations of the ACOPF (see [7](#7-alternative-current-optimal-power-flow)), +the transformers with an impedance (the one specified in `ampl_network_branches.txt`) +considered as null (see [4.2](#42-zero-impedance-branches)) +are treated as lines. Then, the transformation ratios/phase shifts are ignored, as well as the impedance +specified in the tap changer table `ampl_network_tct.txt`. -#### 4.4 Transformer consistency - -TODO +For phase shifters transformers considered as impedant, the reactance values from the tap changer table (in `ampl_network_tct.txt`) +replace the reactance specified in `ampl_network_branches.txt`. The resistance is then calculated proportionnaly to this reactance. +For the ratio tap changers, the impedance remain as specified in `ampl_network_branches.txt`. Please notice there is no +specified handling for cases where resistances/reactances are negative or if there is both a ratio tap changer and a +phase shift transformer on the same branch. #### 4.5 P/Q units' domain @@ -199,36 +190,29 @@ TODO : add - `defaultQmaxPmaxRatio`: Parameter used to calculate `defaultQmin` and `defaultQmax`, the thresholds used to correct the minimum and maximum reactive powers produced by generators (see section [4.5](#45-pq-units-domain)). - The default value for this parameter is 0.3 (MVar/MW), and the thresholds are calculated as follows: + The default value for this parameter is 0.3 (MVAr/MW), and the thresholds are calculated as follows: - `defaultQmin` = - `defaultPmin` x `defaultQmaxPmaxRatio` - `defaultQmax` = `defaultPmax` x `defaultQmaxPmaxRatio` ### 5 Reference bus & main connex component -A reference bus (`null_phase_bus` AMPL parameter) is determined to enforce the zero-phase constraint of the OPFs. +A reference bus (`null_phase_bus` AMPL parameter) enforces the zero-phase constraint of the OPFs. This reference bus corresponds to the bus in the network with the most AC branches connected, -among those belonging to the main connected component (0 in `ampl_network_buses.txt`). -If multiple buses have the same maximum cardinality, the one with the highest `num` is selected. -If no bus is found meeting these criteria, the first bus defined in the file `ampl_network_buses.txt` is chosen -as reference bus. - -The DCOPF and ACOPF are executed on buses connected to the reference bus by AC branches. -Then, buses connected to the reference bus by HVDC lines are excluded in OPF computation. -These buses are determined by solving the `PROBLEM_CCOMP` optimization problem -defined in `reactiveopf.mod`. After the optimization, buses connected by AC branches -are determined by verifying that the associated variable `teta_ccomputation` is set to 0. - -### 6 Optimal power flow problems - -Two OPFs are successively solved. First, a Direct Current Optimal Power Flow (DCOPF) as described in section [6.1](#61-direct-current-optimal-power-flow), -followed by an Alternating Current Optimal Power Flow (ACOPF) described in section [6.2](#62-alternative-current-optimal-power-flow). This is done for -two main reasons: -- If the DCOPF resolution fails (see [6.1](#61-direct-current-optimal-power-flow)), it provides a strong indication that the ACOPF resolution will also fail. +among those belonging to the main connected component ($0$ in `ampl_network_buses.txt`). +If multiple buses have the same maximum cardinality, the one with the highest `num` identifier is selected. +If no bus is found meeting these criteria, the first bus defined in the file `ampl_network_buses.txt` is selected. + +The OPFs are executed on the main connex component (i.e. buses connected to the reference bus by AC branches). +Then, buses connected to the reference bus by HVDC lines are excluded. +The main connex component is determined by solving the `PROBLEM_CCOMP` optimization problem. + +### 6 Direct current optimal power flow + +Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)), a DCOPF is solved for two main reasons: +- If the DCOPF resolution fails, it provides a strong indication that the ACOPF resolution will also fail. The DCOPF serves as a formal consistency check on the data. - The phases computed during the DCOPF resolution will be used as initial points for the ACOPF resolution. -#### 6.1 Direct current optimal power flow - The DCOPF involves the following constraints: - `ctr_null_phase_bus_dc`, which sets the phase of the reference (refer to [5](#5-reference-bus--main-connex-component)) to 0. - `ctr_activeflow`, which defines the active power flowing through the branches of the network. @@ -250,11 +234,12 @@ which helps homogenize the deviations among different generators. The goal is to drive these variables towards 0, ensuring an active power balance at each node. The resolution of this DCOPF is considered as successful if the solver identifies a feasible solution without reaching -a pre-defined limit, and if the sum of all balance variables (`balance_pos` and `balance_neg`) does not exceed the configurable threshold `Pnull` -(see section [3.2](#32-configuration-of-the-run)). In cases where these conditions are not met, -the solving is considered unsuccessful. +a default limit, and if the sum of all balance variables (`balance_pos` and `balance_neg`) does not exceed the configurable threshold `Pnull` +(see [3.2](#32-configuration-of-the-run)). Otherwise, the solving is considered unsuccessful. + +### 7 Alternative current optimal power flow -#### 6.2 Alternative current optimal power flow +TODO : refactor TODO : add @@ -330,70 +315,25 @@ TODO : expliciter le fait qu'on fasse plusieurs optimisations à la suite en jou TODO : add comments on results treatment by Knitro (what kind of solutions are considered as good...) -### 7 Output - -#### 7.1 In case of inconsistency +### 8 Output -If the computation of the main connex component or of the DCOPF fails (see [6.1](#61-direct-current-optimal-power-flow)), -the problem is considered as inconsistent. -Then, the script `reactiveopfexit.run` is executed and the following file is exported: - -`reactiveopf_results_indic.txt`, which contains various indicators to - provide an overview of the run. It includes: - - The error message(s) returned by the execution. - - General information (system OS, computation time, etc.). - - The configurable thresholds/parameters used in the run (see section [3.2](#32-configuration-of-the-run)). - -#### 7.2 In case of convergence +#### 8.1 In case of convergence If the AMPL process defined in `reactiveopf.run` is successful, the script `reactiveopfoutput.run` is executed (even if the solving of ACOPF did not reached a feasible point) and the following files are exported: -- `reactiveopf_results_indic.txt`, which contains various indicators to provide an overview of the - run. It includes: - - General information (system OS, computation time, etc.). - - The configurable thresholds/parameters used in the run (see section [3.2](#32-configuration-of-the-run)). - - The cardinality of the sets used in the optimization problems (number of non-impedance branches, - number of buses with slack variables, etc.). - - Information about calculated angles (maximum/minimum theta, maximum - difference between neighboring buses, etc.). - +| File | Content | Format | +|-------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------| +| reactiveopf_results_indic.txt | General information (system OS, computation time, etc.). The configurable thresholds/parameters (see section [3.2](#32-configuration-of-the-run)). The cardinality of the sets (number of non-impedance branches, number of slack variables, etc.). Information about calculated angles (maximum/minimum theta, maximum difference between neighbors, etc.). | | +| reactiveopf_results_static_var_compensators.csv | Calculated voltage and reactive power values for the SVC that regulate voltage. | 6 columns #"variant" "num" "bus" "vRegul" "V(pu)" "Q(MVAr)" | +| reactiveopf_results_shunts.csv | Calculated reactive power (and susceptance) values for shunts that were either connected or modified after the optimization problems were resolved. | 6 columns #"variant" "num" "bus" "b(pu)" "Q(MVAr)" "section" | +| reactiveopf_results_generators.csv | Calculated active and reactive power values for generating units. | 9 columns #"variant" "num" "bus" "vRegul" "V(pu)" "targetP(MW)" "targetQ(MVAr)" "P(MW)" "Q(MW)" | +| reactiveopf_results_vsc_converter_stations.csv | Calculated reactive power values for VSC converter stations. | 8 columns #"variant" "num" "bus" "vRegul" "targetV(pu)" "targetQ(MVAr)" "P(MW)" "Q(MVAr)" | +| reactiveopf_results_rtc.csv | RTCs and associated taps, with transformer ratio closest to the one calculated after the optimization. | 3 columns #"variant" "num" "tap" | +| reactiveopf_results_reactive_slacks.csv | Calculated reactive slack variables `slack1_balance_Q` and `slack2_balance_Q`. | 6 columns #"variant" "bus" "slack_condensator(MVAr)" "slack_self(MVAr)" "id" "substation" | -- `reactiveopf_results_static_var_compensators.csv`, which contains calculated -voltage and reactive power values for the SVC that regulate voltage. - - Format : 6 columns #"variant" "num" "bus" "vRegul" "V(pu)" "Q(Mvar)" - - -- `reactiveopf_results_shunts.csv`, which contains calculated reactive power (and susceptance) values -for shunts that were either connected or modified after the optimization problems were resolved. - - Format : 6 columns #"variant" "num" "bus" "b(pu)" "Q(Mvar)" "section" - - -- `reactiveopf_results_generators.csv`, which contains -calculated active and reactive power values for generating units. - - Format : 9 columns #"variant" "num" "bus" "vRegul" "V(pu)" - "targetP(MW)" "targetQ(Mvar)" "P(MW)" "Q(MW)" - - -- `reactiveopf_results_vsc_converter_stations.csv`, which contains -calculated reactive power values for VSC converter stations. - - Format : 8 columns #"variant" "num" "bus" "vRegul" "targetV(pu)" - "targetQ(Mvar)" "P(MW)" "Q(Mvar)" - - -- `reactiveopf_results_rtc.csv`, which contains the RTCs and their associated taps, -with the transformation ratio closest to the one calculated after -the optimization. - - Format : 3 columns #"variant" "num" "tap" - - -- `reactiveopf_results_reactive_slacks.csv`, which contains the calculated -reactive slack variables `slack1_balance_Q` and `slack2_balance_Q`. - - Format : 6 columns #"variant" "bus" "slack_condensator(Mvar)" "slack_self(Mvar)" "id" "substation" +#### 8.2 In case of inconsistency +If the computation of the main connex component (see [5](#5-reference-bus--main-connex-component)) or of the DCOPF fails (see [6](#6-direct-current-optimal-power-flow)), +the problem is considered as inconsistent. +Then, the script `reactiveopfexit.run` is executed and the file reactiveopf_results_indic.txt described in previous section is exported, without the information on the calculated angles. From 0448bc4a8edbc2925127465235c6fac6b9e39b9c Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 12:04:41 +0100 Subject: [PATCH 18/51] test. Signed-off-by: parvy --- open-reac/README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/open-reac/README.md b/open-reac/README.md index 11841b04..10091cf1 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -213,6 +213,17 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF serves as a formal consistency check on the data. - The phases computed during the DCOPF resolution will be used as initial points for the ACOPF resolution. +The DCOPF problem solved is : + +\begin{equation} +\begin{tabular}{rl} +minimize & $t$\\ +subject to & $f_0(x) - t \le 0$\\ +& $f_i(x) \le 0$, \quad $i=1, \dots, m$\\ +& $h_i(x) = 0$, \quad $i=1, \dots, p$,\\ +\end{tabular} +\end{equation} + The DCOPF involves the following constraints: - `ctr_null_phase_bus_dc`, which sets the phase of the reference (refer to [5](#5-reference-bus--main-connex-component)) to 0. - `ctr_activeflow`, which defines the active power flowing through the branches of the network. From ef4838398dfce0cb3a7cb6532bafa6b253b8b132 Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 12:13:58 +0100 Subject: [PATCH 19/51] wip. Signed-off-by: parvy --- open-reac/README.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 10091cf1..0d64a3dc 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -213,18 +213,14 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF serves as a formal consistency check on the data. - The phases computed during the DCOPF resolution will be used as initial points for the ACOPF resolution. -The DCOPF problem solved is : +The DCOPF involves the following constraints: +$$ \pmb{\theta_s} = 0, s\in\text{SUBSTATIONS}$$ +$$ \pmb{p}_{ij} = \frac{\pmb{\theta_i} - \pmb{\theta_j}}{x_{ij}} $$ +$$ \sum\limits_{j\in v(i)} \pmb{p}_{ij} = \pmb{P}_i^{in} + \pmb{\sigma}_{P_i^{in}}$$ -\begin{equation} -\begin{tabular}{rl} -minimize & $t$\\ -subject to & $f_0(x) - t \le 0$\\ -& $f_i(x) \le 0$, \quad $i=1, \dots, m$\\ -& $h_i(x) = 0$, \quad $i=1, \dots, p$,\\ -\end{tabular} -\end{equation} +where $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)), +$p_{ij}$ the active power leaving bus $i$ on branch $ij$, and -The DCOPF involves the following constraints: - `ctr_null_phase_bus_dc`, which sets the phase of the reference (refer to [5](#5-reference-bus--main-connex-component)) to 0. - `ctr_activeflow`, which defines the active power flowing through the branches of the network. - `ctr_balance`, which enforces the active power balance at each network node. From 64d2c88626a03bbeb831d502d4e19fbb7ef88273 Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 12:16:19 +0100 Subject: [PATCH 20/51] wip. Signed-off-by: parvy --- open-reac/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 0d64a3dc..be18590f 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -214,9 +214,12 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) - The phases computed during the DCOPF resolution will be used as initial points for the ACOPF resolution. The DCOPF involves the following constraints: -$$ \pmb{\theta_s} = 0, s\in\text{SUBSTATIONS}$$ -$$ \pmb{p}_{ij} = \frac{\pmb{\theta_i} - \pmb{\theta_j}}{x_{ij}} $$ -$$ \sum\limits_{j\in v(i)} \pmb{p}_{ij} = \pmb{P}_i^{in} + \pmb{\sigma}_{P_i^{in}}$$ + +$ \theta_s = 0, s\in\text{SUBSTATIONS}$ + +$ p_{ij} = \frac{\theta_i - \theta_j}{x_{ij}} $ + +$ \sum\limits_{j\in v(i)} p_{ij} = P_i^{in} + \sigma_{P_i^{in}}$ where $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)), $p_{ij}$ the active power leaving bus $i$ on branch $ij$, and From 8b5d9ea6406fbfaecd5e769f05874266ad0f5efb Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 12:23:17 +0100 Subject: [PATCH 21/51] wip. Signed-off-by: parvy --- open-reac/README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index be18590f..b62341b5 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -215,14 +215,23 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF involves the following constraints: -$ \theta_s = 0, s\in\text{SUBSTATIONS}$ +$\theta_s = 0, s\in\text{SUBSTATIONS}$ + +$p_{ij} = \frac{\theta_i - \theta_j}{x_{ij}} $ + +$\sum\limits_{j\in v(i)} p_{ij} = P_i^{in} + \sigma_{P_i}^{+} + \sigma_{P_i}^{-}$ -$ p_{ij} = \frac{\theta_i - \theta_j}{x_{ij}} $ -$ \sum\limits_{j\in v(i)} p_{ij} = P_i^{in} + \sigma_{P_i^{in}}$ where $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)), -$p_{ij}$ the active power leaving bus $i$ on branch $ij$, and +$p_{ij}$ the active power leaving bus $i$ on branch $ij$, and $\sigma_{P_i}$ the slack variables (both positive) +representing the excess or shortfall of active power produced in $i$. + + +And the following objective function : + +$$\text{minimize} 1000\sum\limits_{i\in \text{BUSCC}} \sigma_{P_i}^{+} + \sigma_{P_i}^{-}$$ + - `ctr_null_phase_bus_dc`, which sets the phase of the reference (refer to [5](#5-reference-bus--main-connex-component)) to 0. - `ctr_activeflow`, which defines the active power flowing through the branches of the network. From ebafd77b937485ceaf6774f880044323b109c5d8 Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 12:25:06 +0100 Subject: [PATCH 22/51] wip. Signed-off-by: parvy --- open-reac/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index b62341b5..59ee5fe5 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -215,11 +215,11 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF involves the following constraints: -$\theta_s = 0, s\in\text{SUBSTATIONS}$ +$$\theta_s = 0,\;\; s\in\text{SUBSTATIONS}$$ -$p_{ij} = \frac{\theta_i - \theta_j}{x_{ij}} $ +$$\pmb{p}_{ij} = \frac{\theta_i - \theta_j}{x_{ij}}$$ -$\sum\limits_{j\in v(i)} p_{ij} = P_i^{in} + \sigma_{P_i}^{+} + \sigma_{P_i}^{-}$ +$$\sum\limits_{j\in v(i)} p_{ij} = P_i^{in} + \sigma_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-}$$ From f9dd3e87869d0c494c634e8e3e2c0750b0b9121e Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 12:41:43 +0100 Subject: [PATCH 23/51] wip. Signed-off-by: parvy --- open-reac/README.md | 56 ++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 59ee5fe5..4b745d45 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -184,7 +184,7 @@ For the ratio tap changers, the impedance remain as specified in `ampl_network_b specified handling for cases where resistances/reactances are negative or if there is both a ratio tap changer and a phase shift transformer on the same branch. -#### 4.5 P/Q units' domain +#### 4.4 P/Q units' domain TODO : add - `defaultQmaxPmaxRatio`: Parameter used to calculate `defaultQmin` and `defaultQmax`, @@ -215,46 +215,34 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF involves the following constraints: -$$\theta_s = 0,\;\; s\in\text{SUBSTATIONS}$$ +$$\boldsymbol{\theta}_s = 0, \quad s\in\text{SUBSTATIONS}$$ -$$\pmb{p}_{ij} = \frac{\theta_i - \theta_j}{x_{ij}}$$ +$$\boldsymbol{p}_{ij} = \frac{\boldsymbol{\theta}_i - \boldsymbol{\theta}_j}{x_{ij}}, ij\in\text{BRANCHCC}$$ -$$\sum\limits_{j\in v(i)} p_{ij} = P_i^{in} + \sigma_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-}$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p}_{ij} = P_i^{in} + \boldsymbol{P}_i^{g} + \boldsymbol{\sigma}_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-}, i\in\text{BUSCC}$$ +$$P_{i, \text{min}}^{g} \leq \boldsymbol{P}_i^{g} \leq P_{i, \text{max}}^{g}$$ - -where $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)), -$p_{ij}$ the active power leaving bus $i$ on branch $ij$, and $\sigma_{P_i}$ the slack variables (both positive) -representing the excess or shortfall of active power produced in $i$. - +where : +- $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)). +- $\boldsymbol{p}_{ij}$ the active power leaving bus $i$ on branch $ij$. +- $P_i^{in}$ the constant active power injected or consumed in bus $i$ (by batteries, loads, VSC stations and LCC stations). +- $\boldsymbol{P}_i^{g}$ is the variable active power produced by generators of bus $i$. +- $P_{i, \text{min}}^{g}$ (resp. $P_{i, \text{max}}^{g}$) is the lower bound of +the active power produced by generators on bus $i$ (see [4.4](#44-pq-units-domain)) +- $\boldsymbol{\sigma}_{P_i}$ the slack variables (both positive) +expressing the excess or shortfall of active power produced in $i$. And the following objective function : -$$\text{minimize} 1000\sum\limits_{i\in \text{BUSCC}} \sigma_{P_i}^{+} + \sigma_{P_i}^{-}$$ - - -- `ctr_null_phase_bus_dc`, which sets the phase of the reference (refer to [5](#5-reference-bus--main-connex-component)) to 0. -- `ctr_activeflow`, which defines the active power flowing through the branches of the network. -- `ctr_balance`, which enforces the active power balance at each network node. -This balance takes into account the active power produced by generators and batteries, as well as the power consumed -by loads, VSC stations and LCC stations connected to each bus (in addition to what enters and exits the bus). -Within this balance, the following are variables: - - The active power `P_dcopf` generated by the generating units. - - The slack variables `balance_pos` and `balance_neg` (both positive), which represent - the excess or shortfall of active power produced at each node. - -And the objective function `problem_dcopf_objective`, which minimizes the following summations: -- The sum of squared deviations between the calculated -active power generation for each generator and its -target active power (`targetP (MW)` defined in `ampl_network_generators.txt`). -This sum is normalized by the target active power, -which helps homogenize the deviations among different generators. -- The sum of the variables `balance_pos` and `balance_neg`, penalized by a high coefficient (`penalty_balance`). -The goal is to drive these variables towards 0, ensuring an active power balance at each node. - -The resolution of this DCOPF is considered as successful if the solver identifies a feasible solution without reaching -a default limit, and if the sum of all balance variables (`balance_pos` and `balance_neg`) does not exceed the configurable threshold `Pnull` -(see [3.2](#32-configuration-of-the-run)). Otherwise, the solving is considered unsuccessful. +$$\text{minimize} 1000\sum\limits_{i\in \text{BUSCC}} \boldsymbol{\sigma}_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-} ++ \sum\limits_{g\in\text{UNITON}} (\frac{\boldsymbol{P}_i^{g} - P_i^{g,t}}{\max(1, 0.01 P_i^{g,t})})^2$$ + +where $P_i^{g,t}$ is the target of generator of the generator on bus $i$. The sum of the slack variables is penalized by a +high coefficient to drive these variables towards 0, ensuring active power balance at each bus. +The resolution of this DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` +(see [3.2](#32-configuration-of-the-run)), and if the solver used to solve the problem finds feasible solution without reaching +a default limit. Otherwise, the solving is considered unsuccessful. ### 7 Alternative current optimal power flow From 35a2798fd5ba872f01d9e6e46451e460688322e4 Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 12:58:05 +0100 Subject: [PATCH 24/51] wip. Signed-off-by: parvy --- open-reac/README.md | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 4b745d45..59780909 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -186,6 +186,17 @@ phase shift transformer on the same branch. #### 4.4 P/Q units' domain + +The following corrections apply successively to determine consistent domains for the active +power $P^g$ and reactive power produced $Q^g$ by generators. The thresholds introduced +in [3.2](#32-configuration-of-the-run) are used. Let $P^g_{min}$, $P^g_{max}$, $Q^g_{min}$, and $Q^g_{max}$ +be the bounds of these domains (specified in `ampl_network_generators.txt`), +and $P^g_{min,c}$, $P^g_{max,c}$, $Q^g_{min,c}$, and $Q^g_{max,c}$ be the corrected bounds : + +- If $|P^g_{max}| \geq \text{PQmax}$, then $P^g_{max,c} = \max(\text{defaultPmax}, P^g,t)$. +Same with $P^g_{min}$, $P^g_{min,c}$ and defaultPmin. +- If $|P^g_{max,c} - |P^g_{min,c}| \leq \text{minimalQPrange}$, then $P^g_{max,c}$ and $P^g_{min,c}$ are fixed to $P^{g,t}$. + TODO : add - `defaultQmaxPmaxRatio`: Parameter used to calculate `defaultQmin` and `defaultQmax`, the thresholds used to correct the minimum and maximum reactive powers produced by generators @@ -216,27 +227,20 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF involves the following constraints: $$\boldsymbol{\theta}_s = 0, \quad s\in\text{SUBSTATIONS}$$ - $$\boldsymbol{p}_{ij} = \frac{\boldsymbol{\theta}_i - \boldsymbol{\theta}_j}{x_{ij}}, ij\in\text{BRANCHCC}$$ - $$\sum\limits_{j\in v(i)} \boldsymbol{p}_{ij} = P_i^{in} + \boldsymbol{P}_i^{g} + \boldsymbol{\sigma}_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-}, i\in\text{BUSCC}$$ -$$P_{i, \text{min}}^{g} \leq \boldsymbol{P}_i^{g} \leq P_{i, \text{max}}^{g}$$ - where : - $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)). - $\boldsymbol{p}_{ij}$ the active power leaving bus $i$ on branch $ij$. - $P_i^{in}$ the constant active power injected or consumed in bus $i$ (by batteries, loads, VSC stations and LCC stations). - $\boldsymbol{P}_i^{g}$ is the variable active power produced by generators of bus $i$. -- $P_{i, \text{min}}^{g}$ (resp. $P_{i, \text{max}}^{g}$) is the lower bound of -the active power produced by generators on bus $i$ (see [4.4](#44-pq-units-domain)) - $\boldsymbol{\sigma}_{P_i}$ the slack variables (both positive) expressing the excess or shortfall of active power produced in $i$. And the following objective function : -$$\text{minimize} 1000\sum\limits_{i\in \text{BUSCC}} \boldsymbol{\sigma}_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-} -+ \sum\limits_{g\in\text{UNITON}} (\frac{\boldsymbol{P}_i^{g} - P_i^{g,t}}{\max(1, 0.01 P_i^{g,t})})^2$$ +$$\text{minimize} 1000\sum\limits_{i\in \text{BUSCC}} \boldsymbol{\sigma}_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-} + \sum\limits_{g\in\text{UNITON}} (\frac{\boldsymbol{P}_i^{g} - P_i^{g,t}}{\max(1, 0.01 P_i^{g,t})})^2$$ where $P_i^{g,t}$ is the target of generator of the generator on bus $i$. The sum of the slack variables is penalized by a high coefficient to drive these variables towards 0, ensuring active power balance at each bus. From ef22601cddf963c3f7524a67f377533f465cef7f Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 15:25:41 +0100 Subject: [PATCH 25/51] P/Q units' domain part. Signed-off-by: parvy --- open-reac/README.md | 64 +++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 59780909..0179a6cc 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -108,11 +108,11 @@ These are specified in the file `param_algo.txt`: | 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} | -| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.5](#45-pq-units-domain)) | $9000$ (MW, MVAr) | | -| defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $1000$ (MW) | | -| defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.5](#45-pq-units-domain)) | $0$ (MW) | | -| defaultQmaxPmaxRatio | Ratio used to calculate threshold for corrections of high/low reactive power limits (see [4.5](#45-pq-units-domain)) | $0.3$ (MVAr/MW) | | -| minimalQPrange | Threshold to fix active (resp. reactive) power of generators with active (resp. reactive) power limits that are closer than it (see [4.5](#45-pq-units-domain)) | $1$ (MW, MVAr) | | +| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.4](#44-pq-units-domain)) | $9000$ (MW, MVAr) | | +| defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $1000$ (MW) | | +| defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $0$ (MW) | | +| 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) | | +| 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) | | In addition to the previous parameters, the user can specify which @@ -188,22 +188,34 @@ phase shift transformer on the same branch. The following corrections apply successively to determine consistent domains for the active -power $P^g$ and reactive power produced $Q^g$ by generators. The thresholds introduced -in [3.2](#32-configuration-of-the-run) are used. Let $P^g_{min}$, $P^g_{max}$, $Q^g_{min}$, and $Q^g_{max}$ -be the bounds of these domains (specified in `ampl_network_generators.txt`), -and $P^g_{min,c}$, $P^g_{max,c}$, $Q^g_{min,c}$, and $Q^g_{max,c}$ be the corrected bounds : - -- If $|P^g_{max}| \geq \text{PQmax}$, then $P^g_{max,c} = \max(\text{defaultPmax}, P^g,t)$. -Same with $P^g_{min}$, $P^g_{min,c}$ and defaultPmin. -- If $|P^g_{max,c} - |P^g_{min,c}| \leq \text{minimalQPrange}$, then $P^g_{max,c}$ and $P^g_{min,c}$ are fixed to $P^{g,t}$. - -TODO : add -- `defaultQmaxPmaxRatio`: Parameter used to calculate `defaultQmin` and `defaultQmax`, - the thresholds used to correct the minimum and maximum reactive powers produced by generators - (see section [4.5](#45-pq-units-domain)). - The default value for this parameter is 0.3 (MVAr/MW), and the thresholds are calculated as follows: - - `defaultQmin` = - `defaultPmin` x `defaultQmaxPmaxRatio` - - `defaultQmax` = `defaultPmax` x `defaultQmaxPmaxRatio` +power $P^g$ and reactive power produced $Q^g$ by generators. Please note that in the end, the bounds are rectangular, +not trapezoidal. These bounds are used only in the reactive OPF (see [7](#7-alternative-current-optimal-power-flow)). + +To determine the consistent domain of produced active power, the bounds of the domains +$P^g_{min}$ and $P^g_{max}$, as well as the target $P^g_{t}$ of generator $g$ (all specified in `ampl_network_generators.txt`) are used. +Let $P_{min}^{g,c}$ and $P_{max}^{g,c}$ be the corrected active bounds : + +- By default, $P_{min}^{g,c} = \text{defaultPmin}$ and $P_{max}^{g,c} = \text{defaultPmax}$ (see [3.2](#32-configuration-of-the-run)) +- If $|P^g_{max}| \geq \text{PQmax}$, then $P^g_{max,c} = \max(\text{defaultPmax}, P^g_t)$ +- If $|P^g_{min}| \geq \text{PQmax}$, then $P^g_{min,c} = \min(\text{defaultPmin}, P^g_t)$ +- If $|P^g_{max,c} - P^g_{min,c}| \leq \text{minimalQPrange}$, then $P^g_{max,c} = P^g_{min,c} = P^{g}_t$ (active power is fixed). + +To determine the consistent domain of produced reactive power, the reactive power diagram +(`specified in ampl_network_generators.txt`) of generator +$g$ est utilisé : $qp^g$ (resp. $qP^g$) and $Qp^g$ ($QP^g$) when $P_{min}^{g,c}$ (resp. P_{max}^{g,c}) is reached. +Let $qp^g$ (resp. $qP^g$) and $Qp^g$ (resp. $QP^g$) be the bounds of the corrected reactive diagram, +and $Q_{min}^{g,c}$ and $Q_{max}^{g,c}$ be the corrected reactive bounds : + +- By default, $qp^{g,c} = qP^{g,c} = - \text{defaultPmin} \times \text{defaultQmaxPmaxRatio}$ +and $Qp^{g,c} = QP^{g,c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRatio}$ (see [3.2](#32-configuration-of-the-run)) +- If $|qp^{g}| \geq \text{PQmax}$, then $qp^{g,c} = -\text{defaultQmaxPmaxRatio} \times P_{max}^{g,c}$. + Same with $qP^{g,c}$ +- If $|Qp^{g}|$ \geq \text{PQmax}$, then $Qp^{g,c} = \text{defaultQmaxPmaxRatio} \times P_{max}^{g,c}$. + Same with $QP^{g,c}$ +- If $qp^{g,c} > Qp^{g,c}$, the values are swapped. Same with $qP^{g,c}$ and $QP^{g,c}$ +- If the corrected reactive diagram is too small (distance between extremal values lower than $\text{minimalQPrange}$), + then $qp^{g,c} = Qp^{g,c} = qP^{g,c} = QP^{g,c} = \frac{qp^{g,c} + Qp^{g,c} + qP^{g,c} + QP^{g,c}}{4}$ (reactive power is fixed). +- $Q_{min}^{g,c} = \min(qp^{g,c}, qP^{g,c})$ and $Q_{max}^{g,c} = \min(Qp^{g,c}, QP^{g,c})$ ### 5 Reference bus & main connex component @@ -226,9 +238,11 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF involves the following constraints: -$$\boldsymbol{\theta}_s = 0, \quad s\in\text{SUBSTATIONS}$$ -$$\boldsymbol{p}_{ij} = \frac{\boldsymbol{\theta}_i - \boldsymbol{\theta}_j}{x_{ij}}, ij\in\text{BRANCHCC}$$ -$$\sum\limits_{j\in v(i)} \boldsymbol{p}_{ij} = P_i^{in} + \boldsymbol{P}_i^{g} + \boldsymbol{\sigma}_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-}, i\in\text{BUSCC}$$ +$$\boldsymbol{\theta_s} = 0, \quad s\in\text{SUBSTATIONS}$$ + +$$\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}, ij\in\text{BRANCHCC}$$ + +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} + \boldsymbol{P_i^{g}} + \boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}, i\in\text{BUSCC}$$ where : - $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)). @@ -240,7 +254,7 @@ expressing the excess or shortfall of active power produced in $i$. And the following objective function : -$$\text{minimize} 1000\sum\limits_{i\in \text{BUSCC}} \boldsymbol{\sigma}_{P_i}^{+} + \boldsymbol{\sigma}_{P_i}^{-} + \sum\limits_{g\in\text{UNITON}} (\frac{\boldsymbol{P}_i^{g} - P_i^{g,t}}{\max(1, 0.01 P_i^{g,t})})^2$$ +$$\text{minimize} 1000\sum\limits_{i\in \text{BUSCC}} \boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}} + \sum\limits_{g\in\text{UNITON}} (\frac{\boldsymbol{P_i^{g}} - P_{i,t}^{t}}{\max(1, 0.01 P_i^{g,t})})^2$$ where $P_i^{g,t}$ is the target of generator of the generator on bus $i$. The sum of the slack variables is penalized by a high coefficient to drive these variables towards 0, ensuring active power balance at each bus. From 9cce9e32d25bf8f696ef1868f9efaa228b716f76 Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 15:42:06 +0100 Subject: [PATCH 26/51] Refactor part 4.1. Signed-off-by: parvy --- open-reac/README.md | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 0179a6cc..e0358d4e 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -133,7 +133,7 @@ All of these files share the same format: 2 columns #"num" "id". In addition to the elements specified in section [3.2](#32-configuration-of-the-run), the user may choose to override the voltage limits of specified voltage levels. These values are defined in `ampl_network_substations_override.txt` and are employed to establish the new voltage limits as specified in section -[4.1](#41-voltage-level-limits-overrides). +[4.1](#41-voltage-level-limits-consistency). Format : 4 columns #"num" "minV (pu)" "maxV (pu)" "id" ### 4 Pre-processing @@ -141,32 +141,24 @@ Format : 4 columns #"num" "minV (pu)" "maxV (pu)" "id" Before solving the reactive OPF described in [7](#7-alternative-current-optimal-power-flow), the following pre-processing blocks are executed to ensure the consistency of the values. -#### 4.1 Voltage level limits overrides +#### 4.1 Voltage level limits consistency In order to ensure consistent voltage level limits for the voltage levels, -the consistency thresholds *minimal_voltage_lower_bound* and *maximal_voltage_upper_bound* are employed. -They are initialized as follows: -- $\text{minimal_voltage_lower_bound} = \max(\min\limits_{s\in \text{SUBSTATIONS}}(V_{min}^{s}), \text{min_plausible_low_voltage_limit})$ -- $\text{maximal_voltage_upper_bound} = \min(\max\limits_{s\in \text{SUBSTATIONS}}(V_{max}^{s}), \text{max_plausible_high_voltage_limit})$ +the parameters min_plausible_low_voltage_limit and max_plausible_high_voltage_limit are used +(see [3.2](#32-configuration-of-the-run)). -where $V_{min}$ (resp. $V_{max}$) is the low (resp. high) voltage limit of voltage level $s\in \text{SUBSTATIONS}$. - - - -As a result, the lower voltage bound chosen is equal to the maximum value between -`minimal_voltage_lower_bound` -and the specified `minV (pu)` value in `ampl_network_substations.txt`. -If an override value is specified by the user (see [3.3](#33-voltage-limits-overrides)), it replaces `minV (pu)`. - -The upper voltage bound chosen is equal to the minimum value between `maximal_voltage_upper_bound` -and the specified `maxV (pu)` value in `ampl_network_substations.txt`. -If an override value is specified by the user (see [3.3](#33-voltage-limits-overrides)) and it is higher than -the previously calculated lower voltage bound, then the override value replaces `maxV (pu)`. +Let $V_{min}^s$ (resp. $V_{max}^s$) be the low (resp. high) voltage limit of voltage level $vl$ +specified in `ampl_network_substations.txt`, or +in`ampl_network_substations_override.txt` if an override is given, and $V_{min}^{vl,c}$ (resp. $V_{max}^{vl,c}$) +the corrected low (resp. high) limit. Then, the consistent +voltage level limits of voltage level $vl$ are : +- $V_{min}^{vl,c} = \max(V_{min}, \text{min_plausible_low_voltage_limit})$ +- $V_{max}^{vl,c} = \min(V_{max}, \text{max_plausible_low_voltage_limit})$ #### 4.2 Zero-impedance branches Branches with an impedance magnitude (calculated in p.u.) -below the configurable threshold `Znull` (see section [3.2](#32-configuration-of-runtime)) +below the configurable threshold `Znull` (see section [3.2](#32-configuration-of-the-run)) are considered as non-impedant. These branches will have their reactance replaced by the threshold `Znull` (in p.u.). @@ -186,7 +178,6 @@ phase shift transformer on the same branch. #### 4.4 P/Q units' domain - The following corrections apply successively to determine consistent domains for the active power $P^g$ and reactive power produced $Q^g$ by generators. Please note that in the end, the bounds are rectangular, not trapezoidal. These bounds are used only in the reactive OPF (see [7](#7-alternative-current-optimal-power-flow)). From 83ee8eedf2998ac79be6acfa4848949efe647068 Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 20 Dec 2023 16:00:09 +0100 Subject: [PATCH 27/51] refactor. Signed-off-by: parvy --- open-reac/README.md | 50 ++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index e0358d4e..fb646543 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -152,8 +152,8 @@ specified in `ampl_network_substations.txt`, or in`ampl_network_substations_override.txt` if an override is given, and $V_{min}^{vl,c}$ (resp. $V_{max}^{vl,c}$) the corrected low (resp. high) limit. Then, the consistent voltage level limits of voltage level $vl$ are : -- $V_{min}^{vl,c} = \max(V_{min}, \text{min_plausible_low_voltage_limit})$ -- $V_{max}^{vl,c} = \min(V_{max}, \text{max_plausible_low_voltage_limit})$ +- $V_{min}^{vl,c} = \max(V_{min},$ min_plausible_low_voltage_limit}$)$ +- $V_{max}^{vl,c} = \min(V_{max},$ max_plausible_low_voltage_limit}$)$ #### 4.2 Zero-impedance branches @@ -179,34 +179,34 @@ phase shift transformer on the same branch. #### 4.4 P/Q units' domain The following corrections apply successively to determine consistent domains for the active -power $P^g$ and reactive power produced $Q^g$ by generators. Please note that in the end, the bounds are rectangular, +power $P_g$ and reactive power produced $Q_g$ by generators. Please note that in the end, the bounds are rectangular, not trapezoidal. These bounds are used only in the reactive OPF (see [7](#7-alternative-current-optimal-power-flow)). To determine the consistent domain of produced active power, the bounds of the domains -$P^g_{min}$ and $P^g_{max}$, as well as the target $P^g_{t}$ of generator $g$ (all specified in `ampl_network_generators.txt`) are used. -Let $P_{min}^{g,c}$ and $P_{max}^{g,c}$ be the corrected active bounds : +$P_g^{min}$ and $P_g^{max}$, as well as the target $P_g^{t}$ of generator $g$ (all specified in `ampl_network_generators.txt`) are used. +Let $P_{g}^{min,c}$ and $P_{g}^{max,c}$ be the corrected active bounds : -- By default, $P_{min}^{g,c} = \text{defaultPmin}$ and $P_{max}^{g,c} = \text{defaultPmax}$ (see [3.2](#32-configuration-of-the-run)) -- If $|P^g_{max}| \geq \text{PQmax}$, then $P^g_{max,c} = \max(\text{defaultPmax}, P^g_t)$ -- If $|P^g_{min}| \geq \text{PQmax}$, then $P^g_{min,c} = \min(\text{defaultPmin}, P^g_t)$ -- If $|P^g_{max,c} - P^g_{min,c}| \leq \text{minimalQPrange}$, then $P^g_{max,c} = P^g_{min,c} = P^{g}_t$ (active power is fixed). +- By default, $P_{g}^{min,c} = \text{defaultPmin}$ and $P_{g}^{max,c} = \text{defaultPmax}$ (see [3.2](#32-configuration-of-the-run)) +- If $|P_g^{max}| \geq \text{PQmax}$, then $P_{g}^{max,c} = \max(\text{defaultPmax}, P_g^t)$ +- If $|P_g^{min}| \geq \text{PQmax}$, then $P_{g}^{min,c} = \min(\text{defaultPmin}, P_g^t)$ +- If $|P_{g}^{max,c} - P_{g}^{min,c}| \leq \text{minimalQPrange}$, then $P_{g}^{max,c} = P_{g}^{min,c} = P_{g}^t$ (active power is fixed). To determine the consistent domain of produced reactive power, the reactive power diagram (`specified in ampl_network_generators.txt`) of generator -$g$ est utilisé : $qp^g$ (resp. $qP^g$) and $Qp^g$ ($QP^g$) when $P_{min}^{g,c}$ (resp. P_{max}^{g,c}) is reached. -Let $qp^g$ (resp. $qP^g$) and $Qp^g$ (resp. $QP^g$) be the bounds of the corrected reactive diagram, -and $Q_{min}^{g,c}$ and $Q_{max}^{g,c}$ be the corrected reactive bounds : - -- By default, $qp^{g,c} = qP^{g,c} = - \text{defaultPmin} \times \text{defaultQmaxPmaxRatio}$ -and $Qp^{g,c} = QP^{g,c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRatio}$ (see [3.2](#32-configuration-of-the-run)) -- If $|qp^{g}| \geq \text{PQmax}$, then $qp^{g,c} = -\text{defaultQmaxPmaxRatio} \times P_{max}^{g,c}$. - Same with $qP^{g,c}$ -- If $|Qp^{g}|$ \geq \text{PQmax}$, then $Qp^{g,c} = \text{defaultQmaxPmaxRatio} \times P_{max}^{g,c}$. - Same with $QP^{g,c}$ -- If $qp^{g,c} > Qp^{g,c}$, the values are swapped. Same with $qP^{g,c}$ and $QP^{g,c}$ +$g$ est utilisé : $qp_g$ (resp. $qP_g$) and $Qp_g$ ($QP_g$) when $P_{g}^{min,c}$ (resp. P_{g}^{max,c}) is reached. +Let $qp_g^c$ (resp. $qP_g^c$) and $Qp_g^c$ (resp. $QP_g^c$) be the bounds of the corrected reactive diagram, +and $Q_{g}^{min,c}$ and $Q_{g}^{max,c}$ be the corrected reactive bounds : + +- By default, $qp_g^{c} = qP_{g}^{c} = - \text{defaultPmin} \times \text{defaultQmaxPmaxRatio}$ +and $Qp_{g}^{c} = QP_{g}^{c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRatio}$ (see [3.2](#32-configuration-of-the-run)) +- If $|qp_{g}| \geq \text{PQmax}$, then $qp_{g}^{c} = -\text{defaultQmaxPmaxRatio} \times P_{max}^{g,c}$. + Same with $qP_{g}^{c}$ +- If $|Qp_{g}| \geq \text{PQmax}$, then $Qp_{g}^{c} = \text{defaultQmaxPmaxRatio} \times P_{max}^{g,c}$. + Same with $QP_{g}^{c}$ +- If $qp_{g}^{c} > Qp_{g}^{c}$, the values are swapped. Same with $qP_{g}^{c}$ and $QP_{g}^{c}$ - If the corrected reactive diagram is too small (distance between extremal values lower than $\text{minimalQPrange}$), - then $qp^{g,c} = Qp^{g,c} = qP^{g,c} = QP^{g,c} = \frac{qp^{g,c} + Qp^{g,c} + qP^{g,c} + QP^{g,c}}{4}$ (reactive power is fixed). -- $Q_{min}^{g,c} = \min(qp^{g,c}, qP^{g,c})$ and $Q_{max}^{g,c} = \min(Qp^{g,c}, QP^{g,c})$ + then $qp_{g}^{c} = Qp_{g}^{c} = qP_{g}^{c} = QP_{g}^{c} = \frac{qp_{g}^{c} + Qp_{g}^{c} + qP_{g}^{c} + QP_{g}^{c}}{4}$ (reactive power is fixed). +- $Q_{g}^{min,c} = \min(qp_{g}^{c}, qP_{g}^{c})$ and $Q_{g}^{max,c} = \min(Qp_{g}^{c}, QP_{g}^{c})$ ### 5 Reference bus & main connex component @@ -233,7 +233,7 @@ $$\boldsymbol{\theta_s} = 0, \quad s\in\text{SUBSTATIONS}$$ $$\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}, ij\in\text{BRANCHCC}$$ -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} + \boldsymbol{P_i^{g}} + \boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}, i\in\text{BUSCC}$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}, i\in\text{BUSCC}$$ where : - $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)). @@ -245,9 +245,9 @@ expressing the excess or shortfall of active power produced in $i$. And the following objective function : -$$\text{minimize} 1000\sum\limits_{i\in \text{BUSCC}} \boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}} + \sum\limits_{g\in\text{UNITON}} (\frac{\boldsymbol{P_i^{g}} - P_{i,t}^{t}}{\max(1, 0.01 P_i^{g,t})})^2$$ +$$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}) + \sum\limits_{g} (\frac{\boldsymbol{P_{i,g}^t} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})})^2)$$ -where $P_i^{g,t}$ is the target of generator of the generator on bus $i$. The sum of the slack variables is penalized by a +where $P_{i,g}^{t}$ is the target of generator of the generator on bus $i$. The sum of the slack variables is penalized by a high coefficient to drive these variables towards 0, ensuring active power balance at each bus. The resolution of this DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` (see [3.2](#32-configuration-of-the-run)), and if the solver used to solve the problem finds feasible solution without reaching From 38385b8538298a7e651d442afaba131d2ec21583 Mon Sep 17 00:00:00 2001 From: parvy Date: Fri, 5 Jan 2024 13:56:26 +0100 Subject: [PATCH 28/51] wip. Signed-off-by: parvy --- open-reac/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index fb646543..710827b3 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -179,8 +179,8 @@ phase shift transformer on the same branch. #### 4.4 P/Q units' domain The following corrections apply successively to determine consistent domains for the active -power $P_g$ and reactive power produced $Q_g$ by generators. Please note that in the end, the bounds are rectangular, -not trapezoidal. These bounds are used only in the reactive OPF (see [7](#7-alternative-current-optimal-power-flow)). +power and reactive power produced by generators. Please note that in the end, the corrected bounds are rectangular +(not trapezoidal), and they are used only in the reactive OPF (see [7](#7-alternative-current-optimal-power-flow)). To determine the consistent domain of produced active power, the bounds of the domains $P_g^{min}$ and $P_g^{max}$, as well as the target $P_g^{t}$ of generator $g$ (all specified in `ampl_network_generators.txt`) are used. @@ -222,6 +222,8 @@ The main connex component is determined by solving the `PROBLEM_CCOMP` optimizat ### 6 Direct current optimal power flow +TODO : add special handlings (e.g. groups with P = 0 are excluded from optimization) + Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)), a DCOPF is solved for two main reasons: - If the DCOPF resolution fails, it provides a strong indication that the ACOPF resolution will also fail. The DCOPF serves as a formal consistency check on the data. @@ -255,6 +257,8 @@ a default limit. Otherwise, the solving is considered unsuccessful. ### 7 Alternative current optimal power flow +TODO : add special handlings (e.g. groups with P = 0 are excluded from optimization) + TODO : refactor TODO : From 1baefbafaac2f5020eb06b71982ed93d03e8db5f Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 17 Jan 2024 17:38:36 +0100 Subject: [PATCH 29/51] add todo. Signed-off-by: parvy --- open-reac/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/open-reac/README.md b/open-reac/README.md index 710827b3..2d68fb60 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -257,6 +257,8 @@ a default limit. Otherwise, the solving is considered unsuccessful. ### 7 Alternative current optimal power flow +TODO : current limits are not used in the optimization + TODO : add special handlings (e.g. groups with P = 0 are excluded from optimization) TODO : refactor From d830b5a2d756e4d88c5f8efb96a3ff67df44eec6 Mon Sep 17 00:00:00 2001 From: parvy Date: Wed, 17 Jan 2024 19:14:14 +0100 Subject: [PATCH 30/51] wip. Signed-off-by: parvy --- open-reac/README.md | 79 +++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 2d68fb60..2a84b16f 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -94,7 +94,7 @@ 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 | Default value | Possible value | +| Parameter | Description | 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}$ | @@ -108,23 +108,23 @@ These are specified in the file `param_algo.txt`: | 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} | -| PQmax | Threshold for maximum active and reactive power considered in correction of generator limits (see [4.4](#44-pq-units-domain)) | $9000$ (MW, MVAr) | | -| defaultPmax | Threshold for correction of high active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $1000$ (MW) | | -| defaultPmin | Threshold for correction of low active power limit produced by generators (see [4.4](#44-pq-units-domain)) | $0$ (MW) | | -| 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) | | -| 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) | | +| 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}$ | In addition to the previous parameters, the user can specify which parameters will be variable or fixed in the ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)). This is done using the following files: -| File | Description | Default behavior of modified values | -|-------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| -| param_transformers.txt | Ratio tap changers with a variable transformation ratio (real variable) | Transformation ratios are fixed | -| param_shunt.txt | Shunts with a continuous variable susceptance and which can be modified and/or connected (only if possible bus is defined in `ampl_network_shunts.txt` | Shunt susceptances are fixed | -| param_generators_reactive.txt | Generators with a constant reactive power production. If this value is not consistent (> PQmax), the reactive power production stays variable | Coherent reactive power productions (see [4.5](#45-pq-units-domain)) are variable | -| param_buses_with_reactive_slack.txt | Buses with attached reactive slacks if configurable parameter buses_with_reactive_slacks = "CONFIGURED" | Only buses with no reactive power production have reactive slacks attached | +| File | Description | Default behavior of modified values | +|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| +| param_transformers.txt | Ratio tap changers with a variable transformation ratio (real variable) | Transformation ratios are fixed | +| param_shunt.txt | Shunts with a continuous variable susceptance and which can be modified and/or connected (only if possible bus is defined in `ampl_network_shunts.txt`) | Shunt susceptances are fixed | +| param_generators_reactive.txt | Generators with a constant reactive power production. If this value is not consistent (> PQmax), the reactive power production stays variable | Coherent reactive power productions (see [4.5](#45-pq-units-domain)) are variable | +| param_buses_with_reactive_slack.txt | Buses with attached reactive slacks if configurable parameter buses_with_reactive_slacks = "CONFIGURED" | Only buses with no reactive power production have reactive slacks attached | All of these files share the same format: 2 columns #"num" "id". @@ -138,29 +138,30 @@ Format : 4 columns #"num" "minV (pu)" "maxV (pu)" "id" ### 4 Pre-processing -Before solving the reactive OPF described in [7](#7-alternative-current-optimal-power-flow), -the following pre-processing blocks are executed to ensure the consistency of the values. +Before solving the reactive ACOPF described in [7](#7-alternative-current-optimal-power-flow), +the following pre-processing blocks are executed to ensure the consistency of the values used in the optimization. #### 4.1 Voltage level limits consistency -In order to ensure consistent voltage level limits for the voltage levels, +To ensure consistent voltage level limits for the voltage levels, the parameters min_plausible_low_voltage_limit and max_plausible_high_voltage_limit are used (see [3.2](#32-configuration-of-the-run)). -Let $V_{min}^s$ (resp. $V_{max}^s$) be the low (resp. high) voltage limit of voltage level $vl$ +Let $V_{min}^s$ (resp. $V_{max}^s$) be the low (resp. high) voltage limit of substation $s$ specified in `ampl_network_substations.txt`, or -in`ampl_network_substations_override.txt` if an override is given, and $V_{min}^{vl,c}$ (resp. $V_{max}^{vl,c}$) -the corrected low (resp. high) limit. Then, the consistent -voltage level limits of voltage level $vl$ are : -- $V_{min}^{vl,c} = \max(V_{min},$ min_plausible_low_voltage_limit}$)$ -- $V_{max}^{vl,c} = \min(V_{max},$ max_plausible_low_voltage_limit}$)$ +in `ampl_network_substations_override.txt` if an override is given, and $V_{min}^{s,c}$ (resp. $V_{max}^{s,c}$) +the corrected low (resp. high) limit of substation $s$. Then, the consistent +voltage limits are : +- $V_{min}^{s,c} = \max(V_{min}^s,$ min_plausible_low_voltage_limit}) +- $V_{max}^{s,c} = \min(V_{max}^s,$ max_plausible_low_voltage_limit}) #### 4.2 Zero-impedance branches Branches with an impedance magnitude (calculated in p.u.) -below the configurable threshold `Znull` (see section [3.2](#32-configuration-of-the-run)) +lower than the configurable threshold `Znull` (see section [3.2](#32-configuration-of-the-run)) are considered as non-impedant. -These branches will have their reactance replaced by the threshold `Znull` (in p.u.). +These branches will have their reactance replaced by the threshold `Znull` (in p.u.), +even if the reactance specified in `ampl_network_branches.txt` is negative. #### 4.3 Impedance of transformers @@ -211,7 +212,7 @@ and $Qp_{g}^{c} = QP_{g}^{c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRa ### 5 Reference bus & main connex component A reference bus (`null_phase_bus` AMPL parameter) enforces the zero-phase constraint of the OPFs. -This reference bus corresponds to the bus in the network with the most AC branches connected, +It corresponds to the bus with the most AC branches connected, among those belonging to the main connected component ($0$ in `ampl_network_buses.txt`). If multiple buses have the same maximum cardinality, the one with the highest `num` identifier is selected. If no bus is found meeting these criteria, the first bus defined in the file `ampl_network_buses.txt` is selected. @@ -222,8 +223,6 @@ The main connex component is determined by solving the `PROBLEM_CCOMP` optimizat ### 6 Direct current optimal power flow -TODO : add special handlings (e.g. groups with P = 0 are excluded from optimization) - Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)), a DCOPF is solved for two main reasons: - If the DCOPF resolution fails, it provides a strong indication that the ACOPF resolution will also fail. The DCOPF serves as a formal consistency check on the data. @@ -247,23 +246,19 @@ expressing the excess or shortfall of active power produced in $i$. And the following objective function : -$$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}) + \sum\limits_{g} (\frac{\boldsymbol{P_{i,g}^t} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})})^2)$$ +$$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}) + \sum\limits_{g} (\frac{\boldsymbol{P_{i,g}} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})})^2)$$ where $P_{i,g}^{t}$ is the target of generator of the generator on bus $i$. The sum of the slack variables is penalized by a high coefficient to drive these variables towards 0, ensuring active power balance at each bus. The resolution of this DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` -(see [3.2](#32-configuration-of-the-run)), and if the solver used to solve the problem finds feasible solution without reaching -a default limit. Otherwise, the solving is considered unsuccessful. +(see [3.2](#32-configuration-of-the-run)), and if the solver finds a feasible solution without reaching +one of its default limit. Otherwise, the solving is considered unsuccessful and the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency). ### 7 Alternative current optimal power flow -TODO : current limits are not used in the optimization - -TODO : add special handlings (e.g. groups with P = 0 are excluded from optimization) -TODO : refactor +TODO : refactor -TODO : add - `buses_with_reactive_slacks`: The parameter determining which buses will have reactive slacks attached in the resolution of the ACOPF (see [6.2](#62-alternative-current-optimal-power-flow)). @@ -283,15 +278,13 @@ TODO : add This target lies between the upper and lower voltage limits of the level voltages to which the buses are connected, and is calculated using configurable parameter `ratio_voltage_target`. -This ACOPF relies on specific parameters selected by the user, +The model and the solving of the ACOPF relies on specific parameters selected by the user, as thresholds and equipment of the power network which will be treated as variable or fixed (refer to [3.2](#32-configuration-of-the-run)). LThe voltage variables utilized in the ACOPF are initialized as follows: - The phase angles are set equal to those calculated by solving the DCOPF. - The voltages of buses without reactive slacks (and with nominal voltage greater than `min_plausible_low_voltage_limit`) are set equal to the specified `v (pu)` values in `ampl_network_buses.txt`. - The voltages of buses with reactive slacks are initialized to the midpoint of the voltage level limits to which they are connected. - -The ACOPF involves the following constraints : - `ctr_null_phase_bus`, which sets the phase of the reference bus (refer to [5](#5-reference-bus--main-connex-component)) to 0. - `ctr_balance_P`, which enforces the active power balance at each node of the network. This balance takes into account the active power produced by generators and batteries, as well as the power consumed @@ -309,6 +302,9 @@ Within this balance, the following elements are considered as variables: - The slack variables `slack1_balance_Q` and `slack2_balance_Q`, which represent the excess or shortfall of active power produced at the buses chosen by the user. +And the following objective function : +$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) + \sum\limits_{g} (\alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |\frac{P_{i,g}^t}|)})^2) + \sum\limits_{n} (\boldsymbol{V_n} - V_n^t)^2 + \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij}$$ + And the objective function `problem_acopf_objective` which minimizes the following sums: - The sum of `slack1_balance_Q` and `slack2_balance_Q` variables, penalized by a very high coefficient (`penalty_invest_rea_pos`). The objective is to drive these variables towards 0, ensuring a balance in reactive power at each node. @@ -336,7 +332,11 @@ This sum is penalized by a small coefficient. The goal is to limit this deviatio TODO : expliciter le fait qu'on fasse plusieurs optimisations à la suite en jouant sur alpha si besoin. TODO : add comments on results treatment by Knitro (what kind of solutions are considered as good...) - + +Please note the following : +- units with active power specified in `ampl_network_generators.txt` inférieur au paramètre modifiable Pnull sont exclues de l'optimisation. +- Les current limits ne sont pas prises en compte dans l'optimisation. + ### 8 Output #### 8.1 In case of convergence @@ -353,9 +353,10 @@ If the AMPL process defined in `reactiveopf.run` is successful, the script `reac | reactiveopf_results_vsc_converter_stations.csv | Calculated reactive power values for VSC converter stations. | 8 columns #"variant" "num" "bus" "vRegul" "targetV(pu)" "targetQ(MVAr)" "P(MW)" "Q(MVAr)" | | reactiveopf_results_rtc.csv | RTCs and associated taps, with transformer ratio closest to the one calculated after the optimization. | 3 columns #"variant" "num" "tap" | | reactiveopf_results_reactive_slacks.csv | Calculated reactive slack variables `slack1_balance_Q` and `slack2_balance_Q`. | 6 columns #"variant" "bus" "slack_condensator(MVAr)" "slack_self(MVAr)" "id" "substation" | +| reactiveopf_results_voltages.csv | Calculated voltages for each bus of the main connex component (see [5](#5-reference-bus--main-connex-component)) | 5 columns #"variant" "bus" "V(pu)" "theta(rad)" "id" | #### 8.2 In case of inconsistency If the computation of the main connex component (see [5](#5-reference-bus--main-connex-component)) or of the DCOPF fails (see [6](#6-direct-current-optimal-power-flow)), the problem is considered as inconsistent. -Then, the script `reactiveopfexit.run` is executed and the file reactiveopf_results_indic.txt described in previous section is exported, without the information on the calculated angles. +Then, the script `reactiveopfexit.run` is executed and the file `reactiveopf_results_indic.txt` described in previous section is exported, without the information on the calculated angles. From 59b893b5b675f32c7a2da4821bf9f9c691648aab Mon Sep 17 00:00:00 2001 From: parvy Date: Thu, 18 Jan 2024 12:04:00 +0100 Subject: [PATCH 31/51] wip. Signed-off-by: parvy --- open-reac/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/open-reac/README.md b/open-reac/README.md index 2a84b16f..dbc38933 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -303,7 +303,16 @@ Within this balance, the following elements are considered as variables: which represent the excess or shortfall of active power produced at the buses chosen by the user. And the following objective function : -$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) + \sum\limits_{g} (\alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |\frac{P_{i,g}^t}|)})^2) + \sum\limits_{n} (\boldsymbol{V_n} - V_n^t)^2 + \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij}$$ +$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) ++ \beta_1 \times \sum\limits_{g} (\alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2) ++ \beta_2 \times \sum\limits_{n} (\boldsymbol{V_n} - (1-\rho)V_{s}^{min,c} + \rhoV_{s}^{max,c})^2 ++ \beta_3 \times \sum\limits_{n} (\boldsymbol{V_n} - V_n^t)^2 ++ 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 ++ 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ + +where : +TODO + And the objective function `problem_acopf_objective` which minimizes the following sums: - The sum of `slack1_balance_Q` and `slack2_balance_Q` variables, penalized by a very high coefficient (`penalty_invest_rea_pos`). From 551fb99a2225b03c60354bcbd1cd49129c0731cd Mon Sep 17 00:00:00 2001 From: parvy Date: Thu, 18 Jan 2024 15:58:11 +0100 Subject: [PATCH 32/51] refactor part 5 and 6. Signed-off-by: parvy --- open-reac/README.md | 73 ++++++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index dbc38933..7b275bb1 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -209,48 +209,55 @@ and $Qp_{g}^{c} = QP_{g}^{c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRa then $qp_{g}^{c} = Qp_{g}^{c} = qP_{g}^{c} = QP_{g}^{c} = \frac{qp_{g}^{c} + Qp_{g}^{c} + qP_{g}^{c} + QP_{g}^{c}}{4}$ (reactive power is fixed). - $Q_{g}^{min,c} = \min(qp_{g}^{c}, qP_{g}^{c})$ and $Q_{g}^{max,c} = \min(Qp_{g}^{c}, QP_{g}^{c})$ -### 5 Reference bus & main connex component +### 5 Slack bus & main connex component + +The slack bus $s$ is determined by identifying the AC bus with the highest number of AC branches connected, +within the main connected component (defined in `ampl_network_buses.txt`). +If multiple buses have shuch cardinality, the one with the highest identifier (`num` parameter) is chosen. +In the event no bus satisfies these conditions, the first bus defined in `ampl_network_buses.txt` is selected. -A reference bus (`null_phase_bus` AMPL parameter) enforces the zero-phase constraint of the OPFs. -It corresponds to the bus with the most AC branches connected, -among those belonging to the main connected component ($0$ in `ampl_network_buses.txt`). -If multiple buses have the same maximum cardinality, the one with the highest `num` identifier is selected. -If no bus is found meeting these criteria, the first bus defined in the file `ampl_network_buses.txt` is selected. +The OPFs (see [6](#6-direct-current-optimal-power-flow) and [7](#7-alternative-current-optimal-power-flow)) +are executed on the main connex component (i.e. buses connected to slack bus by AC branches) of the network. +Consequently, buses connected to the slack by HVDC lines are excluded. +This component is determined by solving the following optimization problem (the variables are bolded): -The OPFs are executed on the main connex component (i.e. buses connected to the reference bus by AC branches). -Then, buses connected to the reference bus by HVDC lines are excluded. -The main connex component is determined by solving the `PROBLEM_CCOMP` optimization problem. +$$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i}}$$ + +where $\boldsymbol{\theta_i}$ is the angle of bus $i$, and with : + +$$\boldsymbol{\theta_s} = 0 \quad (1)$$ + +$$\boldsymbol{\theta_i} - \boldsymbol{\theta_j} = 0, \quad ij \in BRANCH$$ + +The sets of buses and branches belonging to the main connex component will be denoted $BUSCC$ and $BRANCHCC$. ### 6 Direct current optimal power flow Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)), a DCOPF is solved for two main reasons: - If the DCOPF resolution fails, it provides a strong indication that the ACOPF resolution will also fail. - The DCOPF serves as a formal consistency check on the data. -- The phases computed during the DCOPF resolution will be used as initial points for the ACOPF resolution. + Thus, it serves as a formal consistency check on the data. +- The phases computed by DCOPF resolution will be used as initial points for the solving of the ACOPF. -The DCOPF involves the following constraints: +The DCOPF involves the following constraint, in addition to the slack $(1)$ introduced in [5](#5-slack-bus--main-connex-component): -$$\boldsymbol{\theta_s} = 0, \quad s\in\text{SUBSTATIONS}$$ - -$$\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}, ij\in\text{BRANCHCC}$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P,i}^{+}} + \boldsymbol{\sigma_{P,i}^{-}}, i\in\text{BUSCC}$$ -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}, i\in\text{BUSCC}$$ - -where : -- $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)). -- $\boldsymbol{p}_{ij}$ the active power leaving bus $i$ on branch $ij$. +where : +- $\boldsymbol{p}_{ij}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}$. - $P_i^{in}$ the constant active power injected or consumed in bus $i$ (by batteries, loads, VSC stations and LCC stations). - $\boldsymbol{P}_i^{g}$ is the variable active power produced by generators of bus $i$. -- $\boldsymbol{\sigma}_{P_i}$ the slack variables (both positive) -expressing the excess or shortfall of active power produced in $i$. +- $\boldsymbol{\sigma}_{P,i}^{+}$ (resp. $\boldsymbol{\sigma}_{P,i}^{-}$) is a positive slack variable +expressing the excess (resp. shortfall) of active power produced in bus $i$. And the following objective function : $$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}) + \sum\limits_{g} (\frac{\boldsymbol{P_{i,g}} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})})^2)$$ -where $P_{i,g}^{t}$ is the target of generator of the generator on bus $i$. The sum of the slack variables is penalized by a +where $P_{i,g}^{t}$ is the target of the generator $g$ on bus $i$. + +The sum of the slack variables is penalized by a high coefficient to drive these variables towards 0, ensuring active power balance at each bus. -The resolution of this DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` +The solving of the DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` (see [3.2](#32-configuration-of-the-run)), and if the solver finds a feasible solution without reaching one of its default limit. Otherwise, the solving is considered unsuccessful and the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency). @@ -302,6 +309,24 @@ Within this balance, the following elements are considered as variables: - The slack variables `slack1_balance_Q` and `slack2_balance_Q`, which represent the excess or shortfall of active power produced at the buses chosen by the user. +The ACOPF involves the following constraints: + +$$\boldsymbol{\theta_s} = 0, \quad s\in\text{SUBSTATIONS}$$ + +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, i\in\text{BUSCC}$$ + +$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 \sum\limits_{vsc}\boldsymbol{b_{i,vsc}} \boldsymbol{V_i}^2 - \boldsymbol{\sigma_{Q_i}^{+}} - \boldsymbol{\sigma_{Q_i}^{-}}, i\in\text{BUSCC}$$ + +where : +- $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)). +- $\boldsymbol{p}_{ij}$ (resp. \boldsymbol{q}_{ij}) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, +calculated as defined in the [PowSyBl documentation](https://www.powsybl.org/pages/documentation/simulation/powerflow/openlf.html). +- $P_i^{in}$ is the constant active power injected or consumed in bus $i$ by batteries, loads, VSC stations and LCC stations. +- $Q_i^{in}$ is the constant reactive power injected or consumed in bus $i$, by fixed generators and fixed shunts (see [3.2](#32-configuration-of-the-run)), batteries, loads and LCC stations). +- $\boldsymbol{P}_{i,g}$ (resp. $\boldsymbol{Q}_i^{g}$) is the variable active (resp. reactive) power produced by generator $g$ of bus $i$. +- $\boldsymbol{b}_{i,g}$ (resp. $\boldsymbol{b}_{i,vsc}$) is the variable susceptance of shunt $s$ (resp. VSC station $vsc$) of bus $i$. It is bounded by the minimum and maximum susceptance of the network, specified in `ampl_network_shunts.txt`. +- $\boldsymbol{\sigma}_{Q_i}$ the slack variables (both positive) + And the following objective function : $$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) + \beta_1 \times \sum\limits_{g} (\alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2) From c37126943266147ade6a6aaf7faa4c890628dcd4 Mon Sep 17 00:00:00 2001 From: parvy Date: Thu, 18 Jan 2024 19:19:53 +0100 Subject: [PATCH 33/51] wip. Signed-off-by: parvy --- open-reac/README.md | 132 +++++++++++--------------------------------- 1 file changed, 32 insertions(+), 100 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 7b275bb1..4fe5399b 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -143,17 +143,17 @@ the following pre-processing blocks are executed to ensure the consistency of th #### 4.1 Voltage level limits consistency -To ensure consistent voltage level limits for the voltage levels, -the parameters min_plausible_low_voltage_limit and max_plausible_high_voltage_limit are used +To ensure consistent voltage level limits for the buses, +the configurable parameters $\text{min_plausible_low_voltage_limit}$ +and $\text{max_plausible_high_voltage_limit}$ are used (see [3.2](#32-configuration-of-the-run)). -Let $V_{min}^s$ (resp. $V_{max}^s$) be the low (resp. high) voltage limit of substation $s$ -specified in `ampl_network_substations.txt`, or -in `ampl_network_substations_override.txt` if an override is given, and $V_{min}^{s,c}$ (resp. $V_{max}^{s,c}$) -the corrected low (resp. high) limit of substation $s$. Then, the consistent -voltage limits are : -- $V_{min}^{s,c} = \max(V_{min}^s,$ min_plausible_low_voltage_limit}) -- $V_{max}^{s,c} = \min(V_{max}^s,$ max_plausible_low_voltage_limit}) +Let $V_{s}^{min}$ (resp. $V_{s}^{max}$) be the low (resp. high) voltage limit of substation $s$ +specified in `ampl_network_substations.txt` (or +in `ampl_network_substations_override.txt` if an override is given for $s$) and $V_{s}^{min,c}$ (resp. $V_{s}^{max,c}$) +its associated corrected low (resp. high) limit. Then, the limits are calculated as follows: +- $V_{s}^{min,c} = \max(V_{s}^min, \text{min_plausible_low_voltage_limit})$ +- $V_{s}^{max,c} = \min(V_{s}^max, \text{max_plausible_low_voltage_limit})$ #### 4.2 Zero-impedance branches @@ -259,115 +259,47 @@ The sum of the slack variables is penalized by a high coefficient to drive these variables towards 0, ensuring active power balance at each bus. The solving of the DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` (see [3.2](#32-configuration-of-the-run)), and if the solver finds a feasible solution without reaching -one of its default limit. Otherwise, the solving is considered unsuccessful and the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency). +one of its default limit. Otherwise, the solving is considered unsuccessful and the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). ### 7 Alternative current optimal power flow -TODO : refactor - -add -- `buses_with_reactive_slacks`: The parameter determining which buses will have reactive slacks attached in the resolution of the ACOPF -(see [6.2](#62-alternative-current-optimal-power-flow)). -It can take the following values: -- "ALL": all buses have reactive slack variables attached. -- "NO_GENERATION": only buses not producing reactive power will have reactive slack variables attached. -- "CONFIGURED": only buses specified in `param_buses_with_reactive_slack.txt` will have reactive slack variables attached. - -TODO : add -- `objective_choice` defining the choice of the objective function for the ACOPF (see [6.2](#62-alternative-current-optimal-power-flow)): -The minimization priority depends on the value of the parameter: -- If $0$, the active power produced by generators. -- If $1$, the deviation between the voltage value and the calculated target of the buses. -- If $2$, the deviation between the voltage value of the buses and the target V specified in `ampl_network_buses.txt`. - -TODO : add -This target lies between the upper and lower voltage limits of the level voltages to which the buses are connected, and is calculated using -configurable parameter `ratio_voltage_target`. - -The model and the solving of the ACOPF relies on specific parameters selected by the user, -as thresholds and equipment of the power network which will be treated as variable or fixed (refer to [3.2](#32-configuration-of-the-run)). -LThe voltage variables utilized in the ACOPF are initialized as follows: -- The phase angles are set equal to those calculated by solving the DCOPF. -- The voltages of buses without reactive slacks (and with nominal voltage greater than `min_plausible_low_voltage_limit`) -are set equal to the specified `v (pu)` values in `ampl_network_buses.txt`. -- The voltages of buses with reactive slacks are initialized to the midpoint of the voltage level limits to which they are connected. -- `ctr_null_phase_bus`, which sets the phase of the reference bus (refer to [5](#5-reference-bus--main-connex-component)) to 0. -- `ctr_balance_P`, which enforces the active power balance at each node of the network. - This balance takes into account the active power produced by generators and batteries, as well as the power consumed - by loads, VSC stations and LCC stations connected to each bus (in addition to what enters and exits the bus). -Within this balance, the active power produced by units and the flows on the branches are considered as variables. -- `ctr_balance_Q` enforces the reactive power balance at each node of the network. - This balance takes into account the reactive power produced by generators, batteries, shunts, static var compensators, VSC stations, -as well as the power consumed by loads and LCC stations connected to each bus (in addition to what enters and exits the bus). -Within this balance, the following elements are considered as variables: - - The flows on the branches (tensions, phases and transformation ratios of transformers defined as variables by the user). - - The reactive power generated by the units defined as variables. - - The susceptance of shunts defined as variables by the user. - - The reactive power generated by SVCs (only the one with `svc_vregul` value equals to `true` in `ampl_network_static_var_compensators.txt`). - - The reactive power generated by VSC stations (all consistent ones defined in `ampl_network_vsc_converter_stations.txt`). - - The slack variables `slack1_balance_Q` and `slack2_balance_Q`, -which represent the excess or shortfall of active power produced at the buses chosen by the user. - -The ACOPF involves the following constraints: - -$$\boldsymbol{\theta_s} = 0, \quad s\in\text{SUBSTATIONS}$$ - -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, i\in\text{BUSCC}$$ +In the following, we denote $V_i$ and $\theta_i$ as the voltage and phase of bus $i$, respectively, and the notations introduced in the previous sections are used. +Before solving the ACOPF, these values are warm-started with the voltage specified at each node in `ampl_network_buses.txt` and the phase calculated by the DCOPF (see [6](#6-direct-current-optimal-power-flow)). + +The constraints of the optimization problem depend on parameters specified by the user (see [3.2](#32-configuration-of-the-run)). In particular, the user can indicate which buses will have +associated slacks for reactive power balance. To do so, these buses must be specified in parameter file `param_buses_with_reactive_slack.txt`, and `buses_with_reactive_slacks` must be set to $\text{CONFIGURED}$. + +The ACOPF involves the following constraints, in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-connex-component): + +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC}$$ $$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 \sum\limits_{vsc}\boldsymbol{b_{i,vsc}} \boldsymbol{V_i}^2 - \boldsymbol{\sigma_{Q_i}^{+}} - \boldsymbol{\sigma_{Q_i}^{-}}, i\in\text{BUSCC}$$ -where : -- $s$ is the reference bus (see [5](#5-reference-bus--main-connex-component)). -- $\boldsymbol{p}_{ij}$ (resp. \boldsymbol{q}_{ij}) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, -calculated as defined in the [PowSyBl documentation](https://www.powsybl.org/pages/documentation/simulation/powerflow/openlf.html). -- $P_i^{in}$ is the constant active power injected or consumed in bus $i$ by batteries, loads, VSC stations and LCC stations. +where : +- $\boldsymbol{p}_{ij}$ (resp. \boldsymbol{q}_{ij}) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, + calculated as defined in the [PowSyBl documentation](https://www.powsybl.org/pages/documentation/simulation/powerflow/openlf.html). +- $P_i^{in}$ is the constant active power injected or consumed in bus $i$ by batteries, loads, VSC stations and LCC stations. - $Q_i^{in}$ is the constant reactive power injected or consumed in bus $i$, by fixed generators and fixed shunts (see [3.2](#32-configuration-of-the-run)), batteries, loads and LCC stations). - $\boldsymbol{P}_{i,g}$ (resp. $\boldsymbol{Q}_i^{g}$) is the variable active (resp. reactive) power produced by generator $g$ of bus $i$. - $\boldsymbol{b}_{i,g}$ (resp. $\boldsymbol{b}_{i,vsc}$) is the variable susceptance of shunt $s$ (resp. VSC station $vsc$) of bus $i$. It is bounded by the minimum and maximum susceptance of the network, specified in `ampl_network_shunts.txt`. - $\boldsymbol{\sigma}_{Q_i}$ the slack variables (both positive) +The objective function also depends on parameters specified by the user. +The objective_choice parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function. Specifically, if objective_choice takes on: +- $0$, the minimization of active power production is favored. +- $1$, the minimization of the difference between $V_i$ and $\text{ratio_voltage_target}V_i^{c,min} + (1-\text{ratio_voltage_target})V_i^{c,max}$ is favored. +- $2$, the minimization of the difference between $V_i$ and its initial value is favored. + And the following objective function : -$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) -+ \beta_1 \times \sum\limits_{g} (\alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2) -+ \beta_2 \times \sum\limits_{n} (\boldsymbol{V_n} - (1-\rho)V_{s}^{min,c} + \rhoV_{s}^{max,c})^2 -+ \beta_3 \times \sum\limits_{n} (\boldsymbol{V_n} - V_n^t)^2 -+ 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 -+ 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ +$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\text{ratio_voltage_target})V_{i}^{min,c} + \text{ratio_voltage_target}V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ where : TODO +TODO : optimization with $\alpha=0$ if needed. -And the objective function `problem_acopf_objective` which minimizes the following sums: - - The sum of `slack1_balance_Q` and `slack2_balance_Q` variables, penalized by a very high coefficient (`penalty_invest_rea_pos`). -The objective is to drive these variables towards 0, ensuring a balance in reactive power at each node. - - The sum of squared barycenter between the two values. -The first is the active power produced by each generator. The second is -the difference between this power and the unit's target P (`unit_Pc` parameter), divided by this target. -This sum is penalized with a significant coefficient only when `objective_choice = 0`. -This barycenter depends on the configurable parameter `coeff_alpha`. -The closer this coefficient is to 1, the more important the first term of the barycenter, -thus emphasizing the minimization of generated active power. -A coefficient closer to 1 increases the deviation between this active power and the generator's target P -(`targetP (MW)` defined in `ampl_network_generators.txt`). - - The sum of squared deviations between the calculated voltage values at each node and a -barycenter between the lower and upper voltage limits of the associated voltage level. -This sum is penalized with a significant coefficient only when `objective_choice = 1`. -This barycenter depends on the configurable parameter `ratio_voltage_target`. - - The sum of squared deviations between the calculated voltage values and their initial values (`v (pu)` in `ampl_network_buses.txt`) at each node. -This sum is penalized with a significant coefficient only when `objective_choice = 2`. - - The sum of squared deviations of variable transformation ratios from their initial values. -This sum is penalized by a small coefficient. The goal is to limit this deviation without overly restricting it. - - The sum of squared ratios of reactive powers generated by units over -their maximal reactive power bounds. -This sum is penalized by a small coefficient. The goal is to limit this deviation without overly restricting it. - -TODO : expliciter le fait qu'on fasse plusieurs optimisations à la suite en jouant sur alpha si besoin. - -TODO : add comments on results treatment by Knitro (what kind of solutions are considered as good...) - -Please note the following : +Please note that : - units with active power specified in `ampl_network_generators.txt` inférieur au paramètre modifiable Pnull sont exclues de l'optimisation. - Les current limits ne sont pas prises en compte dans l'optimisation. From 29b3821b27ba338ec0d3ac1b63a7eec707a822cb Mon Sep 17 00:00:00 2001 From: parvy Date: Thu, 18 Jan 2024 19:27:19 +0100 Subject: [PATCH 34/51] refactor latex. Signed-off-by: parvy --- open-reac/README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 4fe5399b..b56e55f9 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -144,16 +144,15 @@ the following pre-processing blocks are executed to ensure the consistency of th #### 4.1 Voltage level limits consistency To ensure consistent voltage level limits for the buses, -the configurable parameters $\text{min_plausible_low_voltage_limit}$ -and $\text{max_plausible_high_voltage_limit}$ are used +the configurable domain [min_plausible_low_voltage_limit; max_plausible_high_voltage_limit] is used (see [3.2](#32-configuration-of-the-run)). Let $V_{s}^{min}$ (resp. $V_{s}^{max}$) be the low (resp. high) voltage limit of substation $s$ specified in `ampl_network_substations.txt` (or in `ampl_network_substations_override.txt` if an override is given for $s$) and $V_{s}^{min,c}$ (resp. $V_{s}^{max,c}$) its associated corrected low (resp. high) limit. Then, the limits are calculated as follows: -- $V_{s}^{min,c} = \max(V_{s}^min, \text{min_plausible_low_voltage_limit})$ -- $V_{s}^{max,c} = \min(V_{s}^max, \text{max_plausible_low_voltage_limit})$ +- $V_{s}^{min,c} = \max(V_{s}^min,$ min_plausible_low_voltage_limit) +- $V_{s}^{max,c} = \min(V_{s}^max,$ max_plausible_low_voltage_limit) #### 4.2 Zero-impedance branches @@ -221,7 +220,7 @@ are executed on the main connex component (i.e. buses connected to slack bus by Consequently, buses connected to the slack by HVDC lines are excluded. This component is determined by solving the following optimization problem (the variables are bolded): -$$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i}}$$ +$$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i}$$ where $\boldsymbol{\theta_i}$ is the angle of bus $i$, and with : @@ -240,7 +239,7 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF involves the following constraint, in addition to the slack $(1)$ introduced in [5](#5-slack-bus--main-connex-component): -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P,i}^{+}} + \boldsymbol{\sigma_{P,i}^{-}}, i\in\text{BUSCC}$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P,i}^{+}} + \boldsymbol{\sigma_{P,i}^{-}}, \quad i\in\text{BUSCC}$$ where : - $\boldsymbol{p}_{ij}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}$. @@ -274,7 +273,7 @@ The ACOPF involves the following constraints, in addition to the slack constrain $$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC}$$ -$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 \sum\limits_{vsc}\boldsymbol{b_{i,vsc}} \boldsymbol{V_i}^2 - \boldsymbol{\sigma_{Q_i}^{+}} - \boldsymbol{\sigma_{Q_i}^{-}}, i\in\text{BUSCC}$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{vsc}\boldsymbol{b_{i,vsc}} \boldsymbol{V_i}^2 - \boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}, \quad i\in\text{BUSCC}$$ where : - $\boldsymbol{p}_{ij}$ (resp. \boldsymbol{q}_{ij}) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, @@ -288,11 +287,13 @@ where : The objective function also depends on parameters specified by the user. The objective_choice parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function. Specifically, if objective_choice takes on: - $0$, the minimization of active power production is favored. -- $1$, the minimization of the difference between $V_i$ and $\text{ratio_voltage_target}V_i^{c,min} + (1-\text{ratio_voltage_target})V_i^{c,max}$ is favored. +- $1$, the minimization of the difference between $V_i$ and $\rhoV_i^{c,min} + (1-\rho)V_i^{c,max}$ is favored. - $2$, the minimization of the difference between $V_i$ and its initial value is favored. +TODO : explicit rho + And the following objective function : -$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\text{ratio_voltage_target})V_{i}^{min,c} + \text{ratio_voltage_target}V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ +$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ where : TODO From fe7664d951b09260b5088543bd99e73c8254ce2c Mon Sep 17 00:00:00 2001 From: parvy Date: Fri, 19 Jan 2024 13:22:22 +0100 Subject: [PATCH 35/51] refactor. Signed-off-by: parvy --- open-reac/README.md | 141 +++++++++++++++++++++++++------------------- 1 file changed, 81 insertions(+), 60 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index b56e55f9..b2305e2b 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -41,7 +41,7 @@ knitroampl stub ``` -## Reactive Optimal Power Flow +## Reactive optimal power flow --- @@ -71,7 +71,7 @@ each serving a specific function: *ampl_* prefix), and the files used to configure the run (files with *param_* prefix). Refer to section [3](#3-input). - `reactiveopf.mod` defines the sets, parameters and optimization problems (CC, DCOPF, ACOPF) solved in `reactiveopf.run`. - Refer to sections [5](#5-reference-bus--main-connex-component), [6](#6-direct-current-optimal-power-flow) and [7](#7-alternative-current-optimal-power-flow). + Refer to sections [5](#5-slack-bus--main-connex-component), [6](#6-direct-current-optimal-power-flow) and [7](#7-alternative-current-optimal-power-flow). - `reactiveopfoutput.mod` exports result files if the execution of `reactiveopf.run` is successful. Refer to section [8.1](#81-in-case-of-convergence). - `reactiveopfexit.run` contains the code executed when the problem is inconsistent. @@ -94,37 +94,37 @@ 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 | 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 = 1 | $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](#42-zero-impedance-lines)) | $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)) | NO_GENERATION | {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}$ | +| Parameter | Description | 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)) | NO_GENERATION | {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}$ | In addition to the previous parameters, the user can specify which parameters will be variable or fixed in the ACOPF solving (see [7](#7-alternative-current-optimal-power-flow)). This is done using the following files: -| File | Description | Default behavior of modified values | -|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| -| param_transformers.txt | Ratio tap changers with a variable transformation ratio (real variable) | Transformation ratios are fixed | -| param_shunt.txt | Shunts with a continuous variable susceptance and which can be modified and/or connected (only if possible bus is defined in `ampl_network_shunts.txt`) | Shunt susceptances are fixed | -| param_generators_reactive.txt | Generators with a constant reactive power production. If this value is not consistent (> PQmax), the reactive power production stays variable | Coherent reactive power productions (see [4.5](#45-pq-units-domain)) are variable | -| param_buses_with_reactive_slack.txt | Buses with attached reactive slacks if configurable parameter buses_with_reactive_slacks = "CONFIGURED" | Only buses with no reactive power production have reactive slacks attached | +| File | Description | Default behavior of modified values | +|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------| +| `param_transformers.txt` | Ratio tap changers with a variable transformation ratio (real variable) | Transformation ratios are fixed | +| `param_shunt.txt` | Shunts with a continuous variable susceptance and which can be modified and/or connected (only if possible bus is defined in `ampl_network_shunts.txt`) | Shunt susceptances are fixed | +| `param_generators_reactive.txt` | Generators with a constant reactive power production. If this value is not consistent (> PQmax), the reactive power production stays variable | Coherent reactive power productions (see [4.5](#45-pq-units-domain)) are variable | +| `param_buses_with_reactive_slack.txt` | Buses with attached reactive slacks if configurable parameter buses_with_reactive_slacks = "CONFIGURED" | Only buses with no reactive power production have reactive slacks attached | All of these files share the same format: 2 columns #"num" "id". @@ -144,7 +144,7 @@ the following pre-processing blocks are executed to ensure the consistency of th #### 4.1 Voltage level limits consistency To ensure consistent voltage level limits for the buses, -the configurable domain [min_plausible_low_voltage_limit; max_plausible_high_voltage_limit] is used +the configurable domain [`min_plausible_low_voltage_limit`; `max_plausible_high_voltage_limit`] is used (see [3.2](#32-configuration-of-the-run)). Let $V_{s}^{min}$ (resp. $V_{s}^{max}$) be the low (resp. high) voltage limit of substation $s$ @@ -210,14 +210,15 @@ and $Qp_{g}^{c} = QP_{g}^{c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRa ### 5 Slack bus & main connex component -The slack bus $s$ is determined by identifying the AC bus with the highest number of AC branches connected, -within the main connected component (defined in `ampl_network_buses.txt`). -If multiple buses have shuch cardinality, the one with the highest identifier (`num` parameter) is chosen. +The slack bus $s$ is determined by identifying the bus with the highest number of AC branches connected, +within the main component (`cc` set to $0$ in `ampl_network_buses.txt`). +If multiple buses have such cardinality, the one with the highest identifier (`num` parameter) is chosen. In the event no bus satisfies these conditions, the first bus defined in `ampl_network_buses.txt` is selected. The OPFs (see [6](#6-direct-current-optimal-power-flow) and [7](#7-alternative-current-optimal-power-flow)) are executed on the main connex component (i.e. buses connected to slack bus by AC branches) of the network. Consequently, buses connected to the slack by HVDC lines are excluded. + This component is determined by solving the following optimization problem (the variables are bolded): $$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i}$$ @@ -226,9 +227,11 @@ where $\boldsymbol{\theta_i}$ is the angle of bus $i$, and with : $$\boldsymbol{\theta_s} = 0 \quad (1)$$ -$$\boldsymbol{\theta_i} - \boldsymbol{\theta_j} = 0, \quad ij \in BRANCH$$ +$$\boldsymbol{\theta_i} - \boldsymbol{\theta_j} = 0, \quad ij \in BRANCH \quad (2)$$ -The sets of buses and branches belonging to the main connex component will be denoted $BUSCC$ and $BRANCHCC$. +If the solving is unsuccessful, the script +`reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)) and the execution is stopped. +The sets of buses and branches belonging to the main connex component are now denoted $BUSCC$ and $BRANCHCC$. ### 6 Direct current optimal power flow @@ -239,7 +242,7 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF involves the following constraint, in addition to the slack $(1)$ introduced in [5](#5-slack-bus--main-connex-component): -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P,i}^{+}} + \boldsymbol{\sigma_{P,i}^{-}}, \quad i\in\text{BUSCC}$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P,i}^{+}} + \boldsymbol{\sigma_{P,i}^{-}}, \quad i\in\text{BUSCC} \quad (3)$$ where : - $\boldsymbol{p}_{ij}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}$. @@ -250,19 +253,19 @@ expressing the excess (resp. shortfall) of active power produced in bus $i$. And the following objective function : -$$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{P_i}^{+}} + \boldsymbol{\sigma_{P_i}^{-}}) + \sum\limits_{g} (\frac{\boldsymbol{P_{i,g}} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})})^2)$$ +$$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{P,+}} + \boldsymbol{\sigma_{i}^{P,-}}) + \sum\limits_{g} (\frac{\boldsymbol{P_{i,g}} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})})^2)$$ where $P_{i,g}^{t}$ is the target of the generator $g$ on bus $i$. -The sum of the slack variables is penalized by a -high coefficient to drive these variables towards 0, ensuring active power balance at each bus. +The sum of the active slack variables ($\boldsymbol{\sigma_{i}^{P,+}}$ and $\boldsymbol{\sigma_{i}^{P,-}}$) is penalized by a +high coefficient to drive it towards 0, ensuring active power balance at each bus of the network. The solving of the DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` (see [3.2](#32-configuration-of-the-run)), and if the solver finds a feasible solution without reaching -one of its default limit. Otherwise, the solving is considered unsuccessful and the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). +one of its default limit. Otherwise, the solving is considered unsuccessful and the script +`reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)) and the execution is stopped. ### 7 Alternative current optimal power flow - In the following, we denote $V_i$ and $\theta_i$ as the voltage and phase of bus $i$, respectively, and the notations introduced in the previous sections are used. Before solving the ACOPF, these values are warm-started with the voltage specified at each node in `ampl_network_buses.txt` and the phase calculated by the DCOPF (see [6](#6-direct-current-optimal-power-flow)). @@ -271,9 +274,9 @@ associated slacks for reactive power balance. To do so, these buses must be spec The ACOPF involves the following constraints, in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-connex-component): -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC}$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC} \quad (4)$$ -$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{vsc}\boldsymbol{b_{i,vsc}} \boldsymbol{V_i}^2 - \boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}, \quad i\in\text{BUSCC}$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{vsc}\boldsymbol{b_{i,vsc}} \boldsymbol{V_i}^2 - \boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}, \quad i\in\text{BUSCC} \quad (5)$$ where : - $\boldsymbol{p}_{ij}$ (resp. \boldsymbol{q}_{ij}) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, @@ -293,37 +296,55 @@ The objective_choice parameter modifies the values of penalties $\beta_1$, $\bet TODO : explicit rho And the following objective function : -$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ +$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ where : TODO -TODO : optimization with $\alpha=0$ if needed. +The sum of the reactive slack variables ($\boldsymbol{\sigma^{Q,+}}$ and $\boldsymbol{\sigma^{Q,-}}$) is penalized by a +high coefficient to drive it towards 0, ensuring reactive power balance at each bus of the network. +The solving is considered as successful if the solver finds a feasible approximate solution (even if the sum of +slacks is important), and the results files are then exported (see [8.1](#81-in-case-of-convergence)). +Otherwise, it is considered unsuccessful. + +TODO : explicit multiple solving with alpha values Please note that : -- units with active power specified in `ampl_network_generators.txt` inférieur au paramètre modifiable Pnull sont exclues de l'optimisation. -- Les current limits ne sont pas prises en compte dans l'optimisation. +- Units with active power specified in `ampl_network_generators.txt` that is less than the adjustable parameter `Pnull` are excluded from the optimization, +even if the user designates these generators as fixed in the `param_generators_reactive.txt` (see [3.2](#32-configuration-of-the-run)). +- Current limits are not considered in the optimization. ### 8 Output #### 8.1 In case of convergence -If the AMPL process defined in `reactiveopf.run` is successful, the script `reactiveopfoutput.run` is executed -(even if the solving of ACOPF did not reached a feasible point) and the following files are exported: - -| File | Content | Format | -|-------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------| -| reactiveopf_results_indic.txt | General information (system OS, computation time, etc.). The configurable thresholds/parameters (see section [3.2](#32-configuration-of-the-run)). The cardinality of the sets (number of non-impedance branches, number of slack variables, etc.). Information about calculated angles (maximum/minimum theta, maximum difference between neighbors, etc.). | | -| reactiveopf_results_static_var_compensators.csv | Calculated voltage and reactive power values for the SVC that regulate voltage. | 6 columns #"variant" "num" "bus" "vRegul" "V(pu)" "Q(MVAr)" | -| reactiveopf_results_shunts.csv | Calculated reactive power (and susceptance) values for shunts that were either connected or modified after the optimization problems were resolved. | 6 columns #"variant" "num" "bus" "b(pu)" "Q(MVAr)" "section" | -| reactiveopf_results_generators.csv | Calculated active and reactive power values for generating units. | 9 columns #"variant" "num" "bus" "vRegul" "V(pu)" "targetP(MW)" "targetQ(MVAr)" "P(MW)" "Q(MW)" | -| reactiveopf_results_vsc_converter_stations.csv | Calculated reactive power values for VSC converter stations. | 8 columns #"variant" "num" "bus" "vRegul" "targetV(pu)" "targetQ(MVAr)" "P(MW)" "Q(MVAr)" | -| reactiveopf_results_rtc.csv | RTCs and associated taps, with transformer ratio closest to the one calculated after the optimization. | 3 columns #"variant" "num" "tap" | -| reactiveopf_results_reactive_slacks.csv | Calculated reactive slack variables `slack1_balance_Q` and `slack2_balance_Q`. | 6 columns #"variant" "bus" "slack_condensator(MVAr)" "slack_self(MVAr)" "id" "substation" | -| reactiveopf_results_voltages.csv | Calculated voltages for each bus of the main connex component (see [5](#5-reference-bus--main-connex-component)) | 5 columns #"variant" "bus" "V(pu)" "theta(rad)" "id" | +After the solving of the ACOPF, the script `reactiveopfoutput.run` is executed + and the following files (except `reactiveopf_results_indic.txt`) are exported only if the solving +is considered as successful (see [7](#7-alternative-current-optimal-power-flow)): + +| File | Content | Format | +|---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------| +| `reactiveopf_results_indic.txt` | General information (system OS, computation time, etc.). The configurable thresholds/parameters (see section [3.2](#32-configuration-of-the-run)). The cardinality of the sets (number of non-impedance branches, number of slack variables, etc.). Information about calculated angles (maximum/minimum theta, maximum difference between neighbors, etc.). | | +| `reactiveopf_results_static_var_compensators.csv` | Calculated voltage and reactive power values for the SVC that regulate voltage. | 6 columns #"variant" "num" "bus" "vRegul" "V(pu)" "Q(MVAr)" | +| `reactiveopf_results_shunts.csv` | Calculated reactive power (and susceptance) values for shunts that were either connected or modified after the optimization problems were resolved. | 6 columns #"variant" "num" "bus" "b(pu)" "Q(MVAr)" "section" | +| `reactiveopf_results_generators.csv` | Calculated active and reactive power values for generating units. | 9 columns #"variant" "num" "bus" "vRegul" "V(pu)" "targetP(MW)" "targetQ(MVAr)" "P(MW)" "Q(MW)" | +| `reactiveopf_results_vsc_converter_stations.csv` | Calculated reactive power values for VSC converter stations. | 8 columns #"variant" "num" "bus" "vRegul" "targetV(pu)" "targetQ(MVAr)" "P(MW)" "Q(MVAr)" | +| `reactiveopf_results_rtc.csv` | RTCs and associated taps, with transformer ratio closest to the one calculated after the optimization. | 3 columns #"variant" "num" "tap" | +| `reactiveopf_results_reactive_slacks.csv` | Calculated reactive slack variables $\boldsymbol{\sigma^{Q,-}}$ and $\boldsymbol{\sigma^{Q,+}}$. | 6 columns #"variant" "bus" "slack_condensator(MVAr)" "slack_self(MVAr)" "id" "substation" | +| `reactiveopf_results_voltages.csv` | Calculated voltages for each bus of the main connex component (see [5](#5-slack-bus--main-connex-component)). | 5 columns #"variant" "bus" "V(pu)" "theta(rad)" "id" | + +If ACOPF solving is not successful, the user can export the following optional files (aiding for the analysis of ACOPF results) by specifying the + ampl log to a debug level (see [3.2](#32-configuration-of-the-run)): + +| File | Content | Format | +|--------------------------------------------|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------| +| `debug_bus.csv` | Information on calculated voltages (values, bounds, repartition, etc.). | 13 columns #"bus_id" "Vnom" "V" "Vlb" "Vub" "Vmin_mod" "Vmax_mod" "Vmin_OK" "Vmax_OK" "Vmin_ori" "Vmax_ori" "sQ1" "sQ2" | +| `reactiveopf_results_generators_Pnull.csv` | Information on units that are excluded from the solving of ACOPF (see [7](#7-alternative-current-optimal-power-flow)). | 11 columns #"variant" "num" "bus" "vRegul" "V(pu)" "targetP(MW)" "targetQ(Mvar)" "P(MW)" "Q(MW)" "id" "bus_id" | #### 8.2 In case of inconsistency -If the computation of the main connex component (see [5](#5-reference-bus--main-connex-component)) or of the DCOPF fails (see [6](#6-direct-current-optimal-power-flow)), +If the computation of the main connex component (see [5](#5-slack-bus--main-connex-component)) or +of the DCOPF fails (see [6](#6-direct-current-optimal-power-flow)), the problem is considered as inconsistent. -Then, the script `reactiveopfexit.run` is executed and the file `reactiveopf_results_indic.txt` described in previous section is exported, without the information on the calculated angles. +Then, the script `reactiveopfexit.run` is executed and the file `reactiveopf_results_indic.txt` described in [8.1](#81-in-case-of-convergence) + is exported, without the information on the calculated angles. From 8382b2761f20d5b2c3e362ae5b6cf307075c01ac Mon Sep 17 00:00:00 2001 From: parvy Date: Fri, 16 Feb 2024 16:03:25 +0100 Subject: [PATCH 36/51] Modify paragraph on non-linear solver. Signed-off-by: parvy --- open-reac/README.md | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index b2305e2b..aa739ab8 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -11,35 +11,33 @@ for network planning or in operation as well. --- ### AMPL -For this project, you must have [AMPL](https://ampl.com/) installed. -AMPL is a proprietary tool that works as an optimization modelling language. It can be interfaced with many solvers. +For this project, you must have [AMPL](https://ampl.com/) installed on your machine. +AMPL is a proprietary tool that works as an optimization modelling language, +and it can be interfaced with many solvers. -AMPL is sold by many companies including Artelys, you can find keys [here](https://www.artelys.com/solvers/ampl/). +AMPL is sold by many companies including Artelys. You can find keys [here](https://www.artelys.com/solvers/ampl/). -You must add in your `~/.itools/config.yml` an ampl section like this: +To run OpenReac, you must add in your `~/.itools/config.yml` an ampl section like this: ```yaml ampl: # Change to the ampl folder path that contains the ampl executable homeDir: /home/user/ampl ``` -### Knitro +### Non-linear optimization solver -To run this model, in addition of AMPL you'll need Knitro. Knitro is a -proprietary non-linear solver. - -Artelys is the company developping Knitro. It is distributing keys -[here](https://www.artelys.com/solvers/knitro/). - -After the installation is done and that you got a valid licence, you -must have `knitroampl` in your path. - -To check, start a bash and run : +To run the model implemented in AMPL, you'll need a non-linear optimization solver. +By default, the AMPL code is configured to run Knitro, which is a proprietary non-linear, but you +are free to configure a different one. +If you chose to run Knitro, you must have `knitroampl` in your path, after the installation +of the solver is done and that you got a valid licence. To check, start a bash and run : ```bash knitroampl stub ``` +Artelys is the company developing Knitro. You can find keys +[here](https://www.artelys.com/solvers/knitro/). ## Reactive optimal power flow From 44ae05562398ca7f365be1a8c1f6334863d17bec Mon Sep 17 00:00:00 2001 From: parvy Date: Fri, 16 Feb 2024 16:28:23 +0100 Subject: [PATCH 37/51] Improve part on P/Q units' domain correction. Signed-off-by: parvy --- open-reac/README.md | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index aa739ab8..a478bea1 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -177,12 +177,11 @@ phase shift transformer on the same branch. #### 4.4 P/Q units' domain The following corrections apply successively to determine consistent domains for the active -power and reactive power produced by generators. Please note that in the end, the corrected bounds are rectangular -(not trapezoidal), and they are used only in the reactive OPF (see [7](#7-alternative-current-optimal-power-flow)). +power and reactive power produced by generators. To determine the consistent domain of produced active power, the bounds of the domains $P_g^{min}$ and $P_g^{max}$, as well as the target $P_g^{t}$ of generator $g$ (all specified in `ampl_network_generators.txt`) are used. -Let $P_{g}^{min,c}$ and $P_{g}^{max,c}$ be the corrected active bounds : +Let $P_{g}^{min,c}$ and $P_{g}^{max,c}$ be the corrected active bounds: - By default, $P_{g}^{min,c} = \text{defaultPmin}$ and $P_{g}^{max,c} = \text{defaultPmax}$ (see [3.2](#32-configuration-of-the-run)) - If $|P_g^{max}| \geq \text{PQmax}$, then $P_{g}^{max,c} = \max(\text{defaultPmax}, P_g^t)$ @@ -190,22 +189,30 @@ Let $P_{g}^{min,c}$ and $P_{g}^{max,c}$ be the corrected active bounds : - If $|P_{g}^{max,c} - P_{g}^{min,c}| \leq \text{minimalQPrange}$, then $P_{g}^{max,c} = P_{g}^{min,c} = P_{g}^t$ (active power is fixed). To determine the consistent domain of produced reactive power, the reactive power diagram -(`specified in ampl_network_generators.txt`) of generator -$g$ est utilisé : $qp_g$ (resp. $qP_g$) and $Qp_g$ ($QP_g$) when $P_{g}^{min,c}$ (resp. P_{g}^{max,c}) is reached. +(specified in `ampl_network_generators.txt`) of generator +$g$ is used : $qp_g$ (resp. $qP_g$) and $Qp_g$ ($QP_g$) when $P_{g}^{min,c}$ (resp. $P_{g}^{max,c}$) is reached. Let $qp_g^c$ (resp. $qP_g^c$) and $Qp_g^c$ (resp. $QP_g^c$) be the bounds of the corrected reactive diagram, -and $Q_{g}^{min,c}$ and $Q_{g}^{max,c}$ be the corrected reactive bounds : +and $Q_{g}^{min,c}$ and $Q_{g}^{max,c}$ be the corrected reactive bounds: - By default, $qp_g^{c} = qP_{g}^{c} = - \text{defaultPmin} \times \text{defaultQmaxPmaxRatio}$ and $Qp_{g}^{c} = QP_{g}^{c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRatio}$ (see [3.2](#32-configuration-of-the-run)) - If $|qp_{g}| \geq \text{PQmax}$, then $qp_{g}^{c} = -\text{defaultQmaxPmaxRatio} \times P_{max}^{g,c}$. - Same with $qP_{g}^{c}$ + Same with $qP_{g}^{c}$. - If $|Qp_{g}| \geq \text{PQmax}$, then $Qp_{g}^{c} = \text{defaultQmaxPmaxRatio} \times P_{max}^{g,c}$. - Same with $QP_{g}^{c}$ -- If $qp_{g}^{c} > Qp_{g}^{c}$, the values are swapped. Same with $qP_{g}^{c}$ and $QP_{g}^{c}$ -- If the corrected reactive diagram is too small (distance between extremal values lower than $\text{minimalQPrange}$), + Same with $QP_{g}^{c}$. +- If $qp_{g}^{c} > Qp_{g}^{c}$, the values are swapped. Same with $qP_{g}^{c}$ and $QP_{g}^{c}$. +- If the corrected reactive diagram is too small (the distances between the vertices of the reactive diagram are lower than $\text{minimalQPrange}$), then $qp_{g}^{c} = Qp_{g}^{c} = qP_{g}^{c} = QP_{g}^{c} = \frac{qp_{g}^{c} + Qp_{g}^{c} + qP_{g}^{c} + QP_{g}^{c}}{4}$ (reactive power is fixed). - $Q_{g}^{min,c} = \min(qp_{g}^{c}, qP_{g}^{c})$ and $Q_{g}^{max,c} = \min(Qp_{g}^{c}, QP_{g}^{c})$ +Please note that in the end, the corrected bounds are rectangular +(not trapezoidal), and they are used only in the reactive OPF +(see [7](#7-alternative-current-optimal-power-flow)). +The general correction of the generator's reactive power diagram $g$ +is illustrated in the following figure: + +TODO : add figure. + ### 5 Slack bus & main connex component The slack bus $s$ is determined by identifying the bus with the highest number of AC branches connected, From e35b1f882d86a4200a85534a7f0eb2a08fe3ced5 Mon Sep 17 00:00:00 2001 From: parvy Date: Fri, 16 Feb 2024 16:37:44 +0100 Subject: [PATCH 38/51] Refactor with suggestions. Signed-off-by: parvy --- open-reac/README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index a478bea1..d7ad463e 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -1,7 +1,7 @@ # OpenReac OpenReac is a reactive optimal power flow that gives a set of hypotheses -for voltage and reactive controls by network equipments such as +for voltage and reactive controls by network equipment such as generators, shunt compensators and transformers. OpenReac can be used for network planning or in operation as well. @@ -45,11 +45,12 @@ Artelys is the company developing Knitro. You can find keys ### 1 Overview -The reactive optimal power flow (OPF) is implemented with AMPL. Its goal is to propose values -for all voltage and reactive equipment and controllers of the grid +The reactive optimal power flow (OPF) is implemented with AMPL. +Its goal is to compute voltage values on each point of the network as well as control values +for reactive equipment and controllers of the grid (voltage set point of generating units, shunts, transformers ratios...). -In a grid development study, you decide new equipments, new generating units, +In a grid development study, you decide new equipment, new generating units, new substations, new loads, you set values for active and reactive loads, you set values for active power generation and HVDC flows. Then if you wish to do AC powerflow simulations with N-1 analysis, you need @@ -149,8 +150,8 @@ Let $V_{s}^{min}$ (resp. $V_{s}^{max}$) be the low (resp. high) voltage limit of specified in `ampl_network_substations.txt` (or in `ampl_network_substations_override.txt` if an override is given for $s$) and $V_{s}^{min,c}$ (resp. $V_{s}^{max,c}$) its associated corrected low (resp. high) limit. Then, the limits are calculated as follows: -- $V_{s}^{min,c} = \max(V_{s}^min,$ min_plausible_low_voltage_limit) -- $V_{s}^{max,c} = \min(V_{s}^max,$ max_plausible_low_voltage_limit) +- $V_{s}^{min,c} = \max(V_{s}^{min},$ min_plausible_low_voltage_limit) +- $V_{s}^{max,c} = \min(V_{s}^{max},$ max_plausible_low_voltage_limit) #### 4.2 Zero-impedance branches From a5f29f3937dc707f03bed54e182db7573c4f2930 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 19 Feb 2024 14:30:18 +0100 Subject: [PATCH 39/51] Improve everything. Signed-off-by: parvy --- open-reac/README.md | 135 +++++++++++++++++++++++++++++--------------- 1 file changed, 88 insertions(+), 47 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index d7ad463e..018585a9 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -5,11 +5,10 @@ for voltage and reactive controls by network equipment such as generators, shunt compensators and transformers. OpenReac can be used for network planning or in operation as well. +--- ## Getting started ---- - ### AMPL For this project, you must have [AMPL](https://ampl.com/) installed on your machine. AMPL is a proprietary tool that works as an optimization modelling language, @@ -39,10 +38,10 @@ knitroampl stub Artelys is the company developing Knitro. You can find keys [here](https://www.artelys.com/solvers/knitro/). -## Reactive optimal power flow - --- +## Reactive optimal power flow + ### 1 Overview The reactive optimal power flow (OPF) is implemented with AMPL. @@ -159,7 +158,7 @@ Branches with an impedance magnitude (calculated in p.u.) lower than the configurable threshold `Znull` (see section [3.2](#32-configuration-of-the-run)) are considered as non-impedant. These branches will have their reactance replaced by the threshold `Znull` (in p.u.), -even if the reactance specified in `ampl_network_branches.txt` is negative. +**even if the reactance specified in `ampl_network_branches.txt` is negative**. #### 4.3 Impedance of transformers @@ -206,9 +205,11 @@ and $Qp_{g}^{c} = QP_{g}^{c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRa then $qp_{g}^{c} = Qp_{g}^{c} = qP_{g}^{c} = QP_{g}^{c} = \frac{qp_{g}^{c} + Qp_{g}^{c} + qP_{g}^{c} + QP_{g}^{c}}{4}$ (reactive power is fixed). - $Q_{g}^{min,c} = \min(qp_{g}^{c}, qP_{g}^{c})$ and $Q_{g}^{max,c} = \min(Qp_{g}^{c}, QP_{g}^{c})$ -Please note that in the end, the corrected bounds are rectangular -(not trapezoidal), and they are used only in the reactive OPF -(see [7](#7-alternative-current-optimal-power-flow)). +Please note that in the end, **the corrected bounds are rectangular**, +not trapezoidal, and they are used only in the reactive OPF +(see [7](#7-alternative-current-optimal-power-flow)). In addition, bounds $qP_{g}^0$ and $Qp_{g}^0$ are not used, +as generators with zero active power will be excluded from the optimisation (see [7.1](#71-generalities)). + The general correction of the generator's reactive power diagram $g$ is illustrated in the following figure: @@ -216,20 +217,20 @@ TODO : add figure. ### 5 Slack bus & main connex component -The slack bus $s$ is determined by identifying the bus with the highest number of AC branches connected, +The slack bus $s$ is determined by identifying the **bus with the highest number of AC branches connected**, within the main component (`cc` set to $0$ in `ampl_network_buses.txt`). If multiple buses have such cardinality, the one with the highest identifier (`num` parameter) is chosen. In the event no bus satisfies these conditions, the first bus defined in `ampl_network_buses.txt` is selected. The OPFs (see [6](#6-direct-current-optimal-power-flow) and [7](#7-alternative-current-optimal-power-flow)) -are executed on the main connex component (i.e. buses connected to slack bus by AC branches) of the network. -Consequently, buses connected to the slack by HVDC lines are excluded. +are executed on the **main connex component** (i.e. buses connected to slack bus by AC branches) of the network. +Consequently, **buses connected to the slack by HVDC lines are excluded**. This component is determined by solving the following optimization problem (the variables are bolded): $$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i}$$ -where $\boldsymbol{\theta_i}$ is the angle of bus $i$, and with : +where $\boldsymbol{\theta_i}$ is the voltage angle of bus $i$, and with : $$\boldsymbol{\theta_s} = 0 \quad (1)$$ @@ -241,20 +242,25 @@ The sets of buses and branches belonging to the main connex component are now de ### 6 Direct current optimal power flow +#### 6.1 Generalities + Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)), a DCOPF is solved for two main reasons: - If the DCOPF resolution fails, it provides a strong indication that the ACOPF resolution will also fail. Thus, it serves as a formal consistency check on the data. - The phases computed by DCOPF resolution will be used as initial points for the solving of the ACOPF. -The DCOPF involves the following constraint, in addition to the slack $(1)$ introduced in [5](#5-slack-bus--main-connex-component): +#### 6.2 Optimization problem + +The DCOPF model involves the following constraints, +in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-connex-component): $$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P,i}^{+}} + \boldsymbol{\sigma_{P,i}^{-}}, \quad i\in\text{BUSCC} \quad (3)$$ where : -- $\boldsymbol{p}_{ij}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}$. +- $\boldsymbol{p_{ij}}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}$. - $P_i^{in}$ the constant active power injected or consumed in bus $i$ (by batteries, loads, VSC stations and LCC stations). - $\boldsymbol{P}_i^{g}$ is the variable active power produced by generators of bus $i$. -- $\boldsymbol{\sigma}_{P,i}^{+}$ (resp. $\boldsymbol{\sigma}_{P,i}^{-}$) is a positive slack variable +- $\boldsymbol{\sigma_{P,i}^{+}}$ (resp. $\boldsymbol{\sigma_{P,i}^{-}}$) is a positive slack variable expressing the excess (resp. shortfall) of active power produced in bus $i$. And the following objective function : @@ -264,61 +270,96 @@ $$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{P,+}} + \b where $P_{i,g}^{t}$ is the target of the generator $g$ on bus $i$. The sum of the active slack variables ($\boldsymbol{\sigma_{i}^{P,+}}$ and $\boldsymbol{\sigma_{i}^{P,-}}$) is penalized by a -high coefficient to drive it towards 0, ensuring active power balance at each bus of the network. +high coefficient ($1000$) to drive it towards $0$, ensuring active power balance at each bus of the network. The solving of the DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` -(see [3.2](#32-configuration-of-the-run)), and if the solver finds a feasible solution without reaching -one of its default limit. Otherwise, the solving is considered unsuccessful and the script -`reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)) and the execution is stopped. +(see [3.2](#32-configuration-of-the-run)), and if the non-linear solver employed (see [Non-linear solver](#non-linear-optimization-solver)) +finds a feasible solution without reaching one of its default limit. Otherwise, the solving is considered unsuccessful and the script +`reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). ### 7 Alternative current optimal power flow -In the following, we denote $V_i$ and $\theta_i$ as the voltage and phase of bus $i$, respectively, and the notations introduced in the previous sections are used. -Before solving the ACOPF, these values are warm-started with the voltage specified at each node in `ampl_network_buses.txt` and the phase calculated by the DCOPF (see [6](#6-direct-current-optimal-power-flow)). +#### 7.1 Generalities -The constraints of the optimization problem depend on parameters specified by the user (see [3.2](#32-configuration-of-the-run)). In particular, the user can indicate which buses will have -associated slacks for reactive power balance. To do so, these buses must be specified in parameter file `param_buses_with_reactive_slack.txt`, and `buses_with_reactive_slacks` must be set to $\text{CONFIGURED}$. +The goal of the reactive ACOPF is to compute voltage values on each bus, +as well as control values for reactive equipment and controllers of the grid. +Then, the following values will be variable in the optimization: +- $\boldsymbol{V_i}$ and $\boldsymbol{\theta_i}$ the voltage magnitude and phase of bus $i$. +- $\boldsymbol{P}_{i,g}$ (resp. $\boldsymbol{Q}_i^{g}$) the active (resp. reactive) power produced by variable generator $g$ of bus $i$. +- $\boldsymbol{Q_{i,vsc}}$ the reactive power produced by voltage source converter stations $vsc$ of bus $i$. +- $\boldsymbol{b_{i,g}}$ (resp. $\boldsymbol{b_{i,svc}}$) the susceptance of shunt $s$ (resp. of static var compensator $svc$) of bus $i$. +- $\boldsymbol{\rho_{ij}}$ the transformer ratio of the ratio tap changer on branch $ij$, +specified as variable by the user (see [3.2](#32-configuration-of-the-run)). + +Please note that : +- Units with active power specified in `ampl_network_generators.txt` that is less than the configurable parameter `Pnull` **are excluded from the optimization**, + even if the user designates these generators as fixed in the `param_generators_reactive.txt` (see [3.2](#32-configuration-of-the-run)). + Therefore, when the optimization results are exported, these generators are exported with a reactive power target of $0$. +- **Neither current limits nor power limits** on branches are considered in the optimization. + +#### 7.2 Constraints + +The constraints of the optimization problem depend on parameters specified by the user (see [3.2](#32-configuration-of-the-run)). +In particular, the user can indicate which buses will have associated **reactive slacks** $\boldsymbol{\sigma_{i}^{Q,+}}$ and $\boldsymbol{\sigma_{i}^{Q,-}}$ for +reactive power balance. To do so, these buses must be specified in parameter +file `param_buses_with_reactive_slack.txt`, and `buses_with_reactive_slacks` must be set to $\text{CONFIGURED}$. The ACOPF involves the following constraints, in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-connex-component): $$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC} \quad (4)$$ -$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{vsc}\boldsymbol{b_{i,vsc}} \boldsymbol{V_i}^2 - \boldsymbol{\sigma_{Q_i}^{+}} + \boldsymbol{\sigma_{Q_i}^{-}}, \quad i\in\text{BUSCC} \quad (5)$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{Q_i}^{-}} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{svc}\boldsymbol{b_{i,svc}}{V_i}^2 - \sum\limits_{vsc}\boldsymbol{Q_{i,vsc}}, \quad i\in\text{BUSCC} \quad (5)$$ where : -- $\boldsymbol{p}_{ij}$ (resp. \boldsymbol{q}_{ij}) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, +- $\boldsymbol{p_{ij}}$ (resp. $\boldsymbol{q_{ij}}$) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, calculated as defined in the [PowSyBl documentation](https://www.powsybl.org/pages/documentation/simulation/powerflow/openlf.html). + Those are variables because they depend on $\boldsymbol{V_i}$, $\boldsymbol{V_j}$, $\boldsymbol{\theta_i}$, $\boldsymbol{\theta_j}$ and $\boldsymbol{\rho_{ij}}$. - $P_i^{in}$ is the constant active power injected or consumed in bus $i$ by batteries, loads, VSC stations and LCC stations. -- $Q_i^{in}$ is the constant reactive power injected or consumed in bus $i$, by fixed generators and fixed shunts (see [3.2](#32-configuration-of-the-run)), batteries, loads and LCC stations). -- $\boldsymbol{P}_{i,g}$ (resp. $\boldsymbol{Q}_i^{g}$) is the variable active (resp. reactive) power produced by generator $g$ of bus $i$. -- $\boldsymbol{b}_{i,g}$ (resp. $\boldsymbol{b}_{i,vsc}$) is the variable susceptance of shunt $s$ (resp. VSC station $vsc$) of bus $i$. It is bounded by the minimum and maximum susceptance of the network, specified in `ampl_network_shunts.txt`. -- $\boldsymbol{\sigma}_{Q_i}$ the slack variables (both positive) +- $Q_i^{in}$ is the constant reactive power injected or consumed in bus $i$, by fixed generators and fixed shunts (see [3.2](#32-configuration-of-the-run)), batteries, loads and LCC stations. -The objective function also depends on parameters specified by the user. -The objective_choice parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function. Specifically, if objective_choice takes on: -- $0$, the minimization of active power production is favored. -- $1$, the minimization of the difference between $V_i$ and $\rhoV_i^{c,min} + (1-\rho)V_i^{c,max}$ is favored. -- $2$, the minimization of the difference between $V_i$ and its initial value is favored. +In order to bound the variables described in [7.1](#71-generalities), the limits specified in the files of network data (see [3.1](#31-network-data)) +are used. We note the following special treatments: +- The voltage magnitude $\boldsymbol{V_i}$ lies between the corrected voltage limits described in [4.1](#41-voltage-level-limits-consistency). +- The active power $\boldsymbol{P_{i,g}}$ (resp. reactive power $\boldsymbol{Q_{i,g}}$) +produced lies between the corrected limits described in [4.4](#44-pq-units-domain). +- The reactive power $\boldsymbol{Q_{i,vsc}}$ is included in $\[\min(qP_{vsc}, qp_{vsc}, qp_{vsc}^0)$; $\max(QP_{vsc}, Qp_{vsc}, Qp_{vsc}^0)\]$. +**The bounds are therefore rectangular, not trapezoidal.** -TODO : explicit rho +#### 7.3 Objective function -And the following objective function : +The objective function also depends on parameters specified by the user. +The `objective_choice` parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function. +Specifically, if `objective_choice` takes on: +- $0$, the minimization of active power production ($\boldsymbol{P_{i,g}}$) is prioritized. +- $1$, the minimization of the difference between $\boldsymbol{V_i}$ and $\rho V_i^{c,min} + (1-\rho)V_i^{c,max}$ is prioritized. The parameter $\rho$ +equals the configurable parameter `ratio_voltage_target` (see [3.2](#32-configuration-of-the-run)). +- $2$, the minimization of the difference between $\boldsymbol{V_i}$ and its initial value is prioritized. + +The objective function of the ACOPF is : $$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ where : -TODO +- $P_{i,g}^t$ (resp. $V_i^t$) is the target (resp. initial point) specified in `ampl_network_generators.txt` (resp. `ampl_network_buses.txt`). +- $\alpha$ is a parameter configurable by the user (see [3.2](#32-configuration-of-the-run)). +- $Q_{g}^{min,c}$ and $Q_{g}^{max,c}$ are the corrected reactive power bounds of variable $\boldsymbol{Q_{i,g}$, specified in [4.4](#44-pq-units-domain). +- $\rho_{ij}$ is the transformer ratio of line $ij$, specified in `ampl_network_tct.txt`. The sum of the reactive slack variables ($\boldsymbol{\sigma^{Q,+}}$ and $\boldsymbol{\sigma^{Q,-}}$) is penalized by a -high coefficient to drive it towards 0, ensuring reactive power balance at each bus of the network. -The solving is considered as successful if the solver finds a feasible approximate solution (even if the sum of -slacks is important), and the results files are then exported (see [8.1](#81-in-case-of-convergence)). -Otherwise, it is considered unsuccessful. +high coefficient ($10$) to drive it towards $0$, ensuring reactive power balance at each bus of the network. -TODO : explicit multiple solving with alpha values +#### 7.4 Solving -Please note that : -- Units with active power specified in `ampl_network_generators.txt` that is less than the adjustable parameter `Pnull` are excluded from the optimization, -even if the user designates these generators as fixed in the `param_generators_reactive.txt` (see [3.2](#32-configuration-of-the-run)). -- Current limits are not considered in the optimization. +Before solving the ACOPF, these values are warm-started with the voltage specified at each node in `ampl_network_buses.txt` and the phase +calculated by the DCOPF (see [6](#6-direct-current-optimal-power-flow)). TODO : explain warm start + +The solving is considered as successful if the non-linear solver employed (see [Non-linear solver](#non-linear-optimization-solver)) +finds a feasible approximate solution (**even if the sum of +slacks is important**), and the script `reactiveopfoutput.run` is executed (see [8.1](#81-in-case-of-convergence)). + +Note that if the solving of ACOPF fails, and the $\alpha$ parameter is set to $1$ (default value), +then a new resolution is attempted, with the $\alpha$ set to zero. This gives more freedom to the active powers +produced, leaving these variables free withing their respective bounds. + +If ACOPF solving fails, the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). ### 8 Output @@ -340,7 +381,7 @@ is considered as successful (see [7](#7-alternative-current-optimal-power-flow)) | `reactiveopf_results_voltages.csv` | Calculated voltages for each bus of the main connex component (see [5](#5-slack-bus--main-connex-component)). | 5 columns #"variant" "bus" "V(pu)" "theta(rad)" "id" | If ACOPF solving is not successful, the user can export the following optional files (aiding for the analysis of ACOPF results) by specifying the - ampl log to a debug level (see [3.2](#32-configuration-of-the-run)): + ampl log parameter to a debug level (see [3.2](#32-configuration-of-the-run)): | File | Content | Format | |--------------------------------------------|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------| From 725378bd614f5256d60052d6d49cf6be6e67846d Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 19 Feb 2024 15:32:02 +0100 Subject: [PATCH 40/51] Improve ACOPF part. Signed-off-by: parvy --- open-reac/README.md | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 018585a9..98129451 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -30,7 +30,7 @@ By default, the AMPL code is configured to run Knitro, which is a proprietary no are free to configure a different one. If you chose to run Knitro, you must have `knitroampl` in your path, after the installation -of the solver is done and that you got a valid licence. To check, start a bash and run : +of the solver is done and that you got a valid licence. To check, start a bash and run: ```bash knitroampl stub ``` @@ -132,7 +132,7 @@ In addition to the elements specified in section [3.2](#32-configuration-of-the- the voltage limits of specified voltage levels. These values are defined in `ampl_network_substations_override.txt` and are employed to establish the new voltage limits as specified in section [4.1](#41-voltage-level-limits-consistency). -Format : 4 columns #"num" "minV (pu)" "maxV (pu)" "id" +Format: 4 columns #"num" "minV (pu)" "maxV (pu)" "id" ### 4 Pre-processing @@ -190,7 +190,7 @@ Let $P_{g}^{min,c}$ and $P_{g}^{max,c}$ be the corrected active bounds: To determine the consistent domain of produced reactive power, the reactive power diagram (specified in `ampl_network_generators.txt`) of generator -$g$ is used : $qp_g$ (resp. $qP_g$) and $Qp_g$ ($QP_g$) when $P_{g}^{min,c}$ (resp. $P_{g}^{max,c}$) is reached. +$g$ is used: $qp_g$ (resp. $qP_g$) and $Qp_g$ ($QP_g$) when $P_{g}^{min,c}$ (resp. $P_{g}^{max,c}$) is reached. Let $qp_g^c$ (resp. $qP_g^c$) and $Qp_g^c$ (resp. $QP_g^c$) be the bounds of the corrected reactive diagram, and $Q_{g}^{min,c}$ and $Q_{g}^{max,c}$ be the corrected reactive bounds: @@ -213,7 +213,7 @@ as generators with zero active power will be excluded from the optimisation (see The general correction of the generator's reactive power diagram $g$ is illustrated in the following figure: -TODO : add figure. +TODO: add figure. ### 5 Slack bus & main connex component @@ -230,7 +230,7 @@ This component is determined by solving the following optimization problem (the $$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i}$$ -where $\boldsymbol{\theta_i}$ is the voltage angle of bus $i$, and with : +where $\boldsymbol{\theta_i}$ is the voltage angle of bus $i$, and with: $$\boldsymbol{\theta_s} = 0 \quad (1)$$ @@ -256,14 +256,14 @@ in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-c $$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P,i}^{+}} + \boldsymbol{\sigma_{P,i}^{-}}, \quad i\in\text{BUSCC} \quad (3)$$ -where : +where: - $\boldsymbol{p_{ij}}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}$. - $P_i^{in}$ the constant active power injected or consumed in bus $i$ (by batteries, loads, VSC stations and LCC stations). - $\boldsymbol{P}_i^{g}$ is the variable active power produced by generators of bus $i$. - $\boldsymbol{\sigma_{P,i}^{+}}$ (resp. $\boldsymbol{\sigma_{P,i}^{-}}$) is a positive slack variable expressing the excess (resp. shortfall) of active power produced in bus $i$. -And the following objective function : +And the following objective function: $$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{P,+}} + \boldsymbol{\sigma_{i}^{P,-}}) + \sum\limits_{g} (\frac{\boldsymbol{P_{i,g}} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})})^2)$$ @@ -290,7 +290,7 @@ Then, the following values will be variable in the optimization: - $\boldsymbol{\rho_{ij}}$ the transformer ratio of the ratio tap changer on branch $ij$, specified as variable by the user (see [3.2](#32-configuration-of-the-run)). -Please note that : +Please note that: - Units with active power specified in `ampl_network_generators.txt` that is less than the configurable parameter `Pnull` **are excluded from the optimization**, even if the user designates these generators as fixed in the `param_generators_reactive.txt` (see [3.2](#32-configuration-of-the-run)). Therefore, when the optimization results are exported, these generators are exported with a reactive power target of $0$. @@ -309,7 +309,7 @@ $$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\bolds $$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{Q_i}^{-}} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{svc}\boldsymbol{b_{i,svc}}{V_i}^2 - \sum\limits_{vsc}\boldsymbol{Q_{i,vsc}}, \quad i\in\text{BUSCC} \quad (5)$$ -where : +where: - $\boldsymbol{p_{ij}}$ (resp. $\boldsymbol{q_{ij}}$) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, calculated as defined in the [PowSyBl documentation](https://www.powsybl.org/pages/documentation/simulation/powerflow/openlf.html). Those are variables because they depend on $\boldsymbol{V_i}$, $\boldsymbol{V_j}$, $\boldsymbol{\theta_i}$, $\boldsymbol{\theta_j}$ and $\boldsymbol{\rho_{ij}}$. @@ -319,10 +319,13 @@ where : In order to bound the variables described in [7.1](#71-generalities), the limits specified in the files of network data (see [3.1](#31-network-data)) are used. We note the following special treatments: - The voltage magnitude $\boldsymbol{V_i}$ lies between the corrected voltage limits described in [4.1](#41-voltage-level-limits-consistency). -- The active power $\boldsymbol{P_{i,g}}$ (resp. reactive power $\boldsymbol{Q_{i,g}}$) -produced lies between the corrected limits described in [4.4](#44-pq-units-domain). +- The reactive power $\boldsymbol{Q_{i,g}}$ lies between the corrected limits described in [4.4](#44-pq-units-domain). - The reactive power $\boldsymbol{Q_{i,vsc}}$ is included in $\[\min(qP_{vsc}, qp_{vsc}, qp_{vsc}^0)$; $\max(QP_{vsc}, Qp_{vsc}, Qp_{vsc}^0)\]$. **The bounds are therefore rectangular, not trapezoidal.** +- The active power $\boldsymbol{P_{i,g}}$ also lies between the corrected limits described in [4.4](#44-pq-units-domain), +but these bounds are only considered when the configurable parameter $\alpha$ is different than $1$ (default value). +Otherwise, all active powers evolve proportionally to their initial point $P_{i,g}^t$ (specified in `ampl_network_generators.txt`): +$\boldsymbol{P_{i,g}} = P_{i,g}^t + \gamma (P_{g}^{max,c} - P_{i,g}^t)$, where $\gamma$ is optimized and lies in $\[-1;1\]$. #### 7.3 Objective function @@ -334,13 +337,11 @@ Specifically, if `objective_choice` takes on: equals the configurable parameter `ratio_voltage_target` (see [3.2](#32-configuration-of-the-run)). - $2$, the minimization of the difference between $\boldsymbol{V_i}$ and its initial value is prioritized. -The objective function of the ACOPF is : +The objective function of the ACOPF is: $$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ -where : +where: - $P_{i,g}^t$ (resp. $V_i^t$) is the target (resp. initial point) specified in `ampl_network_generators.txt` (resp. `ampl_network_buses.txt`). -- $\alpha$ is a parameter configurable by the user (see [3.2](#32-configuration-of-the-run)). -- $Q_{g}^{min,c}$ and $Q_{g}^{max,c}$ are the corrected reactive power bounds of variable $\boldsymbol{Q_{i,g}$, specified in [4.4](#44-pq-units-domain). - $\rho_{ij}$ is the transformer ratio of line $ij$, specified in `ampl_network_tct.txt`. The sum of the reactive slack variables ($\boldsymbol{\sigma^{Q,+}}$ and $\boldsymbol{\sigma^{Q,-}}$) is penalized by a @@ -348,16 +349,16 @@ high coefficient ($10$) to drive it towards $0$, ensuring reactive power balance #### 7.4 Solving -Before solving the ACOPF, these values are warm-started with the voltage specified at each node in `ampl_network_buses.txt` and the phase -calculated by the DCOPF (see [6](#6-direct-current-optimal-power-flow)). TODO : explain warm start +Before solving the ACOPF, the voltage magnitudes $\boldsymbol{V_i}$ are warm-started with $V_i^t$, +as well as the voltage phases $\boldsymbol{\theta_i}$ with the results of the DCOPF (see [6](#6-direct-current-optimal-power-flow)). The solving is considered as successful if the non-linear solver employed (see [Non-linear solver](#non-linear-optimization-solver)) finds a feasible approximate solution (**even if the sum of slacks is important**), and the script `reactiveopfoutput.run` is executed (see [8.1](#81-in-case-of-convergence)). Note that if the solving of ACOPF fails, and the $\alpha$ parameter is set to $1$ (default value), -then a new resolution is attempted, with the $\alpha$ set to zero. This gives more freedom to the active powers -produced, leaving these variables free withing their respective bounds. +then a new resolution is attempted, with $\alpha$ set to zero. This gives more freedom to the active powers +produced (see [7.2](#72-constraints), leaving these variables free withing their respective bounds. If ACOPF solving fails, the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). From 85920dd4cfc1367a2dd1b4ddd9e849fceeec8578 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 19 Feb 2024 15:40:10 +0100 Subject: [PATCH 41/51] Small refactoring. Signed-off-by: parvy --- open-reac/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 98129451..f73851b7 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -325,17 +325,17 @@ are used. We note the following special treatments: - The active power $\boldsymbol{P_{i,g}}$ also lies between the corrected limits described in [4.4](#44-pq-units-domain), but these bounds are only considered when the configurable parameter $\alpha$ is different than $1$ (default value). Otherwise, all active powers evolve proportionally to their initial point $P_{i,g}^t$ (specified in `ampl_network_generators.txt`): -$\boldsymbol{P_{i,g}} = P_{i,g}^t + \gamma (P_{g}^{max,c} - P_{i,g}^t)$, where $\gamma$ is optimized and lies in $\[-1;1\]$. +$\boldsymbol{P_{i,g}} = P_{i,g}^t + \boldsymbol{\gamma} (P_{g}^{max,c} - P_{i,g}^t)$, where $\boldsymbol{\gamma}$ is optimized and lies in $\[-1;1\]$. #### 7.3 Objective function -The objective function also depends on parameters specified by the user. +The objective function also depends on parameters specified by the user (see [3.2](#32-configuration-of-the-run)). The `objective_choice` parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function. Specifically, if `objective_choice` takes on: -- $0$, the minimization of active power production ($\boldsymbol{P_{i,g}}$) is prioritized. -- $1$, the minimization of the difference between $\boldsymbol{V_i}$ and $\rho V_i^{c,min} + (1-\rho)V_i^{c,max}$ is prioritized. The parameter $\rho$ -equals the configurable parameter `ratio_voltage_target` (see [3.2](#32-configuration-of-the-run)). -- $2$, the minimization of the difference between $\boldsymbol{V_i}$ and its initial value is prioritized. +- $0$, the minimization of active power production $\sum\limits_{i,g}\boldsymbol{P_{i,g}}$ is prioritized. +- $1$, the minimization of $\sum\limits_{i} \boldsymbol{V_i}-(\rho V_i^{c,min} + (1-\rho)V_i^{c,max})$ is prioritized. The parameter $\rho$ +equals the configurable parameter `ratio_voltage_target`. +- $2$, the minimization of $\sum\limits_{i} \boldsymbol{V_i} - V_i^t$ is prioritized. The objective function of the ACOPF is: $$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ @@ -358,7 +358,7 @@ slacks is important**), and the script `reactiveopfoutput.run` is executed (see Note that if the solving of ACOPF fails, and the $\alpha$ parameter is set to $1$ (default value), then a new resolution is attempted, with $\alpha$ set to zero. This gives more freedom to the active powers -produced (see [7.2](#72-constraints), leaving these variables free withing their respective bounds. +produced (see [7.2](#72-constraints)), leaving these variables free withing their respective bounds. If ACOPF solving fails, the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). From 0fb76cd9b176566e5bb16e272a444fddc340c4cf Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 19 Feb 2024 16:27:26 +0100 Subject: [PATCH 42/51] Fix typos. Signed-off-by: parvy --- open-reac/README.md | 86 ++++++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index f73851b7..ba675324 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -14,8 +14,6 @@ For this project, you must have [AMPL](https://ampl.com/) installed on your mach AMPL is a proprietary tool that works as an optimization modelling language, and it can be interfaced with many solvers. -AMPL is sold by many companies including Artelys. You can find keys [here](https://www.artelys.com/solvers/ampl/). - To run OpenReac, you must add in your `~/.itools/config.yml` an ampl section like this: ```yaml ampl: @@ -23,6 +21,8 @@ ampl: homeDir: /home/user/ampl ``` +AMPL is sold by many companies, including Artelys, and you can find keys [here](https://www.artelys.com/solvers/ampl/). + ### Non-linear optimization solver To run the model implemented in AMPL, you'll need a non-linear optimization solver. @@ -35,7 +35,7 @@ of the solver is done and that you got a valid licence. To check, start a bash a knitroampl stub ``` -Artelys is the company developing Knitro. You can find keys +Artelys is the company developing Knitro, and you can find keys [here](https://www.artelys.com/solvers/knitro/). --- @@ -55,10 +55,7 @@ you set values for active power generation and HVDC flows. Then if you wish to do AC powerflow simulations with N-1 analysis, you need all voltage and reactive set points and this reactive OPF is your solution. -Please notice that this reactive OPF: -- does **not** decide active power of generating units and HVDC branches, -- does **not** take into account current nor power limits on branches, -- **use** upper and lower limits for voltage, so be careful with them. +Please notice that this reactive OPF does **not** decide active power of generating units and HVDC branches. ### 2 Division of the code @@ -72,7 +69,7 @@ each serving a specific function: Refer to sections [5](#5-slack-bus--main-connex-component), [6](#6-direct-current-optimal-power-flow) and [7](#7-alternative-current-optimal-power-flow). - `reactiveopfoutput.mod` exports result files if the execution of `reactiveopf.run` is successful. Refer to section [8.1](#81-in-case-of-convergence). -- `reactiveopfexit.run` contains the code executed when the problem is inconsistent. +- `reactiveopfexit.run` contains the code executed when the process fails. Refer to section [8.2](#82-in-case-of-inconsistency). - `reactiveopf.run` executes the AMPL process of OpenReac, calling the previous scripts. @@ -129,10 +126,11 @@ All of these files share the same format: 2 columns #"num" "id". #### 3.3 New voltage limits In addition to the elements specified in section [3.2](#32-configuration-of-the-run), the user may choose to override -the voltage limits of specified voltage levels. These values are defined in `ampl_network_substations_override.txt` and +the voltage limits of specified voltage levels. These values must be defined in `ampl_network_substations_override.txt` and are employed to establish the new voltage limits as specified in section [4.1](#41-voltage-level-limits-consistency). -Format: 4 columns #"num" "minV (pu)" "maxV (pu)" "id" + +Format of `ampl_network_substations_override.txt`: 4 columns #"num" "minV (pu)" "maxV (pu)" "id" ### 4 Pre-processing @@ -154,7 +152,7 @@ its associated corrected low (resp. high) limit. Then, the limits are calculated #### 4.2 Zero-impedance branches -Branches with an impedance magnitude (calculated in p.u.) +Branches with an impedance magnitude, **calculated in per unit**, lower than the configurable threshold `Znull` (see section [3.2](#32-configuration-of-the-run)) are considered as non-impedant. These branches will have their reactance replaced by the threshold `Znull` (in p.u.), @@ -163,16 +161,16 @@ These branches will have their reactance replaced by the threshold `Znull` (in p #### 4.3 Impedance of transformers In the calculations of the ACOPF (see [7](#7-alternative-current-optimal-power-flow)), -the transformers with an impedance (the one specified in `ampl_network_branches.txt`) +the transformers with an impedance (specified in `ampl_network_branches.txt`) considered as null (see [4.2](#42-zero-impedance-branches)) -are treated as lines. Then, the transformation ratios/phase shifts are ignored, as well as the impedance +**are treated as lines**. Then, the transformation ratios/phase shifts are ignored, as well as the impedance specified in the tap changer table `ampl_network_tct.txt`. For phase shifters transformers considered as impedant, the reactance values from the tap changer table (in `ampl_network_tct.txt`) -replace the reactance specified in `ampl_network_branches.txt`. The resistance is then calculated proportionnaly to this reactance. -For the ratio tap changers, the impedance remain as specified in `ampl_network_branches.txt`. Please notice there is no -specified handling for cases where resistances/reactances are negative or if there is both a ratio tap changer and a -phase shift transformer on the same branch. +replace the reactance specified in `ampl_network_branches.txt`. The resistance is then calculated proportionally. +For the ratio tap changers, the impedance stays as specified in `ampl_network_branches.txt`. **Please notice there is no +specified handling for cases where resistance and/or reactance is negative or if there is both a ratio tap changer and a +phase shift transformer on the same branch.** #### 4.4 P/Q units' domain @@ -186,7 +184,7 @@ Let $P_{g}^{min,c}$ and $P_{g}^{max,c}$ be the corrected active bounds: - By default, $P_{g}^{min,c} = \text{defaultPmin}$ and $P_{g}^{max,c} = \text{defaultPmax}$ (see [3.2](#32-configuration-of-the-run)) - If $|P_g^{max}| \geq \text{PQmax}$, then $P_{g}^{max,c} = \max(\text{defaultPmax}, P_g^t)$ - If $|P_g^{min}| \geq \text{PQmax}$, then $P_{g}^{min,c} = \min(\text{defaultPmin}, P_g^t)$ -- If $|P_{g}^{max,c} - P_{g}^{min,c}| \leq \text{minimalQPrange}$, then $P_{g}^{max,c} = P_{g}^{min,c} = P_{g}^t$ (active power is fixed). +- If $|P_{g}^{max,c} - P_{g}^{min,c}| \leq \text{minimalQPrange}$, then $P_{g}^{max,c} = P_{g}^{min,c} = P_{g}^t$ (active power is fixed) To determine the consistent domain of produced reactive power, the reactive power diagram (specified in `ampl_network_generators.txt`) of generator @@ -217,20 +215,19 @@ TODO: add figure. ### 5 Slack bus & main connex component -The slack bus $s$ is determined by identifying the **bus with the highest number of AC branches connected**, +The slack bus $s$ is determined by identifying the bus with the **highest number of AC branches connected**, within the main component (`cc` set to $0$ in `ampl_network_buses.txt`). If multiple buses have such cardinality, the one with the highest identifier (`num` parameter) is chosen. In the event no bus satisfies these conditions, the first bus defined in `ampl_network_buses.txt` is selected. -The OPFs (see [6](#6-direct-current-optimal-power-flow) and [7](#7-alternative-current-optimal-power-flow)) -are executed on the **main connex component** (i.e. buses connected to slack bus by AC branches) of the network. +The OPFs are executed on the **main connex component** (i.e. buses connected to slack bus by AC branches) of the network. Consequently, **buses connected to the slack by HVDC lines are excluded**. This component is determined by solving the following optimization problem (the variables are bolded): $$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i}$$ -where $\boldsymbol{\theta_i}$ is the voltage angle of bus $i$, and with: +where $\boldsymbol{\theta_i}$ is the voltage angle of bus $i$, and with the following constraints: $$\boldsymbol{\theta_s} = 0 \quad (1)$$ @@ -238,7 +235,8 @@ $$\boldsymbol{\theta_i} - \boldsymbol{\theta_j} = 0, \quad ij \in BRANCH \quad ( If the solving is unsuccessful, the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)) and the execution is stopped. -The sets of buses and branches belonging to the main connex component are now denoted $BUSCC$ and $BRANCHCC$. +The sets of buses and branches belonging to the main connex component are now denoted $BUSCC$ and $BRANCHCC$ +, respectively. ### 6 Direct current optimal power flow @@ -254,10 +252,11 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF model involves the following constraints, in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-connex-component): -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}} + \boldsymbol{\sigma_{P,i}^{+}} + \boldsymbol{\sigma_{P,i}^{-}}, \quad i\in\text{BUSCC} \quad (3)$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} + \boldsymbol{\sigma_{P,i}^{+}} - \boldsymbol{\sigma_{P,i}^{-}} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC} \quad (3)$$ where: -- $\boldsymbol{p_{ij}}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{x_{ij}}$. +- $\boldsymbol{p_{ij}}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{X_{ij}}$, where +$X_{ij}$ is the reactance of line $ij$ (specified in `ampl_network_branches.txt`). - $P_i^{in}$ the constant active power injected or consumed in bus $i$ (by batteries, loads, VSC stations and LCC stations). - $\boldsymbol{P}_i^{g}$ is the variable active power produced by generators of bus $i$. - $\boldsymbol{\sigma_{P,i}^{+}}$ (resp. $\boldsymbol{\sigma_{P,i}^{-}}$) is a positive slack variable @@ -271,7 +270,7 @@ where $P_{i,g}^{t}$ is the target of the generator $g$ on bus $i$. The sum of the active slack variables ($\boldsymbol{\sigma_{i}^{P,+}}$ and $\boldsymbol{\sigma_{i}^{P,-}}$) is penalized by a high coefficient ($1000$) to drive it towards $0$, ensuring active power balance at each bus of the network. -The solving of the DCOPF is considered as successful if this sum does not exceed the configurable threshold `Pnull` +The solving of the DCOPF is considered as successful if this sum **does not exceed** the configurable threshold `Pnull` (see [3.2](#32-configuration-of-the-run)), and if the non-linear solver employed (see [Non-linear solver](#non-linear-optimization-solver)) finds a feasible solution without reaching one of its default limit. Otherwise, the solving is considered unsuccessful and the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). @@ -280,8 +279,7 @@ finds a feasible solution without reaching one of its default limit. Otherwise, #### 7.1 Generalities -The goal of the reactive ACOPF is to compute voltage values on each bus, -as well as control values for reactive equipment and controllers of the grid. +The goal of the reactive ACOPF is to compute voltage values on each bus, as well as control values for reactive equipment and controllers of the grid. Then, the following values will be variable in the optimization: - $\boldsymbol{V_i}$ and $\boldsymbol{\theta_i}$ the voltage magnitude and phase of bus $i$. - $\boldsymbol{P}_{i,g}$ (resp. $\boldsymbol{Q}_i^{g}$) the active (resp. reactive) power produced by variable generator $g$ of bus $i$. @@ -292,22 +290,22 @@ specified as variable by the user (see [3.2](#32-configuration-of-the-run)). Please note that: - Units with active power specified in `ampl_network_generators.txt` that is less than the configurable parameter `Pnull` **are excluded from the optimization**, - even if the user designates these generators as fixed in the `param_generators_reactive.txt` (see [3.2](#32-configuration-of-the-run)). - Therefore, when the optimization results are exported, these generators are exported with a reactive power target of $0$. + even if the user designates these generators as fixed in the parameter file `param_generators_reactive.txt` (see [3.2](#32-configuration-of-the-run)). + Therefore, when the optimization results are exported, **these generators are exported with a reactive power target of $0$**. - **Neither current limits nor power limits** on branches are considered in the optimization. #### 7.2 Constraints The constraints of the optimization problem depend on parameters specified by the user (see [3.2](#32-configuration-of-the-run)). -In particular, the user can indicate which buses will have associated **reactive slacks** $\boldsymbol{\sigma_{i}^{Q,+}}$ and $\boldsymbol{\sigma_{i}^{Q,-}}$ for -reactive power balance. To do so, these buses must be specified in parameter -file `param_buses_with_reactive_slack.txt`, and `buses_with_reactive_slacks` must be set to $\text{CONFIGURED}$. +In particular, the user can indicate which buses will have associated **reactive slacks** $\boldsymbol{\sigma_{i}^{Q,+}}$ and $\boldsymbol{\sigma_{i}^{Q,-}}$ +, expressing the excess (resp. shortfall) of reactive power produced in bus $i$, and used to ensure reactive power balance. +To do so, these buses must be specified in parameter file `param_buses_with_reactive_slack.txt`, and `buses_with_reactive_slacks` must be set to $\text{CONFIGURED}$. The ACOPF involves the following constraints, in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-connex-component): $$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC} \quad (4)$$ -$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{Q_i}^{-}} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{svc}\boldsymbol{b_{i,svc}}{V_i}^2 - \sum\limits_{vsc}\boldsymbol{Q_{i,vsc}}, \quad i\in\text{BUSCC} \quad (5)$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{Q_i}^{-}} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{vsc}\boldsymbol{Q_{i,vsc}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{svc}\boldsymbol{b_{i,svc}}{V_i}^2, \quad i\in\text{BUSCC} \quad (5)$$ where: - $\boldsymbol{p_{ij}}$ (resp. $\boldsymbol{q_{ij}}$) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, @@ -317,15 +315,15 @@ where: - $Q_i^{in}$ is the constant reactive power injected or consumed in bus $i$, by fixed generators and fixed shunts (see [3.2](#32-configuration-of-the-run)), batteries, loads and LCC stations. In order to bound the variables described in [7.1](#71-generalities), the limits specified in the files of network data (see [3.1](#31-network-data)) -are used. We note the following special treatments: +are used. We specify the following special treatments: - The voltage magnitude $\boldsymbol{V_i}$ lies between the corrected voltage limits described in [4.1](#41-voltage-level-limits-consistency). - The reactive power $\boldsymbol{Q_{i,g}}$ lies between the corrected limits described in [4.4](#44-pq-units-domain). -- The reactive power $\boldsymbol{Q_{i,vsc}}$ is included in $\[\min(qP_{vsc}, qp_{vsc}, qp_{vsc}^0)$; $\max(QP_{vsc}, Qp_{vsc}, Qp_{vsc}^0)\]$. -**The bounds are therefore rectangular, not trapezoidal.** - The active power $\boldsymbol{P_{i,g}}$ also lies between the corrected limits described in [4.4](#44-pq-units-domain), but these bounds are only considered when the configurable parameter $\alpha$ is different than $1$ (default value). Otherwise, all active powers evolve proportionally to their initial point $P_{i,g}^t$ (specified in `ampl_network_generators.txt`): $\boldsymbol{P_{i,g}} = P_{i,g}^t + \boldsymbol{\gamma} (P_{g}^{max,c} - P_{i,g}^t)$, where $\boldsymbol{\gamma}$ is optimized and lies in $\[-1;1\]$. +- The reactive power $\boldsymbol{Q_{i,vsc}}$ is included in $\[\min(qP_{vsc}, qp_{vsc}, qp_{vsc}^0)$; $\max(QP_{vsc}, Qp_{vsc}, Qp_{vsc}^0)\]$. +**The bounds are therefore rectangular, not trapezoidal.** #### 7.3 Objective function @@ -333,24 +331,24 @@ The objective function also depends on parameters specified by the user (see [3. The `objective_choice` parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function. Specifically, if `objective_choice` takes on: - $0$, the minimization of active power production $\sum\limits_{i,g}\boldsymbol{P_{i,g}}$ is prioritized. -- $1$, the minimization of $\sum\limits_{i} \boldsymbol{V_i}-(\rho V_i^{c,min} + (1-\rho)V_i^{c,max})$ is prioritized. The parameter $\rho$ +- $1$, the minimization of $\sum\limits_{i} \boldsymbol{V_i}-(\rho V_i^{c,max} - (1-\rho)V_i^{c,min})^2$ is prioritized. The parameter $\rho$ equals the configurable parameter `ratio_voltage_target`. -- $2$, the minimization of $\sum\limits_{i} \boldsymbol{V_i} - V_i^t$ is prioritized. +- $2$, the minimization of $\sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2$ is prioritized. The objective function of the ACOPF is: $$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ where: -- $P_{i,g}^t$ (resp. $V_i^t$) is the target (resp. initial point) specified in `ampl_network_generators.txt` (resp. `ampl_network_buses.txt`). +- $P_{i,g}^t$ (resp. $V_i^t$) is the active target (resp. voltage initial point) specified in `ampl_network_generators.txt` (resp. `ampl_network_buses.txt`). - $\rho_{ij}$ is the transformer ratio of line $ij$, specified in `ampl_network_tct.txt`. -The sum of the reactive slack variables ($\boldsymbol{\sigma^{Q,+}}$ and $\boldsymbol{\sigma^{Q,-}}$) is penalized by a +The sum of the reactive slack variables is penalized by a high coefficient ($10$) to drive it towards $0$, ensuring reactive power balance at each bus of the network. #### 7.4 Solving -Before solving the ACOPF, the voltage magnitudes $\boldsymbol{V_i}$ are warm-started with $V_i^t$, -as well as the voltage phases $\boldsymbol{\theta_i}$ with the results of the DCOPF (see [6](#6-direct-current-optimal-power-flow)). +Before solving the ACOPF, the voltage magnitudes $\boldsymbol{V_i}$ are warm-started with $V_i^t$ +(specified in `ampl_network_buses.txt`), as well as the voltage phases $\boldsymbol{\theta_i}$ with the results of the DCOPF (see [6](#6-direct-current-optimal-power-flow)). The solving is considered as successful if the non-linear solver employed (see [Non-linear solver](#non-linear-optimization-solver)) finds a feasible approximate solution (**even if the sum of @@ -360,7 +358,7 @@ Note that if the solving of ACOPF fails, and the $\alpha$ parameter is set to $1 then a new resolution is attempted, with $\alpha$ set to zero. This gives more freedom to the active powers produced (see [7.2](#72-constraints)), leaving these variables free withing their respective bounds. -If ACOPF solving fails, the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). +If ACOPF solving fails another time, the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)). ### 8 Output From df90f42ef281fdb1d3a1dd7b0f1d9bb1a67c44cf Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 19 Feb 2024 16:30:38 +0100 Subject: [PATCH 43/51] Add reactive-diagram.PNG image. Signed-off-by: parvy --- open-reac/README.md | 2 +- open-reac/image/reactive-diagram.PNG | Bin 0 -> 14258 bytes 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 open-reac/image/reactive-diagram.PNG diff --git a/open-reac/README.md b/open-reac/README.md index ba675324..91457005 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -211,7 +211,7 @@ as generators with zero active power will be excluded from the optimisation (see The general correction of the generator's reactive power diagram $g$ is illustrated in the following figure: -TODO: add figure. +![Alt text](image/reactive-diagram.PNG?center=true "Reactive diagram correction") ### 5 Slack bus & main connex component diff --git a/open-reac/image/reactive-diagram.PNG b/open-reac/image/reactive-diagram.PNG new file mode 100644 index 0000000000000000000000000000000000000000..5d3fe2a380d84472c6dd927dcd6503df7161c0eb GIT binary patch literal 14258 zcmch;^9me8dZ z5pV(N_|D?%{rwX@KlqS6XJ*blbMEW9ult@k5jt8bH%RV~Kp>DCs*e@*AP_Sb^Rs|hg#{}FiVsVG1yhUwS9k4p{@H6KDC)v=@}*2LiVwdapbJs}VpR{TE#RXvtJ z5Qw;ns^UWfUyF^oYb`vhndi9n|9)dG3)jC^w|`cB>Gtuh!N3tSjOV(RR5}TWa-uq^|>axV^_T3xZxfGVX_MxiFs9E_%UO781EK#bIB+H(0CSgqARp{v;73ip7GHvYLq zEy_1qxKX2tLmVHuJ2D2ffQ1TS;Iv2+km8c*CQc;1Gg0qlq*5ct2lHsD^cCZrE3(h< zIQEJYRX3+7a>2Z&jyo+|!9eLa$i;efO(3Y?!&BR_> z`l<(G$WL84UHAM>MZd=*0n|$UwEfgvFEJRUL#_R>)tSOdPcM0DTX(^wV~+96lFY^L zesjIYU*VWQ^d)ujDZMTPk$Mq(ZbEo=qT2oZSc_cQjd2t6ybtWP^+ihWD3!J5+6Ma& zt~qKPHMN}ekn0(qFG)G5`TP9}E9=bt9t<aHh_f}MIIVRq45dlaeA*T+(bb~H1$`N;i#kk~x)ecmoXU78u?+8>N9LewCH`~}vG?BdnO!QY z87A3>&^#V7rM}lsfWjHQ@rd45O;^`L#%`Ny2+Pl?q@#b?`*$BQn=>xMmm@2_)ncCA zk!R!kT3&z=kF{{G)-$F{D{7;boXMsU^>%P_x6!N4KSo82#Hymb&=P$jb47bUIlUIx zwO;czwlD_s%hD8nF4D8E9g#bxl5fi**8g2Qp_TEw{rqhC#oQYv5>mu!vF9s~m)c&n z<|DQ)#t*1hzyjsGH%<&+#PJU(9RYM8RYt7hBgY^HlpXsY9O=Jgb zn#M4CPwHB8R}uJI{F3~*`qbPVgW-~G`UKvQBwf@-2F%toEsJ#5-G>}jxZtTe5T8qDPCh|pK+#}gzxxk|O0G&RptUOsL-tSehJyuHg#V^Xak%G7sP=jRi%H&N&HetqtfowWQWQR2B3SClY?UnbYDlW&b4ZCnc+r>zkf1J*j~* zmo-&87_=!QYJV-T*hXW~KU(TxRFt5Lr|aJrVGg61+k)`+*@&_p^X>?T)oHu6&k^j| zCMU+^k^#zQd9(Q&n%#aJv{Do@Cx5!wi*kbe8&%q=+x>PG0_&%i22l$*0g7a6~yI<^63Uxm(VIH&l zdCQbe+PyJb7x6|T37w2Wzp|eOzg}0k5|ytiPr?7fplmF`@0kHllW%`kli#zcv{cH> zTiRS&AuUAYcQM|NBiYzpZ3pzzH{3q8*eKd(WtwK>_a2uGsNmX;f;z>IgQGT45l&NJ zXiu8(`R%`F$bqMPxrNknT<rqAe@m<+4zH;sD-w8G|W^d~p zXB(V7lCM4s=l?mxm7Cd{3ctfcE7g>iZ_qMp^`tG5f21I9s|e%l$o>+g8)Gpx7)P1( zC`>=Y`;wN`8k6UUn!8b>hZg-Bs|@SSoKwz1UPw+|c5ck(YK<%_pZVFu{!*5IYQNuq zGk1y)ZU}1H_m8O$b8C7i1a^wMwA!D%NpWhp8~-AWcA!AG5o48sOg{9P7&kRPp9lR!dTcHUxievku@Lk!!!eYghnjt5LSZIMn|MJbD7-@$( zN!1CL*2@O_#(9ON+hTs?q?8THC1!}*QT(l%iwf!uj8SX1@02bR|7fx)j!A%R3S|w` zi}utW^`mN3$f$+XEV%4;|JJ^y${AV<(j3NSc8tqQlx-n4V3)f!vQb8S?i2-q`3$;T zK~$O!1K#o*D*NuXTKw{(`;Oyfl%%vd9bgqPG9oVZFfhYH@fIo-PXB>EwK1=$FGHK- z!cbZxmqgfe#=p@Ns--=&x`5^CRsGp zm*&ttp$@m`9JOm@m-?A0R2uSB>iEO#3OvTCFr)0dLmPe3Xj*#P-gk>R1+9I{h@y6H zMs`-3_xssVfT{ix*9I*@S=K z%BITFKBl(4WsGXmUYK(BNZiXB8ONlGX>N9ZVENFgYU!*QO3Dq!ebRE)A*>gr;`1`R0Po!l+dPdu8JXC_OIl;E+g5K*Ig1@HSk+;e z)Eok93hR>+Wm+pRs;Yg*j{clCxqtrEjrU{nP8!xAcz5txb8Ka)Y*WbG_3}OL zyzdOlmxm5~->5R0U*}X2H5D&GOPq7eP{H7ql}!Q4sOOxaUxzfDl+~1|{fE|bcHQGz zLWJcq460YwaBVCs*WWK>=AU3*J`Q_dKRu*&c!__x^CMrZb%~eFay}|Ab8PqZfHVI@ zYJGkGejhLQ^R{24B*oP_onxU%>M{(A+vZz`8ZKj72DtAZirW4PYQ=QS$~Y(X)S9x; zny23rHz(UYVh2kTmtPcbL3(lkGzj@6$(V zP^roBC412nmEh#qSgt4TXt>KHH7P5773tSUmYY#y5qm#xbL_@A^d`w8mt>NLBlq1~ z*;Ia|I=<<1ctHj)-=NZVR#oM2jk`HjUJYI#Du%HP|p(R+xjo2 zzaNxOe+VH|9#ql`>?yvqw00nuHDrCmv0gQ9Q5-2?Hg9H;L-lrhfNAH;`zdEVC;{_| zP2U7Y%XemKSw!ajG83n3QNAgs_|hZ~l|L_EexeGEEc1snc3O2Qg5Nv-nj{>M4v$8Y z?U$Zma?@h|ljU^}D)0}4K)4IOvnj=-FfB!v8vgPjDDa7O>Nj@a%%1sb8oA(9C@B6k zDjG3;1&zhq*A4s+HIyRi*MkJ- zjFn>d61L&L&Ri1?&yG?zgVPI-uRtKLbXq>{XY#`j<1-F#J&~GN`m4lA3&ZgwH*usF zR7hm>5Z_Pv1%c4L(ZAzjdF4H$gLu zel+@S%h{LvMFOoF^rM1)2KCJ|O$GT^ zY`elkbM2}kb>7ZrXEinxg;lRE*FWpqvNd`(Pyb>x#32>k6LcJQPvrUT*dcr{l8Ef8 zwBwI(=I!HD>MM+(MMvJ-m3={OulB-SUk`Bc=v=%Y$Jv#!Mxk9LS0xhh$(GCHi(Pp#a?c!LeX@(j2UH$)PB-?TWM)8C5kzcL(b_Q zI_k>?KW#6SZs537J#`$~k}rlo|KNl7GhU{KcGxpc{NLCh&{rY02><7K4rsFL$qTw3 z$*%0FT<4eDNgH`>C;1E&_g#?s8j8Fu8dm+&=5ZX2AcOis$x1$V*0o4dj&~?w13o*L zmlG@}z|udH#Iiq%F(r~m{spx@SJ`eIgRzw7io#G}gwFns+%CL!WY)jT@36Z521)VC zLxQgy9J%RNhz)jfL++@^{I(`1jqo^#WUjI0(-}8qi6Tw%O77V&=hhpqdwlc+^-ck$ z39DN3T+l{E?cZKdA=ZQ~Ve66FC-B<225rX555$R$R^u<`w3VJb;c-pelhxLNijtEQ zD}x8gTs&y<&tfNS+n*&B`6J!OiCxC@Y4!l1m!ViV%iU_&0>s42?s(0Sx^ z>!$Y$rUzGFnl$(hduCI9`YGXM38j{=6#}O1@Fdt^;qf8?1-IFTBzU8OUy$vN_p#@| zPW(UiEiLm0`_U1HxHp|{xLNl37`GpN?fT;DbsUMdd(oFtFXAce#dR6o^2m+iWXC%< z#Wis8E^T|ZdEXM7c#|p}L5RDbI?kVQRT|ZPe%$_c42RvLo+fRemPD2n2@cJS76izh z9cmp*+7?*gB8{oq)1L~BMN>hdO0vLjwWi|K3+I)ljz>(3leRPkC;**=%91T($CzY$~oID>cTbxL)Qm9n{)^YZht(; z@^IuoZOS*!-u=K%-JbkZ=y2=&Y)gP7S5#E@9Z@T8k@4L3Q!hh+!S-D049y2*0LuHE z8TDzJxSaAl`X2UOW$@`bs`A4V8ChI}_H_hgC0~a2ivQwI@?hVzReD=zv-iI?v7U^q z#OoQz#hhxQR`;!dh312#-)d~g#Qo-lQ@&`z)F{s^qSim(M}q1HJ>6xFzmJe17ANP% ziV72@8oh6m&y9^pknMJYX`NxFbv4;)c_B1VKR&Wug_-&vPmPfd z|L&zL)`9+t|3eoNj9tFiWe812({O0gKpn5|PR0Vga&KufLi?qqZ z7gD__`6Chir2!uj>W4MOR(f%XXP>QogjR*DWY072nUt{0ANHXt^U^ii_UbCbbRl;O z!GapCfYL%bY>A1Mb0>2#j~wnucds4A2ydF#t~t|)l8!H`G0aYS>UsP5T(`UfvC+!i zg#%?AcQK7NeyudXT9s*lwNju(jxN2GKd}bAzcRwptH%@W@4L!cb~^jtetz#B+)K1d z$O-+jb#ErBp131_P4od-nPP>@=bG%lWdcYBqu^c5W{p+#P@elLBg->1Ex-TcCq+PL zlq;{fTd{6Fe=D8nH(X5y=2$9!baLhG#DEuH8J0PWpm9yp?TIRzc)IuZI~{?$$eUM^ zH_P4N&S|R{lehK6CBT-TUW=A*Fk!7T+b;a*t)C>`OxP))33HkK&BKY*eTJMZY6d-H z(DQrs)^@FBXV{&E!3m875_WjG(lTF}2{eY`xQp=&iYBy5yLbTCbo~$goFfA|bN*9_ zqg_|&I>FI|ho}S+PMY_&5JxizPnrckrel0*hDK)T0r@q=x4>v$iRw}ou8N{^|y_!xV*UGZNbVm#<@?R#BM4C(n5O~~`E}aW0q$~=CektC%rfKa3FRu?FyvzZNYTbgn;ps;e zO*6Y9)^Lq^{T<;`>>j%E4i@i$n;t2pEC~U#iwt;Emiky z^|QAVg+jY=Un_$|qX|2FPnOu_)1J-Lmc(yOHGzi4vw7TPShZYXe7zzKipg~$2&wj8 zVrDe$^Pz3|LCh|H@R_`m!xwcAiOH?FB=rbQ2w7(WwlyxskRoncxWBECDCQ2;0*l+S zTflzJRMI+p>iBL?3!dN{7dwaP_qDr8tp7} zDif4N<5?yA6}epFpeNZ3&0x>}jKAbU8j|f%;c3<7;X*op&?Ejvck<`|#;^uB_Q&J+ znF+x0R70CL-DeSc_#>Ya+}DmbCu`cl>Cfg{n&LG!gZ7)>>O#1UW!SkxZ}ipi9(1$I zQ78-EP+`0&d4xsysIyrf_8WI{gd}liCnR;u1|3c0Xzk5bCG_v zm?fcC{tRbL1?8t28BnuwRiSrR1hihu>-ZKyeieY|Iutisc4;Nv+3e4tgPd@5{$@Ir1X|P&v!A(sUQoi8B0ps|- zxy=_10wj>d?UPmc_V_KTTHaK0VydYb!Cv|rGod`-wt{--mr)kG`ALEMKd#72MCbF8 zaFmq`4@*eXZo9d<+&9B49KPSfBfFGxrr43G=tB z7j1+<8{o1X$S>e!9`wpHC|6UoV93mIcEy(p`@yyCly-V$0xOvpzrR(Rp3^Cn0>%JvIPFM=WqPL(Gt7gCxiJlwOXlAz_s zb6Y_Gki{;aD}(-)g79?{gs(4B8?_Vve3~ZeABdn+Z{>FL0E0XPd>fLuih&w|h3q$O z^Pu~j|NI|FOu>YdJ3;K7!?VE88*Wz-CR8zPdHRGAM9si4eW#n}sg((?M*=u}(*)f+ zh{&%qo3MZ;p10hs#Ely}sry+l5=-wNbzTkm>|WuSiy`LseF%a^uFFGliK91K*I395 z=mUONb0x-jmXYxQpu+cVuL-ot7g2q0e@vv%lXbpVbY$4x;KtOERn=F&p z#q4?8PL|s?n6!Ab&Dj4nDgfREUg~%~gidNz>WUh8$=bn36I~q04uDj%dIO>YKohj> z2PlAgE9#MDwOp@N>4hc`p194|)T}R=|HO82%wcF60DjiZxBRUyb>vcytg2aU1HwlD ziPLiSw~`!zB~f8iUKOqM8*=Si`jDUnBF*J;UpZsKgmu`e6i^(a^;VJ+M*>p#g)H;c zGPW54K{xQXEh8xcdkgdp13~%=^~jo9Sv4@I3+!b@=Q~sB(A}uxm6&cCHdJMch5xqg z;t0|GhOE2e{Cg}m$cuF$YrkbRD-alb4S~HwOr^Ydw%;BM{2g;ECG`aO5)g3$3_0f~ ztK5fLxY{CF-e{ZK9JvA{jAwt|0`}ndAB(#1cXJSEF8qC47ivufxWLMMv_6*+H1!1r zS7`yzHz2>3cV117AS8L!0Cp%0;`_jAOkW@Y==3Up1jbXWN*4!c@f0iO^06n~@0WfK z(oEg2)TpATr-Fe-QI8u4)ECY%xTtO0z3+# zD`k$A`4qq9Xjb)vO6QTWOaxc8^8eWt%#r)1!uOV;jpiu8k`$iTfw%_#Mom%-od0o> z31vgeGVcHjrg77|@~$$(3O0W@?1LvI@5%skI@Cu1dVuPW-FJL9oGs1R-bNVWupKAAw(2JCAud314W;=4%gpx10#ySoQ}2IR`*F{~3m#4R|L%Ao;o<;E^T#fj>#{fiUO% zFsF;-$ZEE-aUFV%B_{6Zi;A2ceky-0&w&syxeL$}J-Ki?w~*vFj57}YYixZ9E;x^H zGna^vQ2yn1w&DgL3DiJUAs`0kUB+`9BN!M^>8bF%@vL_qh;mm?(e0;Z|3pJoA>anO z2QxI+yCh=UyfG{oy1ZJK&kN_L3vVeP&b>{;f+RG06kbv8F z!EM#)lMBHKQ4*s2k3b3i@@HO%0zX*nv!lv$sc49avyxnK_f^1U*tuS;I0?tDR)tIG zt?LktdY96ktJq6|!#+}>is!n}JRcG7d+d~&E<_;la#8?^S1m8yWzZp#Mzipr@_XzS zIhJ9I2~+`($qi9(!)_q)nBfC~f3l6Z3rY|+{}@eEoJS8dV6-lH&Ydf^5*)dsq+qd* z5-vjol#db&+}kE{$~vnq{Ia{W8@d+zUr(Q6um&Zh=W+1$e^a|oPCN<1K#SV-(RGV` zcTQuO2BA{`BltV5-=>HiYw;dPzTKD?3i;it-*EK)_0Fvr3e3->WS)SN5 z)Dx5Yb`W)Pym^Bcl{i{+kn?5`|-sT$^9*{rg|h&W(@lcSUx87 z0IMSZ1UM=l&TIg0moXJStss8@D57ioNe}-5LdJCEXqzz&Asv*!3SNyCb4K^*d!Pbv6{VCTa*Nh8woz!0aDvuCp!w!8+15esm13Wp$<|Z zcOV+&qiwK9=aErsKwir3Wo-pIc+Br)1MP@sEJtAMm@S^92V_=t&@bJBkI~=}(_0Ag z8p#L=|7ajl#0EhdeK5`TpmvOn7$6IOd}DxL>G%+aJnndm_CJn{KEVD&BEUTMJU zwK_|&YP+LBr4Q+qR1tO~ftQ^Rse^;pqHGMeAXig^Z?i4CW&#Q0^Mg5 zfHul248B&ZX?R*U8LPLF1<~jy-p(vw(8UiBhhH_ug)iJiNiqW5%fn&<$Oz<>@cu1a*t;_@qFe_TxGJXq(>`&f95Z6V?VqlGZR7 zF-f%>SF9q-h1aJto9?ltOU;0nGi!NGm@h!(#9ggG?mznKA7h481L1Ko$heV>lH3_C zHU-EReAwcip$WMFk}Inb3(zDWyhukwIvQJmb^w|eRSK*Ti1dC)AnJvpY`Db@vZaYwYTBq} z5YqCu;9CI+0JbLpDqz{6MIaWaCpw!w?}_ANw)vYJuxpJ2?yjC#&)bMq;+Oh9_R2mR zq6{3ln#J;LJ7qwIwigI=O6BU9}e zf?QiLfERYU{p_!+3n`iG?kIQ})2Eafr>k#*R?ImdRePb1uWnU&DQ%W0 zssIx}#ZEpr0U2;xF<^SSX<8WL~pQjw)~}${yqb-;mzU z03@tj+uE#B&tKi0%>^q+L?&@R8q%x-wJrou{0z$3K;87!hD*l~OaFXL$#tj&RQwXS z{m}u`gqv9tMgU)5lriwmv^1X522|tRe%t;H1eBVX>M0!1S`I!dE@q*;kX=B0x&`fI zSW^|}hbWYHk;}KlYk-VW8-Eiol@YOWQqhFXV2(z>U|cUFBfvWhpQ!>>w=$IBWEN6_ zM+Sm82^0xV_t5+o?!PL#Rf2baP&5!AS^Ae$Rdy4$;NH36->q8!8hs%|Z@Bq(skJqK zA9AHp4)MQ$-goY52)<+hf+ADtw#al}N`tiWy=Nv%^UYVh>qF9kW z8fDaCijf3{Z2~TTLjh_Wt5PcJ{O~n(Jl?Lz{RtHy5fNYD<~w=>f>ttcE-l%=lOU?g zB4lV)NZSFMu%|Q){s&T~M&JRI%Aqf2+A;Z-0Li?dfFYj>`}2|(WRdv1*?$NGrA}Ry zdxk4b07fBxb>R8(YWLl1|Ga-I^FiZ2p4hOmz<@`!ydC*<0Vt(&z%gT^_`r@YJhiOK z@`IqS4JI(A1Dpb%TnLcVPM=`!CNRg&9(GIbeXFwW*gX$N-~}T-Ndjqu>;7Q2IEkd>F;{7?F)dUcSUbs#~oj$y>FAj&NaN3Yy8IGz^U6T_4}Shult=<%!%25h z-78&G?d!%s%gC+}x)xrz(lk3=jVCA6qmOJC90X#h)$K^*qZsNdTa%-#qSOy@(b{Dd zI(nh`_yN9u%tXS|rg^_^)NBg&%ut!Bd(@Shm-{{jh5CD-aE(t%@ii=v3d=_mM(OK2 z@w|^DGau$6!wA_R?P%Huc#U%>snsk7s3u%$HEkumiQ^BeyJNdj{)$Y!W;E6&DF!?@ z60}!y!JBx^U{~3?_i?Ei)RpF~sZ7c+NkP|O21_J&skyU%_L=YXQ;X)iIO!(v&1-EX za3eJuzM3Fklx%*o$O0RJ)Haby=(g57abQqTuK$T2bU8vh&;}H80op1i4Jb)hn2IZ| zrWsi|1w5JbE#!n7!(h-76IF*guwACv@NQZ`6n|FG=g*-Wj`bleY(BOktK~TolI*1-4uZ!vhlT*{d*gwz;3WvvkxZTVqV#3 z?jDy{%*|9d1pS+K?q)v7Bf6YZ&fGY+;c6V%#GMAVSEfNFP=F7w+I>;nogAa@@V#(@ zG4^)99AR-5a_iEk3*+7<11mXM2t2fDr~@DZ3gT_Jcc57IZ&wXjvqRmWUSppUXsRjr zf!5D_X5w6x(YQ}uTIB%%!!dfHZI%r3s=>vK)dFY`izkE6u)6SHK@B^dhwW8PvQ$V>6bcL3r9_yi2Qlr zBiKPFEuS3N)dJyLfa}4uBqp%v08|edT(5eSN)Sp@S!SzuZE4xM4EM0ePfNu8)}<;2 zrPbK38w6ID6e>KsCAU9`h7@NWdI<)M>1D2`}?GmZyWBZ z-jP0!ek5@rlR3Z%-n_sfvCAEws8y^~Y8_{<_{~tzgZhB`Rn~+w7t-Cmg{7c(h>~)% zo&6l@3^A}TUiF`P5Mzza&I;H#FDzfopgG>41-s&7Dyv{u90-ixxuMK4U%-Akeco9NICO8Bqo>fvMVW?J)4WwfegC$V zJwfh7#`OLu1*okvk(2uN`s= zQ3Og)WyJaDx(MmQ3`MXvI1i=6gii~M3+{24cXi=5t45vRKT z?TMmmaML$E{NJOepl=w1HvZ3ZdC&yA`ULE*?*H>*Wp&; zkEDg6YLUo5|bcWhICRV6?0u#`GpQul3=Cn5re>6uPBat&CP z`6iqQntDv2WDtnI-CyEFnzyBo)%YjY?)h92};SbFPKfr{Eol&s1%S6D&9WL;IU*a zjarRfEg!H#wr++Hd~#tGg8v3U-TP>*NIORAS8*RG#>wLr>d_84a5nr7kL2a+1mFt> zD<=bq5-U9%NQ2qK$`ks)hK!Eug6D`Vdr{VlC*Mf$bs~rrCz;Hjj!%!JSoSy9JKcdy z+VrSgKfJb`8HK1Bmg0U^K0cV>ijY`N)bBLP&A~rDOHXjJR$zNW8X&E~K?r{ZQjSHR4_Hsu_mtW)g3ZNx`aiO7O*gtaAj_xde4`aFSs7x! z7fEP;#kqL;sW%O+7aJs^{B%jjvmS}k@atSbLJ8_@{0Ay>cGc)C?%rg-r=+3U)%QqM zVUa6QaerbJ2d8GCgp~fEltuCMJGHqyftDQTRT#wVN*}h+&29aNdgS*$`6~7n@gxZ+ zMI$&vo93s%XsgCxq4EP9LUgw-uwy!!K^Y{JctT7>R&$X)^Qb_D;>Vu(9;w;_hOjlU z{xD?LcD84J+n!u1TqT7g*XWCb{ZZ;7p_*!bOhQG}tKK&k%@0$L7vFSUfXXuA7ti=)!2s(sNDO2MK z&GeOS>E4~IgsO4ewJnVH^JA+CRok z^AmgEXr!s1lLt67K4HHV`Yu1@2?ed3_cYer>MOPKilUyl`m)cWVA2h%@0r0=HQmlB zg+oT7l1;nFQnr*Ep?QV-x1q`6`SqfP zuX!llFm~D;$0y?jiq=XemqxOjhMr8@X|Z_M7`R8hGM!k3R5{{UTb$B|gUu9iXkw)@E*=|2)5>S%ZVCEHPY0zraT0+G7Ww-5A0u3U_M* zpIfvejpC*?OX!vDCoPpuP5NN?Y{RyRGl}ntcd2x^F>6oZlaxk3*`EhGx!z%qgb^%v zi@M+%S@|4)kuX$VaS^fwF=$|e-_=d0w@G(lB;`QHxuBOs zM2Vn|$$wj#LSlEx@Z}$~;38HkS={1r6U5`e%JKTTlo|}_hScgfz7+CqJ0e{H6}4tJ z#2&9{pUsjzrg!GCIj%Cop@~j$E$WTSHaYs>J(I3~AB?HspTFK$#$GX;3HvQUu{2!8 zlWjc?&kAqh)iRK53qF#CrHV@4y%fThXgn@cFe*m-P!pV_l+^oqvgR_uhmP3FnXlku zB%IKJ{(Ya&Su6TD+rvm9^({CjC$DMI_F9FBU^J|;X{Gk|HvMY3DSNo&kp;3cvN3UI zt&H$`xGwasM&P^Psb%pw`*}HbWF<*mBIPyGF9co>hTUCA9?(KbHW1}bDQlV9Xc{jQ zH!2<3#hRK~Q@z0myKG@L_NrZ>toXMM?K2vsM9{l!iPQEaA*AqwAhoSgfo3){zFk_UOLY zvciTox@Z}8|1IH12N@y}7ncOe2%C9Mha3VfCnrWVE^k1uRgcquzNmz)&3iS=td(SVn2F-(0a zzZDtl%q6v(DqZKO1#W=MNw<0ll}e^*&E3?kL=A}!vrjePK>2A~I!mJ{SCsxAe^17p c(06{NEnwo|(bFv_5HcXDN?M8)3RW-wKlN#M*Z=?k literal 0 HcmV?d00001 From 9099fe61f039d7686be6b8e2bbfc8aec20a05c19 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 19 Feb 2024 16:35:24 +0100 Subject: [PATCH 44/51] Apply style to reactive-diagram.PNG image. Signed-off-by: parvy --- open-reac/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/open-reac/README.md b/open-reac/README.md index 91457005..1aad5407 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -211,7 +211,9 @@ as generators with zero active power will be excluded from the optimisation (see The general correction of the generator's reactive power diagram $g$ is illustrated in the following figure: -![Alt text](image/reactive-diagram.PNG?center=true "Reactive diagram correction") +
+ Reactive Diagram Correction +
### 5 Slack bus & main connex component From 2b6142c98ff80d681d898920ec06eeb228bbc938 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 19 Feb 2024 16:41:43 +0100 Subject: [PATCH 45/51] Refactor. Signed-off-by: parvy --- open-reac/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 1aad5407..d63eed61 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -333,8 +333,8 @@ The objective function also depends on parameters specified by the user (see [3. The `objective_choice` parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function. Specifically, if `objective_choice` takes on: - $0$, the minimization of active power production $\sum\limits_{i,g}\boldsymbol{P_{i,g}}$ is prioritized. -- $1$, the minimization of $\sum\limits_{i} \boldsymbol{V_i}-(\rho V_i^{c,max} - (1-\rho)V_i^{c,min})^2$ is prioritized. The parameter $\rho$ -equals the configurable parameter `ratio_voltage_target`. +- $1$, the minimization of $\sum\limits_{i} \boldsymbol{V_i}-(\rho V_i^{c,max} - (1-\rho)V_i^{c,min})^2$ is prioritized ($\rho$ +equals the configurable parameter `ratio_voltage_target`). - $2$, the minimization of $\sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2$ is prioritized. The objective function of the ACOPF is: From 4d5e597e5e6127d8dfba98ab72bf6d0eb2685804 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 26 Feb 2024 12:12:24 +0100 Subject: [PATCH 46/51] Refactor. Signed-off-by: parvy --- open-reac/README.md | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index d63eed61..051fc2de 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -223,17 +223,19 @@ If multiple buses have such cardinality, the one with the highest identifier (`n In the event no bus satisfies these conditions, the first bus defined in `ampl_network_buses.txt` is selected. The OPFs are executed on the **main connex component** (i.e. buses connected to slack bus by AC branches) of the network. -Consequently, **buses connected to the slack by HVDC lines are excluded**. +Consequently, **buses connected to the slack only by HVDC lines are excluded**. This component is determined by solving the following optimization problem (the variables are bolded): -$$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i}$$ +$$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i^{cc}}$$ -where $\boldsymbol{\theta_i}$ is the voltage angle of bus $i$, and with the following constraints: +where $\boldsymbol{\theta_i^{cc}}$ is the voltage angle of bus $i$, and with the following constraints: -$$\boldsymbol{\theta_s} = 0 \quad (1)$$ +$$\boldsymbol{\theta_s^{cc}} = 0 \quad (1)$$ -$$\boldsymbol{\theta_i} - \boldsymbol{\theta_j} = 0, \quad ij \in BRANCH \quad (2)$$ +$$\boldsymbol{\theta_i^{cc}} - \boldsymbol{\theta_j^{cc}} = 0, \quad ij \in BRANCH \quad (2)$$ + +$$0 \leq \boldsymbol{\theta_i^{cc}} \leq 1, \quad i \in BUS \quad (3)$$ If the solving is unsuccessful, the script `reactiveopfexit.run` is executed (see [8.2](#82-in-case-of-inconsistency)) and the execution is stopped. @@ -254,13 +256,13 @@ Before to address the ACOPF (see [7](#7-alternative-current-optimal-power-flow)) The DCOPF model involves the following constraints, in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-connex-component): -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} + \boldsymbol{\sigma_{P,i}^{+}} - \boldsymbol{\sigma_{P,i}^{-}} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC} \quad (3)$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} + \boldsymbol{\sigma_{P,i}^{+}} - \boldsymbol{\sigma_{P,i}^{-}} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC} \quad (4)$$ where: - $\boldsymbol{p_{ij}}$ is the active power leaving bus $i$ on branch $ij$, defined as $\boldsymbol{p_{ij}} = \frac{\boldsymbol{\theta_i} - \boldsymbol{\theta_j}}{X_{ij}}$, where $X_{ij}$ is the reactance of line $ij$ (specified in `ampl_network_branches.txt`). - $P_i^{in}$ the constant active power injected or consumed in bus $i$ (by batteries, loads, VSC stations and LCC stations). -- $\boldsymbol{P}_i^{g}$ is the variable active power produced by generators of bus $i$. +- $\boldsymbol{P_{i,g}}$ is the variable active power produced by generators of bus $i$. - $\boldsymbol{\sigma_{P,i}^{+}}$ (resp. $\boldsymbol{\sigma_{P,i}^{-}}$) is a positive slack variable expressing the excess (resp. shortfall) of active power produced in bus $i$. @@ -284,7 +286,7 @@ finds a feasible solution without reaching one of its default limit. Otherwise, The goal of the reactive ACOPF is to compute voltage values on each bus, as well as control values for reactive equipment and controllers of the grid. Then, the following values will be variable in the optimization: - $\boldsymbol{V_i}$ and $\boldsymbol{\theta_i}$ the voltage magnitude and phase of bus $i$. -- $\boldsymbol{P}_{i,g}$ (resp. $\boldsymbol{Q}_i^{g}$) the active (resp. reactive) power produced by variable generator $g$ of bus $i$. +- $\boldsymbol{P_{i,g}}$ (resp. $\boldsymbol{Q_{i,g}}$) the active (resp. reactive) power produced by variable generator $g$ of bus $i$. - $\boldsymbol{Q_{i,vsc}}$ the reactive power produced by voltage source converter stations $vsc$ of bus $i$. - $\boldsymbol{b_{i,g}}$ (resp. $\boldsymbol{b_{i,svc}}$) the susceptance of shunt $s$ (resp. of static var compensator $svc$) of bus $i$. - $\boldsymbol{\rho_{ij}}$ the transformer ratio of the ratio tap changer on branch $ij$, @@ -305,9 +307,9 @@ To do so, these buses must be specified in parameter file `param_buses_with_reac The ACOPF involves the following constraints, in addition to the slack constraint $(1)$ introduced in [5](#5-slack-bus--main-connex-component): -$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC} \quad (4)$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{p_{ij}} = P_i^{in} - \sum\limits_{g}\boldsymbol{P_{i,g}}, \quad i\in\text{BUSCC} \quad (5)$$ -$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{Q_i}^{-}} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{vsc}\boldsymbol{Q_{i,vsc}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{svc}\boldsymbol{b_{i,svc}}{V_i}^2, \quad i\in\text{BUSCC} \quad (5)$$ +$$\sum\limits_{j\in v(i)} \boldsymbol{q_{ij}} = Q_i^{in} - \boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{Q_i}^{-}} - \sum\limits_{g}\boldsymbol{Q_{i,g}} - \sum\limits_{vsc}\boldsymbol{Q_{i,vsc}} - \sum\limits_{s}\boldsymbol{b_{i,s}}{V_i}^2 - \sum\limits_{svc}\boldsymbol{b_{i,svc}}{V_i}^2, \quad i\in\text{BUSCC} \quad (6)$$ where: - $\boldsymbol{p_{ij}}$ (resp. $\boldsymbol{q_{ij}}$) is the active (resp. reactive) power leaving bus $i$ on branch $ij$, @@ -319,18 +321,20 @@ where: In order to bound the variables described in [7.1](#71-generalities), the limits specified in the files of network data (see [3.1](#31-network-data)) are used. We specify the following special treatments: - The voltage magnitude $\boldsymbol{V_i}$ lies between the corrected voltage limits described in [4.1](#41-voltage-level-limits-consistency). -- The reactive power $\boldsymbol{Q_{i,g}}$ lies between the corrected limits described in [4.4](#44-pq-units-domain). +- The reactive power $\boldsymbol{Q_{i,g}}$ produced by unit $g$ lies between the corrected limits described in [4.4](#44-pq-units-domain). - The active power $\boldsymbol{P_{i,g}}$ also lies between the corrected limits described in [4.4](#44-pq-units-domain), but these bounds are only considered when the configurable parameter $\alpha$ is different than $1$ (default value). Otherwise, all active powers evolve proportionally to their initial point $P_{i,g}^t$ (specified in `ampl_network_generators.txt`): $\boldsymbol{P_{i,g}} = P_{i,g}^t + \boldsymbol{\gamma} (P_{g}^{max,c} - P_{i,g}^t)$, where $\boldsymbol{\gamma}$ is optimized and lies in $\[-1;1\]$. -- The reactive power $\boldsymbol{Q_{i,vsc}}$ is included in $\[\min(qP_{vsc}, qp_{vsc}, qp_{vsc}^0)$; $\max(QP_{vsc}, Qp_{vsc}, Qp_{vsc}^0)\]$. +- The reactive power $\boldsymbol{Q_{i,vsc}}$ produced by voltage source converter station $vsc$ is included in $\[\min(qP_{vsc}, qp_{vsc}, qp_{vsc}^0)$; $\max(QP_{vsc}, Qp_{vsc}, Qp_{vsc}^0)\]$. **The bounds are therefore rectangular, not trapezoidal.** #### 7.3 Objective function The objective function also depends on parameters specified by the user (see [3.2](#32-configuration-of-the-run)). -The `objective_choice` parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function. +The `objective_choice` parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function, as follows: +if `objective_choice` $= i$, then $beta_i = 1$ and $beta_j = 0.01$ pour $j \neq i$. + Specifically, if `objective_choice` takes on: - $0$, the minimization of active power production $\sum\limits_{i,g}\boldsymbol{P_{i,g}}$ is prioritized. - $1$, the minimization of $\sum\limits_{i} \boldsymbol{V_i}-(\rho V_i^{c,max} - (1-\rho)V_i^{c,min})^2$ is prioritized ($\rho$ @@ -338,7 +342,7 @@ equals the configurable parameter `ratio_voltage_target`). - $2$, the minimization of $\sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2$ is prioritized. The objective function of the ACOPF is: -$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \times \sum\limits_{g} \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ +$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \times \sum\limits_{g} \left( \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 \right) + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ where: - $P_{i,g}^t$ (resp. $V_i^t$) is the active target (resp. voltage initial point) specified in `ampl_network_generators.txt` (resp. `ampl_network_buses.txt`). From c450d00d8511aa715fad66db3b4096e08c5a3199 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 26 Feb 2024 12:16:22 +0100 Subject: [PATCH 47/51] add left/right to improve equations. Signed-off-by: parvy --- 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 051fc2de..47ed2dd6 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -342,7 +342,7 @@ equals the configurable parameter `ratio_voltage_target`). - $2$, the minimization of $\sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2$ is prioritized. The objective function of the ACOPF is: -$$\text{minimize} (10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \times \sum\limits_{g} \left( \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 \right) + \beta_2 \times \sum\limits_{i} (\boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c})^2 + \beta_3 \times \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} (\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})})^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2$$ +$$\text{minimize} \left( 10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \sum\limits_{g} \left( \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 \right) + \beta_2 \sum\limits_{i} \left( \boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c} \right)^2 + \beta_3 \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} \left(\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})}\right)^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2 \right)$$ where: - $P_{i,g}^t$ (resp. $V_i^t$) is the active target (resp. voltage initial point) specified in `ampl_network_generators.txt` (resp. `ampl_network_buses.txt`). From cf9566b6208638b1fc68d5cf1af98d792ee70b32 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 26 Feb 2024 12:20:34 +0100 Subject: [PATCH 48/51] improve equations form. Signed-off-by: parvy --- open-reac/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 47ed2dd6..0981ca75 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -184,7 +184,7 @@ Let $P_{g}^{min,c}$ and $P_{g}^{max,c}$ be the corrected active bounds: - By default, $P_{g}^{min,c} = \text{defaultPmin}$ and $P_{g}^{max,c} = \text{defaultPmax}$ (see [3.2](#32-configuration-of-the-run)) - If $|P_g^{max}| \geq \text{PQmax}$, then $P_{g}^{max,c} = \max(\text{defaultPmax}, P_g^t)$ - If $|P_g^{min}| \geq \text{PQmax}$, then $P_{g}^{min,c} = \min(\text{defaultPmin}, P_g^t)$ -- If $|P_{g}^{max,c} - P_{g}^{min,c}| \leq \text{minimalQPrange}$, then $P_{g}^{max,c} = P_{g}^{min,c} = P_{g}^t$ (active power is fixed) +- If $|P_{g}^{max,c} - P_{g}^{min,c}| \leq \text{minimalQPrange}$, then $P_{g}^{max,c} = P_{g}^{min,c} = P_{g}^t$ (active power is fixed). To determine the consistent domain of produced reactive power, the reactive power diagram (specified in `ampl_network_generators.txt`) of generator @@ -227,7 +227,7 @@ Consequently, **buses connected to the slack only by HVDC lines are excluded**. This component is determined by solving the following optimization problem (the variables are bolded): -$$\text{minimize} \sum\limits_{i} \boldsymbol{\theta_i^{cc}}$$ +$$\text{minimize} \left(\sum\limits_{i} \boldsymbol{\theta_i^{cc}}\right)$$ where $\boldsymbol{\theta_i^{cc}}$ is the voltage angle of bus $i$, and with the following constraints: @@ -268,7 +268,7 @@ expressing the excess (resp. shortfall) of active power produced in bus $i$. And the following objective function: -$$\text{minimize} (1000\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{P,+}} + \boldsymbol{\sigma_{i}^{P,-}}) + \sum\limits_{g} (\frac{\boldsymbol{P_{i,g}} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})})^2)$$ +$$\text{minimize} \left(1000 \sum\limits_{i} (\boldsymbol{\sigma_{i}^{P,+}} + \boldsymbol{\sigma_{i}^{P,-}}) + \sum\limits_{g} \left(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^{t}}{\max(1, \frac{P_{i,g}^t}{100})}\right)^2\right)$$ where $P_{i,g}^{t}$ is the target of the generator $g$ on bus $i$. @@ -342,7 +342,7 @@ equals the configurable parameter `ratio_voltage_target`). - $2$, the minimization of $\sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2$ is prioritized. The objective function of the ACOPF is: -$$\text{minimize} \left( 10\times\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \sum\limits_{g} \left( \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 \right) + \beta_2 \sum\limits_{i} \left( \boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c} \right)^2 + \beta_3 \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \times \sum\limits_{g} \left(\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})}\right)^2 + 0.1 \times \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2 \right)$$ +$$\text{minimize} \left( 10\sum\limits_{i} (\boldsymbol{\sigma_{i}^{Q,+}} + \boldsymbol{\sigma_{i}^{Q,-}}) + \beta_1 \sum\limits_{g} \left( \alpha\boldsymbol{P_{i,g}} + (1-\alpha)(\frac{\boldsymbol{P_{i,g}} - P_{i,g}^t}{\max(1, |P_{i,g}^t|)})^2 \right) + \beta_2 \sum\limits_{i} \left( \boldsymbol{V_i} - (1-\rho)V_{i}^{min,c} + \rho V_{i}^{max,c} \right)^2 + \beta_3 \sum\limits_{i} (\boldsymbol{V_i} - V_i^t)^2 + 0.1 \sum\limits_{g} \left(\frac{\boldsymbol{Q_{i,g}}}{\max(1,Q_{g}^{min,c}, Q_{g}^{max,c})}\right)^2 + 0.1 \sum\limits_{ij} (\boldsymbol{\rho_{ij}} - \rho_{ij})^2 \right)$$ where: - $P_{i,g}^t$ (resp. $V_i^t$) is the active target (resp. voltage initial point) specified in `ampl_network_generators.txt` (resp. `ampl_network_buses.txt`). From ba886f29468eaf4fb06748744cb918376e510310 Mon Sep 17 00:00:00 2001 From: parvy Date: Mon, 26 Feb 2024 12:22:55 +0100 Subject: [PATCH 49/51] fix typos. Signed-off-by: parvy --- open-reac/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 0981ca75..61bc37d0 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -332,8 +332,8 @@ $\boldsymbol{P_{i,g}} = P_{i,g}^t + \boldsymbol{\gamma} (P_{g}^{max,c} - P_{i,g} #### 7.3 Objective function The objective function also depends on parameters specified by the user (see [3.2](#32-configuration-of-the-run)). -The `objective_choice` parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function, as follows: -if `objective_choice` $= i$, then $beta_i = 1$ and $beta_j = 0.01$ pour $j \neq i$. +The `objective_choice` parameter modifies the values of penalties $\beta_1$, $\beta_2$, and $\beta_3$ in the objective function: +if `objective_choice` $= i$, then $\beta_i = 1$ and $\beta_j = 0.01$ for $j \neq i$. Specifically, if `objective_choice` takes on: - $0$, the minimization of active power production $\sum\limits_{i,g}\boldsymbol{P_{i,g}}$ is prioritized. From 6d8ae9153126840e1f8931132487f6853683c45f Mon Sep 17 00:00:00 2001 From: parvy Date: Tue, 27 Feb 2024 12:59:42 +0100 Subject: [PATCH 50/51] Modify with suggestions. Signed-off-by: parvy --- open-reac/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index 61bc37d0..edc32f1e 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -26,7 +26,7 @@ AMPL is sold by many companies, including Artelys, and you can find keys [here]( ### Non-linear optimization solver To run the model implemented in AMPL, you'll need a non-linear optimization solver. -By default, the AMPL code is configured to run Knitro, which is a proprietary non-linear, but you +By default, the AMPL code is configured to run Knitro, which is a proprietary non-linear solver, but you are free to configure a different one. If you chose to run Knitro, you must have `knitroampl` in your path, after the installation @@ -47,7 +47,7 @@ Artelys is the company developing Knitro, and you can find keys The reactive optimal power flow (OPF) is implemented with AMPL. Its goal is to compute voltage values on each point of the network as well as control values for reactive equipment and controllers of the grid -(voltage set point of generating units, shunts, transformers ratios...). +(voltage set point of generating units, shunts, transformer ratios...). In a grid development study, you decide new equipment, new generating units, new substations, new loads, you set values for active and reactive loads, @@ -92,7 +92,7 @@ These are specified in the file `param_algo.txt`: | Parameter | Description | 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} | +| `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\]$ | @@ -137,7 +137,7 @@ Format of `ampl_network_substations_override.txt`: 4 columns #"num" "minV (pu)" Before solving the reactive ACOPF described in [7](#7-alternative-current-optimal-power-flow), the following pre-processing blocks are executed to ensure the consistency of the values used in the optimization. -#### 4.1 Voltage level limits consistency +#### 4.1 Voltage level limit consistency To ensure consistent voltage level limits for the buses, the configurable domain [`min_plausible_low_voltage_limit`; `max_plausible_high_voltage_limit`] is used @@ -205,7 +205,8 @@ and $Qp_{g}^{c} = QP_{g}^{c} = \text{defaultPmax} \times \text{defaultQmaxPmaxRa Please note that in the end, **the corrected bounds are rectangular**, not trapezoidal, and they are used only in the reactive OPF -(see [7](#7-alternative-current-optimal-power-flow)). In addition, bounds $qP_{g}^0$ and $Qp_{g}^0$ are not used, +(see [7](#7-alternative-current-optimal-power-flow)). The trapezoidal diagram should be added shortly. +In addition, bounds $qP_{g}^0$ and $Qp_{g}^0$ are not used, as generators with zero active power will be excluded from the optimisation (see [7.1](#71-generalities)). The general correction of the generator's reactive power diagram $g$ From 10bbe44840bb457a54d7f50bcc59c942ffefa53d Mon Sep 17 00:00:00 2001 From: parvy Date: Thu, 29 Feb 2024 10:54:31 +0100 Subject: [PATCH 51/51] Remove some comments. Signed-off-by: parvy --- open-reac/README.md | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/open-reac/README.md b/open-reac/README.md index edc32f1e..0bf0b1d0 100644 --- a/open-reac/README.md +++ b/open-reac/README.md @@ -21,8 +21,6 @@ ampl: homeDir: /home/user/ampl ``` -AMPL is sold by many companies, including Artelys, and you can find keys [here](https://www.artelys.com/solvers/ampl/). - ### Non-linear optimization solver To run the model implemented in AMPL, you'll need a non-linear optimization solver. @@ -30,13 +28,7 @@ By default, the AMPL code is configured to run Knitro, which is a proprietary no are free to configure a different one. If you chose to run Knitro, you must have `knitroampl` in your path, after the installation -of the solver is done and that you got a valid licence. To check, start a bash and run: -```bash -knitroampl stub -``` - -Artelys is the company developing Knitro, and you can find keys -[here](https://www.artelys.com/solvers/knitro/). +of the solver is done and that you got a valid licence. ---