Skip to content

Commit 4d190d8

Browse files
committed
fix current sensor output values
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
1 parent accaeb1 commit 4d190d8

File tree

1 file changed

+22
-4
lines changed
  • power_grid_model_c/power_grid_model/include/power_grid_model/main_core

1 file changed

+22
-4
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,22 @@ constexpr auto output_result(Component const& power_or_current_sensor, MainModel
284284
return power_or_current_sensor.template get_null_output<sym>();
285285
}
286286

287+
auto const get_current_or_power_branch_f = [&solver_output, &obj_math_id]<power_or_current_sensor_c Sensor>() {
288+
if constexpr (std::derived_from<Sensor, GenericPowerSensor>) {
289+
return solver_output[obj_math_id.group].branch[obj_math_id.pos].s_f;
290+
} else if constexpr (std::derived_from<Sensor, GenericCurrentSensor>) {
291+
return solver_output[obj_math_id.group].branch[obj_math_id.pos].i_f;
292+
}
293+
};
294+
295+
auto const get_current_or_power_branch_t = [&solver_output, &obj_math_id]<power_or_current_sensor_c Sensor>() {
296+
if constexpr (std::derived_from<Sensor, GenericPowerSensor>) {
297+
return solver_output[obj_math_id.group].branch[obj_math_id.pos].s_t;
298+
} else if constexpr (std::derived_from<Sensor, GenericCurrentSensor>) {
299+
return solver_output[obj_math_id.group].branch[obj_math_id.pos].i_t;
300+
}
301+
};
302+
287303
switch (terminal_type) {
288304
using enum MeasuredTerminalType;
289305

@@ -296,10 +312,10 @@ constexpr auto output_result(Component const& power_or_current_sensor, MainModel
296312
[[fallthrough]];
297313
case branch3_3:
298314
return power_or_current_sensor.template get_output<sym>(
299-
solver_output[obj_math_id.group].branch[obj_math_id.pos].s_f);
315+
get_current_or_power_branch_f.template operator()<Component>());
300316
case branch_to:
301317
return power_or_current_sensor.template get_output<sym>(
302-
solver_output[obj_math_id.group].branch[obj_math_id.pos].s_t);
318+
get_current_or_power_branch_t.template operator()<Component>());
303319
case source:
304320
return power_or_current_sensor.template get_output<sym>(
305321
solver_output[obj_math_id.group].source[obj_math_id.pos].s);
@@ -405,7 +421,8 @@ constexpr ResIt output_result(MainModelState<ComponentContainer> const& state,
405421
MathOutput<std::vector<SolverOutputType>> const& math_output, ResIt res_it) {
406422
return detail::produce_output<Component, Idx2D>(
407423
state, res_it, [&state, &math_output](Component const& component, Idx2D const math_id) {
408-
return output_result<Component>(component, state, math_output.solver_output, math_id);
424+
return output_result<Component>(component, state, math_output.solver_output,
425+
math_id); // probably here is where all the math_id things are called
409426
});
410427
}
411428
template <std::derived_from<Base> Component, class ComponentContainer, solver_output_type SolverOutputType,
@@ -414,7 +431,8 @@ template <std::derived_from<Base> Component, class ComponentContainer, solver_ou
414431
requires(Component const& component, MainModelState<ComponentContainer> const& state,
415432
std::vector<SolverOutputType> const& solver_output, Idx obj_seq) {
416433
{
417-
output_result<Component>(component, state, solver_output, obj_seq)
434+
output_result<Component>(component, state, solver_output,
435+
obj_seq) // probably here is where the sensors things are called
418436
} -> detail::assignable_to<std::add_lvalue_reference_t<std::iter_value_t<ResIt>>>;
419437
}
420438
constexpr ResIt output_result(MainModelState<ComponentContainer> const& state,

0 commit comments

Comments
 (0)