Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add branches opened on one side in ACOPF optimization #84

Merged
merged 36 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b767132
Divide OpenReacRunnerTest into several TUs
p-arvy Nov 27, 2024
8da89b0
Add TUs for ACOPF indicators
p-arvy Nov 27, 2024
50548d2
Add tests on equipment bounds in optimization of OpenReac
p-arvy Dec 4, 2024
802dd1d
Improve tests on ouput indicators of OpenReac
p-arvy Dec 4, 2024
81908d8
Clean
p-arvy Dec 4, 2024
f6746be
Add resources
p-arvy Dec 4, 2024
28047a0
Merge branch 'refs/heads/main' into refactor-open-reac-tests
p-arvy Dec 4, 2024
84e5da6
Clean
p-arvy Dec 12, 2024
a54206b
Clean code adding new TUs
p-arvy Dec 12, 2024
cd043e8
Clean
p-arvy Dec 12, 2024
1f1c0dd
Merge branch 'refs/heads/main' into refactor-open-reac-tests
p-arvy Dec 12, 2024
3a3b1fd
Merge branch 'refs/heads/main' into refactor-open-reac-tests
p-arvy Dec 13, 2024
d78e93d
Clean
p-arvy Dec 30, 2024
724d6fe
Put computer and time indicators as DEBUG indicators
p-arvy Dec 17, 2024
abfc91b
Clean
p-arvy Dec 19, 2024
2afbe89
Add indicators test for OpenReac
p-arvy Dec 12, 2024
e11a2f6
Add tests for bounds
p-arvy Dec 12, 2024
6f4612b
Add TUs on Q bounds
p-arvy Dec 13, 2024
8aa0e87
Small clean
p-arvy Dec 13, 2024
1044424
Update resources
p-arvy Dec 17, 2024
7070e0e
Clean
p-arvy Dec 19, 2024
f5149f3
Clean after rebase
p-arvy Dec 30, 2024
ac830a4
Add indicators test for OpenReac
p-arvy Dec 12, 2024
d08278b
line opened on one side
p-arvy Sep 17, 2024
2bd4228
wip
p-arvy Nov 27, 2024
68edf3a
Add RTC on opened branch and associated TUs
p-arvy Nov 27, 2024
75a1d48
Fix indicators on opened branches
p-arvy Dec 16, 2024
2e2f102
Add TUs on opened branches
p-arvy Dec 16, 2024
4785e96
Add resources for branches tests
p-arvy Dec 16, 2024
da38e46
Clean
p-arvy Dec 16, 2024
cc66e6a
Small clean
p-arvy Dec 16, 2024
e01c18d
Update TUs
p-arvy Dec 18, 2024
287b62b
Clean
p-arvy Dec 19, 2024
2063122
Add doc
p-arvy Dec 19, 2024
9d951c1
Improve comment
p-arvy Dec 30, 2024
e088e57
Merge branch 'main' into add-branches-opened-one-side
So-Fras Jan 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/optimizer/acOptimalPowerflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Please note that:
even if the user designates these generators as fixed in the parameter file `param_generators_reactive.txt` (see [Configuration of the run](inputs.md#configuration-of-the-run)).
Therefore, when the optimization results are exported, **these generators are exported with a reactive power target of $0$**.
- **Neither current limits nor power limits** on branches are considered in the optimization.
- Branches with one side open are considered in optimization.

## Constraints

Expand Down
12 changes: 6 additions & 6 deletions docs/optimizer/inputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Please note that for these parameters, the AMPL code defines default values whic
In addition to the previous parameters, the user can specify which parameters will be variable or fixed in the ACOPF solving (see [AC optimal powerflow](acOptimalPowerflow.md)).
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 [P/Q unit domain](preprocessing.md#pq-unit-domain)) are variable |
| `param_buses_with_reactive_slack.txt` | Buses with attached reactive slacks if configurable parameter buses_with_reactive_slacks = "CONFIGURED" | Only buses with no reactive power production have reactive slacks attached |
| File | Description | Default behavior of modified values |
|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| `param_transformers.txt` | Ratio tap changers with a variable transformation ratio (real variable). Note that ratio tap changers on branches with one side open are not optimized. | Transformation ratios are fixed |
| `param_shunt.txt` | Shunts with a continuous variable susceptance and which can be modified and/or connected (only if possible bus is defined in `ampl_network_shunts.txt`) | Shunt susceptances are fixed |
| `param_generators_reactive.txt` | Generators with a constant reactive power production. If this value is not consistent (> PQmax), the reactive power production stays variable | Coherent reactive power productions (see [P/Q unit domain](preprocessing.md#pq-unit-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".

Expand Down
111 changes: 73 additions & 38 deletions open-reac/src/main/resources/openreac/acopf.mod
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,58 @@ var Red_Tran_Rea_Inv{(qq,m,n) in BRANCHCC } =
+ V[n] * (branch_admi[qq,m,n]*cos(branch_angper[qq,m,n])-branch_Bex_mod[qq,m,n])
;

var Red_Tran_Act_Dir_Side_2_Opened{(qq,m,n) in BRANCHCC_WITH_SIDE_2_OPENED} =
(branch_Ror[qq,m,n])**2 * V[m] * (branch_Gor_mod[qq,m,n] + (branch_admi[qq,m,n])**2 * branch_Gex_mod[qq,m,n] / ( (branch_Gex_mod[qq,m,n] + branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]))**2
+ (- branch_Bex_mod[qq,m,n] + branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]))**2 )
+ ((branch_Bex_mod[qq,m,n])**2 + (branch_Gex_mod[qq,m,n])**2) * branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]) / ( (branch_Gex_mod[qq,m,n] + branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]))**2
+ (- branch_Bex_mod[qq,m,n] + branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]))**2 ))
;

var Red_Tran_Rea_Dir_Side_2_Opened{(qq,m,n) in BRANCHCC_WITH_SIDE_2_OPENED} =
- (branch_Ror[qq,m,n])**2 * V[m] * (branch_Bor_mod[qq,m,n] + (branch_admi[qq,m,n])**2 * branch_Bex_mod[qq,m,n] / ( (branch_Gex_mod[qq,m,n] + branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]))**2
+ (- branch_Bex_mod[qq,m,n] + branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]))**2 )
- ((branch_Bex_mod[qq,m,n])**2 + (branch_Gex_mod[qq,m,n])**2) * branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]) / ( (branch_Gex_mod[qq,m,n] + branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]))**2
+ (-branch_Bex_mod[qq,m,n] + branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]))**2 ))
;

var Red_Tran_Act_Inv_Side_1_Opened{(qq,m,n) in BRANCHCC_WITH_SIDE_1_OPENED} =
V[n] * (branch_Gex_mod[qq,m,n] + (branch_admi[qq,m,n])**2 * branch_Gor_mod[qq,m,n] / ( (branch_Gor_mod[qq,m,n] + branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]))**2
+ (- branch_Bor_mod[qq,m,n] + branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]))**2 )
+ ((branch_Bor_mod[qq,m,n])**2 + (branch_Gor_mod[qq,m,n])**2) * branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]) / ( (branch_Gor_mod[qq,m,n] + branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]))**2
+ (- branch_Bor_mod[qq,m,n] + branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]))**2 ))
;

var Red_Tran_Rea_Inv_Side_1_Opened{(qq,m,n) in BRANCHCC_WITH_SIDE_1_OPENED} =
- V[n] * (branch_Bex_mod[qq,m,n]
+ (branch_admi[qq,m,n])**2 * branch_Bor_mod[qq,m,n] / ( (branch_Gor_mod[qq,m,n] + branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]))**2
+ (- branch_Bor_mod[qq,m,n] + branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]))**2 )
- ((branch_Bor_mod[qq,m,n])**2 + (branch_Gor_mod[qq,m,n])**2) * branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]) / ( (branch_Gor_mod[qq,m,n] + branch_admi[qq,m,n] * sin(branch_angper[qq,m,n]))**2
+ (- branch_Bor_mod[qq,m,n] + branch_admi[qq,m,n] * cos(branch_angper[qq,m,n]))**2 ))
;


#
# Active Balance
#

subject to ctr_balance_P{PROBLEM_ACOPF,k in BUSCC}:
# Flows
sum{(qq,k,n) in BRANCHCC} base100MVA * V[k] * Red_Tran_Act_Dir[qq,k,n]
+ sum{(qq,m,k) in BRANCHCC} base100MVA * V[k] * Red_Tran_Act_Inv[qq,m,k]
# Generating units
- sum{(g,k) in UNITON} P[g,k]
# Batteries
- sum{(b,k) in BATTERYCC} battery_p0[1,b,k]
# Loads
+ sum{(c,k) in LOADCC} load_PFix[1,c,k] # Fixed value
# VSC converters
+ sum{(v,k) in VSCCONVON} vscconv_P0[1,v,k] # Fixed value
# LCC converters
+ sum{(l,k) in LCCCONVON} lccconv_P0[1,l,k] # Fixed value
= 0; # No slack variables for active power. If data are really too bad, may not converge.
# Flows
sum{(qq,k,n) in BRANCHCC} base100MVA * V[k] * Red_Tran_Act_Dir[qq,k,n]
+ sum{(qq,m,k) in BRANCHCC} base100MVA * V[k] * Red_Tran_Act_Inv[qq,m,k]
# Flows on branches with one side opened
+ sum{(qq,k,n) in BRANCHCC_WITH_SIDE_2_OPENED} base100MVA * V[k] * Red_Tran_Act_Dir_Side_2_Opened[qq,k,n]
+ sum{(qq,m,k) in BRANCHCC_WITH_SIDE_1_OPENED} base100MVA * V[k] * Red_Tran_Act_Inv_Side_1_Opened[qq,m,k]
# Generating units
- sum{(g,k) in UNITON} P[g,k]
# Batteries
- sum{(b,k) in BATTERYCC} battery_p0[1,b,k]
# Loads
+ sum{(c,k) in LOADCC} load_PFix[1,c,k] # Fixed value
# VSC converters
+ sum{(v,k) in VSCCONVON} vscconv_P0[1,v,k] # Fixed value
# LCC converters
+ sum{(l,k) in LCCCONVON} lccconv_P0[1,l,k] # Fixed value
= 0; # No slack variables for active power. If data are really too bad, may not converge.


#
Expand All @@ -167,30 +199,33 @@ var slack2_shunt_B{BUSCC_SLACK} >= 0;
#subject to ctr_compl_slack_Q{PROBLEM_ACOPF,k in BUSCC_SLACK}: slack1_balance_Q[k] >= 0 complements slack2_balance_Q[k] >= 0;

subject to ctr_balance_Q{PROBLEM_ACOPF,k in BUSCC}:
# Flows
sum{(qq,k,n) in BRANCHCC} base100MVA * V[k] * Red_Tran_Rea_Dir[qq,k,n]
+ sum{(qq,m,k) in BRANCHCC} base100MVA * V[k] * Red_Tran_Rea_Inv[qq,m,k]
# Generating units
- sum{(g,k) in UNITON: (g,k) not in UNIT_FIXQ } Q[g,k]
- sum{(g,k) in UNIT_FIXQ} unit_Qc[1,g,k]
# Batteries
- sum{(b,k) in BATTERYCC} battery_q0[1,b,k]
# Loads
+ sum{(c,k) in LOADCC} load_QFix[1,c,k]
# Shunts
- sum{(shunt,k) in SHUNT_FIX} base100MVA * shunt_valnom[1,shunt,k] * V[k]^2
- sum{(shunt,k) in SHUNT_VAR} base100MVA * shunt_var[shunt,k] * V[k]^2
# SVC
- sum{(svc,k) in SVCON} base100MVA * svc_qvar[svc,k] * V[k]^2
# VSC converters
- sum{(v,k) in VSCCONVON} vscconv_qvar[v,k]
# LCC converters
+ sum{(l,k) in LCCCONVON} lccconv_Q0[1,l,k] # Fixed value
# Slack variables
+ if k in BUSCC_SLACK then
(- base100MVA * V[k]^2 * slack1_shunt_B[k] # Homogeneous to a generation of reactive power (condensator)
+ base100MVA * V[k]^2 * slack2_shunt_B[k]) # homogeneous to a reactive load (self)
= 0;
# Flows
sum{(qq,k,n) in BRANCHCC} base100MVA * V[k] * Red_Tran_Rea_Dir[qq,k,n]
+ sum{(qq,m,k) in BRANCHCC} base100MVA * V[k] * Red_Tran_Rea_Inv[qq,m,k]
# Flows on branches with one side opened
+ sum{(qq,k,n) in BRANCHCC_WITH_SIDE_2_OPENED} base100MVA * V[k] * Red_Tran_Rea_Dir_Side_2_Opened[qq,k,n]
+ sum{(qq,m,k) in BRANCHCC_WITH_SIDE_1_OPENED} base100MVA * V[k] * Red_Tran_Rea_Inv_Side_1_Opened[qq,m,k]
# Generating units
- sum{(g,k) in UNITON: (g,k) not in UNIT_FIXQ } Q[g,k]
- sum{(g,k) in UNIT_FIXQ} unit_Qc[1,g,k]
# Batteries
- sum{(b,k) in BATTERYCC} battery_q0[1,b,k]
# Loads
+ sum{(c,k) in LOADCC} load_QFix[1,c,k]
# Shunts
- sum{(shunt,k) in SHUNT_FIX} base100MVA * shunt_valnom[1,shunt,k] * V[k]^2
- sum{(shunt,k) in SHUNT_VAR} base100MVA * shunt_var[shunt,k] * V[k]^2
# SVC
- sum{(svc,k) in SVCON} base100MVA * svc_qvar[svc,k] * V[k]^2
# VSC converters
- sum{(v,k) in VSCCONVON} vscconv_qvar[v,k]
# LCC converters
+ sum{(l,k) in LCCCONVON} lccconv_Q0[1,l,k] # Fixed value
# Slack variables
+ if k in BUSCC_SLACK then
(- base100MVA * V[k]^2 * slack1_shunt_B[k] # Homogeneous to a generation of reactive power (condensator)
+ base100MVA * V[k]^2 * slack2_shunt_B[k]) # homogeneous to a reactive load (self)
= 0;


#
Expand Down
43 changes: 25 additions & 18 deletions open-reac/src/main/resources/openreac/commons.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ set BUS2:= setof {(1,n) in BUS:
set BRANCH2:= setof {(1,qq,m,n) in BRANCH: m in BUS2 and n in BUS2} (qq,m,n);

set BUSCC dimen 1 default {};
# Branches with bus on side 1 and 2 in CC
set BRANCHCC := {(qq,m,n) in BRANCH2: m in BUSCC and n in BUSCC};
# Branches with bus on side 1 in CC, and disconnected bus on side 2
set BRANCHCC_WITH_SIDE_2_OPENED := setof {(1,qq,m,n) in BRANCH: m in BUSCC and n == -1 and m != n} (qq,m,n);
# Branches with bus on side 2 in CC, and disconnected bus on side 1
set BRANCHCC_WITH_SIDE_1_OPENED := setof {(1,qq,m,n) in BRANCH: m == -1 and n in BUSCC and m != n} (qq,m,n);
set ALL_BRANCHCC := BRANCHCC union BRANCHCC_WITH_SIDE_2_OPENED union BRANCHCC_WITH_SIDE_1_OPENED;


###############################################################################
Expand Down Expand Up @@ -94,38 +100,38 @@ set LCCCONVON := setof{(t,l,n) in LCCCONV:

# Branches with zero or near zero impedances
# Notice: module of Z is equal to square root of (R^2+X^2)
set BRANCHZNULL := {(qq,m,n) in BRANCHCC: branch_R[1,qq,m,n]^2+branch_X[1,qq,m,n]^2 <= Znull^2};
set BRANCHZNULL := {(qq,m,n) in ALL_BRANCHCC: branch_R[1,qq,m,n]^2+branch_X[1,qq,m,n]^2 <= Znull^2};


# If in BRANCHZNULL, then set X to ZNULL
param branch_X_mod{(qq,m,n) in BRANCHCC} :=
param branch_X_mod{(qq,m,n) in ALL_BRANCHCC} :=
if (qq,m,n) in BRANCHZNULL then Znull
else branch_X[1,qq,m,n];
check {(qq,m,n) in BRANCHCC}: abs(branch_X_mod[qq,m,n]) > 0;
check {(qq,m,n) in ALL_BRANCHCC}: abs(branch_X_mod[qq,m,n]) > 0;

# If in BRANCHZNULL, then set Gor/Gex/Bor/Bex to 0
param branch_Gor_mod{(qq,m,n) in BRANCHCC} :=
if (qq,m,n) in BRANCHZNULL then 0
param branch_Gor_mod{(qq,m,n) in ALL_BRANCHCC} :=
if (qq,m,n) in BRANCHCC and (qq,m,n) in BRANCHZNULL then 0
else branch_Gor[1,qq,m,n];

param branch_Gex_mod{(qq,m,n) in BRANCHCC} :=
if (qq,m,n) in BRANCHZNULL then 0
param branch_Gex_mod{(qq,m,n) in ALL_BRANCHCC} :=
if (qq,m,n) in BRANCHCC and (qq,m,n) in BRANCHZNULL then 0
else branch_Gex[1,qq,m,n];

param branch_Bor_mod{(qq,m,n) in BRANCHCC} :=
if (qq,m,n) in BRANCHZNULL then 0
param branch_Bor_mod{(qq,m,n) in ALL_BRANCHCC} :=
if (qq,m,n) in BRANCHCC and (qq,m,n) in BRANCHZNULL then 0
else branch_Bor[1,qq,m,n];

param branch_Bex_mod{(qq,m,n) in BRANCHCC} :=
if (qq,m,n) in BRANCHZNULL then 0
param branch_Bex_mod{(qq,m,n) in ALL_BRANCHCC} :=
if (qq,m,n) in BRANCHCC and (qq,m,n) in BRANCHZNULL then 0
else branch_Bex[1,qq,m,n];

# Busses with valid voltage value
set BUSVV := {n in BUSCC : bus_V0[1,n] >= min_plausible_low_voltage_limit};

# Reactive
set SHUNTCC := {(1,s,n) in SHUNT: n in BUSCC or shunt_possiblebus[1,s,n] in BUSCC}; # We want to be able to reconnect shunts
set BRANCHCC_REGL := {(qq,m,n) in BRANCHCC diff BRANCHZNULL: branch_ptrRegl[1,qq,m,n] != -1 };
set BRANCHCC_REGL := {(qq,m,n) in BRANCHCC union BRANCHCC_WITH_SIDE_2_OPENED diff BRANCHZNULL: branch_ptrRegl[1,qq,m,n] != -1 }; # ratio tap changers also have impact on lines with side 2 open
set BRANCHCC_DEPH := {(qq,m,n) in BRANCHCC diff BRANCHZNULL: branch_ptrDeph[1,qq,m,n] != -1 };
set SVCCC := {(1,svc,n) in SVC: n in BUSCC};

Expand Down Expand Up @@ -164,6 +170,7 @@ set UNIT_FIXQ := {(g,n) in UNITON: g in PARAM_UNIT_FIXQ and abs(unit_Qc[1,g,n])<
set BRANCHCC_REGL_VAR :=
{ (qq,m,n) in BRANCHCC_REGL:
qq in PARAM_TRANSFORMERS_RATIO_VARIABLE
and (qq,m,n) not in BRANCHCC_WITH_SIDE_2_OPENED # ratio tap changers on open branches are not optimized
and regl_ratio_min[1,branch_ptrRegl[1,qq,m,n]] < regl_ratio_max[1,branch_ptrRegl[1,qq,m,n]]
};
set BRANCHCC_REGL_FIX := BRANCHCC_REGL diff BRANCHCC_REGL_VAR;
Expand All @@ -184,18 +191,18 @@ param branch_Rdeph{(qq,m,n) in BRANCHCC_DEPH} =
else branch_R[1,qq,m,n]
;

param branch_angper{(qq,m,n) in BRANCHCC} =
param branch_angper{(qq,m,n) in ALL_BRANCHCC} =
if (qq,m,n) in BRANCHCC_DEPH
then atan2(branch_Rdeph[qq,m,n], branch_Xdeph[qq,m,n])
else atan2(branch_R[1,qq,m,n] , branch_X_mod[qq,m,n] );

param branch_admi {(qq,m,n) in BRANCHCC} =
param branch_admi {(qq,m,n) in ALL_BRANCHCC} =
if (qq,m,n) in BRANCHCC_DEPH
then 1./sqrt(branch_Rdeph[qq,m,n]^2 + branch_Xdeph[qq,m,n]^2 )
else 1./sqrt(branch_R[1,qq,m,n]^2 + branch_X_mod[qq,m,n]^2 );

# Later in this file, a variable branch_Ror_var will be created, to replace branch_Ror when it is not variable
param branch_Ror {(qq,m,n) in BRANCHCC} =
param branch_Ror {(qq,m,n) in ALL_BRANCHCC} =
( if ((qq,m,n) in BRANCHCC_REGL)
then tap_ratio[1,regl_table[1,branch_ptrRegl[1,qq,m,n]],regl_tap0[1,branch_ptrRegl[1,qq,m,n]]]
else 1.0
Expand All @@ -205,13 +212,13 @@ param branch_Ror {(qq,m,n) in BRANCHCC} =
else 1.0
)
* (branch_cstratio[1,qq,m,n]);
param branch_Rex {(q,m,n) in BRANCHCC} = 1; # In IIDM, everything is in bus1 so ratio at bus2 is always 1
param branch_Rex {(q,m,n) in ALL_BRANCHCC} = 1; # In IIDM, everything is in bus1 so ratio at bus2 is always 1

param branch_dephor {(qq,m,n) in BRANCHCC} =
param branch_dephor {(qq,m,n) in ALL_BRANCHCC} =
if ((qq,m,n) in BRANCHCC_DEPH)
then tap_angle [1,deph_table[1,branch_ptrDeph[1,qq,m,n]],deph_tap0[1,branch_ptrDeph[1,qq,m,n]]]
else 0;
param branch_dephex {(qq,m,n) in BRANCHCC} = 0; # In IIDM, everything is in bus1 so dephase at bus2 is always 0
param branch_dephex {(qq,m,n) in ALL_BRANCHCC} = 0; # In IIDM, everything is in bus1 so dephase at bus2 is always 0


###############################################################################
Expand Down
2 changes: 1 addition & 1 deletion open-reac/src/main/resources/openreac/dcopf.run
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ printf{LOG_INFO} "OK all slack variables for DCOPF are null\n";
let dcopf_status := "OK";

# Print flows on branches with zero impedance
for{(qq,m,n) in BRANCHZNULL} printf{LOG_INFO} "Flow on zero impedance branch %Q: %.f MW\n",branch_id[1,qq,m,n],activeflow[qq,m,n];
for{(qq,m,n) in BRANCHCC inter BRANCHZNULL} printf{LOG_INFO} "Flow on zero impedance branch %Q: %.f MW\n",branch_id[1,qq,m,n],activeflow[qq,m,n];

# Print flows on most loaded lines
let temp1 := max{(qq,m,n) in BRANCHCC}abs(activeflow[qq,m,n]);
Expand Down
40 changes: 38 additions & 2 deletions open-reac/src/main/resources/openreac/reactiveopfoutput.run
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,10 @@ printf "%s %i\n","nb_bus_with_voltage_value",card(BUSVV) > (fileOut);
printf "%s %i\n","nb_bus_with_reactive_slacks",card(BUSCC_SLACK) > (fileOut);
printf "%s %i\n","nb_bus_without_reactive_slacks",card(BUSCC diff BUSCC_SLACK) > (fileOut);
printf "%s %i\n","nb_branch_in_data_file",card(BRANCH) > (fileOut);
printf "%s %i\n","nb_branch_in_AC_CC",card(BRANCHCC) > (fileOut);
printf "%s %i\n","nb_branch_with_nonsmall_impedance",card(BRANCHCC diff BRANCHZNULL) > (fileOut);
printf "%s %i\n","nb_branch_in_AC_CC",card(ALL_BRANCHCC) > (fileOut);
printf "%s %i\n","nb_branch_in_AC_CC_side_1_opened",card(BRANCHCC_WITH_SIDE_1_OPENED) > (fileOut);
printf "%s %i\n","nb_branch_in_AC_CC_side_2_opened",card(BRANCHCC_WITH_SIDE_2_OPENED) > (fileOut);
printf "%s %i\n","nb_branch_with_nonsmall_impedance",card(ALL_BRANCHCC diff BRANCHZNULL) > (fileOut);
printf "%s %i\n","nb_branch_with_zero_or_small_impedance",card(BRANCHZNULL) > (fileOut);
printf "%s %i\n","nb_unit_in_data_file",card(UNIT) > (fileOut);
printf "%s %i\n","nb_unit_in_AC_CC",card(UNITCC) > (fileOut);
Expand Down Expand Up @@ -376,3 +378,37 @@ for {(g,n) in UNITCC diff UNITON}
'"' & bus_id[1,n] & '"'
> (fileOut);
close (fileOut);

# write flows on the branches
let fileOut := "reactiveopf_results_branches.csv";
printf{LOG_DEBUG} "#qq;m;n;P1;Q1;P2;Q2;branch_id;\n" > (fileOut);
for {(qq,m,n) in ALL_BRANCHCC}
printf{LOG_DEBUG} "%i;%i;%i;%.3f;%.3f;%.3f;%.3f;%s;\n",
qq,m,n,
# p1 flow
if (qq,m,n) in BRANCHCC
then base100MVA * V[m] * Red_Tran_Act_Dir[qq,m,n]
else if (qq,m,n) in BRANCHCC_WITH_SIDE_2_OPENED
then base100MVA * V[m] * Red_Tran_Act_Dir_Side_2_Opened[qq,m,n]
else 0, # no flow as branch is opened on side 1
# q1 flow
if (qq,m,n) in BRANCHCC
then base100MVA * V[m] * Red_Tran_Rea_Dir[qq,m,n]
else if (qq,m,n) in BRANCHCC_WITH_SIDE_2_OPENED
then base100MVA * V[m] * Red_Tran_Rea_Dir_Side_2_Opened[qq,m,n]
else 0, # no flow as branch is opened on side 1
# p2 flow
if (qq,m,n) in BRANCHCC
then base100MVA * V[n] * Red_Tran_Act_Inv[qq,m,n]
else if (qq,m,n) in BRANCHCC_WITH_SIDE_1_OPENED
then base100MVA * V[n] * Red_Tran_Act_Inv_Side_1_Opened[qq,m,n]
else 0, # no flow as branch is opened on side 2
# q2 flow
if (qq,m,n) in BRANCHCC
then base100MVA * V[n] * Red_Tran_Rea_Inv[qq,m,n]
else if (qq,m,n) in BRANCHCC_WITH_SIDE_1_OPENED
then base100MVA * V[n] * Red_Tran_Rea_Inv_Side_1_Opened[qq,m,n]
else 0, # no flow as branch is opened on side 2
'"' & branch_id[1,qq,m,n] & '"'
> (fileOut);
close (fileOut);
Loading
Loading