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

Feature / Updated transformer weight before transformer ranking #698

Merged
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
2 changes: 1 addition & 1 deletion docs/user_manual/calculations.md
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ Power flow calculations that take the behavior of these regulators into account

The following control logic is used:

- Regulated transformers are ranked according to how close they are to {hoverxreftooltip}`sources <user_manual/components:source>` in terms of the amount of transformers inbetween.
- Regulated transformers are ranked according to how close they are to {hoverxreftooltip}`sources <user_manual/components:source>` in terms of the amount of regulated transformers inbetween.
- Transformers are regulated in order according to their ranks.
- Initialize all transformers to their starting tap position (see {hoverxreftooltip}`user_manual/calculations:Initialization and exploitation of regulated transformers`)
- Find the optimal state using the following procedure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ using RankedTransformerGroups = std::vector<std::vector<Idx2D>>;

constexpr auto infty = std::numeric_limits<Idx>::max();
constexpr Idx2D unregulated_idx = {-1, -1};

struct TrafoGraphVertex {
bool is_source{};
};
Expand All @@ -66,6 +65,7 @@ struct TrafoGraphEdge {
}
};

constexpr TrafoGraphEdge unregulated_edge_prop = {unregulated_idx, 0};
using TrafoGraphEdges = std::vector<std::pair<TrafoGraphIdx, TrafoGraphIdx>>;
using TrafoGraphEdgeProperties = std::vector<TrafoGraphEdge>;

Expand Down Expand Up @@ -113,11 +113,12 @@ inline void process_trafo3w_edge(main_core::main_model_state_c auto const& state
auto const& non_tap_side_node = tap_at_first_side ? to_node : from_node;
// add regulated idx only when the first side node is tap side node.
// This is done to add only one directional edge with regulated idx.
Idx2D const regulated_idx = from_node == tap_side_node ? unregulated_idx : trafo3w_idx;
figueroa1395 marked this conversation as resolved.
Show resolved Hide resolved
add_to_edge(state, edges, edge_props, tap_side_node, non_tap_side_node, {regulated_idx, 1});
auto const edge_value =
(from_node == tap_side_node) ? unregulated_edge_prop : TrafoGraphEdge{trafo3w_idx, 1};
add_to_edge(state, edges, edge_props, tap_side_node, non_tap_side_node, edge_value);
} else {
add_to_edge(state, edges, edge_props, from_node, to_node, {unregulated_idx, 1});
add_to_edge(state, edges, edge_props, to_node, from_node, {unregulated_idx, 1});
add_to_edge(state, edges, edge_props, from_node, to_node, unregulated_edge_prop);
add_to_edge(state, edges, edge_props, to_node, from_node, unregulated_edge_prop);
}
}
}
Expand Down Expand Up @@ -153,8 +154,8 @@ constexpr void add_edge(main_core::MainModelState<ComponentContainer> const& sta
add_to_edge(state, edges, edge_props, tap_side_node, non_tap_side_node,
{main_core::get_component_idx_by_id(state, transformer.id()), 1});
} else {
add_to_edge(state, edges, edge_props, from_node, to_node, {unregulated_idx, 1});
add_to_edge(state, edges, edge_props, to_node, from_node, {unregulated_idx, 1});
add_to_edge(state, edges, edge_props, from_node, to_node, unregulated_edge_prop);
add_to_edge(state, edges, edge_props, to_node, from_node, unregulated_edge_prop);
}
}
}
Expand All @@ -172,8 +173,8 @@ constexpr void add_edge(main_core::MainModelState<ComponentContainer> const& sta
if (!branch.from_status() || !branch.to_status()) {
continue;
}
add_to_edge(state, edges, edge_props, branch.from_node(), branch.to_node(), {unregulated_idx, 0});
add_to_edge(state, edges, edge_props, branch.to_node(), branch.from_node(), {unregulated_idx, 0});
add_to_edge(state, edges, edge_props, branch.from_node(), branch.to_node(), unregulated_edge_prop);
add_to_edge(state, edges, edge_props, branch.to_node(), branch.from_node(), unregulated_edge_prop);
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/cpp_unit_tests/test_tap_position_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ TEST_CASE("Test Transformer ranking") {
expected_edges_prop.insert(expected_edges_prop.end(),
{{{3, 0}, 1}, {{3, 1}, 1}, {{3, 2}, 1}, {{3, 3}, 1}, {{3, 4}, 1}});
expected_edges_prop.insert(expected_edges_prop.end(),
{{{4, 0}, 1}, {unregulated_idx, 1}, {unregulated_idx, 1}, {unregulated_idx, 1}});
{{{4, 0}, 1}, {unregulated_idx, 0}, {unregulated_idx, 0}, {unregulated_idx, 0}});
expected_edges_prop.insert(expected_edges_prop.end(), 10, {unregulated_idx, 0});

std::vector<pgm_tap::TrafoGraphVertex> const expected_vertex_props{
Expand Down Expand Up @@ -336,8 +336,8 @@ TEST_CASE("Test Transformer ranking") {

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, 3}, Idx2D{3, 2}, Idx2D{3, 4}}};
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);
}
}
Expand Down
Loading