@@ -386,6 +386,39 @@ class Topology {
386386 // set branch idx in coupling
387387 comp_coup_.branch [idx] = Idx2D{.group = math_group, .pos = branch_pos};
388388 }
389+ for (auto const & [idx, branch_node_idx, branch_connected] :
390+ std::views::zip (std::views::iota (0 ), comp_topo_.branch_node_idx , comp_conn_.branch_connected )) {
391+ assert (std::ssize (branch_connected) == 2 ); // NOSONAR(R354)
392+
393+ auto const [i, j] = branch_node_idx;
394+ IntS const i_status = branch_connected[0 ];
395+ IntS const j_status = branch_connected[1 ];
396+ Idx2D const i_math = comp_coup_.node [i];
397+ Idx2D const j_math = comp_coup_.node [j];
398+ Idx const math_group = [&]() {
399+ if (i_status != 0 && i_math.group != -1 ) {
400+ return i_math.group ;
401+ }
402+ if (j_status != 0 && j_math.group != -1 ) {
403+ return j_math.group ;
404+ }
405+ return Idx{-1 };
406+ }();
407+ // skip if no math model connected
408+ if (math_group == -1 ) {
409+ continue ;
410+ }
411+ assert (i_status || j_status);
412+ // get and set branch idx in math model
413+ BranchIdx const branch_idx{get_group_pos_if (math_group, i_status, i_math),
414+ get_group_pos_if (math_group, j_status, j_math)};
415+ // current branch position index in math model
416+ auto const branch_pos = math_topology_[math_group].n_branch ();
417+ // push back
418+ math_topology_[math_group].branch_bus_idx .push_back (branch_idx);
419+ // set branch idx in coupling
420+ comp_coup_.branch [idx] = Idx2D{.group = math_group, .pos = branch_pos};
421+ }
389422 // k as branch number for 3-way branch
390423 for (auto const & [idx, i, i_status, j_math] :
391424 std::views::zip (std::views::iota (0 ), comp_topo_.branch3_node_idx , comp_conn_.branch3_connected ,
0 commit comments