Skip to content

Commit a82a056

Browse files
authored
Merge pull request #1137 from PowerGridModel/fix/inf-appliance-measurement-with-injection
State estimation: Infinite sigma appliance measurement with valid injection sensor
2 parents eb07050 + 72b246e commit a82a056

File tree

18 files changed

+237
-2
lines changed

18 files changed

+237
-2
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/math_solver/measured_values.hpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,22 @@ template <symmetry_tag sym> class MeasuredValues {
510510
if (std::empty(sensors)) {
511511
return unmeasured;
512512
}
513-
result_data.push_back(combine_measurements(input_data, sensors));
513+
514+
auto combined_measurement = combine_measurements(input_data, sensors);
515+
516+
// if the combined measurement has infinite variance it is unmeasured
517+
if constexpr (std::is_same_v<CalcParam, PowerSensorCalcParam<sym>>) {
518+
if (is_inf(combined_measurement.real_component.variance) ||
519+
is_inf(combined_measurement.imag_component.variance)) {
520+
return unmeasured;
521+
}
522+
} else if constexpr (std::is_same_v<CalcParam, VoltageSensorCalcParam<sym>>) {
523+
if (is_inf(combined_measurement.variance)) {
524+
return unmeasured;
525+
}
526+
}
527+
528+
result_data.push_back(std::move(combined_measurement));
514529
return static_cast<Idx>(result_data.size()) - 1;
515530
}
516531

tests/data/state_estimation/high-variance-measurement/sym_output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
{
3636
"id": 31,
3737
"energized": 1,
38-
"p": 0.0,
38+
"p": 999092.970521542,
3939
"q": 0.0
4040
}
4141
]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "1.0",
3+
"type": "asym_output",
4+
"is_batch": false,
5+
"attributes": {},
6+
"data": {
7+
"node": [
8+
{"id": 1, "energized": 1, "u_pu": [1, 0.99999999999999989, 0.99999999999999989], "u": [5773.5026918962576, 5773.5026918962567, 5773.5026918962567], "u_angle": [0, -2.0943951023931957, 2.0943951023931957], "p": [400.00048483079809, 400.00048485464004, 400.0004848153082], "q": [40.000969609839856, 40.000969638952533, 40.000969610956247]},
9+
{"id": 2, "energized": 1, "u_pu": [0.99999855999532739, 0.99999855999532672, 0.99999855999532716], "u": [5773.4943780254043, 5773.4943780253998, 5773.4943780254025], "u_angle": [-2.28000328312611e-06, -2.0943973823964792, 2.0943928223899122], "p": [-400.00000002940186, -400.00000005324364, -400.00000001391209], "q": [-40.000000007047362, -40.000000036159726, -40.000000008163674]}
10+
],
11+
"line": [
12+
{"id": 3, "energized": 1, "p_from": [400.00048483079809, 400.00048485464004, 400.0004848153082], "q_from": [40.000969609839856, 40.000969638952533, 40.000969610956247], "i_from": [0.069627681011491596, 0.069627681016102408, 0.069627681008841244], "s_from": [401.99560375034059, 401.9956037769611, 401.99560373503869], "p_to": [-400.00000002940186, -400.00000005324364, -400.00000001391209], "q_to": [-40.000000007047362, -40.000000036159726, -40.000000008163674], "i_to": [0.069627681011491596, 0.069627681016102408, 0.069627681008841244], "s_to": [401.99502487479276, 401.99502490141305, 401.99502485949091]}
13+
],
14+
"source": [
15+
{"id": 4, "energized": 1, "p": [400.00048483079809, 400.00048485464004, 400.0004848153082], "q": [40.000969609839856, 40.000969638952533, 40.000969610956247], "i": [0.069627681011491596, 0.069627681016102408, 0.069627681008841244], "s": [401.99560375034059, 401.9956037769611, 401.99560373503869], "pf": [0.99503696333758518, 0.995036963331002, 0.9950369633369287]}
16+
],
17+
"asym_load": [
18+
{"id": 6, "energized": 1, "p": [666.66666669606843, 666.66666671991027, 666.66666668057871], "q": [66.666666673714019, 66.66666670282639, 66.666666674830338], "i": [0.11604613501569351, 0.11604613502030431, 0.11604613501304316], "s": [669.9917081046832, 669.99170813130343, 669.9917080893814], "pf": [0.99503719020938208, 0.99503719020543235, 0.99503719020898818]}
19+
],
20+
"asym_gen": [
21+
{"id": 17, "energized": 1, "p": [266.66666666666663, 266.66666666666663, 266.66666666666663], "q": [26.666666666666664, 26.666666666666664, 26.666666666666664], "i": [0.046418454004201894, 0.046418454004201928, 0.046418454004201894], "s": [267.99668322989032, 267.99668322989032, 267.99668322989032], "pf": [0.99503719020998926, 0.99503719020998926, 0.99503719020998926]}
22+
],
23+
"sym_voltage_sensor": [
24+
{"id": 11, "energized": 1, "u_residual": [0, 6.4098756212785464e-13, 6.4098756212785464e-13], "u_angle_residual": [0, 2.0943951023931957, -2.0943951023931957]}
25+
],
26+
"sym_power_sensor": [
27+
{"id": 12, "energized": 1, "p_residual": [2.9401900474475735e-08, 5.3243723087866471e-08, 1.391212087660983e-08], "q_residual": [7.0473683312644031e-09, 3.6159732615577881e-08, 8.1636809580916855e-09]},
28+
{"id": 15, "energized": 1, "p_residual": [-666.66666669606843, -666.66666671991027, -666.66666668057871], "q_residual": [-66.666666673714019, -66.66666670282639, -66.666666674830338]},
29+
{"id": 16, "energized": 1, "p_residual": [0, 0, 0], "q_residual": [0, 0, 0]}
30+
]
31+
}
32+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
3+
SPDX-License-Identifier: MPL-2.0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "1.0",
3+
"type": "input",
4+
"is_batch": false,
5+
"attributes": {},
6+
"data": {
7+
"node": [
8+
{"id": 1, "u_rated": 10000},
9+
{"id": 2, "u_rated": 10000}
10+
],
11+
"line": [
12+
{"id": 3, "from_node": 1, "to_node": 2, "from_status": 1, "to_status": 1, "r1": 0.10000000000000001, "x1": 0.20000000000000001, "c1": 0, "tan1": 0, "r0": 0.29999999999999999, "x0": 0.90000000000000002, "c0": 0, "tan0": 0}
13+
],
14+
"source": [
15+
{"id": 4, "node": 1, "status": 1, "u_ref": 1}
16+
],
17+
"asym_load": [
18+
{"id": 6, "node": 2, "status": 1, "type": 0}
19+
],
20+
"asym_gen": [
21+
{"id": 17, "node": 2, "status": 1, "type": 0}
22+
],
23+
"sym_voltage_sensor": [
24+
{"id": 11, "measured_object": 1, "u_sigma": 100, "u_measured": 10000, "u_angle_measured": 0}
25+
],
26+
"sym_power_sensor": [
27+
{"id": 12, "measured_object": 2, "measured_terminal_type": 9, "power_sigma": 200, "p_measured": -1200, "q_measured": -120},
28+
{"id": 15, "measured_object": 6, "measured_terminal_type": 4, "power_sigma": "inf", "p_measured": 0, "q_measured": 0},
29+
{"id": 16, "measured_object": 17, "measured_terminal_type": 5, "power_sigma": 200, "p_measured": 800, "q_measured": 80}
30+
]
31+
}
32+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
3+
SPDX-License-Identifier: MPL-2.0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"calculation_method": [
3+
"iterative_linear",
4+
"newton_raphson"
5+
],
6+
"rtol": 1e-05,
7+
"atol": 1e-05
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
3+
SPDX-License-Identifier: MPL-2.0
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"version": "1.0",
3+
"type": "sym_output",
4+
"is_batch": false,
5+
"attributes": {},
6+
"data": {
7+
"node": [
8+
{"id": 1, "energized": 1, "u_pu": 1, "u": 10000, "u_angle": 0, "p": 1200.0014543787074, "q": 120.00290877267616},
9+
{"id": 2, "energized": 1, "u_pu": 0.99999855999532739, "u": 9999.9855999532738, "u_angle": -2.2800032832191506e-06, "p": -1199.9999999745187, "q": -119.99999996429891}
10+
],
11+
"line": [
12+
{"id": 3, "energized": 1, "p_from": 1200.0014543787074, "q_from": 120.00290877267616, "i_from": 0.069627681004633887, "s_from": 1205.986811132243, "p_to": -1199.9999999745187, "q_to": -119.99999996429891, "i_to": 0.069627681004633887, "s_to": 1205.9850745055996}
13+
],
14+
"source": [
15+
{"id": 4, "energized": 1, "p": 1200.0014543787074, "q": 120.00290877267616, "i": 0.069627681004633887, "s": 1205.986811132243, "pf": 0.99503696334131864}
16+
],
17+
"asym_load": [
18+
{"id": 6, "energized": 1, "p": 1999.9999999745187, "q": 199.99999996429889, "i": 0.11604613500883577, "s": 2009.9751241952706, "pf": 0.99503719021162229}
19+
],
20+
"asym_gen": [
21+
{"id": 17, "energized": 1, "p": 799.99999999999989, "q": 80, "i": 0.046418454004201887, "s": 803.99004968967108, "pf": 0.99503719020998915}
22+
],
23+
"sym_voltage_sensor": [
24+
{"id": 11, "energized": 1, "u_residual": 0, "u_angle_residual": 0}
25+
],
26+
"sym_power_sensor": [
27+
{"id": 12, "energized": 1, "p_residual": -2.5481136298188822e-08, "q_residual": -3.5701083474053152e-08},
28+
{"id": 15, "energized": 1, "p_residual": -1999.9999999745187, "q_residual": -199.99999996429889},
29+
{"id": 16, "energized": 1, "p_residual": 0, "q_residual": 0}
30+
]
31+
}
32+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
3+
SPDX-License-Identifier: MPL-2.0

0 commit comments

Comments
 (0)