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

Step-up transformer tap changer support: additional tests #868

Draft
wants to merge 4 commits into
base: feature/step-up-transformer-tap-changer-support
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
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);
Comment on lines +334 to +353
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this test grid?

Copy link
Contributor Author

@figueroa1395 figueroa1395 Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the introduction of the new logic, the old grid was no longer valid for the transformer ranking algorithm, as it was pointed out by you in b642c97. Hence, the old grid was left in since it was still valid for the other parts of the "full" algorithm, while marking the transformer ranking part with CHECK_THROWS_AS(pgm_tap::rank_transformers(state), AutomaticTapInputError) in d947149; whereas the new grid is only used for the ranking itself.


std::vector<ThreeWindingTransformerInput> transformers3w{
get_transformer3w(17, 0, 4, 5, Branch3Side::side_2, 0)};
figueroa1395 marked this conversation as resolved.
Show resolved Hide resolved
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,24 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "u_rated": 10000},
{"id": 4, "u_rated": 400}
],
"transformer": [
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 10000, "u2": 400, "sn": 100000, "uk": 0.1, "pk": 1000, "i0": 1e-06, "p0": 100, "winding_from": 2, "winding_to": 1, "clock": 5, "tap_side": 0, "tap_pos": 3, "tap_min": -11, "tap_max": 9, "tap_size": 100}
],
"sym_load": [
{"id": 5, "node": 4, "status": 1, "type": 0, "p_specified": 30000, "q_specified": 10000}
],
"source": [
{"id": 1, "node": 2, "status": 1, "u_ref": 1.0}
],
"transformer_tap_regulator": [
{"id": 6, "regulated_object": 3, "status": 1, "control_side": 0, "u_set": 10000, "u_band": 500}
]
}
}
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": "AutomaticTapInputError",
"reason": "Control logic automatic tap regulator in step up transformer is not yet implemented"
}
}
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,24 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "energized": 1, "u_pu": 0.9999994897958192, "u": 9999.994897958191, "u_angle": -4.976276188195561e-08, "p": 30201.87675109433, "q": 11046.68183452673},
{"id": 4, "energized": 1, "u_pu": 0.976387253223602, "u": 390.5549012894408, "u_angle": -2.618511710996588, "p": -29999.99999999977, "q": -9999.999999999955}
],
"transformer": [
{"id": 3, "energized": 1, "loading": 0.3215870860033959, "p_from": 30201.87675109433, "q_from": 11046.68183452673, "i_from": 1.856686505546027, "s_from": 32158.70860033959, "p_to": -29999.99999999977, "q_to": -9999.999999999955, "i_to": 46.74738051738032, "s_to": 31622.77660168356}
],
"sym_load": [
{"id": 5, "energized": 1, "p": 30000, "q": 10000, "i": 46.74738051738068, "s": 31622.77660168379, "pf": 0.9486832980505139}
],
"source": [
{"id": 1, "energized": 1, "p": 30201.87675109433, "q": 11046.68183452673, "i": 1.856686505546027, "s": 32158.70860033959, "pf": 0.9391507950905532}
],
"transformer_tap_regulator": [
{"id": 6, "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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "u_rated": 10000},
{"id": 4, "u_rated": 400}
],
"transformer": [
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 10000, "u2": 400, "sn": 100000, "uk": 0.1, "pk": 1000, "i0": 1e-06, "p0": 100, "winding_from": 2, "winding_to": 1, "clock": 5, "tap_side": 0, "tap_pos": 3, "tap_min": -11, "tap_max": 9, "tap_size": 100}
],
"sym_load": [
{"id": 5, "node": 4, "status": 1, "type": 0, "p_specified": 30000, "q_specified": 10000}
],
"source": [
{"id": 1, "node": 2, "status": 1, "u_ref": 1.0}
],
"transformer_tap_regulator": [
{"id": 6, "regulated_object": 3, "status": 1, "control_side": 0, "u_set": 10000, "u_band": 500}
]
}
}
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": "AutomaticTapInputError",
"reason": "Control logic automatic tap regulator in step up transformer is not yet implemented"
}
}
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,24 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "energized": 1, "u_pu": 0.9999994897958192, "u": 9999.994897958191, "u_angle": -4.976276188195561e-08, "p": 30201.65062487359, "q": 11004.60371157344},
{"id": 4, "energized": 1, "u_pu": 0.9966854346351138, "u": 398.6741738540455, "u_angle": -2.618511710996588, "p": -30000.00000000017, "q": -10000.00000000001}
],
"transformer": [
{"id": 3, "energized": 1, "loading": 0.3214406637803785, "p_from": 30201.65062487359, "q_from": 11004.60371157344, "i_from": 1.855841127489525, "s_from": 32144.06637803785, "p_to": -30000.00000000017, "q_to": -10000.00000000001, "i_to": 45.7953381003046, "s_to": 31622.77660168396}
],
"sym_load": [
{"id": 5, "energized": 1, "p": 30000, "q": 10000, "i": 45.79533810030436, "s": 31622.77660168379, "pf": 0.9486832980505139}
],
"source": [
{"id": 1, "energized": 1, "p": 30201.65062487359, "q": 11004.60371157344, "i": 1.855841127489525, "s": 32144.06637803785, "pf": 0.9395715610364904}
],
"transformer_tap_regulator": [
{"id": 6, "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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "u_rated": 10000},
{"id": 4, "u_rated": 400}
],
"transformer": [
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 10000, "u2": 400, "sn": 100000, "uk": 0.1, "pk": 1000, "i0": 1e-06, "p0": 10000, "winding_from": 2, "winding_to": 1, "clock": 5, "tap_side": 0, "tap_pos": 3, "tap_min": -11, "tap_max": 9, "tap_size": 100}
],
"sym_load": [
{"id": 5, "node": 4, "status": 1, "type": 0, "p_specified": 30000, "q_specified": 10000}
],
"source": [
{"id": 1, "node": 2, "status": 1, "u_ref": 1.0}
],
"transformer_tap_regulator": [
{"id": 6, "regulated_object": 3, "status": 1, "control_side": 0, "u_set": 10000, "u_band": 500}
]
}
}
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": "AutomaticTapInputError",
"reason": "Control logic automatic tap regulator in step up transformer is not yet implemented"
}
}
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,24 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "energized": 1, "u_pu": 0.999999490008046, "u": 9999.994900080461, "u_angle": -4.976345265642619e-08, "p": 30201.76880478965, "q": 10963.46426253733},
{"id": 4, "energized": 1, "u_pu": 1.017806866433826, "u": 407.1227465735306, "u_angle": -2.618471703642352, "p": -30000.00000000019, "q": -10000.00000000026}
],
"transformer": [
{"id": 3, "energized": 1, "loading": 0.3213011651976846, "p_from": 30201.76880478965, "q_from": 10963.46426253733, "i_from": 1.855035723331389, "s_from": 32130.11651976846, "p_to": -30000.00000000019, "q_to": -10000.00000000026, "i_to": 44.84499757669082, "s_to": 31622.77660168405}
],
"sym_load": [
{"id": 5, "energized": 1, "p": 30000, "q": 10000, "i": 44.84499757669044, "s": 31622.77660168379, "pf": 0.9486832980505139}
],
"source": [
{"id": 1, "energized": 1, "p": 30201.76880478965, "q": 10963.46426253733, "i": 1.855035723331389, "s": 32130.11651976846, "pf": 0.939983170811336}
],
"transformer_tap_regulator": [
{"id": 6, "energized": 1, "tap_pos": -3}
]
}
}
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,24 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "u_rated": 10000},
{"id": 4, "u_rated": 400}
],
"transformer": [
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 10000, "u2": 400, "sn": 100000, "uk": 0.1, "pk": 1000, "i0": 1e-06, "p0": 100, "winding_from": 2, "winding_to": 1, "clock": 5, "tap_side": 0, "tap_pos": 3, "tap_min": -11, "tap_max": 9, "tap_size": 100}
],
"sym_load": [
{"id": 5, "node": 4, "status": 1, "type": 0, "p_specified": 30000, "q_specified": 10000}
],
"source": [
{"id": 1, "node": 2, "status": 1, "u_ref": 1.0}
],
"transformer_tap_regulator": [
{"id": 6, "regulated_object": 3, "status": 1, "control_side": 0, "u_set": 10000, "u_band": 500}
]
}
}
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": "AutomaticTapInputError",
"reason": "Control logic automatic tap regulator in step up transformer is not yet implemented"
}
}
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,24 @@
{
"version": "1.0",
"type": "sym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 2, "energized": 1, "u_pu": 0.9999994897958192, "u": 9999.994897958191, "u_angle": -4.976276188195561e-08, "p": 30201.87675109433, "q": 11046.68183452673},
{"id": 4, "energized": 1, "u_pu": 0.976387253223602, "u": 390.5549012894408, "u_angle": -2.618511710996588, "p": -29999.99999999977, "q": -9999.999999999955}
],
"transformer": [
{"id": 3, "energized": 1, "loading": 0.3215870860033959, "p_from": 30201.87675109433, "q_from": 11046.68183452673, "i_from": 1.856686505546027, "s_from": 32158.70860033959, "p_to": -29999.99999999977, "q_to": -9999.999999999955, "i_to": 46.74738051738032, "s_to": 31622.77660168356}
],
"sym_load": [
{"id": 5, "energized": 1, "p": 30000, "q": 10000, "i": 46.74738051738068, "s": 31622.77660168379, "pf": 0.9486832980505139}
],
"source": [
{"id": 1, "energized": 1, "p": 30201.87675109433, "q": 11046.68183452673, "i": 1.856686505546027, "s": 32158.70860033959, "pf": 0.9391507950905532}
],
"transformer_tap_regulator": [
{"id": 6, "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