From 0387a6c0e6d9747aa2548090db81e0eaee0b8fad Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Thu, 5 Dec 2024 22:12:13 +0100 Subject: [PATCH 1/4] add bug test case Signed-off-by: Tony Xiang --- .../leaf-without-power-sensor/input.json | 27 +++++++++++++++++++ .../input.json.license | 3 +++ .../leaf-without-power-sensor/params.json | 8 ++++++ .../params.json.license | 3 +++ .../leaf-without-power-sensor/sym_output.json | 27 +++++++++++++++++++ .../sym_output.json.license | 3 +++ 6 files changed, 71 insertions(+) create mode 100644 tests/data/state_estimation/leaf-without-power-sensor/input.json create mode 100644 tests/data/state_estimation/leaf-without-power-sensor/input.json.license create mode 100644 tests/data/state_estimation/leaf-without-power-sensor/params.json create mode 100644 tests/data/state_estimation/leaf-without-power-sensor/params.json.license create mode 100644 tests/data/state_estimation/leaf-without-power-sensor/sym_output.json create mode 100644 tests/data/state_estimation/leaf-without-power-sensor/sym_output.json.license diff --git a/tests/data/state_estimation/leaf-without-power-sensor/input.json b/tests/data/state_estimation/leaf-without-power-sensor/input.json new file mode 100644 index 000000000..0302bec36 --- /dev/null +++ b/tests/data/state_estimation/leaf-without-power-sensor/input.json @@ -0,0 +1,27 @@ +{ + "version": "1.0", + "type": "input", + "is_batch": false, + "attributes": {}, + "data": { + "node": [ + {"id": 0, "u_rated": 10}, + {"id": 1, "u_rated": 10} + ], + "line": [ + {"id": 2, "from_node": 0, "to_node": 1, "from_status": 1, "to_status": 1, "r1": 1.0, "x1": 0.0, "c1": 0.0, "tan1": 0.0, "i_n": 500} + ], + "source": [ + {"id": 3, "node": 0, "status": 1, "u_ref": 1.0} + ], + "sym_load": [ + {"id": 4, "node": 1, "status": 1, "type": 0, "p_specified": 9, "q_specified": 0} + ], + "sym_power_sensor": [ + {"id": 5, "measured_object": 2, "measured_terminal_type": 0, "power_sigma": 1, "p_measured": 10, "q_measured": 0} + ], + "sym_voltage_sensor": [ + {"id": 6, "measured_object": 0, "u_sigma": 1, "u_measured": 10} + ] + } +} \ No newline at end of file diff --git a/tests/data/state_estimation/leaf-without-power-sensor/input.json.license b/tests/data/state_estimation/leaf-without-power-sensor/input.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/leaf-without-power-sensor/input.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: Contributors to the Power Grid Model project + +SPDX-License-Identifier: MPL-2.0 diff --git a/tests/data/state_estimation/leaf-without-power-sensor/params.json b/tests/data/state_estimation/leaf-without-power-sensor/params.json new file mode 100644 index 000000000..10f5b5b7f --- /dev/null +++ b/tests/data/state_estimation/leaf-without-power-sensor/params.json @@ -0,0 +1,8 @@ +{ + "calculation_method": ["newton_raphson"], + "rtol": 1e-8, + "atol": { + "default": 1e-8, + ".+_residual": 5e-4 + } +} \ No newline at end of file diff --git a/tests/data/state_estimation/leaf-without-power-sensor/params.json.license b/tests/data/state_estimation/leaf-without-power-sensor/params.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/leaf-without-power-sensor/params.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: Contributors to the Power Grid Model project + +SPDX-License-Identifier: MPL-2.0 diff --git a/tests/data/state_estimation/leaf-without-power-sensor/sym_output.json b/tests/data/state_estimation/leaf-without-power-sensor/sym_output.json new file mode 100644 index 000000000..c0abb2f1c --- /dev/null +++ b/tests/data/state_estimation/leaf-without-power-sensor/sym_output.json @@ -0,0 +1,27 @@ +{ + "version": "1.0", + "type": "sym_output", + "is_batch": false, + "attributes": {}, + "data": { + "node": [ + {"id": 0, "energized": 1, "u_pu": 1, "u": 10, "u_angle": 0}, + {"id": 1, "energized": 1, "u_pu": 0.9, "u": 9, "u_angle": 0} + ], + "line": [ + {"id": 2, "energized": 1, "p_from": 10, "q_from": 0, "p_to": -9, "q_to": -0} + ], + "source": [ + {"id": 3, "energized": 1, "p": 10, "q": 0} + ], + "sym_load": [ + {"id": 4, "energized": 1, "p": 9, "q": 0} + ], + "sym_power_sensor": [ + {"id": 5, "energized": 1, "p_residual": 0, "q_residual": 0} + ], + "sym_voltage_sensor": [ + {"id": 6, "energized": 1, "u_residual": 0} + ] + } +} \ No newline at end of file diff --git a/tests/data/state_estimation/leaf-without-power-sensor/sym_output.json.license b/tests/data/state_estimation/leaf-without-power-sensor/sym_output.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/leaf-without-power-sensor/sym_output.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: Contributors to the Power Grid Model project + +SPDX-License-Identifier: MPL-2.0 From a68bb7f2a149f5ea807f01c8e8f865a18200b250 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Thu, 5 Dec 2024 22:15:22 +0100 Subject: [PATCH 2/4] reproduce error Signed-off-by: Tony Xiang --- .../data/state_estimation/leaf-without-power-sensor/input.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/data/state_estimation/leaf-without-power-sensor/input.json b/tests/data/state_estimation/leaf-without-power-sensor/input.json index 0302bec36..a6a823bcb 100644 --- a/tests/data/state_estimation/leaf-without-power-sensor/input.json +++ b/tests/data/state_estimation/leaf-without-power-sensor/input.json @@ -18,7 +18,7 @@ {"id": 4, "node": 1, "status": 1, "type": 0, "p_specified": 9, "q_specified": 0} ], "sym_power_sensor": [ - {"id": 5, "measured_object": 2, "measured_terminal_type": 0, "power_sigma": 1, "p_measured": 10, "q_measured": 0} + {"id": 5, "measured_object": 3, "measured_terminal_type": 2, "power_sigma": 1, "p_measured": 10, "q_measured": 0} ], "sym_voltage_sensor": [ {"id": 6, "measured_object": 0, "u_sigma": 1, "u_measured": 10} From 3d5edca737d6b653a7897af037ad4372dbc33002 Mon Sep 17 00:00:00 2001 From: Tony Xiang Date: Thu, 5 Dec 2024 22:39:26 +0100 Subject: [PATCH 3/4] reproduce middle sensor Signed-off-by: Tony Xiang --- .../leaf-without-power-sensor/params.json | 2 +- .../middle-without-power-sensor/input.json | 29 +++++++++++++++++++ .../input.json.license | 3 ++ .../middle-without-power-sensor/params.json | 8 +++++ .../params.json.license | 3 ++ .../sym_output.json | 29 +++++++++++++++++++ .../sym_output.json.license | 3 ++ 7 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/data/state_estimation/middle-without-power-sensor/input.json create mode 100644 tests/data/state_estimation/middle-without-power-sensor/input.json.license create mode 100644 tests/data/state_estimation/middle-without-power-sensor/params.json create mode 100644 tests/data/state_estimation/middle-without-power-sensor/params.json.license create mode 100644 tests/data/state_estimation/middle-without-power-sensor/sym_output.json create mode 100644 tests/data/state_estimation/middle-without-power-sensor/sym_output.json.license diff --git a/tests/data/state_estimation/leaf-without-power-sensor/params.json b/tests/data/state_estimation/leaf-without-power-sensor/params.json index 10f5b5b7f..a0e22b030 100644 --- a/tests/data/state_estimation/leaf-without-power-sensor/params.json +++ b/tests/data/state_estimation/leaf-without-power-sensor/params.json @@ -1,5 +1,5 @@ { - "calculation_method": ["newton_raphson"], + "calculation_method": ["newton_raphson", "iterative_linear"], "rtol": 1e-8, "atol": { "default": 1e-8, diff --git a/tests/data/state_estimation/middle-without-power-sensor/input.json b/tests/data/state_estimation/middle-without-power-sensor/input.json new file mode 100644 index 000000000..60c774719 --- /dev/null +++ b/tests/data/state_estimation/middle-without-power-sensor/input.json @@ -0,0 +1,29 @@ +{ + "version": "1.0", + "type": "input", + "is_batch": false, + "attributes": {}, + "data": { + "node": [ + {"id": 0, "u_rated": 10}, + {"id": 1, "u_rated": 10}, + {"id": 7, "u_rated": 10} + ], + "line": [ + {"id": 2, "from_node": 0, "to_node": 1, "from_status": 1, "to_status": 1, "r1": 1.0, "x1": 0.0, "c1": 0.0, "tan1": 0.0, "i_n": 500}, + {"id": 8, "from_node": 1, "to_node": 7, "from_status": 1, "to_status": 1, "r1": 1.0, "x1": 0.0, "c1": 0.0, "tan1": 0.0, "i_n": 500} + ], + "source": [ + {"id": 3, "node": 0, "status": 1, "u_ref": 1.0} + ], + "sym_load": [ + {"id": 4, "node": 1, "status": 1, "type": 0, "p_specified": 9, "q_specified": 0} + ], + "sym_power_sensor": [ + {"id": 5, "measured_object": 3, "measured_terminal_type": 2, "power_sigma": 1, "p_measured": 10, "q_measured": 0} + ], + "sym_voltage_sensor": [ + {"id": 6, "measured_object": 0, "u_sigma": 1, "u_measured": 10} + ] + } +} \ No newline at end of file diff --git a/tests/data/state_estimation/middle-without-power-sensor/input.json.license b/tests/data/state_estimation/middle-without-power-sensor/input.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/middle-without-power-sensor/input.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: Contributors to the Power Grid Model project + +SPDX-License-Identifier: MPL-2.0 diff --git a/tests/data/state_estimation/middle-without-power-sensor/params.json b/tests/data/state_estimation/middle-without-power-sensor/params.json new file mode 100644 index 000000000..a0e22b030 --- /dev/null +++ b/tests/data/state_estimation/middle-without-power-sensor/params.json @@ -0,0 +1,8 @@ +{ + "calculation_method": ["newton_raphson", "iterative_linear"], + "rtol": 1e-8, + "atol": { + "default": 1e-8, + ".+_residual": 5e-4 + } +} \ No newline at end of file diff --git a/tests/data/state_estimation/middle-without-power-sensor/params.json.license b/tests/data/state_estimation/middle-without-power-sensor/params.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/middle-without-power-sensor/params.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: Contributors to the Power Grid Model project + +SPDX-License-Identifier: MPL-2.0 diff --git a/tests/data/state_estimation/middle-without-power-sensor/sym_output.json b/tests/data/state_estimation/middle-without-power-sensor/sym_output.json new file mode 100644 index 000000000..9ea2249f5 --- /dev/null +++ b/tests/data/state_estimation/middle-without-power-sensor/sym_output.json @@ -0,0 +1,29 @@ +{ + "version": "1.0", + "type": "sym_output", + "is_batch": false, + "attributes": {}, + "data": { + "node": [ + {"id": 0, "energized": 1, "u_pu": 1, "u": 10, "u_angle": 0}, + {"id": 1, "energized": 1, "u_pu": 0.9, "u": 9, "u_angle": 0}, + {"id": 7, "energized": 1, "u_pu": 0.9, "u": 9, "u_angle": 0} + ], + "line": [ + {"id": 2, "energized": 1, "p_from": 10, "q_from": 0, "p_to": -9, "q_to": 0}, + {"id": 8, "energized": 1, "p_from": 0, "q_from": 0, "p_to": 0, "q_to": 0} + ], + "source": [ + {"id": 3, "energized": 1, "p": 10, "q": 0} + ], + "sym_load": [ + {"id": 4, "energized": 1, "p": 9, "q": 0} + ], + "sym_power_sensor": [ + {"id": 5, "energized": 1, "p_residual": 0, "q_residual": 0} + ], + "sym_voltage_sensor": [ + {"id": 6, "energized": 1, "u_residual": 0} + ] + } +} \ No newline at end of file diff --git a/tests/data/state_estimation/middle-without-power-sensor/sym_output.json.license b/tests/data/state_estimation/middle-without-power-sensor/sym_output.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/middle-without-power-sensor/sym_output.json.license @@ -0,0 +1,3 @@ +SPDX-FileCopyrightText: Contributors to the Power Grid Model project + +SPDX-License-Identifier: MPL-2.0 From 6a3028bfab31afd211017687079cb9046f3c7787 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Fri, 6 Dec 2024 09:27:41 +0100 Subject: [PATCH 4/4] mark repro cases as xfail Signed-off-by: Martijn Govers --- .../state_estimation/leaf-without-power-sensor/params.json | 4 ++++ .../state_estimation/middle-without-power-sensor/params.json | 4 ++++ tests/unit/utils.py | 2 ++ 3 files changed, 10 insertions(+) diff --git a/tests/data/state_estimation/leaf-without-power-sensor/params.json b/tests/data/state_estimation/leaf-without-power-sensor/params.json index a0e22b030..4167e1fbf 100644 --- a/tests/data/state_estimation/leaf-without-power-sensor/params.json +++ b/tests/data/state_estimation/leaf-without-power-sensor/params.json @@ -4,5 +4,9 @@ "atol": { "default": 1e-8, ".+_residual": 5e-4 + }, + "fail": { + "raises": "SparseMatrixError", + "reason": "Bug in Sparse LU solver found in #853" } } \ No newline at end of file diff --git a/tests/data/state_estimation/middle-without-power-sensor/params.json b/tests/data/state_estimation/middle-without-power-sensor/params.json index a0e22b030..4167e1fbf 100644 --- a/tests/data/state_estimation/middle-without-power-sensor/params.json +++ b/tests/data/state_estimation/middle-without-power-sensor/params.json @@ -4,5 +4,9 @@ "atol": { "default": 1e-8, ".+_residual": 5e-4 + }, + "fail": { + "raises": "SparseMatrixError", + "reason": "Bug in Sparse LU solver found in #853" } } \ No newline at end of file diff --git a/tests/unit/utils.py b/tests/unit/utils.py index 6de4a7429..7d246e3fd 100644 --- a/tests/unit/utils.py +++ b/tests/unit/utils.py @@ -29,6 +29,7 @@ PowerGridBatchError, PowerGridError, PowerGridSerializationError, + SparseMatrixError, ) from power_grid_model.utils import json_deserialize, json_deserialize_from_file, json_serialize_to_file @@ -55,6 +56,7 @@ AutomaticTapCalculationError, InvalidTransformerClock, NotObservableError, + SparseMatrixError, PowerGridSerializationError, AssertionError, OSError,