From 9a4d63153474fc028a59614c5102097aba64fbad Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 26 Mar 2025 08:16:42 +0100 Subject: [PATCH 1/7] current sensor main model impl Signed-off-by: Martijn Govers --- .../power_grid_model/all_components.hpp | 14 +++++- .../calculation_parameters.hpp | 19 ++++++-- .../power_grid_model/main_core/input.hpp | 38 +++++++++++++-- .../power_grid_model/main_core/output.hpp | 40 +++++++++++----- .../power_grid_model/main_core/topology.hpp | 29 +++++++++++ .../include/power_grid_model/main_model.hpp | 12 +++-- .../power_grid_model/main_model_impl.hpp | 7 +++ .../include/power_grid_model/topology.hpp | 48 +++++++++++++++---- .../power_grid_model_c/src/model.cpp | 15 +++--- tests/native_api_tests/test_api_model.cpp | 41 ++++++++++++++++ 10 files changed, 221 insertions(+), 42 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/all_components.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/all_components.hpp index 7ed9be5a3..617d48455 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/all_components.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/all_components.hpp @@ -9,6 +9,7 @@ #include "common/component_list.hpp" // component include #include "component/appliance.hpp" +#include "component/current_sensor.hpp" #include "component/fault.hpp" #include "component/generic_branch.hpp" #include "component/line.hpp" @@ -29,6 +30,17 @@ namespace power_grid_model { using AllComponents = ComponentList; + AsymVoltageSensor, SymCurrentSensor, AsymCurrentSensor, Fault, TransformerTapRegulator>; + +template +concept power_or_current_sensor_c = + std::derived_from || std::derived_from; + +static_assert(power_or_current_sensor_c); +static_assert(power_or_current_sensor_c); +static_assert(power_or_current_sensor_c); +static_assert(power_or_current_sensor_c); +static_assert(!power_or_current_sensor_c); +static_assert(!power_or_current_sensor_c); } // namespace power_grid_model diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/calculation_parameters.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/calculation_parameters.hpp index 77ed0abe1..772b9edf9 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/calculation_parameters.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/calculation_parameters.hpp @@ -103,15 +103,19 @@ template struct CurrentSensorCalcParam { }; template -concept sensor_calc_param_type = - std::derived_from> || - std::derived_from> || - std::derived_from> || std::derived_from>; +concept sensor_calc_param_type = std::derived_from> || + std::derived_from> || + std::derived_from> || + std::derived_from> || + std::derived_from> || + std::derived_from>; static_assert(sensor_calc_param_type>); static_assert(sensor_calc_param_type>); static_assert(sensor_calc_param_type>); static_assert(sensor_calc_param_type>); +static_assert(sensor_calc_param_type>); +static_assert(sensor_calc_param_type>); struct TransformerTapRegulatorCalcParam { double u_set{}; @@ -150,6 +154,8 @@ struct MathModelTopology { DenseGroupedIdxVector power_sensors_per_branch_from; DenseGroupedIdxVector power_sensors_per_branch_to; DenseGroupedIdxVector power_sensors_per_bus; + DenseGroupedIdxVector current_sensors_per_branch_from; + DenseGroupedIdxVector current_sensors_per_branch_to; DenseGroupedIdxVector tap_regulators_per_branch; Idx n_bus() const { return static_cast(phase_shift.size()); } @@ -359,6 +365,8 @@ struct ComponentTopology { IdxVector voltage_sensor_node_idx; IdxVector power_sensor_object_idx; // the index is relative to branch, source, shunt or load_gen std::vector power_sensor_terminal_type; + IdxVector current_sensor_object_idx; // the index is relative to branch + std::vector current_sensor_terminal_type; std::vector regulator_type; IdxVector regulated_object_idx; // the index is relative to branch or branch3 std::vector regulated_object_type; @@ -418,7 +426,8 @@ struct TopologicalComponentToMathCoupling { std::vector load_gen; std::vector source; std::vector voltage_sensor; - std::vector power_sensor; // can be coupled to branch-from/to, source, load_gen, or shunt sensor + std::vector power_sensor; // can be coupled to branch-from/to, source, load_gen, or shunt sensor + std::vector current_sensor; // can be coupled to branch-from/to std::vector regulator; }; diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp index fd39b6ac4..a8c96588b 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp @@ -94,11 +94,41 @@ inline void add_component(MainModelState& state, ForwardIter get_component(state, measured_object); break; default: - throw MissingCaseForEnumError(std::string(GenericPowerSensor::name) + " item retrieval", - input.measured_terminal_type); + throw MissingCaseForEnumError{std::format("{} item retrieval", GenericPowerSensor::name), + input.measured_terminal_type}; } emplace_component(state, id, input); + } else if constexpr (std::derived_from) { + // it is not allowed to place a sensor at a link + if (get_component_idx_by_id(state, input.measured_object).group == get_component_type_index(state)) { + throw InvalidMeasuredObject("Link", "CurrentSensor"); + } + // check correctness and get node based on measured terminal type + ID const node = [&state, measured_object = input.measured_object, + measured_terminal_type = input.measured_terminal_type] { + switch (measured_terminal_type) { + using enum MeasuredTerminalType; + + case branch_from: + return get_component(state, measured_object).node(BranchSide::from); + case branch_to: + return get_component(state, measured_object).node(BranchSide::to); + case branch3_1: + return get_component(state, measured_object).node(Branch3Side::side_1); + case branch3_2: + return get_component(state, measured_object).node(Branch3Side::side_2); + case branch3_3: + return get_component(state, measured_object).node(Branch3Side::side_2); + default: + throw MissingCaseForEnumError{std::format("{} item retrieval", GenericCurrentSensor::name), + measured_terminal_type}; + } + }(); + + double const u_rated = get_component(state, node).u_rated(); + + emplace_component(state, id, input, u_rated); } else if constexpr (std::derived_from) { // check that fault object exists (currently, only faults at nodes are supported) get_component(state, input.fault_object); @@ -118,7 +148,7 @@ inline void add_component(MainModelState& state, ForwardIter case from: return regulated_object.node(static_cast(input.control_side)); default: - throw MissingCaseForEnumError{std::string{Component::name} + " item retrieval", + throw MissingCaseForEnumError{std::format("{} item retrieval", Component::name), input.control_side}; } } else if (regulated_object_idx.group == get_component_type_index(state)) { @@ -129,7 +159,7 @@ inline void add_component(MainModelState& state, ForwardIter case side_3: return regulated_object.node(static_cast(input.control_side)); default: - throw MissingCaseForEnumError{std::string{Component::name} + " item retrieval", + throw MissingCaseForEnumError{std::format("{} item retrieval", Component::name), input.control_side}; } } else { diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp index 345848885..34b96e23c 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp @@ -66,6 +66,13 @@ constexpr auto comp_base_sequence_cbegin(MainModelState cons get_component_sequence_offset(state); } +template Component, class ComponentContainer> + requires model_component_state_c +constexpr auto comp_base_sequence_cbegin(MainModelState const& state) { + return state.comp_topo->current_sensor_object_idx.cbegin() + + get_component_sequence_offset(state); +} + template Component, class ComponentContainer> requires model_component_state_c constexpr auto comp_base_sequence_cbegin(MainModelState const& state) { @@ -235,14 +242,14 @@ inline auto output_result(Component const& voltage_sensor, MainModelState Component, class ComponentContainer, +template requires model_component_state_c -constexpr auto output_result(Component const& power_sensor, MainModelState const& state, +constexpr auto output_result(Component const& power_or_current_sensor, MainModelState const& state, std::vector const& solver_output, Idx const obj_seq) { using sym = typename SolverOutputType::sym; - auto const terminal_type = power_sensor.get_terminal_type(); + auto const terminal_type = power_or_current_sensor.get_terminal_type(); Idx2D const obj_math_id = [&]() { switch (terminal_type) { using enum MeasuredTerminalType; @@ -274,7 +281,7 @@ constexpr auto output_result(Component const& power_sensor, MainModelState(); + return power_or_current_sensor.template get_null_output(); } switch (terminal_type) { @@ -285,29 +292,36 @@ constexpr auto output_result(Component const& power_sensor, MainModelState(solver_output[obj_math_id.group].branch[obj_math_id.pos].s_f); + return power_or_current_sensor.template get_output( + solver_output[obj_math_id.group].branch[obj_math_id.pos].s_f); case branch_to: - return power_sensor.template get_output(solver_output[obj_math_id.group].branch[obj_math_id.pos].s_t); + return power_or_current_sensor.template get_output( + solver_output[obj_math_id.group].branch[obj_math_id.pos].s_t); case source: - return power_sensor.template get_output(solver_output[obj_math_id.group].source[obj_math_id.pos].s); + return power_or_current_sensor.template get_output( + solver_output[obj_math_id.group].source[obj_math_id.pos].s); case shunt: - return power_sensor.template get_output(solver_output[obj_math_id.group].shunt[obj_math_id.pos].s); + return power_or_current_sensor.template get_output( + solver_output[obj_math_id.group].shunt[obj_math_id.pos].s); case load: [[fallthrough]]; case generator: - return power_sensor.template get_output(solver_output[obj_math_id.group].load_gen[obj_math_id.pos].s); + return power_or_current_sensor.template get_output( + solver_output[obj_math_id.group].load_gen[obj_math_id.pos].s); case node: - return power_sensor.template get_output(solver_output[obj_math_id.group].bus_injection[obj_math_id.pos]); + return power_or_current_sensor.template get_output( + solver_output[obj_math_id.group].bus_injection[obj_math_id.pos]); default: throw MissingCaseForEnumError(std::string(GenericPowerSensor::name) + " output_result()", terminal_type); } } -template Component, class ComponentContainer, +template requires model_component_state_c -constexpr auto output_result(Component const& power_sensor, MainModelState const& /* state */, +constexpr auto output_result(Component const& power_or_current_sensor, + MainModelState const& /* state */, std::vector const& /* solver_output */, Idx const /* obj_seq */) { - return power_sensor.get_null_sc_output(); + return power_or_current_sensor.get_null_sc_output(); } // output fault diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp index fd88d340a..edcd76152 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp @@ -136,6 +136,35 @@ constexpr void register_topology_components(MainModelState c [](GenericPowerSensor const& power_sensor) { return power_sensor.get_terminal_type(); }); } +template Component, class ComponentContainer> + requires model_component_state_c +constexpr void register_topology_components(MainModelState const& state, + ComponentTopology& comp_topo) { + detail::register_topo_components( + state, comp_topo.current_sensor_object_idx, [&state](GenericCurrentSensor const& current_sensor) { + using enum MeasuredTerminalType; + + auto const measured_object = current_sensor.measured_object(); + + switch (current_sensor.get_terminal_type()) { + case branch_from: + case branch_to: + return get_component_sequence_idx(state, measured_object); + case branch3_1: + case branch3_2: + case branch3_3: + return get_component_sequence_idx(state, measured_object); + default: + throw MissingCaseForEnumError("Current sensor idx to seq transformation", + current_sensor.get_terminal_type()); + } + }); + + detail::register_topo_components( + state, comp_topo.current_sensor_terminal_type, + [](GenericCurrentSensor const& current_sensor) { return current_sensor.get_terminal_type(); }); +} + template Component, class ComponentContainer> requires model_component_state_c constexpr void register_topology_components(MainModelState const& state, diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model.hpp index 1c732680d..f6c77099a 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model.hpp @@ -14,10 +14,10 @@ namespace power_grid_model { class MainModel { private: - using Impl = - MainModelImpl, - AllComponents>; + using Impl = MainModelImpl< + ExtraRetrievableTypes, + AllComponents>; public: using Options = MainModelOptions; @@ -68,6 +68,10 @@ class MainModel { CalculationInfo calculation_info() const { return impl().calculation_info(); } + void check_no_experimental_features_used(Options const& options) const { + impl().check_no_experimental_features_used(options); + } + private: Impl& impl() { assert(impl_ != nullptr); diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp index f01ec01c4..b636337ec 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp @@ -801,6 +801,13 @@ class MainModelImpl, ComponentLis CalculationInfo calculation_info() const { return calculation_info_; } + void check_no_experimental_features_used(Options const& options) const { + if (options.calculation_type == CalculationType::state_estimation && + state_.components.template size() > 0) { + throw ExperimentalFeature{"State estimation", "current sensors"}; + } + } + private: template requires solver_output_type diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp index f67319c7d..7f672f3a9 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/topology.hpp @@ -163,6 +163,7 @@ class Topology { comp_coup_.source.resize(comp_topo_.source_node_idx.size(), unknown_idx2d); comp_coup_.voltage_sensor.resize(comp_topo_.voltage_sensor_node_idx.size(), unknown_idx2d); comp_coup_.power_sensor.resize(comp_topo_.power_sensor_object_idx.size(), unknown_idx2d); + comp_coup_.current_sensor.resize(comp_topo_.current_sensor_object_idx.size(), unknown_idx2d); } void build_sparse_graph() { @@ -452,7 +453,7 @@ class Topology { Idx size() const { return static_cast(sensor_obj_idx.size()); } Idx2D find_math_object(Idx component_i) const { Idx const obj_idx = sensor_obj_idx[component_i]; - switch (power_sensor_terminal_type[component_i]) { + switch (sensor_terminal_type[component_i]) { using enum MeasuredTerminalType; case branch_from: @@ -472,7 +473,7 @@ class Topology { // NOLINTBEGIN(cppcoreguidelines-avoid-const-or-ref-data-members) IdxVector const& sensor_obj_idx; - std::vector const& power_sensor_terminal_type; + std::vector const& sensor_terminal_type; std::vector const& branch_coupling; std::vector const& branch3_coupling; // NOLINTEND(cppcoreguidelines-avoid-const-or-ref-data-members) @@ -600,7 +601,7 @@ class Topology { // branch 'from' power sensors // include all branch3 sensors - auto const predicate_from_sensor = [this](Idx i) { + auto const predicate_from_power_sensor = [this](Idx i) { using enum MeasuredTerminalType; return comp_topo_.power_sensor_terminal_type[i] == branch_from || @@ -609,16 +610,16 @@ class Topology { comp_topo_.power_sensor_terminal_type[i] == branch3_2 || comp_topo_.power_sensor_terminal_type[i] == branch3_3; }; - SensorBranchObjectFinder const object_finder_from_sensor{.sensor_obj_idx = comp_topo_.power_sensor_object_idx, - .power_sensor_terminal_type = - comp_topo_.power_sensor_terminal_type, - .branch_coupling = comp_coup_.branch, - .branch3_coupling = comp_coup_.branch3}; + SensorBranchObjectFinder const object_finder_from_power_sensor{ + .sensor_obj_idx = comp_topo_.power_sensor_object_idx, + .sensor_terminal_type = comp_topo_.power_sensor_terminal_type, + .branch_coupling = comp_coup_.branch, + .branch3_coupling = comp_coup_.branch3}; // branch 'from' power sensors couple_object_components<&MathModelTopology::n_branch>( [](MathModelTopology& math_topo) -> auto& { return math_topo.power_sensors_per_branch_from; }, - object_finder_from_sensor, comp_coup_.power_sensor, predicate_from_sensor); + object_finder_from_power_sensor, comp_coup_.power_sensor, predicate_from_power_sensor); // branch 'to' power sensors couple_object_components<&MathModelTopology::n_branch>( @@ -633,6 +634,35 @@ class Topology { {.component_obj_idx = comp_topo_.power_sensor_object_idx, .objects_coupling = comp_coup_.node}, comp_coup_.power_sensor, [this](Idx i) { return comp_topo_.power_sensor_terminal_type[i] == MeasuredTerminalType::node; }); + + // branch 'from' current sensors + // include all branch3 sensors + auto const predicate_from_current_sensor = [this](Idx i) { + using enum MeasuredTerminalType; + + return comp_topo_.current_sensor_terminal_type[i] == branch_from || + // all branch3 sensors are at from side in the mathemtical model + comp_topo_.current_sensor_terminal_type[i] == branch3_1 || + comp_topo_.current_sensor_terminal_type[i] == branch3_2 || + comp_topo_.current_sensor_terminal_type[i] == branch3_3; + }; + SensorBranchObjectFinder const object_finder_from_current_sensor{ + .sensor_obj_idx = comp_topo_.current_sensor_object_idx, + .sensor_terminal_type = comp_topo_.current_sensor_terminal_type, + .branch_coupling = comp_coup_.branch, + .branch3_coupling = comp_coup_.branch3}; + + // branch 'from' current sensors + couple_object_components<&MathModelTopology::n_branch>( + [](MathModelTopology& math_topo) -> auto& { return math_topo.current_sensors_per_branch_from; }, + object_finder_from_current_sensor, comp_coup_.current_sensor, predicate_from_current_sensor); + + // branch 'to' current sensors + couple_object_components<&MathModelTopology::n_branch>( + [](MathModelTopology& math_topo) -> auto& { return math_topo.current_sensors_per_branch_to; }, + {.component_obj_idx = comp_topo_.current_sensor_object_idx, .objects_coupling = comp_coup_.branch}, + comp_coup_.current_sensor, + [this](Idx i) { return comp_topo_.current_sensor_terminal_type[i] == MeasuredTerminalType::branch_to; }); } }; diff --git a/power_grid_model_c/power_grid_model_c/src/model.cpp b/power_grid_model_c/power_grid_model_c/src/model.cpp index b03b78b6b..8310c62ea 100644 --- a/power_grid_model_c/power_grid_model_c/src/model.cpp +++ b/power_grid_model_c/power_grid_model_c/src/model.cpp @@ -56,8 +56,11 @@ void PGM_get_indexer(PGM_Handle* handle, PGM_PowerGridModel const* model, char c } namespace { -void check_calculate_experimental_features(PGM_Options const& /* opt */) { +void check_no_experimental_features_used(MainModel const& model, MainModel::Options const& opt) { // optionally add experimental feature checks here + using namespace std::string_literals; + + model.check_no_experimental_features_used(opt); } void check_calculate_valid_options(PGM_Options const& opt) { @@ -67,10 +70,6 @@ void check_calculate_valid_options(PGM_Options const& opt) { InvalidArguments::TypeValuePair{.name = "PGM_TapChangingStrategy", .value = std::to_string(opt.tap_changing_strategy)}}; } - - if (opt.experimental_features == PGM_experimental_features_disabled) { - check_calculate_experimental_features(opt); - } } constexpr auto get_calculation_type(PGM_Options const& opt) { @@ -160,8 +159,12 @@ void PGM_calculate(PGM_Handle* handle, PGM_PowerGridModel* model, PGM_Options co // call calculation try { check_calculate_valid_options(*opt); - auto const options = extract_calculation_options(*opt); + + if (opt->experimental_features == PGM_experimental_features_disabled) { + check_no_experimental_features_used(*model, options); + } + model->calculate(options, *output_dataset, exported_update_dataset); } catch (BatchCalculationError& e) { handle->err_code = PGM_batch_error; diff --git a/tests/native_api_tests/test_api_model.cpp b/tests/native_api_tests/test_api_model.cpp index 1482b61b8..05b2278cb 100644 --- a/tests/native_api_tests/test_api_model.cpp +++ b/tests/native_api_tests/test_api_model.cpp @@ -1062,6 +1062,47 @@ TEST_CASE("API Model") { } } } + + SUBCASE("Current sensor is experimental") { + auto const input_data_se_json = R"json({ + "version": "1.0", + "type": "input", + "is_batch": false, + "attributes": {}, + "data": { + "node": [ + {"id": 1, "u_rated": 10000}, + {"id": 2, "u_rated": 10000} + ], + "line": [ + {"id": 3, "from_node": 1, "to_node": 2, "r": 0.1, "x": 0.2} + ], + "sym_current_sensor": [ + {"id": 4, "measured_object": 3, "measured_terminal_type": 0} + ] + } +})json"; + + auto const owning_input_dataset_se = load_dataset(input_data_se_json); + auto const& input_dataset_se = owning_input_dataset_se.dataset; + + auto const run_se_with_current_sensor = [&input_dataset_se](PGM_CalculationMethod method, + PGM_ExperimentalFeatures experimental_features) { + Model model{50.0, input_dataset_se}; + Options options{}; + options.set_calculation_type(PGM_state_estimation); + options.set_calculation_method(method); + options.set_experimental_features(experimental_features); + DatasetMutable const output_dataset{"sym_output", false, 1}; + model.calculate(options, output_dataset); + }; + for (auto const method : {PGM_default_method, PGM_iterative_linear, PGM_newton_raphson}) { + CAPTURE(method); + CHECK_THROWS_WITH_AS(run_se_with_current_sensor(method, PGM_experimental_features_disabled), + "State estimation is not implemented for current sensors!\n", PowerGridRegularError); + CHECK_NOTHROW(run_se_with_current_sensor(method, PGM_experimental_features_enabled)); + } + } } } // namespace power_grid_model_cpp From 7f4f058da0b1015c1749afaa9dc1def9776c59c0 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 26 Mar 2025 09:33:12 +0100 Subject: [PATCH 2/7] implement current sensor in main model Signed-off-by: Martijn Govers --- .../dataset_definitions.json | 16 ++++ .../power_grid_model_c/dataset_definitions.h | 76 +++++++++++++++++++ .../src/dataset_definitions.cpp | 76 +++++++++++++++++++ .../_core/dataset_definitions.py | 2 + .../basic-current-sensor/input.json | 27 +++++++ .../basic-current-sensor/input.json.license | 3 + .../basic-current-sensor/params.json | 27 +++++++ .../basic-current-sensor/params.json.license | 3 + .../basic-current-sensor/sym_output.json | 7 ++ .../sym_output.json.license | 3 + tests/native_api_tests/test_api_model.cpp | 2 +- tests/unit/test_0Z_model_validation.py | 4 +- 12 files changed, 243 insertions(+), 3 deletions(-) create mode 100644 tests/data/state_estimation/basic-current-sensor/input.json create mode 100644 tests/data/state_estimation/basic-current-sensor/input.json.license create mode 100644 tests/data/state_estimation/basic-current-sensor/params.json create mode 100644 tests/data/state_estimation/basic-current-sensor/params.json.license create mode 100644 tests/data/state_estimation/basic-current-sensor/sym_output.json create mode 100644 tests/data/state_estimation/basic-current-sensor/sym_output.json.license diff --git a/code_generation/data/dataset_class_maps/dataset_definitions.json b/code_generation/data/dataset_class_maps/dataset_definitions.json index e4cb9073d..24ef30c29 100644 --- a/code_generation/data/dataset_class_maps/dataset_definitions.json +++ b/code_generation/data/dataset_class_maps/dataset_definitions.json @@ -52,6 +52,10 @@ "names": ["sym_power_sensor", "asym_power_sensor"], "class_name": "PowerSensorInput" }, + { + "names": ["sym_current_sensor", "asym_current_sensor"], + "class_name": "CurrentSensorInput" + }, { "names": ["fault"], "class_name": "FaultInput" @@ -90,6 +94,10 @@ "names": ["sym_power_sensor", "asym_power_sensor"], "class_name": "PowerSensorOutput" }, + { + "names": ["sym_current_sensor", "asym_current_sensor"], + "class_name": "CurrentSensorOutput" + }, { "names": ["fault"], "class_name": "FaultOutput" @@ -144,6 +152,10 @@ "names": ["sym_power_sensor", "asym_power_sensor"], "class_name": "PowerSensorUpdate" }, + { + "names": ["sym_current_sensor", "asym_current_sensor"], + "class_name": "CurrentSensorUpdate" + }, { "names": ["fault"], "class_name": "FaultUpdate" @@ -178,6 +190,10 @@ "names": ["sym_power_sensor", "asym_power_sensor"], "class_name": "SensorShortCircuitOutput" }, + { + "names": ["sym_current_sensor", "asym_current_sensor"], + "class_name": "SensorShortCircuitOutput" + }, { "names": ["fault"], "class_name": "FaultShortCircuitOutput" diff --git a/power_grid_model_c/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h b/power_grid_model_c/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h index 3be340891..63f0f5882 100644 --- a/power_grid_model_c/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +++ b/power_grid_model_c/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h @@ -261,6 +261,28 @@ PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_power_sensor_p_ PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_power_sensor_q_measured; PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_power_sensor_p_sigma; PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_power_sensor_q_sigma; +// component sym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_input_sym_current_sensor; +// attributes of input sym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_measured_object; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_measured_terminal_type; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_angle_measurement_type; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_i_sigma; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_i_angle_sigma; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_i_measured; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_i_angle_measured; +// component asym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_input_asym_current_sensor; +// attributes of input asym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_measured_object; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_measured_terminal_type; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_angle_measurement_type; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_i_sigma; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_i_angle_sigma; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_i_measured; +PGM_API extern PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_i_angle_measured; // component fault PGM_API extern PGM_MetaComponent const* const PGM_def_input_fault; // attributes of input fault @@ -452,6 +474,20 @@ PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_asym_power_sens PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_asym_power_sensor_energized; PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_asym_power_sensor_p_residual; PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_asym_power_sensor_q_residual; +// component sym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_sym_output_sym_current_sensor; +// attributes of sym_output sym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_sym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_sym_current_sensor_energized; +PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_sym_current_sensor_i_residual; +PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_sym_current_sensor_i_angle_residual; +// component asym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_sym_output_asym_current_sensor; +// attributes of sym_output asym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_asym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_asym_current_sensor_energized; +PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_asym_current_sensor_i_residual; +PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_asym_current_sensor_i_angle_residual; // component fault PGM_API extern PGM_MetaComponent const* const PGM_def_sym_output_fault; // attributes of sym_output fault @@ -638,6 +674,20 @@ PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_asym_power_sen PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_asym_power_sensor_energized; PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_asym_power_sensor_p_residual; PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_asym_power_sensor_q_residual; +// component sym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_asym_output_sym_current_sensor; +// attributes of asym_output sym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_sym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_sym_current_sensor_energized; +PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_sym_current_sensor_i_residual; +PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_sym_current_sensor_i_angle_residual; +// component asym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_asym_output_asym_current_sensor; +// attributes of asym_output asym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_asym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_asym_current_sensor_energized; +PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_asym_current_sensor_i_residual; +PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_asym_current_sensor_i_angle_residual; // component fault PGM_API extern PGM_MetaComponent const* const PGM_def_asym_output_fault; // attributes of asym_output fault @@ -758,6 +808,22 @@ PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_power_sensor_p PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_power_sensor_q_measured; PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_power_sensor_p_sigma; PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_power_sensor_q_sigma; +// component sym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_update_sym_current_sensor; +// attributes of update sym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_i_sigma; +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_i_angle_sigma; +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_i_measured; +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_i_angle_measured; +// component asym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_update_asym_current_sensor; +// attributes of update asym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_i_sigma; +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_i_angle_sigma; +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_i_measured; +PGM_API extern PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_i_angle_measured; // component fault PGM_API extern PGM_MetaComponent const* const PGM_def_update_fault; // attributes of update fault @@ -879,6 +945,16 @@ PGM_API extern PGM_MetaComponent const* const PGM_def_sc_output_asym_power_senso // attributes of sc_output asym_power_sensor PGM_API extern PGM_MetaAttribute const* const PGM_def_sc_output_asym_power_sensor_id; PGM_API extern PGM_MetaAttribute const* const PGM_def_sc_output_asym_power_sensor_energized; +// component sym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_sc_output_sym_current_sensor; +// attributes of sc_output sym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_sc_output_sym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_sc_output_sym_current_sensor_energized; +// component asym_current_sensor +PGM_API extern PGM_MetaComponent const* const PGM_def_sc_output_asym_current_sensor; +// attributes of sc_output asym_current_sensor +PGM_API extern PGM_MetaAttribute const* const PGM_def_sc_output_asym_current_sensor_id; +PGM_API extern PGM_MetaAttribute const* const PGM_def_sc_output_asym_current_sensor_energized; // component fault PGM_API extern PGM_MetaComponent const* const PGM_def_sc_output_fault; // attributes of sc_output fault diff --git a/power_grid_model_c/power_grid_model_c/src/dataset_definitions.cpp b/power_grid_model_c/power_grid_model_c/src/dataset_definitions.cpp index 9639a9755..ceec394e6 100644 --- a/power_grid_model_c/power_grid_model_c/src/dataset_definitions.cpp +++ b/power_grid_model_c/power_grid_model_c/src/dataset_definitions.cpp @@ -250,6 +250,28 @@ PGM_MetaAttribute const* const PGM_def_input_asym_power_sensor_p_measured = PGM_ PGM_MetaAttribute const* const PGM_def_input_asym_power_sensor_q_measured = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_power_sensor", "q_measured"); PGM_MetaAttribute const* const PGM_def_input_asym_power_sensor_p_sigma = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_power_sensor", "p_sigma"); PGM_MetaAttribute const* const PGM_def_input_asym_power_sensor_q_sigma = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_power_sensor", "q_sigma"); +// component sym_current_sensor +PGM_MetaComponent const* const PGM_def_input_sym_current_sensor = PGM_meta_get_component_by_name(nullptr, "input", "sym_current_sensor"); +// attributes of input sym_current_sensor +PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "input", "sym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_measured_object = PGM_meta_get_attribute_by_name(nullptr, "input", "sym_current_sensor", "measured_object"); +PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_measured_terminal_type = PGM_meta_get_attribute_by_name(nullptr, "input", "sym_current_sensor", "measured_terminal_type"); +PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_angle_measurement_type = PGM_meta_get_attribute_by_name(nullptr, "input", "sym_current_sensor", "angle_measurement_type"); +PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_i_sigma = PGM_meta_get_attribute_by_name(nullptr, "input", "sym_current_sensor", "i_sigma"); +PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_i_angle_sigma = PGM_meta_get_attribute_by_name(nullptr, "input", "sym_current_sensor", "i_angle_sigma"); +PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_i_measured = PGM_meta_get_attribute_by_name(nullptr, "input", "sym_current_sensor", "i_measured"); +PGM_MetaAttribute const* const PGM_def_input_sym_current_sensor_i_angle_measured = PGM_meta_get_attribute_by_name(nullptr, "input", "sym_current_sensor", "i_angle_measured"); +// component asym_current_sensor +PGM_MetaComponent const* const PGM_def_input_asym_current_sensor = PGM_meta_get_component_by_name(nullptr, "input", "asym_current_sensor"); +// attributes of input asym_current_sensor +PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_measured_object = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_current_sensor", "measured_object"); +PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_measured_terminal_type = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_current_sensor", "measured_terminal_type"); +PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_angle_measurement_type = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_current_sensor", "angle_measurement_type"); +PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_i_sigma = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_current_sensor", "i_sigma"); +PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_i_angle_sigma = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_current_sensor", "i_angle_sigma"); +PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_i_measured = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_current_sensor", "i_measured"); +PGM_MetaAttribute const* const PGM_def_input_asym_current_sensor_i_angle_measured = PGM_meta_get_attribute_by_name(nullptr, "input", "asym_current_sensor", "i_angle_measured"); // component fault PGM_MetaComponent const* const PGM_def_input_fault = PGM_meta_get_component_by_name(nullptr, "input", "fault"); // attributes of input fault @@ -441,6 +463,20 @@ PGM_MetaAttribute const* const PGM_def_sym_output_asym_power_sensor_id = PGM_met PGM_MetaAttribute const* const PGM_def_sym_output_asym_power_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "asym_power_sensor", "energized"); PGM_MetaAttribute const* const PGM_def_sym_output_asym_power_sensor_p_residual = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "asym_power_sensor", "p_residual"); PGM_MetaAttribute const* const PGM_def_sym_output_asym_power_sensor_q_residual = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "asym_power_sensor", "q_residual"); +// component sym_current_sensor +PGM_MetaComponent const* const PGM_def_sym_output_sym_current_sensor = PGM_meta_get_component_by_name(nullptr, "sym_output", "sym_current_sensor"); +// attributes of sym_output sym_current_sensor +PGM_MetaAttribute const* const PGM_def_sym_output_sym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "sym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_sym_output_sym_current_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "sym_current_sensor", "energized"); +PGM_MetaAttribute const* const PGM_def_sym_output_sym_current_sensor_i_residual = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "sym_current_sensor", "i_residual"); +PGM_MetaAttribute const* const PGM_def_sym_output_sym_current_sensor_i_angle_residual = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "sym_current_sensor", "i_angle_residual"); +// component asym_current_sensor +PGM_MetaComponent const* const PGM_def_sym_output_asym_current_sensor = PGM_meta_get_component_by_name(nullptr, "sym_output", "asym_current_sensor"); +// attributes of sym_output asym_current_sensor +PGM_MetaAttribute const* const PGM_def_sym_output_asym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "asym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_sym_output_asym_current_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "asym_current_sensor", "energized"); +PGM_MetaAttribute const* const PGM_def_sym_output_asym_current_sensor_i_residual = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "asym_current_sensor", "i_residual"); +PGM_MetaAttribute const* const PGM_def_sym_output_asym_current_sensor_i_angle_residual = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "asym_current_sensor", "i_angle_residual"); // component fault PGM_MetaComponent const* const PGM_def_sym_output_fault = PGM_meta_get_component_by_name(nullptr, "sym_output", "fault"); // attributes of sym_output fault @@ -627,6 +663,20 @@ PGM_MetaAttribute const* const PGM_def_asym_output_asym_power_sensor_id = PGM_me PGM_MetaAttribute const* const PGM_def_asym_output_asym_power_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "asym_power_sensor", "energized"); PGM_MetaAttribute const* const PGM_def_asym_output_asym_power_sensor_p_residual = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "asym_power_sensor", "p_residual"); PGM_MetaAttribute const* const PGM_def_asym_output_asym_power_sensor_q_residual = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "asym_power_sensor", "q_residual"); +// component sym_current_sensor +PGM_MetaComponent const* const PGM_def_asym_output_sym_current_sensor = PGM_meta_get_component_by_name(nullptr, "asym_output", "sym_current_sensor"); +// attributes of asym_output sym_current_sensor +PGM_MetaAttribute const* const PGM_def_asym_output_sym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "sym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_asym_output_sym_current_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "sym_current_sensor", "energized"); +PGM_MetaAttribute const* const PGM_def_asym_output_sym_current_sensor_i_residual = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "sym_current_sensor", "i_residual"); +PGM_MetaAttribute const* const PGM_def_asym_output_sym_current_sensor_i_angle_residual = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "sym_current_sensor", "i_angle_residual"); +// component asym_current_sensor +PGM_MetaComponent const* const PGM_def_asym_output_asym_current_sensor = PGM_meta_get_component_by_name(nullptr, "asym_output", "asym_current_sensor"); +// attributes of asym_output asym_current_sensor +PGM_MetaAttribute const* const PGM_def_asym_output_asym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "asym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_asym_output_asym_current_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "asym_current_sensor", "energized"); +PGM_MetaAttribute const* const PGM_def_asym_output_asym_current_sensor_i_residual = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "asym_current_sensor", "i_residual"); +PGM_MetaAttribute const* const PGM_def_asym_output_asym_current_sensor_i_angle_residual = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "asym_current_sensor", "i_angle_residual"); // component fault PGM_MetaComponent const* const PGM_def_asym_output_fault = PGM_meta_get_component_by_name(nullptr, "asym_output", "fault"); // attributes of asym_output fault @@ -747,6 +797,22 @@ PGM_MetaAttribute const* const PGM_def_update_asym_power_sensor_p_measured = PGM PGM_MetaAttribute const* const PGM_def_update_asym_power_sensor_q_measured = PGM_meta_get_attribute_by_name(nullptr, "update", "asym_power_sensor", "q_measured"); PGM_MetaAttribute const* const PGM_def_update_asym_power_sensor_p_sigma = PGM_meta_get_attribute_by_name(nullptr, "update", "asym_power_sensor", "p_sigma"); PGM_MetaAttribute const* const PGM_def_update_asym_power_sensor_q_sigma = PGM_meta_get_attribute_by_name(nullptr, "update", "asym_power_sensor", "q_sigma"); +// component sym_current_sensor +PGM_MetaComponent const* const PGM_def_update_sym_current_sensor = PGM_meta_get_component_by_name(nullptr, "update", "sym_current_sensor"); +// attributes of update sym_current_sensor +PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "update", "sym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_i_sigma = PGM_meta_get_attribute_by_name(nullptr, "update", "sym_current_sensor", "i_sigma"); +PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_i_angle_sigma = PGM_meta_get_attribute_by_name(nullptr, "update", "sym_current_sensor", "i_angle_sigma"); +PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_i_measured = PGM_meta_get_attribute_by_name(nullptr, "update", "sym_current_sensor", "i_measured"); +PGM_MetaAttribute const* const PGM_def_update_sym_current_sensor_i_angle_measured = PGM_meta_get_attribute_by_name(nullptr, "update", "sym_current_sensor", "i_angle_measured"); +// component asym_current_sensor +PGM_MetaComponent const* const PGM_def_update_asym_current_sensor = PGM_meta_get_component_by_name(nullptr, "update", "asym_current_sensor"); +// attributes of update asym_current_sensor +PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "update", "asym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_i_sigma = PGM_meta_get_attribute_by_name(nullptr, "update", "asym_current_sensor", "i_sigma"); +PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_i_angle_sigma = PGM_meta_get_attribute_by_name(nullptr, "update", "asym_current_sensor", "i_angle_sigma"); +PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_i_measured = PGM_meta_get_attribute_by_name(nullptr, "update", "asym_current_sensor", "i_measured"); +PGM_MetaAttribute const* const PGM_def_update_asym_current_sensor_i_angle_measured = PGM_meta_get_attribute_by_name(nullptr, "update", "asym_current_sensor", "i_angle_measured"); // component fault PGM_MetaComponent const* const PGM_def_update_fault = PGM_meta_get_component_by_name(nullptr, "update", "fault"); // attributes of update fault @@ -868,6 +934,16 @@ PGM_MetaComponent const* const PGM_def_sc_output_asym_power_sensor = PGM_meta_ge // attributes of sc_output asym_power_sensor PGM_MetaAttribute const* const PGM_def_sc_output_asym_power_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "sc_output", "asym_power_sensor", "id"); PGM_MetaAttribute const* const PGM_def_sc_output_asym_power_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "sc_output", "asym_power_sensor", "energized"); +// component sym_current_sensor +PGM_MetaComponent const* const PGM_def_sc_output_sym_current_sensor = PGM_meta_get_component_by_name(nullptr, "sc_output", "sym_current_sensor"); +// attributes of sc_output sym_current_sensor +PGM_MetaAttribute const* const PGM_def_sc_output_sym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "sc_output", "sym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_sc_output_sym_current_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "sc_output", "sym_current_sensor", "energized"); +// component asym_current_sensor +PGM_MetaComponent const* const PGM_def_sc_output_asym_current_sensor = PGM_meta_get_component_by_name(nullptr, "sc_output", "asym_current_sensor"); +// attributes of sc_output asym_current_sensor +PGM_MetaAttribute const* const PGM_def_sc_output_asym_current_sensor_id = PGM_meta_get_attribute_by_name(nullptr, "sc_output", "asym_current_sensor", "id"); +PGM_MetaAttribute const* const PGM_def_sc_output_asym_current_sensor_energized = PGM_meta_get_attribute_by_name(nullptr, "sc_output", "asym_current_sensor", "energized"); // component fault PGM_MetaComponent const* const PGM_def_sc_output_fault = PGM_meta_get_component_by_name(nullptr, "sc_output", "fault"); // attributes of sc_output fault diff --git a/src/power_grid_model/_core/dataset_definitions.py b/src/power_grid_model/_core/dataset_definitions.py index d8f8031b8..4a0ea9ba5 100644 --- a/src/power_grid_model/_core/dataset_definitions.py +++ b/src/power_grid_model/_core/dataset_definitions.py @@ -71,6 +71,8 @@ class ComponentType(str, Enum, metaclass=_MetaEnum): asym_voltage_sensor = "asym_voltage_sensor" sym_power_sensor = "sym_power_sensor" asym_power_sensor = "asym_power_sensor" + sym_current_sensor = "sym_current_sensor" + asym_current_sensor = "asym_current_sensor" fault = "fault" diff --git a/tests/data/state_estimation/basic-current-sensor/input.json b/tests/data/state_estimation/basic-current-sensor/input.json new file mode 100644 index 000000000..ebdcaf08c --- /dev/null +++ b/tests/data/state_estimation/basic-current-sensor/input.json @@ -0,0 +1,27 @@ +{ + "version": "1.0", + "type": "input", + "is_batch": false, + "attributes": {}, + "data": { + "node": [ + {"id": 1, "u_rated": 10000}, + {"id": 2, "u_rated": 10000} + ], + "line": [ + {"id": 3, "from_node": 1, "to_node": 2, "from_status": 1, "to_status": 1, "r1": 0.000416, "x1": 0.000136, "c1": 1e-09, "tan1": 0} + ], + "source": [ + {"id": 4, "node": 1, "status": 1, "u_ref": 1} + ], + "sym_load": [ + {"id": 5, "node": 2, "status": 1, "type": 0} + ], + "sym_voltage_sensor": [ + {"id": 6, "measured_object": 1, "u_sigma": 200, "u_measured": 10000} + ], + "sym_current_sensor": [ + {"id": 7, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} + ] + } +} \ No newline at end of file diff --git a/tests/data/state_estimation/basic-current-sensor/input.json.license b/tests/data/state_estimation/basic-current-sensor/input.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/basic-current-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/basic-current-sensor/params.json b/tests/data/state_estimation/basic-current-sensor/params.json new file mode 100644 index 000000000..b8769a93e --- /dev/null +++ b/tests/data/state_estimation/basic-current-sensor/params.json @@ -0,0 +1,27 @@ +{ + "calculation_method": [ + "iterative_linear", + "newton_raphson" + ], + "rtol": 1e-8, + "atol": { + "default": 1e-8, + ".+_residual": 5e-4 + }, + "extra_params": { + "iterative_linear": { + "experimental_features": "enabled", + "fail": { + "raises": "NotObservableError", + "reason": "Current sensors are not yet implemented for this calculation method" + } + }, + "newton_raphson": { + "experimental_features": "enabled", + "fail": { + "raises": "NotObservableError", + "reason": "Current sensors are not yet implemented for this calculation method" + } + } + } +} \ No newline at end of file diff --git a/tests/data/state_estimation/basic-current-sensor/params.json.license b/tests/data/state_estimation/basic-current-sensor/params.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/basic-current-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/basic-current-sensor/sym_output.json b/tests/data/state_estimation/basic-current-sensor/sym_output.json new file mode 100644 index 000000000..682b959f0 --- /dev/null +++ b/tests/data/state_estimation/basic-current-sensor/sym_output.json @@ -0,0 +1,7 @@ +{ + "version": "1.0", + "type": "sym_output", + "is_batch": false, + "attributes": {}, + "data": {} +} \ No newline at end of file diff --git a/tests/data/state_estimation/basic-current-sensor/sym_output.json.license b/tests/data/state_estimation/basic-current-sensor/sym_output.json.license new file mode 100644 index 000000000..760105916 --- /dev/null +++ b/tests/data/state_estimation/basic-current-sensor/sym_output.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/native_api_tests/test_api_model.cpp b/tests/native_api_tests/test_api_model.cpp index 05b2278cb..925d0c2e1 100644 --- a/tests/native_api_tests/test_api_model.cpp +++ b/tests/native_api_tests/test_api_model.cpp @@ -1074,7 +1074,7 @@ TEST_CASE("API Model") { {"id": 1, "u_rated": 10000}, {"id": 2, "u_rated": 10000} ], - "line": [ + "line": [ {"id": 3, "from_node": 1, "to_node": 2, "r": 0.1, "x": 0.2} ], "sym_current_sensor": [ diff --git a/tests/unit/test_0Z_model_validation.py b/tests/unit/test_0Z_model_validation.py index 74e3279ab..120113af1 100644 --- a/tests/unit/test_0Z_model_validation.py +++ b/tests/unit/test_0Z_model_validation.py @@ -72,8 +72,8 @@ def get_kwargs(sym: bool, calculation_type: str, calculation_method: str, params elif calculation_method in value: base_kwargs[key] = value[calculation_method] - for key, value in extra_kwargs.items(): - base_kwargs[key] = value + base_kwargs.update(params.get("extra_params", {}).get(calculation_method, {})) + base_kwargs.update(extra_kwargs) if calculation_method == "iec60909": base_kwargs["short_circuit_voltage_scaling"] = params["short_circuit_voltage_scaling"] From 6967bbae425da4e999a1faeab3c5ac7c84250466 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 26 Mar 2025 09:56:38 +0100 Subject: [PATCH 3/7] improve formatting Signed-off-by: Martijn Govers --- .../basic-current-sensor/input.json | 50 +++++++++---------- tests/native_api_tests/test_api_model.cpp | 13 ++++- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/tests/data/state_estimation/basic-current-sensor/input.json b/tests/data/state_estimation/basic-current-sensor/input.json index ebdcaf08c..80b42f043 100644 --- a/tests/data/state_estimation/basic-current-sensor/input.json +++ b/tests/data/state_estimation/basic-current-sensor/input.json @@ -1,27 +1,27 @@ { - "version": "1.0", - "type": "input", - "is_batch": false, - "attributes": {}, - "data": { - "node": [ - {"id": 1, "u_rated": 10000}, - {"id": 2, "u_rated": 10000} - ], - "line": [ - {"id": 3, "from_node": 1, "to_node": 2, "from_status": 1, "to_status": 1, "r1": 0.000416, "x1": 0.000136, "c1": 1e-09, "tan1": 0} - ], - "source": [ - {"id": 4, "node": 1, "status": 1, "u_ref": 1} - ], - "sym_load": [ - {"id": 5, "node": 2, "status": 1, "type": 0} - ], - "sym_voltage_sensor": [ - {"id": 6, "measured_object": 1, "u_sigma": 200, "u_measured": 10000} - ], - "sym_current_sensor": [ - {"id": 7, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} - ] - } + "version": "1.0", + "type": "input", + "is_batch": false, + "attributes": {}, + "data": { + "node": [ + {"id": 1, "u_rated": 10000}, + {"id": 2, "u_rated": 10000} + ], + "line": [ + {"id": 3, "from_node": 1, "to_node": 2, "from_status": 1, "to_status": 1, "r1": 0.000416, "x1": 0.000136, "c1": 1e-09, "tan1": 0} + ], + "source": [ + {"id": 4, "node": 1, "status": 1, "u_ref": 1} + ], + "sym_load": [ + {"id": 5, "node": 2, "status": 1, "type": 0} + ], + "sym_voltage_sensor": [ + {"id": 6, "measured_object": 1, "u_sigma": 200, "u_measured": 10000} + ], + "sym_current_sensor": [ + {"id": 7, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} + ] + } } \ No newline at end of file diff --git a/tests/native_api_tests/test_api_model.cpp b/tests/native_api_tests/test_api_model.cpp index 925d0c2e1..1227ff6a7 100644 --- a/tests/native_api_tests/test_api_model.cpp +++ b/tests/native_api_tests/test_api_model.cpp @@ -1075,10 +1075,19 @@ TEST_CASE("API Model") { {"id": 2, "u_rated": 10000} ], "line": [ - {"id": 3, "from_node": 1, "to_node": 2, "r": 0.1, "x": 0.2} + {"id": 3, "from_node": 1, "to_node": 2, "from_status": 1, "to_status": 1, "r1": 0.000416, "x1": 0.000136, "c1": 1e-09, "tan1": 0} + ], + "source": [ + {"id": 4, "node": 1, "status": 1, "u_ref": 1} + ], + "sym_load": [ + {"id": 5, "node": 2, "status": 1, "type": 0} + ], + "sym_voltage_sensor": [ + {"id": 6, "measured_object": 1, "u_sigma": 200, "u_measured": 10000} ], "sym_current_sensor": [ - {"id": 4, "measured_object": 3, "measured_terminal_type": 0} + {"id": 7, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} ] } })json"; From 9e586ca8f0e0dc3f8d4b30a6ac155fd8645a5f03 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 26 Mar 2025 09:56:38 +0100 Subject: [PATCH 4/7] improve formatting Signed-off-by: Martijn Govers --- .../basic-current-sensor/input.json | 50 +++++++++---------- tests/native_api_tests/test_api_model.cpp | 4 +- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/data/state_estimation/basic-current-sensor/input.json b/tests/data/state_estimation/basic-current-sensor/input.json index ebdcaf08c..80b42f043 100644 --- a/tests/data/state_estimation/basic-current-sensor/input.json +++ b/tests/data/state_estimation/basic-current-sensor/input.json @@ -1,27 +1,27 @@ { - "version": "1.0", - "type": "input", - "is_batch": false, - "attributes": {}, - "data": { - "node": [ - {"id": 1, "u_rated": 10000}, - {"id": 2, "u_rated": 10000} - ], - "line": [ - {"id": 3, "from_node": 1, "to_node": 2, "from_status": 1, "to_status": 1, "r1": 0.000416, "x1": 0.000136, "c1": 1e-09, "tan1": 0} - ], - "source": [ - {"id": 4, "node": 1, "status": 1, "u_ref": 1} - ], - "sym_load": [ - {"id": 5, "node": 2, "status": 1, "type": 0} - ], - "sym_voltage_sensor": [ - {"id": 6, "measured_object": 1, "u_sigma": 200, "u_measured": 10000} - ], - "sym_current_sensor": [ - {"id": 7, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} - ] - } + "version": "1.0", + "type": "input", + "is_batch": false, + "attributes": {}, + "data": { + "node": [ + {"id": 1, "u_rated": 10000}, + {"id": 2, "u_rated": 10000} + ], + "line": [ + {"id": 3, "from_node": 1, "to_node": 2, "from_status": 1, "to_status": 1, "r1": 0.000416, "x1": 0.000136, "c1": 1e-09, "tan1": 0} + ], + "source": [ + {"id": 4, "node": 1, "status": 1, "u_ref": 1} + ], + "sym_load": [ + {"id": 5, "node": 2, "status": 1, "type": 0} + ], + "sym_voltage_sensor": [ + {"id": 6, "measured_object": 1, "u_sigma": 200, "u_measured": 10000} + ], + "sym_current_sensor": [ + {"id": 7, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} + ] + } } \ No newline at end of file diff --git a/tests/native_api_tests/test_api_model.cpp b/tests/native_api_tests/test_api_model.cpp index 925d0c2e1..73e3504d2 100644 --- a/tests/native_api_tests/test_api_model.cpp +++ b/tests/native_api_tests/test_api_model.cpp @@ -1075,10 +1075,10 @@ TEST_CASE("API Model") { {"id": 2, "u_rated": 10000} ], "line": [ - {"id": 3, "from_node": 1, "to_node": 2, "r": 0.1, "x": 0.2} + {"id": 3, "from_node": 1, "to_node": 2, "from_status": 0, "to_status": 0, "r1": 0.000416, "x1": 0.000136, "c1": 1e-09, "tan1": 0} ], "sym_current_sensor": [ - {"id": 4, "measured_object": 3, "measured_terminal_type": 0} + {"id": 7, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} ] } })json"; From 24241ed4689197b36a1dceea13ef425143548c5e Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 26 Mar 2025 11:38:56 +0100 Subject: [PATCH 5/7] fix missing register component to topology Signed-off-by: Martijn Govers --- .../include/power_grid_model/main_model_impl.hpp | 1 + tests/native_api_tests/test_api_model.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp index b636337ec..738c752db 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_model_impl.hpp @@ -333,6 +333,7 @@ class MainModelImpl, ComponentLis main_core::register_topology_components(state_, comp_topo); main_core::register_topology_components(state_, comp_topo); main_core::register_topology_components(state_, comp_topo); + main_core::register_topology_components(state_, comp_topo); main_core::register_topology_components(state_, comp_topo); state_.comp_topo = std::make_shared(std::move(comp_topo)); } diff --git a/tests/native_api_tests/test_api_model.cpp b/tests/native_api_tests/test_api_model.cpp index 73e3504d2..352d20324 100644 --- a/tests/native_api_tests/test_api_model.cpp +++ b/tests/native_api_tests/test_api_model.cpp @@ -1078,7 +1078,7 @@ TEST_CASE("API Model") { {"id": 3, "from_node": 1, "to_node": 2, "from_status": 0, "to_status": 0, "r1": 0.000416, "x1": 0.000136, "c1": 1e-09, "tan1": 0} ], "sym_current_sensor": [ - {"id": 7, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} + {"id": 4, "measured_object": 3, "measured_terminal_type": 0, "angle_measurement_type": 0, "i_sigma": 1, "i_angle_sigma": 0.05, "i_measured": 10, "i_angle_measured": 0.3} ] } })json"; From f2b6e0ec8808da80275de0d47be808d65149a648 Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Wed, 26 Mar 2025 12:09:51 +0100 Subject: [PATCH 6/7] sonar cloud Signed-off-by: Martijn Govers --- .../include/power_grid_model/main_core/input.hpp | 7 ++++--- tests/native_api_tests/test_api_model.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp index a8c96588b..0f85d110e 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp @@ -109,17 +109,18 @@ inline void add_component(MainModelState& state, ForwardIter measured_terminal_type = input.measured_terminal_type] { switch (measured_terminal_type) { using enum MeasuredTerminalType; + using enum Branch3Side; case branch_from: return get_component(state, measured_object).node(BranchSide::from); case branch_to: return get_component(state, measured_object).node(BranchSide::to); case branch3_1: - return get_component(state, measured_object).node(Branch3Side::side_1); + return get_component(state, measured_object).node(side_1); case branch3_2: - return get_component(state, measured_object).node(Branch3Side::side_2); + return get_component(state, measured_object).node(side_2); case branch3_3: - return get_component(state, measured_object).node(Branch3Side::side_2); + return get_component(state, measured_object).node(side_2); default: throw MissingCaseForEnumError{std::format("{} item retrieval", GenericCurrentSensor::name), measured_terminal_type}; diff --git a/tests/native_api_tests/test_api_model.cpp b/tests/native_api_tests/test_api_model.cpp index 352d20324..2265b05bd 100644 --- a/tests/native_api_tests/test_api_model.cpp +++ b/tests/native_api_tests/test_api_model.cpp @@ -1088,13 +1088,13 @@ TEST_CASE("API Model") { auto const run_se_with_current_sensor = [&input_dataset_se](PGM_CalculationMethod method, PGM_ExperimentalFeatures experimental_features) { - Model model{50.0, input_dataset_se}; - Options options{}; - options.set_calculation_type(PGM_state_estimation); - options.set_calculation_method(method); - options.set_experimental_features(experimental_features); + Model model_with_current_sensor{50.0, input_dataset_se}; + Options experimental_options{}; + experimental_options.set_calculation_type(PGM_state_estimation); + experimental_options.set_calculation_method(method); + experimental_options.set_experimental_features(experimental_features); DatasetMutable const output_dataset{"sym_output", false, 1}; - model.calculate(options, output_dataset); + model_with_current_sensor.calculate(experimental_options, output_dataset); }; for (auto const method : {PGM_default_method, PGM_iterative_linear, PGM_newton_raphson}) { CAPTURE(method); From 02829188e0284f561d548d96dad66e5d180866de Mon Sep 17 00:00:00 2001 From: Martijn Govers Date: Tue, 1 Apr 2025 15:12:30 +0200 Subject: [PATCH 7/7] resolve some comments Signed-off-by: Martijn Govers --- .../include/power_grid_model/main_core/input.hpp | 4 ++++ .../include/power_grid_model/main_core/output.hpp | 8 +++++--- .../include/power_grid_model/main_core/topology.hpp | 5 +++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp index 0f85d110e..5102125cb 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/input.hpp @@ -74,7 +74,9 @@ inline void add_component(MainModelState& state, ForwardIter get_component(state, measured_object); break; case branch3_1: + [[fallthrough]]; case branch3_2: + [[fallthrough]]; case branch3_3: get_component(state, measured_object); break; @@ -156,7 +158,9 @@ inline void add_component(MainModelState& state, ForwardIter auto const& regulated_object = get_component(state, regulated_object_idx); switch (input.control_side) { case side_1: + [[fallthrough]]; case side_2: + [[fallthrough]]; case side_3: return regulated_object.node(static_cast(input.control_side)); default: diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp index 34b96e23c..58a37295b 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp @@ -276,7 +276,7 @@ constexpr auto output_result(Component const& power_or_current_sensor, MainModel case node: return state.topo_comp_coup->node[obj_seq]; default: - throw MissingCaseForEnumError(std::string(GenericPowerSensor::name) + " output_result()", terminal_type); + throw MissingCaseForEnumError{std::format("{} output_result()", Component::name), terminal_type}; } }(); @@ -289,8 +289,11 @@ constexpr auto output_result(Component const& power_or_current_sensor, MainModel case branch_from: // all power sensors in branch3 are at from side in the mathematical model + [[fallthrough]]; case branch3_1: + [[fallthrough]]; case branch3_2: + [[fallthrough]]; case branch3_3: return power_or_current_sensor.template get_output( solver_output[obj_math_id.group].branch[obj_math_id.pos].s_f); @@ -312,7 +315,7 @@ constexpr auto output_result(Component const& power_or_current_sensor, MainModel return power_or_current_sensor.template get_output( solver_output[obj_math_id.group].bus_injection[obj_math_id.pos]); default: - throw MissingCaseForEnumError(std::string(GenericPowerSensor::name) + " output_result()", terminal_type); + throw MissingCaseForEnumError{std::format("{} output_result()", Component::name), terminal_type}; } } template const& state, res_it = output_result(state, math_output, res_it); return res_it; } - } // namespace power_grid_model::main_core diff --git a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp index edcd76152..745e5f1dc 100644 --- a/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp +++ b/power_grid_model_c/power_grid_model/include/power_grid_model/main_core/topology.hpp @@ -120,7 +120,9 @@ constexpr void register_topology_components(MainModelState c case generator: return get_component_sequence_idx(state, measured_object); case branch3_1: + [[fallthrough]]; case branch3_2: + [[fallthrough]]; case branch3_3: return get_component_sequence_idx(state, measured_object); case node: @@ -148,10 +150,13 @@ constexpr void register_topology_components(MainModelState c switch (current_sensor.get_terminal_type()) { case branch_from: + [[fallthrough]]; case branch_to: return get_component_sequence_idx(state, measured_object); case branch3_1: + [[fallthrough]]; case branch3_2: + [[fallthrough]]; case branch3_3: return get_component_sequence_idx(state, measured_object); default: