Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,11 @@
using enum MeasuredTerminalType;

case branch_from:
return measured_component_active<Branch>(state, obj_seq, BranchSide::from);
return measured_component_active<Edge>(state, obj_seq,
BranchSide::from); // TODO(mgovers): cleanup v2: change back to Branch

Check warning on line 64 in power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=PowerGridModel_power-grid-model&issues=AaCBunTsvbmvCQdksVIF&open=AaCBunTsvbmvCQdksVIF&pullRequest=1580
case branch_to:
return measured_component_active<Branch>(state, obj_seq, BranchSide::to);
return measured_component_active<Edge>(state, obj_seq,
BranchSide::to); // TODO(mgovers): cleanup v2: change back to Branch

Check warning on line 67 in power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=PowerGridModel_power-grid-model&issues=AaCBunTsvbmvCQdksVIG&open=AaCBunTsvbmvCQdksVIG&pullRequest=1580
case source:
return measured_component_active<Source>(state, obj_seq);
case shunt:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
case branch_from:
[[fallthrough]];
case branch_to:
return get_component_sequence_idx<Branch>(components, measured_object);
return get_component_sequence_idx<Edge>(
components, measured_object); // TODO(mgovers): cleanup v2: change back to Branch

Check warning on line 125 in power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=PowerGridModel_power-grid-model&issues=AaCBunXovbmvCQdksVIH&open=AaCBunXovbmvCQdksVIH&pullRequest=1580
case source:
return get_component_sequence_idx<Source>(components, measured_object);
case shunt:
Expand Down Expand Up @@ -152,28 +153,29 @@
template <std::same_as<GenericCurrentSensor> Component, class ComponentContainer>
requires common::component_container_c<ComponentContainer, Component, Branch, Branch3>
constexpr void register_topology_components(ComponentContainer const& components, ComponentTopology& comp_topo) {
apply_registration<Component>(components, comp_topo.current_sensor_object_idx,
[&components](GenericCurrentSensor const& current_sensor) {
using enum MeasuredTerminalType;

auto const measured_object = current_sensor.measured_object();

switch (current_sensor.get_terminal_type()) {
case branch_from:
[[fallthrough]];
case branch_to:
return get_component_sequence_idx<Branch>(components, measured_object);
case branch3_1:
[[fallthrough]];
case branch3_2:
[[fallthrough]];
case branch3_3:
return get_component_sequence_idx<Branch3>(components, measured_object);
default:
throw MissingCaseForEnumError("Current sensor idx to seq transformation",
current_sensor.get_terminal_type());
}
});
apply_registration<Component>(
components, comp_topo.current_sensor_object_idx, [&components](GenericCurrentSensor const& current_sensor) {
using enum MeasuredTerminalType;

auto const measured_object = current_sensor.measured_object();

switch (current_sensor.get_terminal_type()) {
case branch_from:
[[fallthrough]];
case branch_to:
return get_component_sequence_idx<Edge>(
components, measured_object); // TODO(mgovers): cleanup v2: change back to Branch

Check warning on line 167 in power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=PowerGridModel_power-grid-model&issues=AaCBunXovbmvCQdksVII&open=AaCBunXovbmvCQdksVII&pullRequest=1580
case branch3_1:
[[fallthrough]];
case branch3_2:
[[fallthrough]];
case branch3_3:
return get_component_sequence_idx<Branch3>(components, measured_object);
default:
throw MissingCaseForEnumError("Current sensor idx to seq transformation",
current_sensor.get_terminal_type());
}
});

apply_registration<Component>(
components, comp_topo.current_sensor_terminal_type,
Expand All @@ -187,7 +189,8 @@
components, comp_topo.regulated_object_idx, [&components](Regulator const& regulator) {
switch (regulator.regulated_object_type()) {
case ComponentType::branch:
return get_component_sequence_idx<Branch>(components, regulator.regulated_object());
return get_component_sequence_idx<Edge>(
components, regulator.regulated_object()); // TODO(mgovers): cleanup v2: change back to Branch

Check warning on line 193 in power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this "TODO" comment.

See more on https://sonarcloud.io/project/issues?id=PowerGridModel_power-grid-model&issues=AaCBunXovbmvCQdksVIJ&open=AaCBunXovbmvCQdksVIJ&pullRequest=1580
case ComponentType::branch3:
return get_component_sequence_idx<Branch3>(components, regulator.regulated_object());
case ComponentType::generic_load_gen:
Expand Down
2 changes: 1 addition & 1 deletion tests/cpp_unit_tests/main_core/test_main_core_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace power_grid_model::main_core {
namespace {

using PowerSensorOutputComponents =
Container<ExtraRetrievableTypes<Base, Branch, Branch3, Appliance, GenericLoadGen, GenericPowerSensor>,
Container<ExtraRetrievableTypes<Base, Edge, Branch, Branch3, Appliance, GenericLoadGen, GenericPowerSensor>,
GenericBranch, ThreeWindingTransformer, Source, Shunt, SymGenerator, SymLoad, SymPowerSensor>;
using PowerSensorOutputState = MainModelState<PowerSensorOutputComponents>;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "1.0",
"type": "asym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 30, "energized": 1, "u_pu": [1.000000010064068, 1.000000010064068, 1.000000010064068], "u": [230.94011000004724, 230.94011000004724, 230.94011000004724], "p": [0, 0, 0], "q": [0, 0, 0]},
{"id": 90, "energized": 1, "u_pu": [1.0000101193813746, 1.0000101193813751, 1.0000101193813746], "u": [5773.5611161718643, 5773.5611161718671, 5773.5611161718643], "p": [393.33930563990441, 393.33930564063223, 393.33930563908439], "q": [0.00709388887433921, 0.0070938906288457171, 0.0070938892082683235]},
{"id": 112, "energized": 1, "u_pu": [1.000000010064068, 1.000000010064068, 1.000000010064068], "u": [230.94011000004724, 230.94011000004724, 230.94011000004724], "p": [0, 0, 0], "q": [0, 0, 0]}
],
"source": [
{"id": 207, "energized": 1, "p": [393.33930563990441, 393.33930564063223, 393.33930563908439], "q": [0.00709388887433921, 0.0070938906288457171, 0.0070938892082683235], "i": [0.068127676799353901, 0.068127676799479939, 0.068127676799211861], "s": [393.33930570387372, 393.33930570460149, 393.3393057030537], "pf": [0.99999999983736865, 0.99999999983736876, 0.99999999983736865]}
],
"transformer": [
{"id": 208, "energized": 1, "loading": 0.0018730443128754427, "p_from": [393.33930563990441, 393.33930564063223, 393.33930563908439], "q_from": [0.00709388887433921, 0.0070938906288644295, 0.0070938892082577018], "i_from": [0.068127676799353901, 0.068127676799479939, 0.068127676799211875], "s_from": [393.33930570387372, 393.33930570460149, 393.3393057030537], "p_to": [-2.9599540235974926e-10, -1.065247035871966e-09, -2.960409795477462e-10], "q_to": [1.7763675350654815e-09, -6.8662416846613241e-11, 5.1280073347288324e-10], "i_to": [7.797950250597033e-12, 4.6222270443732789e-12, 2.5639502485114186e-12], "s_to": [1.8008594886477745e-09, 1.0674576220727582e-09, 5.9211895242587547e-10]}
],
"link": [
{"id": 229, "energized": 1, "loading": 0, "p_from": [0, 0, 0], "q_from": [0, 0, 0], "i_from": [0, 0, 0], "s_from": [0, 0, 0], "p_to": [0, 0, 0], "q_to": [0, 0, 0], "i_to": [0, 0, 0], "s_to": [0, 0, 0]}
],
"asym_voltage_sensor": [
{"id": 329, "energized": 1, "u_residual": [0, 0, 0]}
],
"asym_power_sensor": [
{"id": 466, "energized": 1, "p_residual": [0, 0, 0], "q_residual": [0, 0, 0]},
{"id": 467, "energized": 1, "p_residual": [0, 0, 0], "q_residual": [0, 0, 0]}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"version": "1.0",
"type": "input",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 30, "u_rated": 400},
{"id": 90, "u_rated": 10000},
{"id": 112, "u_rated": 400}
],
"source": [
{"id": 207, "node": 90, "status": 1, "u_ref": 1, "u_ref_angle": 0}
],
"transformer": [
{"id": 208, "from_node": 90, "to_node": 112, "from_status": 1, "to_status": 1, "u1": 10000, "u2": 400, "sn": 630000, "uk": 0.040000000000000001, "pk": 6800.2200000000003, "i0": 0.0018730158730158729, "p0": 1180, "winding_from": 1, "winding_to": 1, "clock": 0, "tap_side": 1, "tap_pos": 5, "tap_min": 1, "tap_max": 9, "tap_nom": 5, "tap_size": 10, "r_grounding_from": 0, "x_grounding_from": 0, "r_grounding_to": 0, "x_grounding_to": 0}
],
"link": [
{"id": 229, "from_node": 30, "to_node": 112, "from_status": 1, "to_status": 1}
],
"asym_voltage_sensor": [
{"id": 329, "measured_object": 30, "u_sigma": 2.3094, "u_measured": [230.94011, 230.94011, 230.94011]}
],
"asym_power_sensor": [
{"id": 466, "measured_object": 208, "measured_terminal_type": 1, "p_measured": [0, 0, 0], "q_measured": [0, 0, 0], "p_sigma": [1000, 1000, 1000], "q_sigma": [1000, 1000, 1000]},
{"id": 467, "measured_object": 112, "measured_terminal_type": 9, "p_measured": [0, 0, 0], "q_measured": [0, 0, 0], "p_sigma": [1000, 1000, 1000], "q_sigma": [1000, 1000, 1000]}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"calculation_method": ["iterative_linear", "newton_raphson"],
"rtol": 1e-8,
"atol": {
"default": 1e-5,
"p": 2e-2,
"q": 2e-2,
"s": 2e-2,
"p_from": 2e-2,
"q_from": 2e-2,
"i_from": 1e-4,
"s_from": 2e-2,
"p_to": 2e-2,
"q_to": 2e-2,
"i_to": 1e-4,
"s_to": 2e-2,
"p_residual": 1e-2,
"q_residual": 2e-2
}
}
28 changes: 28 additions & 0 deletions tests/data/state_estimation/link-after-trafo/asym_output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "1.0",
"type": "asym_output",
"is_batch": false,
"attributes": {},
"data": {
"node": [
{"id": 30, "energized": 1, "u_pu": [1.000000010064068, 1.000000010064068, 1.000000010064068], "u": [230.94011000004724, 230.94011000004724, 230.94011000004724], "p": [0, 0, 0], "q": [0, 0, 0]},
{"id": 90, "energized": 1, "u_pu": [1.0000101193813746, 1.0000101193813751, 1.0000101193813746], "u": [5773.5611161718643, 5773.5611161718671, 5773.5611161718643], "p": [393.33930563990441, 393.33930564063223, 393.33930563908439], "q": [0.00709388887433921, 0.0070938906288457171, 0.0070938892082683235]},
{"id": 112, "energized": 1, "u_pu": [1.000000010064068, 1.000000010064068, 1.000000010064068], "u": [230.94011000004724, 230.94011000004724, 230.94011000004724], "p": [0, 0, 0], "q": [0, 0, 0]}
],
"source": [
{"id": 207, "energized": 1, "p": [393.33930563990441, 393.33930564063223, 393.33930563908439], "q": [0.00709388887433921, 0.0070938906288457171, 0.0070938892082683235], "i": [0.068127676799353901, 0.068127676799479939, 0.068127676799211861], "s": [393.33930570387372, 393.33930570460149, 393.3393057030537], "pf": [0.99999999983736865, 0.99999999983736876, 0.99999999983736865]}
],
"transformer": [
{"id": 208, "energized": 1, "loading": 0.0018730443128754427, "p_from": [393.33930563990441, 393.33930564063223, 393.33930563908439], "q_from": [0.00709388887433921, 0.0070938906288644295, 0.0070938892082577018], "i_from": [0.068127676799353901, 0.068127676799479939, 0.068127676799211875], "s_from": [393.33930570387372, 393.33930570460149, 393.3393057030537], "p_to": [-2.9599540235974926e-10, -1.065247035871966e-09, -2.960409795477462e-10], "q_to": [1.7763675350654815e-09, -6.8662416846613241e-11, 5.1280073347288324e-10], "i_to": [7.797950250597033e-12, 4.6222270443732789e-12, 2.5639502485114186e-12], "s_to": [1.8008594886477745e-09, 1.0674576220727582e-09, 5.9211895242587547e-10]}
],
"link": [
{"id": 229, "energized": 1, "loading": 0, "p_from": [0, 0, 0], "q_from": [0, 0, 0], "i_from": [0, 0, 0], "s_from": [0, 0, 0], "p_to": [0, 0, 0], "q_to": [0, 0, 0], "i_to": [0, 0, 0], "s_to": [0, 0, 0]}
],
"asym_voltage_sensor": [
{"id": 329, "energized": 1, "u_residual": [0, 0, 0]}
],
"asym_power_sensor": [
{"id": 466, "energized": 1, "p_residual": [0, 0, 0], "q_residual": [0, 0, 0]}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>

SPDX-License-Identifier: MPL-2.0
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
{"id": 229, "from_node": 30, "to_node": 112, "from_status": 1, "to_status": 1}
],
"asym_voltage_sensor": [
{"id": 329, "measured_object": 30, "u_sigma": 2.3094000000000001, "u_measured": [230.94011, 230.94011, 230.94011]}

{"id": 329, "measured_object": 30, "u_sigma": 2.3094, "u_measured": [230.94011, 230.94011, 230.94011]}
],
"asym_power_sensor": [
{"id": 466, "measured_object": 208, "measured_terminal_type": 1, "p_measured": [0, 0, 0], "q_measured": [0, 0, 0], "p_sigma": [1000, 1000, 1000], "q_sigma": [1000, 1000, 1000]}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>

SPDX-License-Identifier: MPL-2.0
20 changes: 20 additions & 0 deletions tests/data/state_estimation/link-after-trafo/params.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"calculation_method": ["iterative_linear", "newton_raphson"],
"rtol": 1e-8,
"atol": {
"default": 1e-5,
"p": 2e-2,
"q": 2e-2,
"s": 2e-2,
"p_from": 2e-2,
"q_from": 2e-2,
"i_from": 1e-4,
"s_from": 2e-2,
"p_to": 2e-2,
"q_to": 2e-2,
"i_to": 1e-4,
"s_to": 2e-2,
"p_residual": 1e-2,
"q_residual": 2e-2
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>

SPDX-License-Identifier: MPL-2.0
Loading
Loading