Skip to content

Commit 1f174e3

Browse files
Merge pull request #837 from PowerGridModel/fix/observability-voltage-count-check
Fix / Observability internal voltage count check
2 parents d168e2d + 21d4440 commit 1f174e3

File tree

1 file changed

+11
-9
lines changed
  • power_grid_model_c/power_grid_model/include/power_grid_model/math_solver

1 file changed

+11
-9
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/observability.hpp

+11-9
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ Idx count_bus_injection_sensors(const Idx n_bus, const MeasuredValues<sym>& meas
4545

4646
template <symmetry_tag sym>
4747
std::tuple<Idx, Idx> count_voltage_sensors(const Idx n_bus, const MeasuredValues<sym>& measured_values) {
48-
Idx n_voltage_magnitude{};
49-
Idx n_voltage_phasor{};
48+
Idx n_voltage_sensor{};
49+
Idx n_voltage_phasor_sensor{};
5050
for (Idx bus = 0; bus != n_bus; ++bus) {
5151
if (measured_values.has_voltage(bus)) {
52-
n_voltage_magnitude++;
52+
n_voltage_sensor++;
5353
if (measured_values.has_angle_measurement(bus)) {
54-
n_voltage_phasor++;
54+
n_voltage_phasor_sensor++;
5555
}
5656
}
5757
}
58-
return std::make_tuple(n_voltage_magnitude, n_voltage_phasor);
58+
return std::make_tuple(n_voltage_sensor, n_voltage_phasor_sensor);
5959
}
6060

6161
} // namespace detail
@@ -66,17 +66,19 @@ inline void necessary_observability_check(MeasuredValues<sym> const& measured_va
6666
Idx const n_bus{topo->n_bus()};
6767
std::vector<BranchIdx> const& branch_bus_idx{topo->branch_bus_idx};
6868

69-
auto const [n_voltage_magnitude, n_voltage_phasor] = detail::count_voltage_sensors(n_bus, measured_values);
70-
if (n_voltage_magnitude + n_voltage_phasor < 1) {
69+
auto const [n_voltage_sensor, n_voltage_phasor_sensor] = detail::count_voltage_sensors(n_bus, measured_values);
70+
if (n_voltage_sensor < 1) {
7171
throw NotObservableError{};
7272
}
73+
7374
Idx const n_injection_sensor = detail::count_bus_injection_sensors(n_bus, measured_values);
7475
Idx const n_branch_sensor = detail::count_branch_sensors(branch_bus_idx, n_bus, measured_values);
76+
Idx const n_power_sensor = n_injection_sensor + n_branch_sensor;
7577

76-
if (n_voltage_phasor == 0 && n_branch_sensor + n_injection_sensor < n_bus - 1) {
78+
if (n_voltage_phasor_sensor == 0 && n_power_sensor < n_bus - 1) {
7779
throw NotObservableError{};
7880
}
79-
if (n_voltage_phasor > 0 && n_branch_sensor + n_injection_sensor + n_voltage_phasor < n_bus) {
81+
if (n_voltage_phasor_sensor > 0 && n_power_sensor + n_voltage_phasor_sensor < n_bus) {
8082
throw NotObservableError{};
8183
}
8284
}

0 commit comments

Comments
 (0)