File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
include/power_grid_model/component Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -87,10 +87,18 @@ class VoltageSensor : public GenericVoltageSensor {
8787 RealValue<sym> u_measured_;
8888 RealValue<sym> u_angle_measured_;
8989
90+ bool has_angle () const {
91+ if constexpr (sym) {
92+ return !is_nan (u_angle_measured_);
93+ }
94+ else {
95+ return !u_angle_measured_.isNaN ().any ();
96+ }
97+ }
98+
9099 SensorCalcParam<true > sym_calc_param () const final {
91- bool const has_angle = !is_nan (u_angle_measured_);
92100 double u_variance = u_sigma_ * u_sigma_;
93- if (has_angle) {
101+ if (has_angle () ) {
94102 ComplexValue<true > const u = pos_seq (u_measured_ * exp (1i * u_angle_measured_));
95103 return {u, u_variance};
96104 }
@@ -101,9 +109,8 @@ class VoltageSensor : public GenericVoltageSensor {
101109 }
102110
103111 SensorCalcParam<false > asym_calc_param () const final {
104- bool const has_angle = !is_nan (u_angle_measured_);
105112 double u_variance = u_sigma_ * u_sigma_;
106- if (has_angle) {
113+ if (has_angle () ) {
107114 ComplexValue<false > const u{u_measured_ * exp (1i * u_angle_measured_)};
108115 return {u, u_variance};
109116 }
Original file line number Diff line number Diff line change @@ -223,7 +223,8 @@ TEST_CASE("Test voltage sensor") {
223223
224224 SUBCASE (" Test sym/asym calc_param for asymmetric voltage sensor, angle = nan" ) {
225225 RealValue<false > const u_measured{10.1e3 / sqrt3, 10.2e3 / sqrt3, 10.3e3 / sqrt3};
226- RealValue<false > const u_angle_measured{nan, nan, nan};
226+ // if one of the angle is nan, the whole measurment is treated as no angle value
227+ RealValue<false > const u_angle_measured{1.0 , 2.0 , nan};
227228 double const u_sigma = 1.0 ;
228229 double const u_rated = 10.0e3 ;
229230
You can’t perform that action at this time.
0 commit comments