Skip to content

Commit

Permalink
CurrentSensor template
Browse files Browse the repository at this point in the history
Signed-off-by: petersalemink95 <peter.salemink95@gmail.com>
  • Loading branch information
petersalemink95 committed Dec 30, 2024
1 parent b464409 commit ca09197
Showing 1 changed file with 72 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

#include "sensor.hpp"

#include "../calculation_parameters.hpp"
#include "../common/common.hpp"
#include "../common/enum.hpp"

namespace power_grid_model {

class GenericCurrentSensor : public Sensor {
Expand Down Expand Up @@ -58,11 +62,75 @@ class GenericCurrentSensor : public Sensor {

// virtual function getter for sym and asym param
// override them in real sensors function
virtual PowerSensorCalcParam<symmetric_t> sym_calc_param() const = 0;
virtual PowerSensorCalcParam<asymmetric_t> asym_calc_param() const = 0;
virtual CurrentSensorCalcParam<symmetric_t> sym_calc_param() const = 0;
virtual CurrentSensorCalcParam<asymmetric_t> asym_calc_param() const = 0;

virtual CurrentSensorOutput<symmetric_t> get_sym_output(ComplexValue<symmetric_t> const& i) const = 0;
virtual CurrentSensorOutput<asymmetric_t> get_asym_output(ComplexValue<asymmetric_t> const& i) const = 0;
};

template <symmetry_tag current_sensor_symmetry_> class CurrentSensor : public GenericCurrentSensor {
public:
using current_sensor_symmetry = current_sensor_symmetry_;

static constexpr char const* name =
is_symmetric_v<current_sensor_symmetry> ? "sym_current_sensor" : "asym_current_sensor";
using InputType = CurrentSensorInput<current_sensor_symmetry>;
using UpdateType = CurrentSensorUpdate<current_sensor_symmetry>;
template <symmetry_tag sym_calc> using OutputType = CurrentSensorOutput<sym_calc>;

// TODO: add u_rated to calculate base_current = base_power_3p / u_rated / sqrt3
explicit CurrentSensor(CurrentSensorInput<current_sensor_symmetry> const& current_sensor_input)
: GenericCurrentSensor{current_sensor_input},
i_sigma_{current_sensor_input.i_sigma / base_power<current_sensor_symmetry>},
i_angle_measured_{current_sensor_input.i_angle_measured} {
set_current(current_sensor_input.i_measured);
};

UpdateChange update(CurrentSensorUpdate<current_sensor_symmetry> const& update_data) {
// TODO
return {false, false};
}

PowerSensorUpdate<current_sensor_symmetry> inverse(PowerSensorUpdate<current_sensor_symmetry> update_data) const {
// TODO

return update_data;
}

private:
ComplexValue<current_sensor_symmetry> i_measured_{};
RealValue<current_sensor_symmetry> i_angle_measured_{};
double i_sigma_{};

virtual PowerSensorOutput<symmetric_t> get_sym_output(ComplexValue<symmetric_t> const& i) const = 0;
virtual PowerSensorOutput<asymmetric_t> get_asym_output(ComplexValue<asymmetric_t> const& i) const = 0;
void set_current(RealValue<current_sensor_symmetry> const& i_measured) {
// TODO
}

CurrentSensorCalcParam<symmetric_t> sym_calc_param() const final {
CurrentSensorCalcParam<symmetric_t> calc_param{};
// TODO
return calc_param;
}
CurrentSensorCalcParam<asymmetric_t> asym_calc_param() const final {
CurrentSensorCalcParam<asymmetric_t> calc_param{};
// TODO
return calc_param;
}
CurrentSensorOutput<symmetric_t> get_sym_output(ComplexValue<symmetric_t> const& i) const final {
return get_generic_output<symmetric_t>(i);
}
CurrentSensorOutput<asymmetric_t> get_asym_output(ComplexValue<asymmetric_t> const& i) const final {
return get_generic_output<asymmetric_t>(i);
}
template <symmetry_tag sym_calc>
CurrentSensorOutput<sym_calc> get_generic_output(ComplexValue<sym_calc> const& i) const {
CurrentSensorOutput<sym_calc> output{};
return output;
}
};

using SymCurrentSensor = CurrentSensor<symmetric_t>;
using AsymCurrentSensor = CurrentSensor<asymmetric_t>;

} // namespace power_grid_model

0 comments on commit ca09197

Please sign in to comment.