-
Notifications
You must be signed in to change notification settings - Fork 76
Merge links into nodes: link registration dual code path #1550
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
base: main
Are you sure you want to change the base?
Changes from all commits
07f87d1
e7bcce6
58d7218
42317ee
adf74ba
185cc17
9ad2ec5
6fdc169
22c17af
f6ee4f7
66876c0
953427d
74ddc1b
c942f48
25934a4
d656dd6
0e496b2
8404bcc
bf78a89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,11 +132,11 @@ constexpr auto output_result(Component const& node, MainModelState<ComponentCont | |
| // output link | ||
| template <std::same_as<Link> Component, class ComponentContainer, steady_state_solver_output_type SolverOutputType> | ||
| requires model_component_state_c<MainModelState, ComponentContainer, Component> | ||
| constexpr auto output_result(Component const& link, MainModelState<ComponentContainer> const& /* state */, | ||
| constexpr auto output_result(Component const& link, MainModelState<ComponentContainer> const& state, | ||
| MathOutput<std::vector<SolverOutputType>> const& math_output, Idx2D const& topo_id) { | ||
| using sym = decode_symmetry_v<SolverOutputType>; | ||
|
|
||
| if (topo_id.group == disconnected) { | ||
| if (topo_id.group == disconnected || state.topo_comp_coup->node[topo_id.group].group == disconnected) { | ||
| return link.template get_null_output<sym>(); | ||
| } | ||
| if (!link.edge_status()) { | ||
|
|
@@ -146,9 +146,9 @@ constexpr auto output_result(Component const& link, MainModelState<ComponentCont | |
| } | ||
| template <std::same_as<Link> Component, class ComponentContainer, short_circuit_solver_output_type SolverOutputType> | ||
| requires model_component_state_c<MainModelState, ComponentContainer, Component> | ||
| inline auto output_result(Component const& link, MainModelState<ComponentContainer> const& /* state */, | ||
| inline auto output_result(Component const& link, MainModelState<ComponentContainer> const& state, | ||
| MathOutput<std::vector<SolverOutputType>> const& math_output, Idx2D const& topo_id) { | ||
| if (topo_id.group == disconnected) { | ||
| if (topo_id.group == disconnected || state.topo_comp_coup->node[topo_id.group].group == disconnected) { | ||
|
Comment on lines
139
to
+151
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was another bug. The output didn't understand that a link was not energized if it's statuses where on but it wasn't connected to a source. |
||
| return link.get_null_sc_output(); | ||
| } | ||
| if (!link.edge_status()) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ | |
| #include <concepts> | ||
|
|
||
| namespace power_grid_model::main_core { | ||
| template <std::derived_from<Edge> ComponentType, class ComponentContainer> | ||
| template <std::derived_from<Branch> ComponentType, class ComponentContainer> | ||
| requires model_component_state_c<MainModelState, ComponentContainer, ComponentType> | ||
| constexpr auto get_branch_nodes(MainModelState<ComponentContainer> const& state, Idx topology_sequence_idx) { | ||
| return state.comp_topo->branch_node_idx[topology_sequence_idx]; | ||
|
|
@@ -56,7 +56,7 @@ constexpr auto get_math_id(MainModelState<ComponentContainer> const& state, Idx | |
| return state.topo_comp_coup->node[topology_sequence_idx]; | ||
| } | ||
|
|
||
| template <std::derived_from<Edge> ComponentType, class ComponentContainer> | ||
| template <std::derived_from<Branch> ComponentType, class ComponentContainer> | ||
| requires model_component_state_c<MainModelState, ComponentContainer, ComponentType> | ||
| constexpr auto get_math_id(MainModelState<ComponentContainer> const& state, Idx topology_sequence_idx) { | ||
| return state.topo_comp_coup->branch[topology_sequence_idx]; | ||
|
|
@@ -92,10 +92,24 @@ constexpr auto comp_base_sequence_cbegin(MainModelState<ComponentContainer> cons | |
| return state.reduced_topology->topo_node_coup.coupling.user_nodes_to_topo_nodes.cbegin(); | ||
| } | ||
|
|
||
| template <std::derived_from<Edge> Component, class ComponentContainer> | ||
| template <std::derived_from<Branch> Component, class ComponentContainer> | ||
| requires model_component_state_c<MainModelState, ComponentContainer, Component> | ||
| constexpr auto comp_base_sequence_cbegin(MainModelState<ComponentContainer> const& state) { | ||
| return state.topo_comp_coup->branch.cbegin() + get_component_sequence_offset<Edge, Component>(state.components); | ||
| return state.topo_comp_coup->branch.cbegin() + get_component_sequence_offset<Branch, Component>(state.components); | ||
| } | ||
|
|
||
| template <std::same_as<Link> Component, class ComponentContainer> | ||
| requires model_component_state_c<MainModelState, ComponentContainer, Component> | ||
| constexpr auto comp_base_sequence_cbegin(MainModelState<ComponentContainer> const& state) { | ||
| auto const& link_topo_ids = state.reduced_topology->topo_node_coup.coupling.user_links_to_topo_nodes; | ||
|
|
||
| if (std::ranges::ssize(link_topo_ids) == get_component_size<Link>(state.components)) { | ||
| // new path: links are not branches | ||
| return link_topo_ids.cbegin(); | ||
| } else { | ||
| // legacy path: links are branches | ||
| return state.topo_comp_coup->branch.cbegin() + get_component_sequence_offset<Edge, Link>(state.components); | ||
| } | ||
|
Comment on lines
+101
to
+112
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of the issues so far, were related to the "two-path dispatch", similar to this. Where in the old path Branches included links, so the offset was different to the new path (or the container to use was different), where branches and links are separated. I think it's good that we spam TODOs in every such two-code-path place introduced here, so we can easily pinpoint for the cleanup after v2. |
||
| } | ||
|
|
||
| template <std::derived_from<Branch3> Component, class ComponentContainer> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the SC bug. Wrong mapping was used.