Skip to content

Commit

Permalink
Adapt iidm importer to extended version of AMPL exporter (#81)
Browse files Browse the repository at this point in the history
* Adapt iidm importer to new version of AMPL exporter
* Small fix
* Update README

---------

Signed-off-by: p-arvy <[email protected]>
  • Loading branch information
p-arvy authored Nov 19, 2024
1 parent 837fb4b commit e432731
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 28 deletions.
2 changes: 1 addition & 1 deletion open-reac/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ each serving a specific function:
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 the
[AMPL export of PowSyBl](https://github.com/powsybl/powsybl-core/blob/main/ampl-converter/src/main/java/com/powsybl/ampl/converter/AmplNetworkWriter.java).
[extended version of PowSyBl AMPL export](https://github.com/powsybl/powsybl-core/blob/main/ampl-converter/src/main/java/com/powsybl/ampl/converter/version/ExtendedAmplExporter.java), which is the default version.

#### 3.2 Configuration of the run

Expand Down
2 changes: 1 addition & 1 deletion open-reac/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<description>OpenReac optimizer</description>

<properties>
<powsybl-core.version>6.4.1</powsybl-core.version>
<powsybl-core.version>6.5.0-RC1</powsybl-core.version>
<powsybl-open-loadflow.version>1.12.1</powsybl-open-loadflow.version>
</properties>

Expand Down
45 changes: 27 additions & 18 deletions open-reac/src/main/resources/openreac/iidm_importer.mod
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ check maximal_voltage_upper_bound > minimal_voltage_lower_bound;
set BUS dimen 2 ; # [variant, bus]
param bus_substation{BUS} integer;
param bus_CC {BUS} integer; # num of connex component. Computation only in CC number 0 (=main connex component)
param bus_SC {BUS} integer; # num of synchronous component. Computation only in SC number 0 (=main synchronous component)
param bus_V0 {BUS};
param bus_angl0 {BUS};
param bus_injA {BUS};
param bus_injR {BUS};
param bus_slack {BUS} symbolic; # Is bus a slack bus
param bus_fault {BUS};
param bus_curative {BUS};
param bus_id {BUS} symbolic;
Expand All @@ -95,31 +97,33 @@ param null_phase_bus;
set UNIT dimen 3; # [variant, unit, bus]
param unit_potentialbus{UNIT} integer;
param unit_substation {UNIT} integer;
param unit_Pmin {UNIT};
param unit_Pmax {UNIT};
param unit_qP {UNIT};
param unit_qp0 {UNIT};
param unit_qp {UNIT};
param unit_QP {UNIT};
param unit_Qp0 {UNIT};
param unit_Qp {UNIT};
param unit_vregul {UNIT} symbolic; # Does unit do voltage regulation, or PQ bus?
param unit_Vc {UNIT}; # Voltage set point (in case of voltage regulation)
param unit_Pc {UNIT}; # Active power set point
param unit_Qc {UNIT}; # Rective power set point (in case no voltage regulation)
param unit_fault {UNIT};
param unit_curative{UNIT};
param unit_id {UNIT} symbolic;
param unit_name {UNIT} symbolic; # description
param unit_P0 {UNIT}; # Initial value of P (if relevant)
param unit_Q0 {UNIT}; # Initial value of Q (if relevant)
param unit_Pmin {UNIT};
param unit_Pmax {UNIT};
param unit_qP {UNIT};
param unit_qp0 {UNIT};
param unit_qp {UNIT};
param unit_QP {UNIT};
param unit_Qp0 {UNIT};
param unit_Qp {UNIT};
param unit_vregul {UNIT} symbolic; # Does unit do voltage regulation, or PQ bus?
param unit_vregul_bus {UNIT} integer; # Bus regulated by unit, if it does voltage regulation
param unit_Vc {UNIT}; # Voltage set point (in case of voltage regulation)
param unit_Pc {UNIT}; # Active power set point
param unit_Qc {UNIT}; # Rective power set point (in case no voltage regulation)
param unit_fault {UNIT};
param unit_curative {UNIT};
param unit_id {UNIT} symbolic;
param unit_name {UNIT} symbolic; # description
param unit_P0 {UNIT}; # Initial value of P (if relevant)
param unit_Q0 {UNIT}; # Initial value of Q (if relevant)

#
# Consistency
#
check {(t,g,n) in UNIT}: t in TIME;
check {(t,g,n) in UNIT}: (t,n) in BUS or n==-1;
check {(t,g,n) in UNIT}: (t,unit_substation[t,g,n]) in SUBSTATIONS;
check {(t,g,n) in UNIT}: (t,unit_vregul_bus[t,g,n]) in BUS or unit_vregul_bus[t,g,n] == -1;
check {(t,g,n) in UNIT}: unit_Pmax[t,g,n] >= -Pnull;
check {(t,g,n) in UNIT}: unit_Pmax[t,g,n] >= unit_Pmin[t,g,n];
# Checks below are useless since values will be corrected for units in UNITON
Expand Down Expand Up @@ -202,6 +206,7 @@ param svc_substation {SVC} integer;
param svc_bmin {SVC}; # Susceptance B in p.u.: compute B*100*V^2 to get MVAr
param svc_bmax {SVC}; # Susceptance B in p.u.: compute B*100*V^2 to get MVAr
param svc_vregul {SVC} symbolic; # true if SVC is in voltage regulation mode
param svc_vregul_bus {SVC} integer; # Bus regulated by SVC, if it is in voltage regulation mode
param svc_targetV {SVC}; # Voltage target for voltage regulation mode
param svc_targetQ {SVC};
param svc_fault {SVC};
Expand All @@ -214,6 +219,7 @@ param svc_Q0 {SVC}; # Fixed value to be used if SVC is not in voltage r
# Consistency checks
check {(t,svc,n) in SVC}: (t,n) in BUS or n==-1;
check {(t,svc,n) in SVC}: (t,svc_substation[t,svc,n]) in SUBSTATIONS;
check {(t,svc,n) in SVC}: (t,svc_vregul_bus[t,svc,n]) in BUS or svc_vregul_bus[t,svc,n] == -1;



Expand Down Expand Up @@ -259,7 +265,10 @@ check {(t,b,n) in BATTERY} : abs(battery_q0[t,b,n]) <= PQmax;

set TAPS dimen 3; # [variant, num, tap]
param tap_ratio {TAPS};
param tap_r {TAPS};
param tap_x {TAPS};
param tap_g {TAPS};
param tap_b {TAPS};
param tap_angle {TAPS};
param tap_fault {TAPS};
param tap_curative {TAPS};
Expand Down
16 changes: 8 additions & 8 deletions open-reac/src/main/resources/openreac/reactiveopf.dat
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ data;
param: SUBSTATIONS: substation_horizon substation_fodist substation_Vnomi substation_Vmin substation_Vmax substation_fault substation_curative substation_country substation_id substation_description := include ampl_network_substations.txt;

# ampl_network_buses.txt
#"variant" "num" "substation" "cc" "v (pu)" "theta (rad)" "p (MW)" "q (MVar)" "fault" "curative" "id"
param: BUS: bus_substation bus_CC bus_V0 bus_angl0 bus_injA bus_injR bus_fault bus_curative bus_id := include ampl_network_buses.txt;
#"variant" "num" "substation" "cc" "sc" "v (pu)" "theta (rad)" "p (MW)" "q (MVar)" "slack bus" "fault" "curative" "id"
param: BUS: bus_substation bus_CC bus_SC bus_V0 bus_angl0 bus_injA bus_injR bus_slack bus_fault bus_curative bus_id := include ampl_network_buses.txt;

# ampl_network_generators.txt
#"variant" "num" "bus" "con. bus" "substation" "minP (MW)" "maxP (MW)" "minQmaxP (MVar)" "minQ0 (MVar)" "minQminP (MVar)" "maxQmaxP (MVar)" "maxQ0 (MVar)" "maxQminP (MVar)" "v regul." "targetV (pu)" "targetP (MW)" "targetQ (MVar)" "fault" "curative" "id" "description" "P (MW)" "Q (MVar)"
param: UNIT: unit_potentialbus unit_substation unit_Pmin unit_Pmax unit_qP unit_qp0 unit_qp unit_QP unit_Qp0 unit_Qp unit_vregul unit_Vc unit_Pc unit_Qc unit_fault unit_curative unit_id unit_name unit_P0 unit_Q0 := include ampl_network_generators.txt;
#"variant" "num" "bus" "con. bus" "substation" "minP (MW)" "maxP (MW)" "minQmaxP (MVar)" "minQ0 (MVar)" "minQminP (MVar)" "maxQmaxP (MVar)" "maxQ0 (MVar)" "maxQminP (MVar)" "v regul." "v regul. bus" "targetV (pu)" "targetP (MW)" "targetQ (MVar)" "fault" "curative" "id" "description" "P (MW)" "Q (MVar)"
param: UNIT: unit_potentialbus unit_substation unit_Pmin unit_Pmax unit_qP unit_qp0 unit_qp unit_QP unit_Qp0 unit_Qp unit_vregul unit_vregul_bus unit_Vc unit_Pc unit_Qc unit_fault unit_curative unit_id unit_name unit_P0 unit_Q0 := include ampl_network_generators.txt;

# ampl_network_loads.txt
#"variant" "num" "bus" "substation" "p (MW)" "q (MVar)" "fault" "curative" "id" "description" "p (MW)" "q (MVar)"
Expand All @@ -37,16 +37,16 @@ param: LOAD: load_substation load_PFix load_QFix load_fault load_curative load_i
param: SHUNT: shunt_possiblebus shunt_substation shunt_valmin shunt_valmax shunt_interPoints shunt_valnom shunt_fault shunt_curative shunt_id shunt_nom shunt_P0 shunt_Q0 shunt_sections_count := include ampl_network_shunts.txt;

# ampl_network_static_var_compensators.txt
#"variant" "num" "bus" "con. bus" "substation" "minB (pu)" "maxB (pu)" "v regul." "targetV (pu)" "targetQ (MVar)" "fault" "curative" "id" "description" "P (MW)" "Q (MVar)"
param: SVC: svc_possiblebus svc_substation svc_bmin svc_bmax svc_vregul svc_targetV svc_targetQ svc_fault svc_curative svc_id svc_description svc_P0 svc_Q0 := include ampl_network_static_var_compensators.txt;
#"variant" "num" "bus" "con. bus" "substation" "minB (pu)" "maxB (pu)" "v regul." "v regul. bus" "targetV (pu)" "targetQ (MVar)" "fault" "curative" "id" "description" "P (MW)" "Q (MVar)"
param: SVC: svc_possiblebus svc_substation svc_bmin svc_bmax svc_vregul svc_vregul_bus svc_targetV svc_targetQ svc_fault svc_curative svc_id svc_description svc_P0 svc_Q0 := include ampl_network_static_var_compensators.txt;

# ampl_network_batteries.txt
#"variant" "num" "bus" "con. bus" "substation" "p0 (MW)" "q0 (MW)" "minP (MW)" "maxP (MW)" "minQmaxP (MVar)" "minQ0 (MVar)" "minQminP (MVar)" "maxQmaxP (MVar)" "maxQ0 (MVar)" "maxQminP (MVar)" "fault" "curative" "id" "description" "P (MW)" "Q (MVar)"
param: BATTERY: battery_possiblebus battery_substation battery_p0 battery_q0 battery_Pmin battery_Pmax battery_qP battery_qp0 battery_qp battery_QP battery_Qp0 battery_Qp battery_fault battery_curative battery_id battery_name battery_P0 battery_Q0 := include ampl_network_batteries.txt;

# ampl_network_tct.txt
#"variant" "num" "tap" "var ratio" "x (pu)" "angle (rad)" "fault" "curative"
param: TAPS: tap_ratio tap_x tap_angle tap_fault tap_curative := include ampl_network_tct.txt;
#"variant" "num" "tap" "var ratio" "r (pu)" "x (pu)" "g (pu)" "b (pu)" "angle (rad)" "fault" "curative"
param: TAPS: tap_ratio tap_r tap_x tap_g tap_b tap_angle tap_fault tap_curative := include ampl_network_tct.txt;

# ampl_network_rtc.txt
#"num" "tap" "table" "onLoad" "targetV" "fault" "curative" "id"
Expand Down

0 comments on commit e432731

Please sign in to comment.