Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

current sensor skeleton #861

Merged
merged 43 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
66ce29b
angle measurement type enum
petersalemink95 Dec 24, 2024
411f160
current sensor input
petersalemink95 Dec 24, 2024
51c972d
current sensor update
petersalemink95 Dec 24, 2024
8480a5f
current sensor output
petersalemink95 Dec 24, 2024
8dc4374
current sensor file with license
petersalemink95 Dec 24, 2024
5c09d74
add measured terminal type to input
petersalemink95 Dec 24, 2024
083b2bf
generic current sensor + empty test file
petersalemink95 Dec 24, 2024
2c71a55
disable mypy call-overload
petersalemink95 Dec 24, 2024
a0609c7
change sigma
petersalemink95 Dec 24, 2024
b464409
CurrentSensorCalcParam
petersalemink95 Dec 30, 2024
ca09197
CurrentSensor template
petersalemink95 Dec 30, 2024
7c32e89
Revert "change sigma"
petersalemink95 Dec 30, 2024
dade513
i_angle_sigma in constructor
petersalemink95 Dec 30, 2024
235c14e
calculate + use base_current
petersalemink95 Dec 30, 2024
901107d
i angle sigma without division
petersalemink95 Dec 31, 2024
8a30ac7
use scalar
petersalemink95 Dec 31, 2024
5983d7f
add dummy variables for passing build
petersalemink95 Dec 31, 2024
5db6375
DCO Remediation Commit for petersalemink95 <peter.salemink95@gmail.com>
petersalemink95 Dec 31, 2024
768037e
calc param with separate i and i_angle variance
petersalemink95 Dec 31, 2024
48656f6
first tests - temp save
petersalemink95 Dec 31, 2024
513ce1e
unused vairables
petersalemink95 Dec 31, 2024
812f018
passing tests
petersalemink95 Dec 31, 2024
d1fbb47
fill update function
petersalemink95 Jan 2, 2025
d9c5ab2
implement inverse + test sym inverse
petersalemink95 Jan 2, 2025
19ca13f
fix scalars
petersalemink95 Jan 2, 2025
b1ca230
test asym inverse
petersalemink95 Jan 2, 2025
285f5f6
move comment
petersalemink95 Jan 2, 2025
fa2e628
Merge branch 'main' into feature/current-sensor-skeleton
petersalemink95 Jan 2, 2025
31b3451
Merge branch 'main' into feature/current-sensor-skeleton
TonyXiang8787 Jan 2, 2025
87fb7c1
double variances
petersalemink95 Jan 3, 2025
30267eb
merge
petersalemink95 Jan 3, 2025
4885381
add angle measurement type to calc param
petersalemink95 Jan 3, 2025
ac3511e
use inv_sqrt3
petersalemink95 Jan 7, 2025
e0eb9e4
Merge branch 'main' into feature/current-sensor-skeleton
petersalemink95 Jan 7, 2025
da8c0ce
remove convert_direction + test only branch
petersalemink95 Jan 7, 2025
3691a73
only accept branches
petersalemink95 Jan 7, 2025
f30dd34
single base_current_
petersalemink95 Jan 8, 2025
00ab5e5
update switch statement
petersalemink95 Jan 8, 2025
c250f3b
fix indent
petersalemink95 Jan 8, 2025
87b323f
update calc_param
petersalemink95 Jan 8, 2025
dc5310a
use scalar
petersalemink95 Jan 8, 2025
1d149ac
base_current_inv_
petersalemink95 Jan 8, 2025
4ae0b48
Merge branch 'main' into feature/current-sensor-skeleton
petersalemink95 Jan 9, 2025
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
39 changes: 39 additions & 0 deletions code_generation/data/attribute_classes/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,45 @@
"description": "line drop compensation reactance"
}
]
},
{
"name": "GenericCurrentSensorInput",
"base": "SensorInput",
"attributes": [
{
"data_type": "MeasuredTerminalType",
"names": "measured_terminal_type",
"description": "type of measured terminal"
},
{
"data_type": "AngleMeasurementType",
"names": "angle_measurement_type",
"description": "type of angle measurement"
},
{
"data_type": "double",
"names": [
"i_sigma",
"i_angle_sigma"
petersalemink95 marked this conversation as resolved.
Show resolved Hide resolved
],
"description": "sigma of error margin of current (angle) measurement"
}
]
},
{
"name": "CurrentSensorInput",
"base": "GenericCurrentSensorInput",
"is_template": true,
"attributes": [
{
"data_type": "RealValue<sym>",
"names": [
"i_measured",
"i_angle_measured"
],
"description": "measured current and current angle"
}
]
}
]
}
15 changes: 15 additions & 0 deletions code_generation/data/attribute_classes/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,21 @@
"base": "BaseOutput",
"is_template": false,
"attributes": []
},
{
"name": "CurrentSensorOutput",
"base": "BaseOutput",
petersalemink95 marked this conversation as resolved.
Show resolved Hide resolved
"is_template": true,
"attributes": [
{
"data_type": "RealValue<sym>",
"names": [
"i_residual",
"i_angle_residual"
],
"description": "deviation between the measured value and calculated value"
}
]
}
]
}
23 changes: 23 additions & 0 deletions code_generation/data/attribute_classes/update.json
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,29 @@
"description": "line drop compensation reactance"
}
]
},
{
"name": "CurrentSensorUpdate",
"base": "BaseUpdate",
"is_template": true,
"attributes": [
{
"data_type": "double",
"names": [
"i_sigma",
"i_angle_sigma"
],
"description": "sigma of error margin of current (angle) measurement"
},
{
"data_type": "RealValue<sym>",
"names": [
"i_measured",
"i_angle_measured"
],
"description": "measured current and current angle"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,52 @@ struct TransformerTapRegulatorInput {
operator RegulatorInput const&() const { return reinterpret_cast<RegulatorInput const&>(*this); }
};

struct GenericCurrentSensorInput {
ID id{na_IntID}; // ID of the object
ID measured_object{na_IntID}; // ID of the measured object
MeasuredTerminalType measured_terminal_type{static_cast<MeasuredTerminalType>(na_IntS)}; // type of measured terminal
AngleMeasurementType angle_measurement_type{static_cast<AngleMeasurementType>(na_IntS)}; // type of angle measurement
double i_sigma{nan}; // sigma of error margin of current (angle) measurement
double i_angle_sigma{nan}; // sigma of error margin of current (angle) measurement

// implicit conversions to BaseInput
operator BaseInput&() { return reinterpret_cast<BaseInput&>(*this); }
operator BaseInput const&() const { return reinterpret_cast<BaseInput const&>(*this); }

// implicit conversions to SensorInput
operator SensorInput&() { return reinterpret_cast<SensorInput&>(*this); }
operator SensorInput const&() const { return reinterpret_cast<SensorInput const&>(*this); }
};

template <symmetry_tag sym_type>
struct CurrentSensorInput {
using sym = sym_type;

ID id{na_IntID}; // ID of the object
ID measured_object{na_IntID}; // ID of the measured object
MeasuredTerminalType measured_terminal_type{static_cast<MeasuredTerminalType>(na_IntS)}; // type of measured terminal
AngleMeasurementType angle_measurement_type{static_cast<AngleMeasurementType>(na_IntS)}; // type of angle measurement
double i_sigma{nan}; // sigma of error margin of current (angle) measurement
double i_angle_sigma{nan}; // sigma of error margin of current (angle) measurement
RealValue<sym> i_measured{nan}; // measured current and current angle
RealValue<sym> i_angle_measured{nan}; // measured current and current angle

// implicit conversions to BaseInput
operator BaseInput&() { return reinterpret_cast<BaseInput&>(*this); }
operator BaseInput const&() const { return reinterpret_cast<BaseInput const&>(*this); }

// implicit conversions to SensorInput
operator SensorInput&() { return reinterpret_cast<SensorInput&>(*this); }
operator SensorInput const&() const { return reinterpret_cast<SensorInput const&>(*this); }

// implicit conversions to GenericCurrentSensorInput
operator GenericCurrentSensorInput&() { return reinterpret_cast<GenericCurrentSensorInput&>(*this); }
operator GenericCurrentSensorInput const&() const { return reinterpret_cast<GenericCurrentSensorInput const&>(*this); }
};

using SymCurrentSensorInput = CurrentSensorInput<symmetric_t>;
using AsymCurrentSensorInput = CurrentSensorInput<asymmetric_t>;



} // namespace power_grid_model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,38 @@ struct get_attributes_list<TransformerTapRegulatorInput> {
};
};

template<>
struct get_attributes_list<GenericCurrentSensorInput> {
static constexpr std::array<MetaAttribute, 6> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::id>(offsetof(GenericCurrentSensorInput, id), "id"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::measured_object>(offsetof(GenericCurrentSensorInput, measured_object), "measured_object"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::measured_terminal_type>(offsetof(GenericCurrentSensorInput, measured_terminal_type), "measured_terminal_type"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::angle_measurement_type>(offsetof(GenericCurrentSensorInput, angle_measurement_type), "angle_measurement_type"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::i_sigma>(offsetof(GenericCurrentSensorInput, i_sigma), "i_sigma"),
meta_data_gen::get_meta_attribute<&GenericCurrentSensorInput::i_angle_sigma>(offsetof(GenericCurrentSensorInput, i_angle_sigma), "i_angle_sigma"),
};
};

template <symmetry_tag sym_type>
struct get_attributes_list<CurrentSensorInput<sym_type>> {
using sym = sym_type;

static constexpr std::array<MetaAttribute, 8> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::id>(offsetof(CurrentSensorInput<sym>, id), "id"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::measured_object>(offsetof(CurrentSensorInput<sym>, measured_object), "measured_object"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::measured_terminal_type>(offsetof(CurrentSensorInput<sym>, measured_terminal_type), "measured_terminal_type"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::angle_measurement_type>(offsetof(CurrentSensorInput<sym>, angle_measurement_type), "angle_measurement_type"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_sigma>(offsetof(CurrentSensorInput<sym>, i_sigma), "i_sigma"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_angle_sigma>(offsetof(CurrentSensorInput<sym>, i_angle_sigma), "i_angle_sigma"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_measured>(offsetof(CurrentSensorInput<sym>, i_measured), "i_measured"),
meta_data_gen::get_meta_attribute<&CurrentSensorInput<sym>::i_angle_measured>(offsetof(CurrentSensorInput<sym>, i_angle_measured), "i_angle_measured"),
};
};




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,20 @@ struct get_attributes_list<RegulatorShortCircuitOutput> {
};
};

template <symmetry_tag sym_type>
struct get_attributes_list<CurrentSensorOutput<sym_type>> {
using sym = sym_type;

static constexpr std::array<MetaAttribute, 4> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::id>(offsetof(CurrentSensorOutput<sym>, id), "id"),
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::energized>(offsetof(CurrentSensorOutput<sym>, energized), "energized"),
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::i_residual>(offsetof(CurrentSensorOutput<sym>, i_residual), "i_residual"),
meta_data_gen::get_meta_attribute<&CurrentSensorOutput<sym>::i_angle_residual>(offsetof(CurrentSensorOutput<sym>, i_angle_residual), "i_angle_residual"),
};
};




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,21 @@ struct get_attributes_list<TransformerTapRegulatorUpdate> {
};
};

template <symmetry_tag sym_type>
struct get_attributes_list<CurrentSensorUpdate<sym_type>> {
using sym = sym_type;

static constexpr std::array<MetaAttribute, 5> value{
// all attributes including base class

meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::id>(offsetof(CurrentSensorUpdate<sym>, id), "id"),
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_sigma>(offsetof(CurrentSensorUpdate<sym>, i_sigma), "i_sigma"),
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_angle_sigma>(offsetof(CurrentSensorUpdate<sym>, i_angle_sigma), "i_angle_sigma"),
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_measured>(offsetof(CurrentSensorUpdate<sym>, i_measured), "i_measured"),
meta_data_gen::get_meta_attribute<&CurrentSensorUpdate<sym>::i_angle_measured>(offsetof(CurrentSensorUpdate<sym>, i_angle_measured), "i_angle_measured"),
};
};




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,23 @@ struct RegulatorShortCircuitOutput {
operator BaseOutput const&() const { return reinterpret_cast<BaseOutput const&>(*this); }
};

template <symmetry_tag sym_type>
struct CurrentSensorOutput {
using sym = sym_type;

ID id{na_IntID}; // ID of the object
IntS energized{na_IntS}; // whether the object is energized
RealValue<sym> i_residual{nan}; // deviation between the measured value and calculated value
RealValue<sym> i_angle_residual{nan}; // deviation between the measured value and calculated value

// implicit conversions to BaseOutput
operator BaseOutput&() { return reinterpret_cast<BaseOutput&>(*this); }
operator BaseOutput const&() const { return reinterpret_cast<BaseOutput const&>(*this); }
};

using SymCurrentSensorOutput = CurrentSensorOutput<symmetric_t>;
using AsymCurrentSensorOutput = CurrentSensorOutput<asymmetric_t>;



} // namespace power_grid_model
Expand Down
Loading
Loading