Skip to content

Commit

Permalink
Add tests for 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 17, 2024
1 parent 998c9f3 commit 7a27af3
Show file tree
Hide file tree
Showing 6 changed files with 537 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
* SPDX-License-Identifier: MPL-2.0
*/
package com.powsybl.openreac.optimization;

import com.powsybl.iidm.network.Network;
import com.powsybl.openreac.network.VoltageControlNetworkFactory;
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;

/**
* Test the equipment bounds in OpenReac optimization.
*
* @author Pierre ARVY {@literal <pierre.arvy at artelys.com>}
*/
class OpecReacOptimizationBoundsTest extends AbstractOpenReacRunnerTest {

@Test
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();
OpenReacResult result = runOpenReac(network, "optimization/bounds/generators-pmax-too-small", true);
assertEquals(OpenReacStatus.NOT_OK, result.getStatus());

// increase max p of generators to allow power balance
network.getGenerator("g2").setMaxP(2.5);
network.getGenerator("g3").setMaxP(2.5);
result = runOpenReac(network, "optimization/bounds/generators-pmax", true);
assertEquals(OpenReacStatus.OK, result.getStatus());
}

@Test
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.getLoad("l4").setP0(3);
network.getGenerator("g2").setMinP(2);
network.getGenerator("g3").setMinP(2);
OpenReacResult result = runOpenReac(network, "optimization/bounds/generators-pmin-too-high", true);
assertEquals(OpenReacStatus.NOT_OK, result.getStatus());

// decrease min p of generators to allow power balance
// but targetP will be fixed in optimization, because it is too close of maxP
network.getGenerator("g2").setMinP(1);
network.getGenerator("g3").setMinP(1);
result = runOpenReac(network, "optimization/bounds/generators-target-p-too-close-pmax", true);
assertEquals(OpenReacStatus.NOT_OK, result.getStatus());

// increase max p of generators to allow modification of targetP in optimization
network.getGenerator("g2").setMaxP(2.5);
network.getGenerator("g3").setMaxP(2.5);
result = runOpenReac(network, "optimization/bounds/generators-pmin", true);
assertEquals(OpenReacStatus.OK, result.getStatus());
}

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

ctime_start 'Wed Dec 04 18:39:06 2024'
last_solve_result_num 200
nb_iter_last 67
nb_iter_total 67
_ampl_elapsed_time 0.140000
_total_solve_time 0.046875
total_time 0

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

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.05
min_teta_ac -0.03
teta_min -3.05
max_delta_teta_dc 0.050000
max_delta_teta_ac 0.030638
min_delta_teta_dc -0.025000
min_delta_teta_ac -0.014361

nb_reactive_slacks 4
nb_slacks_condensator 4
sum_slacks_condensator 2.6
nb_slacks_self 4
sum_slacks_self 2.5
messageInfo1 'Acopf optimization was ***not*** successfull - Convergence to an infeasible solution'
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
final_status OK
dcopf_status OK

ctime_start 'Wed Dec 04 18:39:06 2024'
last_solve_result_num 0
nb_iter_last 7
nb_iter_total 7
_ampl_elapsed_time 0.139000
_total_solve_time 0.031250
total_time 0

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

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.03
teta_max 3.02
min_teta_dc -0.05
min_teta_ac -0.05
teta_min -3.05
max_delta_teta_dc 0.050000
max_delta_teta_ac 0.051670
min_delta_teta_dc -0.025000
min_delta_teta_ac -0.025352

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

ctime_start 'Wed Dec 04 18:39:05 2024'
last_solve_result_num 200
nb_iter_last 60
nb_iter_total 60
_ampl_elapsed_time 0.155000
_total_solve_time 0.046875
total_time 0

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

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.01
max_teta_ac 0.02
teta_max 3.01
min_teta_dc -0.03
min_teta_ac -0.04
teta_min -3.03
max_delta_teta_dc 0.030000
max_delta_teta_ac 0.035331
min_delta_teta_dc -0.015000
min_delta_teta_ac -0.018693

nb_reactive_slacks 4
nb_slacks_condensator 4
sum_slacks_condensator 1.3
nb_slacks_self 4
sum_slacks_self 1.2
messageInfo1 'Acopf optimization was ***not*** successfull - Convergence to an infeasible solution'
Loading

0 comments on commit 7a27af3

Please sign in to comment.