Skip to content

Commit eef1fd4

Browse files
committed
resolve some comments
Signed-off-by: Santiago Figueroa Manrique <figueroa1395@gmail.com>
1 parent 2db3fad commit eef1fd4

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/all_components.hpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,4 @@ using AllComponents =
3131
ComponentList<Node, Line, Link, GenericBranch, Transformer, ThreeWindingTransformer, Shunt, Source, SymGenerator,
3232
AsymGenerator, SymLoad, AsymLoad, SymPowerSensor, AsymPowerSensor, SymVoltageSensor,
3333
AsymVoltageSensor, SymCurrentSensor, AsymCurrentSensor, Fault, TransformerTapRegulator>;
34-
35-
template <typename T>
36-
concept power_or_current_sensor_c =
37-
std::derived_from<T, GenericPowerSensor> || std::derived_from<T, GenericCurrentSensor>;
38-
39-
static_assert(power_or_current_sensor_c<SymPowerSensor>);
40-
static_assert(power_or_current_sensor_c<AsymPowerSensor>);
41-
static_assert(power_or_current_sensor_c<SymCurrentSensor>);
42-
static_assert(power_or_current_sensor_c<AsymCurrentSensor>);
43-
static_assert(!power_or_current_sensor_c<SymVoltageSensor>);
44-
static_assert(!power_or_current_sensor_c<AsymVoltageSensor>);
45-
4634
} // namespace power_grid_model

power_grid_model_c/power_grid_model/include/power_grid_model/component/current_sensor.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ template <symmetry_tag current_sensor_symmetry_> class CurrentSensor : public Ge
156156
output.energized = 1; // current sensor is always energized
157157
auto i_output = i;
158158
auto const i_calc_param = calc_param<sym_calc>();
159-
auto const& angle_measurement_type = i_calc_param.angle_measurement_type;
160-
auto const& i_measured_complex = i_calc_param.measurement.value();
159+
auto const angle_measurement_type = i_calc_param.angle_measurement_type;
160+
auto const i_measured_complex = i_calc_param.measurement.value();
161161
if (angle_measurement_type == AngleMeasurementType::local_angle) {
162162
// I_l = conj(I_g) * exp(i * u_angle)
163163
// Tranform back the output angle to the local angle frame of reference

power_grid_model_c/power_grid_model/include/power_grid_model/main_core/output.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ constexpr auto output_result(Component const& power_sensor, MainModelState<Compo
312312
throw MissingCaseForEnumError{std::format("{} output_result()", Component::name), terminal_type};
313313
}
314314
}
315+
template <std::derived_from<GenericPowerSensor> Component, class ComponentContainer,
316+
short_circuit_solver_output_type SolverOutputType>
317+
requires model_component_state_c<MainModelState, ComponentContainer, Component>
318+
constexpr auto output_result(Component const& power_or_current_sensor,
319+
MainModelState<ComponentContainer> const& /* state */,
320+
std::vector<SolverOutputType> const& /* solver_output */, Idx const /* obj_seq */) {
321+
return power_or_current_sensor.get_null_sc_output();
322+
}
315323

316324
// output current sensor
317325
template <std::derived_from<GenericCurrentSensor> Component, class ComponentContainer,
@@ -371,7 +379,7 @@ constexpr auto output_result(Component const& current_sensor, MainModelState<Com
371379
throw MissingCaseForEnumError{std::format("{} output_result()", Component::name), terminal_type};
372380
}
373381
}
374-
template <power_or_current_sensor_c Component, class ComponentContainer,
382+
template <std::derived_from<GenericCurrentSensor> Component, class ComponentContainer,
375383
short_circuit_solver_output_type SolverOutputType>
376384
requires model_component_state_c<MainModelState, ComponentContainer, Component>
377385
constexpr auto output_result(Component const& power_or_current_sensor,

tests/cpp_unit_tests/test_current_sensor.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@ TEST_CASE("Test current sensor") {
8686
sym_current_sensor.get_output<asymmetric_t>(conj(i_asym_local), ComplexValue<asymmetric_t>{1.0});
8787

8888
// Check symmetric sensor output for symmetric parameters
89-
if (angle_measurement_type == AngleMeasurementType::global_angle) {
90-
CHECK(sym_sensor_param.angle_measurement_type == AngleMeasurementType::global_angle);
91-
} else {
92-
CHECK(sym_sensor_param.angle_measurement_type == AngleMeasurementType::local_angle);
93-
}
89+
CHECK(sym_sensor_param.angle_measurement_type == angle_measurement_type);
90+
9491
// Var(I_Re) ≈ Var(I) * cos^2(pi/4) + Var(θ) * I^2 * sin^2(pi/4)
9592
CHECK(sym_sensor_param.measurement.real_component.variance ==
9693
doctest::Approx(0.5 * (i_variance_pu + i_angle_variance_pu * i_pu * i_pu)));
@@ -135,11 +132,7 @@ TEST_CASE("Test current sensor") {
135132
}
136133

137134
CHECK(sym_current_sensor.get_terminal_type() == terminal_type);
138-
if (angle_measurement_type == AngleMeasurementType::global_angle) {
139-
CHECK(sym_current_sensor.get_angle_measurement_type() == AngleMeasurementType::global_angle);
140-
} else {
141-
CHECK(sym_current_sensor.get_angle_measurement_type() == AngleMeasurementType::local_angle);
142-
}
135+
CHECK(sym_current_sensor.get_angle_measurement_type() == angle_measurement_type);
143136
}
144137
}
145138
SUBCASE("Wrong measured terminal type") {

0 commit comments

Comments
 (0)