Skip to content

Commit

Permalink
Add TUs on Q bounds
Browse files Browse the repository at this point in the history
Signed-off-by: p-arvy <pierre.arvy@artelys.com>
  • Loading branch information
p-arvy committed Dec 13, 2024
1 parent 2369941 commit 655c429
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

import com.powsybl.iidm.network.Network;
import com.powsybl.openreac.network.VoltageControlNetworkFactory;
import com.powsybl.openreac.parameters.input.OpenReacParameters;
import com.powsybl.openreac.parameters.output.OpenReacResult;
import com.powsybl.openreac.parameters.output.OpenReacStatus;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.*;

/**
* Test the equipment bounds in OpenReac optimization.
Expand All @@ -29,7 +30,7 @@ void testGeneratorsMaxPBounds() throws IOException {
Network network = VoltageControlNetworkFactory.createWithTwoVoltageControls();
// due to the disconnection, the network is now imbalanced
// and max p of generators is not enough to provide balance
network.getLine("l45").getTerminal2().disconnect();
network.getLine("l45").disconnect();
OpenReacResult result = runOpenReac(network, "optimization/bounds/generators-pmax-too-small", true);
assertEquals(OpenReacStatus.NOT_OK, result.getStatus());

Expand All @@ -45,7 +46,7 @@ void testGeneratorsMinPBounds() throws IOException {
Network network = VoltageControlNetworkFactory.createWithTwoVoltageControls();
// due to the modifications, the network is now imbalanced
// and min p of generators is not small enough to provide balance
network.getLine("l45").getTerminal2().disconnect();
network.getLine("l45").disconnect();
network.getLoad("l4").setP0(3);
network.getGenerator("g2").setMinP(2);
network.getGenerator("g3").setMinP(2);
Expand All @@ -66,4 +67,61 @@ void testGeneratorsMinPBounds() throws IOException {
assertEquals(OpenReacStatus.OK, result.getStatus());
}

@Test
void testGeneratorRectangularQBounds() throws IOException {
Network network = VoltageControlNetworkFactory.createWithTwoVoltageControls();
network.getLine("l45").disconnect();
network.getLoad("l4").setP0(4).setQ0(2);

// set reactive limits to both generators
network.getGenerator("g2").newReactiveCapabilityCurve()
.beginPoint()
.setP(0)
.setMinQ(-0.25)
.setMaxQ(0.25)
.endPoint()
.beginPoint()
.setP(2)
.setMinQ(-2)
.setMaxQ(2)
.endPoint()
.add();
network.getGenerator("g3").newReactiveCapabilityCurve()
.beginPoint()
.setP(0)
.setMinQ(-0.25)
.setMaxQ(0.25)
.endPoint()
.beginPoint()
.setP(2)
.setMinQ(-2)
.setMaxQ(2)
.endPoint()
.add();

OpenReacResult result = runOpenReac(network, "optimization/bounds/generator-rectangular-bounds", true);
assertEquals(OpenReacStatus.OK, result.getStatus());
// rectangular bounds in ACOPF implies Q bounds are not large enough to remove reactive slacks in optimization
assertTrue(Integer.parseInt(result.getIndicators().get("nb_reactive_slacks")) > 0);
}

@Test
void testGeneratorQmaxPmaxRatioBounds() throws IOException {
Network network = VoltageControlNetworkFactory.createWithTwoVoltageControls();
network.getLine("l45").disconnect();
network.getLoad("l4").setP0(4).setQ0(2);

OpenReacParameters parameters = new OpenReacParameters();
OpenReacResult result = runOpenReac(network, "optimization/bounds/qmax-pmax-default-ratio", parameters, true);
assertEquals(OpenReacStatus.OK, result.getStatus());
// there are slacks as Q bounds are not large enough
assertTrue(Integer.parseInt(result.getIndicators().get("nb_reactive_slacks")) > 0);

parameters.setDefaultQmaxPmaxRatio(1);
result = runOpenReac(network, "optimization/bounds/same-qmax-pmax", parameters, true);
assertEquals(OpenReacStatus.OK, result.getStatus());
// Q bounds are large enough to remove reactive slacks in optimization
assertEquals(0, Integer.parseInt(result.getIndicators().get("nb_reactive_slacks")));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
final_status OK
dcopf_status OK

ctime_start 'Fri Dec 13 17:11:19 2024'
last_solve_result_num 0
nb_iter_last 16
nb_iter_total 16
_ampl_elapsed_time 0.110000
_total_solve_time 0.031250
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_16986647128066492619'

log_level_ampl INFO
log_level_knitro 2
objective_choice 0
ratio_voltage_target 0.500000
coeff_alpha 1.000000
Pnull 0.010000
Znull 0.000100
epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks ALL
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
defaultQmaxPmaxRatio 0.300000
defaultQmin -300.000000
defaultQmax 300.000000
minimalQPrange 1.000000
default_variable_scaling_factor 1.000000
default_constraint_scaling_factor 1.000000
reactive_slack_variable_scaling_factor 0.100000
transformer_ratio_variable_scaling_factor 0.001000
shunt_variable_scaling_factor 0.100000

nb_substations 5
nb_bus_in_data_file 5
nb_bus_in_ACDC_CC 4
nb_bus_in_AC_CC 4
nb_bus_in_ACDC_but_out_AC_CC 0
nb_bus_with_voltage_value 0
nb_bus_with_reactive_slacks 4
nb_bus_without_reactive_slacks 0
nb_branch_in_data_file 4
nb_branch_in_AC_CC 3
nb_branch_with_nonsmall_impedance 3
nb_branch_with_zero_or_small_impedance 0
nb_unit_in_data_file 3
nb_unit_in_AC_CC 2
nb_unit_up_and_running 2
nb_unit_with_variable_reactive_power 2
nb_unit_with_fixed_reactive_power 0
nb_load_in_data_file 2
nb_load_in_AC_CC 1
nb_shunt_in_data_file 0
nb_shunt_connectable_or_in_AC_CC 0
nb_shunt_with_fixed_value 0
nb_shunt_with_variable_value 0
nb_transformers_with_variable_ratio 0
nb_transformers_with_fixed_ratio 0
nb_svc_in_data_file 0
nb_svc_in_AC_CC 0
nb_svc_up_and_operating 0
nb_vsc_converter_in_data_file 0
nb_vsc_converter_up_and_running 0
nb_lcc_converter_in_data_file 0
nb_lcc_converter_up_and_running 0
nb_batteries 0
sum_batteries_pmax 0.0
sum_batteries_pmin 0.0

max_teta_dc 0.02
max_teta_ac 0.01
teta_max 3.02
min_teta_dc -0.04
min_teta_ac -0.02
teta_min -3.04
max_delta_teta_dc 0.040000
max_delta_teta_ac 0.017957
min_delta_teta_dc -0.020000
min_delta_teta_ac -0.008898

nb_reactive_slacks 2
nb_slacks_condensator 2
sum_slacks_condensator 1.6
nb_slacks_self 0
sum_slacks_self 0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
final_status OK
dcopf_status OK

ctime_start 'Fri Dec 13 17:28:32 2024'
last_solve_result_num 0
nb_iter_last 11
nb_iter_total 11
_ampl_elapsed_time 0.158000
_total_solve_time 0.031250
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_5023287104601431718'

log_level_ampl INFO
log_level_knitro 2
objective_choice 0
ratio_voltage_target 0.500000
coeff_alpha 1.000000
Pnull 0.010000
Znull 0.000100
epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks ALL
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
defaultQmaxPmaxRatio 0.300000
defaultQmin -300.000000
defaultQmax 300.000000
minimalQPrange 1.000000
default_variable_scaling_factor 1.000000
default_constraint_scaling_factor 1.000000
reactive_slack_variable_scaling_factor 0.100000
transformer_ratio_variable_scaling_factor 0.001000
shunt_variable_scaling_factor 0.100000

nb_substations 5
nb_bus_in_data_file 5
nb_bus_in_ACDC_CC 4
nb_bus_in_AC_CC 4
nb_bus_in_ACDC_but_out_AC_CC 0
nb_bus_with_voltage_value 0
nb_bus_with_reactive_slacks 4
nb_bus_without_reactive_slacks 0
nb_branch_in_data_file 4
nb_branch_in_AC_CC 3
nb_branch_with_nonsmall_impedance 3
nb_branch_with_zero_or_small_impedance 0
nb_unit_in_data_file 3
nb_unit_in_AC_CC 2
nb_unit_up_and_running 2
nb_unit_with_variable_reactive_power 2
nb_unit_with_fixed_reactive_power 0
nb_load_in_data_file 2
nb_load_in_AC_CC 1
nb_shunt_in_data_file 0
nb_shunt_connectable_or_in_AC_CC 0
nb_shunt_with_fixed_value 0
nb_shunt_with_variable_value 0
nb_transformers_with_variable_ratio 0
nb_transformers_with_fixed_ratio 0
nb_svc_in_data_file 0
nb_svc_in_AC_CC 0
nb_svc_up_and_operating 0
nb_vsc_converter_in_data_file 0
nb_vsc_converter_up_and_running 0
nb_lcc_converter_in_data_file 0
nb_lcc_converter_up_and_running 0
nb_batteries 0
sum_batteries_pmax 0.0
sum_batteries_pmin 0.0

max_teta_dc 0.02
max_teta_ac 0.01
teta_max 3.02
min_teta_dc -0.04
min_teta_ac -0.02
teta_min -3.04
max_delta_teta_dc 0.040000
max_delta_teta_ac 0.017964
min_delta_teta_dc -0.020000
min_delta_teta_ac -0.008913

nb_reactive_slacks 1
nb_slacks_condensator 1
sum_slacks_condensator 0.9
nb_slacks_self 0
sum_slacks_self 0.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
final_status OK
dcopf_status OK

ctime_start 'Fri Dec 13 17:39:45 2024'
last_solve_result_num 0
nb_iter_last 6
nb_iter_total 6
_ampl_elapsed_time 0.064000
_total_solve_time 0.046875
total_time 0

operatingSystem windows
OS 'Windows_NT'
COMPUTERNAME 'ARTELYS-PC253'
directory 'C:\Users\parvy\AppData\Local\Temp\ampl_13860690371447850895'

log_level_ampl INFO
log_level_knitro 2
objective_choice 0
ratio_voltage_target 0.500000
coeff_alpha 1.000000
Pnull 0.010000
Znull 0.000100
epsilon_nominal_voltage 1.000000
min_plausible_low_voltage_limit 0.500000
max_plausible_high_voltage_limit 1.500000
ignore_voltage_bounds 0.000000
buses_with_reactive_slacks ALL
PQmax 9000.000000
defaultPmax 1000.000000
defaultPmin 0.000000
defaultQmaxPmaxRatio 1.000000
defaultQmin -1000.000000
defaultQmax 1000.000000
minimalQPrange 1.000000
default_variable_scaling_factor 1.000000
default_constraint_scaling_factor 1.000000
reactive_slack_variable_scaling_factor 0.100000
transformer_ratio_variable_scaling_factor 0.001000
shunt_variable_scaling_factor 0.100000

nb_substations 5
nb_bus_in_data_file 5
nb_bus_in_ACDC_CC 4
nb_bus_in_AC_CC 4
nb_bus_in_ACDC_but_out_AC_CC 0
nb_bus_with_voltage_value 0
nb_bus_with_reactive_slacks 4
nb_bus_without_reactive_slacks 0
nb_branch_in_data_file 4
nb_branch_in_AC_CC 3
nb_branch_with_nonsmall_impedance 3
nb_branch_with_zero_or_small_impedance 0
nb_unit_in_data_file 3
nb_unit_in_AC_CC 2
nb_unit_up_and_running 2
nb_unit_with_variable_reactive_power 2
nb_unit_with_fixed_reactive_power 0
nb_load_in_data_file 2
nb_load_in_AC_CC 1
nb_shunt_in_data_file 0
nb_shunt_connectable_or_in_AC_CC 0
nb_shunt_with_fixed_value 0
nb_shunt_with_variable_value 0
nb_transformers_with_variable_ratio 0
nb_transformers_with_fixed_ratio 0
nb_svc_in_data_file 0
nb_svc_in_AC_CC 0
nb_svc_up_and_operating 0
nb_vsc_converter_in_data_file 0
nb_vsc_converter_up_and_running 0
nb_lcc_converter_in_data_file 0
nb_lcc_converter_up_and_running 0
nb_batteries 0
sum_batteries_pmax 0.0
sum_batteries_pmin 0.0

max_teta_dc 0.02
max_teta_ac 0.01
teta_max 3.02
min_teta_dc -0.04
min_teta_ac -0.02
teta_min -3.04
max_delta_teta_dc 0.040000
max_delta_teta_ac 0.018117
min_delta_teta_dc -0.020000
min_delta_teta_ac -0.008933

nb_reactive_slacks 0
nb_slacks_condensator 0
sum_slacks_condensator 0.0
nb_slacks_self 0
sum_slacks_self 0.0

0 comments on commit 655c429

Please sign in to comment.