File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
power_grid_model_c/power_grid_model/include/power_grid_model/component Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,18 @@ template <symmetry_tag current_sensor_symmetry_> class CurrentSensor : public Ge
165
165
i_output = conj (i_output) * (cos (u_angle) + 1i * sin (u_angle));
166
166
}
167
167
output.i_residual = (cabs (i_measured_complex) - cabs (i_output)) * base_current_;
168
- output.i_angle_residual = arg (i_measured_complex) - arg (i_output);
168
+ // arg(e^i * u_angle) = u_angle in (-pi, pi]
169
+ auto const unbounded_i_angle_residual = arg (i_measured_complex) - arg (i_output);
170
+ if constexpr (is_symmetric_v<sym_calc>) {
171
+ output.i_angle_residual = arg (ComplexValue<sym_calc>{cos (unbounded_i_angle_residual), sin (unbounded_i_angle_residual)});
172
+ } else {
173
+ output.i_angle_residual = arg (
174
+ ComplexValue<sym_calc>{
175
+ cos (unbounded_i_angle_residual (0 )) + 1i * sin (unbounded_i_angle_residual (0 )),
176
+ cos (unbounded_i_angle_residual (1 )) + 1i * sin (unbounded_i_angle_residual (1 )),
177
+ cos (unbounded_i_angle_residual (2 )) + 1i * sin (unbounded_i_angle_residual (2 )),
178
+ });
179
+ }
169
180
return output;
170
181
}
171
182
};
You can’t perform that action at this time.
0 commit comments