Skip to content

Commit

Permalink
Merge pull request #868 from PowerGridModel/step-up-trafo-validation
Browse files Browse the repository at this point in the history
Step-up transformer tap changer support: additional tests
  • Loading branch information
figueroa1395 authored Jan 21, 2025
2 parents ef777a7 + e81df62 commit 84dcd7f
Show file tree
Hide file tree
Showing 49 changed files with 608 additions and 7 deletions.
63 changes: 56 additions & 7 deletions tests/cpp_unit_tests/test_tap_position_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ TEST_CASE("Test Transformer ranking") {
CHECK_NOTHROW(pgm_tap::build_transformer_graph(get_state(6, 2, 1, 4, 5)));
}

SUBCASE("Full grid") {
SUBCASE("Full grid 1 - For graph construction steps") {
// =====Test Grid=====
// ________[0]________
// || | |
Expand Down Expand Up @@ -324,15 +324,64 @@ TEST_CASE("Test Transformer ranking") {
}

SUBCASE("Ranking complete the graph") {
// (TODO: jguo) existing demo grid is not compatible with the updated ranking
// The test grid needs to be updated here to match the new ranking logic
// pgm_tap::RankedTransformerGroups order = pgm_tap::rank_transformers(state);
// pgm_tap::RankedTransformerGroups const ref_order{
// {{Idx2D{3, 0}, Idx2D{3, 1}, Idx2D{4, 0}}, {Idx2D{3, 3}, Idx2D{3, 2}, Idx2D{3, 4}}}};
// CHECK(order == ref_order);
// The test grid 1 is not compatible with the updated logic for step up transformers
CHECK_THROWS_AS(pgm_tap::rank_transformers(state), AutomaticTapInputError);
}
}

// The test grid 2 is compatible with the updated logic for step up transformers
SUBCASE("Full grid 2 - For transformer ranking only") {
// =====Test Grid=====
// ________[0]________
// || | |
// [1] [4]--[5]
// | | |
// [2] | [8]
// | [6] |
// [3]----[7]---| [9]
// | |
// L--------------[10]
TestState state;
std::vector<NodeInput> nodes{{0, 150e3}, {1, 10e3}, {2, 10e3}, {3, 10e3}, {4, 10e3}, {5, 50e3},
{6, 10e3}, {7, 10e3}, {8, 10e3}, {9, 10e3}, {10, 10e3}};
main_core::add_component<Node>(state, nodes.begin(), nodes.end(), 50.0);

std::vector<TransformerInput> transformers{
get_transformer(11, 0, 1, BranchSide::from), get_transformer(12, 0, 1, BranchSide::from),
get_transformer(13, 2, 3, BranchSide::from), get_transformer(14, 6, 7, BranchSide::from),
get_transformer(15, 5, 8, BranchSide::from), get_transformer(16, 9, 10, BranchSide::from)};
main_core::add_component<Transformer>(state, transformers.begin(), transformers.end(), 50.0);

std::vector<ThreeWindingTransformerInput> transformers3w{
get_transformer3w(17, 0, 4, 5, Branch3Side::side_2, 0)};
main_core::add_component<ThreeWindingTransformer>(state, transformers3w.begin(), transformers3w.end(), 50.0);

std::vector<LineInput> lines{get_line_input(18, 4, 6), get_line_input(19, 3, 10)};
main_core::add_component<Line>(state, lines.begin(), lines.end(), 50.0);

std::vector<LinkInput> links{{20, 1, 2, 1, 1}, {21, 3, 7, 1, 1}, {22, 8, 9, 1, 1}};
main_core::add_component<Link>(state, links.begin(), links.end(), 50.0);

std::vector<SourceInput> sources{{23, 0, 1, 1.0, 0, nan, nan, nan}};
main_core::add_component<Source>(state, sources.begin(), sources.end(), 50.0);

std::vector<TransformerTapRegulatorInput> regulators{
get_regulator(24, 11, ControlSide::to), get_regulator(25, 12, ControlSide::to),
get_regulator(26, 13, ControlSide::to), get_regulator(27, 14, ControlSide::to),
get_regulator(28, 15, ControlSide::to), get_regulator(29, 16, ControlSide::to),
get_regulator(30, 17, ControlSide::side_2)};
main_core::add_component<TransformerTapRegulator>(state, regulators.begin(), regulators.end(), 50.0);

state.components.set_construction_complete();

// Subcases
SUBCASE("Ranking complete the graph") {
pgm_tap::RankedTransformerGroups order = pgm_tap::rank_transformers(state);
pgm_tap::RankedTransformerGroups const ref_order{
{{Idx2D{3, 0}, Idx2D{3, 1}, Idx2D{4, 0}, Idx2D{3, 4}}, {Idx2D{3, 2}, Idx2D{3, 3}, Idx2D{3, 5}}}};
CHECK(order == ref_order);
}
}
}

namespace optimizer::tap_position_optimizer::test {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "u_rated": 150000},
{"id": 4, "u_rated": 10500},
{"id": 6, "u_rated": 21000}
],
"transformer": [
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 150000, "u2": 11000, "sn": 66000000, "uk": 0.199, "pk": 217000, "i0": 1e-3, "p0": 19500, "winding_from": 1, "winding_to": 2, "clock": 5, "tap_side": 0, "tap_pos": -1, "tap_min": -8, "tap_max": 9, "tap_size": 2500},
{"id": 5, "from_node": 4, "to_node": 6, "from_status": 1, "to_status": 1, "u1": 10600, "u2": 21000, "sn": 20000000, "uk": 0.119, "pk": 127000, "i0": 1e-03, "p0": 5700, "winding_from": 1, "winding_to": 1, "clock": 2, "tap_side": 1, "tap_pos": 4, "tap_min": -13, "tap_max": 4, "tap_size": 270}
],
"sym_load": [
{"id": 7, "node": 6, "status": 1, "type": 0, "p_specified": 10000000, "q_specified": 5000000}
],
"source": [
{"id": 1, "node": 2, "status": 1, "u_ref": 1.0}
],
"transformer_tap_regulator": [
{"id": 8, "regulated_object": 5, "status": 1, "control_side": 1, "u_set": 21000, "u_band": 522}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"calculation_method": "newton_raphson",
"tap_changing_strategy": "any_valid_tap",
"rtol": 1e-05,
"atol": 1e-05,
"fail": {
"raises": "AssertionError",
"reason": "Results don't match expected values due to the step up transformer"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "energized": 1, "u_pu": 0.999278516660926, "u": 149891.7774991389, "u_angle": -4.976276188195561e-08, "p": 10072090.38950087, "q": 6233932.488836197},
{"id": 4, "energized": 1, "u_pu": 1.04527504169727, "u": 10975.38793782133, "u_angle": -2.618511710996588, "p": 1.347554049236793e-07, "q": -6.249688283352644e-08},
{"id": 6, "energized": 1, "u_pu": 1.000888626113226, "u": 21018.66114837775, "u_angle": -2.618511710996588, "p": -10000000.00000001, "q": -4999999.999999996}
],
"transformer": [
{"id": 3, "energized": 1, "loading": 0.1794728270763556, "p_from": 10072090.38950087, "q_from": 6233932.488836197, "i_from": 45.62513918866066, "s_from": 11845206.58703947, "p_to": -10045576.12305796, "q_to": -5762159.458271895, "i_to": 609.2000361925834, "s_to": 11580849.76444753},
{"id": 5, "energized": 1, "loading": 0.579042488222381, "p_from": 10045576.12305808, "q_from": 5762159.458271859, "i_from": 609.2000361925881, "s_from": 11580849.76444762, "p_to": -10000000.00000001, "q_to": -4999999.999999996, "i_to": 307.1067275936952, "s_to": 11180339.88749895}
],
"sym_load": [
{"id": 7, "energized": 1, "p": 10000000, "q": 5000000, "i": 307.1067275936951, "s": 11180339.88749895, "pf": 0.8944271909999159}
],
"source": [
{"id": 1, "energized": 1, "p": 10072090.38950087, "q": 6233932.488836197, "i": 45.62513918866066, "s": 11845206.58703947, "pf": 0.8503093901731802}
],
"transformer_tap_regulator": [
{"id": 8, "energized": 1, "tap_pos": 0}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "u_rated": 150000},
{"id": 4, "u_rated": 10500},
{"id": 6, "u_rated": 21000}
],
"transformer": [
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 150000, "u2": 11000, "sn": 66000000, "uk": 0.199, "pk": 217000, "i0": 1e-3, "p0": 19500, "winding_from": 1, "winding_to": 2, "clock": 5, "tap_side": 0, "tap_pos": -1, "tap_min": -8, "tap_max": 9, "tap_size": 2500},
{"id": 5, "from_node": 4, "to_node": 6, "from_status": 1, "to_status": 1, "u1": 10600, "u2": 21000, "sn": 20000000, "uk": 0.119, "pk": 127000, "i0": 1e-03, "p0": 5700, "winding_from": 1, "winding_to": 1, "clock": 2, "tap_side": 1, "tap_pos": 4, "tap_min": -13, "tap_max": 4, "tap_size": 270}
],
"sym_load": [
{"id": 7, "node": 6, "status": 1, "type": 0, "p_specified": 10000000, "q_specified": 5000000}
],
"source": [
{"id": 1, "node": 2, "status": 1, "u_ref": 1.0}
],
"transformer_tap_regulator": [
{"id": 8, "regulated_object": 5, "status": 1, "control_side": 1, "u_set": 21000, "u_band": 522}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"calculation_method": "newton_raphson",
"tap_changing_strategy": "fast_any_tap",
"rtol": 1e-05,
"atol": 1e-05,
"fail": {
"raises": "AssertionError",
"reason": "Results don't match expected values due to the step up transformer"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "energized": 1, "u_pu": 0.999278516660926, "u": 149891.7774991389, "u_angle": -4.976276188195561e-08, "p": 10072090.38950087, "q": 6233932.488836197},
{"id": 4, "energized": 1, "u_pu": 1.04527504169727, "u": 10975.38793782133, "u_angle": -2.618511710996588, "p": 1.347554049236793e-07, "q": -6.249688283352644e-08},
{"id": 6, "energized": 1, "u_pu": 1.000888626113226, "u": 21018.66114837775, "u_angle": -2.618511710996588, "p": -10000000.00000001, "q": -4999999.999999996}
],
"transformer": [
{"id": 3, "energized": 1, "loading": 0.1794728270763556, "p_from": 10072090.38950087, "q_from": 6233932.488836197, "i_from": 45.62513918866066, "s_from": 11845206.58703947, "p_to": -10045576.12305796, "q_to": -5762159.458271895, "i_to": 609.2000361925834, "s_to": 11580849.76444753},
{"id": 5, "energized": 1, "loading": 0.579042488222381, "p_from": 10045576.12305808, "q_from": 5762159.458271859, "i_from": 609.2000361925881, "s_from": 11580849.76444762, "p_to": -10000000.00000001, "q_to": -4999999.999999996, "i_to": 307.1067275936952, "s_to": 11180339.88749895}
],
"sym_load": [
{"id": 7, "energized": 1, "p": 10000000, "q": 5000000, "i": 307.1067275936951, "s": 11180339.88749895, "pf": 0.8944271909999159}
],
"source": [
{"id": 1, "energized": 1, "p": 10072090.38950087, "q": 6233932.488836197, "i": 45.62513918866066, "s": 11845206.58703947, "pf": 0.8503093901731802}
],
"transformer_tap_regulator": [
{"id": 8, "energized": 1, "tap_pos": 0}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "u_rated": 150000},
{"id": 4, "u_rated": 10500},
{"id": 6, "u_rated": 21000}
],
"transformer": [
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 150000, "u2": 11000, "sn": 66000000, "uk": 0.199, "pk": 217000, "i0": 1e-3, "p0": 19500, "winding_from": 1, "winding_to": 2, "clock": 5, "tap_side": 0, "tap_pos": -1, "tap_min": -8, "tap_max": 9, "tap_size": 2500},
{"id": 5, "from_node": 4, "to_node": 6, "from_status": 1, "to_status": 1, "u1": 10600, "u2": 21000, "sn": 20000000, "uk": 0.119, "pk": 127000, "i0": 1e-03, "p0": 5700, "winding_from": 1, "winding_to": 1, "clock": 2, "tap_side": 1, "tap_pos": 4, "tap_min": -13, "tap_max": 4, "tap_size": 270}
],
"sym_load": [
{"id": 7, "node": 6, "status": 1, "type": 0, "p_specified": 10000000, "q_specified": 5000000}
],
"source": [
{"id": 1, "node": 2, "status": 1, "u_ref": 1.0}
],
"transformer_tap_regulator": [
{"id": 8, "regulated_object": 5, "status": 1, "control_side": 1, "u_set": 21000, "u_band": 522}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"calculation_method": "newton_raphson",
"tap_changing_strategy": "max_voltage_tap",
"rtol": 1e-05,
"atol": 1e-05,
"fail": {
"raises": "AssertionError",
"reason": "Results don't match expected values due to the step up transformer"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "energized": 1, "u_pu": 0.999278516660926, "u": 149891.7774991389, "u_angle": -4.976276188195561e-08, "p": 10072090.38950087, "q": 6233932.488836197},
{"id": 4, "energized": 1, "u_pu": 1.04527504169727, "u": 10975.38793782133, "u_angle": -2.618511710996588, "p": 1.347554049236793e-07, "q": -6.249688283352644e-08},
{"id": 6, "energized": 1, "u_pu": 1.000888626113226, "u": 21018.66114837775, "u_angle": -2.618511710996588, "p": -10000000.00000001, "q": -4999999.999999996}
],
"transformer": [
{"id": 3, "energized": 1, "loading": 0.1794728270763556, "p_from": 10072090.38950087, "q_from": 6233932.488836197, "i_from": 45.62513918866066, "s_from": 11845206.58703947, "p_to": -10045576.12305796, "q_to": -5762159.458271895, "i_to": 609.2000361925834, "s_to": 11580849.76444753},
{"id": 5, "energized": 1, "loading": 0.579042488222381, "p_from": 10045576.12305808, "q_from": 5762159.458271859, "i_from": 609.2000361925881, "s_from": 11580849.76444762, "p_to": -10000000.00000001, "q_to": -4999999.999999996, "i_to": 307.1067275936952, "s_to": 11180339.88749895}
],
"sym_load": [
{"id": 7, "energized": 1, "p": 10000000, "q": 5000000, "i": 307.1067275936951, "s": 11180339.88749895, "pf": 0.8944271909999159}
],
"source": [
{"id": 1, "energized": 1, "p": 10072090.38950087, "q": 6233932.488836197, "i": 45.62513918866066, "s": 11845206.58703947, "pf": 0.8503093901731802}
],
"transformer_tap_regulator": [
{"id": 8, "energized": 1, "tap_pos": 0}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "u_rated": 150000},
{"id": 4, "u_rated": 10500},
{"id": 6, "u_rated": 21000}
],
"transformer": [
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 150000, "u2": 11000, "sn": 66000000, "uk": 0.199, "pk": 217000, "i0": 1e-3, "p0": 19500, "winding_from": 1, "winding_to": 2, "clock": 5, "tap_side": 0, "tap_pos": -1, "tap_min": -8, "tap_max": 9, "tap_size": 2500},
{"id": 5, "from_node": 4, "to_node": 6, "from_status": 1, "to_status": 1, "u1": 10600, "u2": 21000, "sn": 20000000, "uk": 0.119, "pk": 127000, "i0": 1e-03, "p0": 5700, "winding_from": 1, "winding_to": 1, "clock": 2, "tap_side": 1, "tap_pos": 4, "tap_min": -13, "tap_max": 4, "tap_size": 270}
],
"sym_load": [
{"id": 7, "node": 6, "status": 1, "type": 0, "p_specified": 10000000, "q_specified": 5000000}
],
"source": [
{"id": 1, "node": 2, "status": 1, "u_ref": 1.0}
],
"transformer_tap_regulator": [
{"id": 8, "regulated_object": 5, "status": 1, "control_side": 1, "u_set": 21000, "u_band": 522}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"calculation_method": "newton_raphson",
"tap_changing_strategy": "min_voltage_tap",
"rtol": 1e-05,
"atol": 1e-05,
"fail": {
"raises": "AssertionError",
"reason": "Results don't match expected values due to the step up transformer"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "energized": 1, "u_pu": 0.999278516660926, "u": 149891.7774991389, "u_angle": -4.976276188195561e-08, "p": 10072090.38950087, "q": 6233932.488836197},
{"id": 4, "energized": 1, "u_pu": 1.04527504169727, "u": 10975.38793782133, "u_angle": -2.618511710996588, "p": 1.347554049236793e-07, "q": -6.249688283352644e-08},
{"id": 6, "energized": 1, "u_pu": 0.9880200580631995, "u": 20748.42121932719, "u_angle": -2.618511710996588, "p": -10000000.00000001, "q": -4999999.999999996}
],
"transformer": [
{"id": 3, "energized": 1, "loading": 0.1794728270763556, "p_from": 10072090.38950087, "q_from": 6233932.488836197, "i_from": 45.62513918866066, "s_from": 11845206.58703947, "p_to": -10045576.12305796, "q_to": -5762159.458271895, "i_to": 609.2000361925834, "s_to": 11580849.76444753},
{"id": 5, "energized": 1, "loading": 0.579042488222381, "p_from": 10045576.12305808, "q_from": 5762159.458271859, "i_from": 609.2000361925881, "s_from": 11580849.76444762, "p_to": -10000000.00000001, "q_to": -4999999.999999996, "i_to": 311.1066705001248, "s_to": 11180339.88749895}
],
"sym_load": [
{"id": 7, "energized": 1, "p": 10000000, "q": 5000000, "i": 311.1066705001252, "s": 11180339.88749895, "pf": 0.8944271909999159}
],
"source": [
{"id": 1, "energized": 1, "p": 10072090.38950087, "q": 6233932.488836197, "i": 45.62513918866066, "s": 11845206.58703947, "pf": 0.8503093901731802}
],
"transformer_tap_regulator": [
{"id": 8, "energized": 1, "tap_pos": -1}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>

SPDX-License-Identifier: MPL-2.0
Loading

0 comments on commit 84dcd7f

Please sign in to comment.