Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
97cd5b3
license
petersalemink95 Mar 7, 2024
d8e1863
tap regulator input
petersalemink95 Mar 7, 2024
b9413fb
control side
petersalemink95 Mar 7, 2024
d8bc646
constructor + empty test
petersalemink95 Mar 13, 2024
240373c
ControlSide enum
petersalemink95 Mar 14, 2024
b9c55c8
transformer regulator update struct
petersalemink95 Mar 14, 2024
99c67ef
output struct + update update
petersalemink95 Mar 14, 2024
fd152c5
reach_limit is not needed
petersalemink95 Mar 15, 2024
ebd7c7b
update function
petersalemink95 Mar 15, 2024
1c39f96
get_output
petersalemink95 Mar 15, 2024
1ec949d
transformer tap regulator param
petersalemink95 Mar 15, 2024
9390e48
calc_param
petersalemink95 Mar 18, 2024
7e02cce
update component type enum
petersalemink95 Mar 19, 2024
19294a5
u_rated + beginning test
petersalemink95 Mar 19, 2024
a74ad90
(generic) regulator class
petersalemink95 Mar 19, 2024
f47576b
test energized
petersalemink95 Mar 19, 2024
b26d172
complete tests
petersalemink95 Mar 20, 2024
d2bdc2e
Merge branch 'main' into feature/regulator-class
petersalemink95 Mar 20, 2024
099b3fe
input json
petersalemink95 Mar 21, 2024
5a71392
update json
petersalemink95 Mar 21, 2024
b0ec7e8
output json
petersalemink95 Mar 21, 2024
998c1fe
use code gen
petersalemink95 Mar 21, 2024
0ac9bbc
fix some errors
petersalemink95 Mar 21, 2024
232a88c
code up and running again after updates
petersalemink95 Mar 21, 2024
a98a454
Merge branch 'main' into feature/regulator-class
petersalemink95 Mar 21, 2024
a6f2cc9
add const where possible
petersalemink95 Mar 21, 2024
2251d3e
updated input and update classes
petersalemink95 Mar 22, 2024
9e0d1ca
inverse update
petersalemink95 Mar 22, 2024
127f6f8
SC output type
petersalemink95 Mar 22, 2024
c30699a
general sc output
petersalemink95 Mar 22, 2024
926b5fe
fix build
petersalemink95 Mar 22, 2024
8ef7c80
fix some errors
petersalemink95 Mar 22, 2024
40aa49a
static_cast
petersalemink95 Mar 22, 2024
dd0224a
Merge remote-tracking branch 'origin/main' into feature/regulator-class
mgovers Mar 25, 2024
5ac5dba
add test tap regulator update inverse + fix typo
mgovers Mar 25, 2024
309a6a2
make gcc happy
mgovers Mar 25, 2024
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
47 changes: 47 additions & 0 deletions code_generation/data/attribute_classes/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,53 @@
"description": "short circuit impedance"
}
]
},
{
"name": "RegulatorInput",
"base": "BaseInput",
"attributes": [
{
"data_type": "ID",
"names": "regulated_object",
"description": "ID of the regulated object"
},
{
"data_type": "IntS",
"names": "status",
"description": "regulator enabled"
}
]
},
{
"name": "TransformerTapRegulatorInput",
"base": "RegulatorInput",
"attributes": [
{
"data_type": "ControlSide",
"names": "control_side",
"description": "control side of the (three winding) transformer"
},
{
"data_type": "double",
"names": "u_set",
"description": "voltage setpoint"
},
{
"data_type": "double",
"names": "u_band",
"description": "voltage bandwidth"
},
{
"data_type": "double",
"names": "line_drop_compensation_r",
"description": "line drop compensation resistance"
},
{
"data_type": "double",
"names": "line_drop_compensation_x",
"description": "line drop compensation reactance"
}
]
}
]
}
18 changes: 18 additions & 0 deletions code_generation/data/attribute_classes/output.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,24 @@
"base": "BaseOutput",
"is_template": false,
"attributes": []
},
{
"name": "TransformerTapRegulatorOutput",
"base": "BaseOutput",
"is_template": false,
"attributes": [
{
"data_type": "IntS",
"names": "tap_pos",
"description": "result of regulated tap position"
}
]
},
{
"name": "RegulatorShortCircuitOutput",
"base": "BaseOutput",
"is_template": false,
"attributes": []
}
]
}
37 changes: 37 additions & 0 deletions code_generation/data/attribute_classes/update.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,43 @@
"description": "short circuit impedance"
}
]
},
{
"name": "RegulatorUpdate",
"base": "BaseUpdate",
"attributes": [
{
"data_type": "IntS",
"names": "status",
"description": "regulator enables"
}
]
},
{
"name": "TransformerTapRegulatorUpdate",
"base": "RegulatorUpdate",
"attributes": [
{
"data_type": "double",
"names": "u_set",
"description": "voltage setpoint"
},
{
"data_type": "double",
"names": "u_band",
"description": "voltage bandwidth"
},
{
"data_type": "double",
"names": "line_drop_compensation_r",
"description": "line drop compensation resistance"
},
{
"data_type": "double",
"names": "line_drop_compensation_x",
"description": "line drop compensation reactance"
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
#include "component/source.hpp"
#include "component/three_winding_transformer.hpp"
#include "component/transformer.hpp"
#include "component/transformer_tap_regulator.hpp"
#include "component/voltage_sensor.hpp"

namespace power_grid_model {

using AllComponents =
ComponentList<Node, Line, Link, Transformer, ThreeWindingTransformer, Shunt, Source, SymGenerator, AsymGenerator,
SymLoad, AsymLoad, SymPowerSensor, AsymPowerSensor, SymVoltageSensor, AsymVoltageSensor, Fault>;
using AllComponents = ComponentList<Node, Line, Link, Transformer, ThreeWindingTransformer, Shunt, Source, SymGenerator,
AsymGenerator, SymLoad, AsymLoad, SymPowerSensor, AsymPowerSensor, SymVoltageSensor,
AsymVoltageSensor, Fault, TransformerTapRegulator>;

} // namespace power_grid_model
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,35 @@ struct FaultInput {
operator BaseInput const&() const { return reinterpret_cast<BaseInput const&>(*this); }
};

struct RegulatorInput {
ID id; // ID of the object
ID regulated_object; // ID of the regulated object
IntS status; // regulator enabled

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

struct TransformerTapRegulatorInput {
ID id; // ID of the object
ID regulated_object; // ID of the regulated object
IntS status; // regulator enabled
ControlSide control_side; // control side of the (three winding) transformer
double u_set; // voltage setpoint
double u_band; // voltage bandwidth
double line_drop_compensation_r; // line drop compensation resistance
double line_drop_compensation_x; // line drop compensation reactance

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

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



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

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

meta_data_gen::get_meta_attribute<RegulatorInput, &RegulatorInput::id, offsetof(RegulatorInput, id), []{ return "id"; }>::value,
meta_data_gen::get_meta_attribute<RegulatorInput, &RegulatorInput::regulated_object, offsetof(RegulatorInput, regulated_object), []{ return "regulated_object"; }>::value,
meta_data_gen::get_meta_attribute<RegulatorInput, &RegulatorInput::status, offsetof(RegulatorInput, status), []{ return "status"; }>::value,
};
};

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

meta_data_gen::get_meta_attribute<TransformerTapRegulatorInput, &TransformerTapRegulatorInput::id, offsetof(TransformerTapRegulatorInput, id), []{ return "id"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorInput, &TransformerTapRegulatorInput::regulated_object, offsetof(TransformerTapRegulatorInput, regulated_object), []{ return "regulated_object"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorInput, &TransformerTapRegulatorInput::status, offsetof(TransformerTapRegulatorInput, status), []{ return "status"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorInput, &TransformerTapRegulatorInput::control_side, offsetof(TransformerTapRegulatorInput, control_side), []{ return "control_side"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorInput, &TransformerTapRegulatorInput::u_set, offsetof(TransformerTapRegulatorInput, u_set), []{ return "u_set"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorInput, &TransformerTapRegulatorInput::u_band, offsetof(TransformerTapRegulatorInput, u_band), []{ return "u_band"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorInput, &TransformerTapRegulatorInput::line_drop_compensation_r, offsetof(TransformerTapRegulatorInput, line_drop_compensation_r), []{ return "line_drop_compensation_r"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorInput, &TransformerTapRegulatorInput::line_drop_compensation_x, offsetof(TransformerTapRegulatorInput, line_drop_compensation_x), []{ return "line_drop_compensation_x"; }>::value,
};
};



// template specialization functors to get nan
Expand Down Expand Up @@ -719,6 +746,37 @@ struct get_component_nan<FaultInput> {
}
};

template<>
struct get_component_nan<RegulatorInput> {
RegulatorInput operator() () const {
RegulatorInput comp;
// all attributes including base class

set_nan(comp.id);
set_nan(comp.regulated_object);
set_nan(comp.status);
return comp;
}
};

template<>
struct get_component_nan<TransformerTapRegulatorInput> {
TransformerTapRegulatorInput operator() () const {
TransformerTapRegulatorInput comp;
// all attributes including base class

set_nan(comp.id);
set_nan(comp.regulated_object);
set_nan(comp.status);
set_nan(comp.control_side);
set_nan(comp.u_set);
set_nan(comp.u_band);
set_nan(comp.line_drop_compensation_r);
set_nan(comp.line_drop_compensation_x);
return comp;
}
};



} // namespace power_grid_model::meta_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,27 @@ struct get_attributes_list<SensorShortCircuitOutput> {
};
};

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

meta_data_gen::get_meta_attribute<TransformerTapRegulatorOutput, &TransformerTapRegulatorOutput::id, offsetof(TransformerTapRegulatorOutput, id), []{ return "id"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorOutput, &TransformerTapRegulatorOutput::energized, offsetof(TransformerTapRegulatorOutput, energized), []{ return "energized"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorOutput, &TransformerTapRegulatorOutput::tap_pos, offsetof(TransformerTapRegulatorOutput, tap_pos), []{ return "tap_pos"; }>::value,
};
};

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

meta_data_gen::get_meta_attribute<RegulatorShortCircuitOutput, &RegulatorShortCircuitOutput::id, offsetof(RegulatorShortCircuitOutput, id), []{ return "id"; }>::value,
meta_data_gen::get_meta_attribute<RegulatorShortCircuitOutput, &RegulatorShortCircuitOutput::energized, offsetof(RegulatorShortCircuitOutput, energized), []{ return "energized"; }>::value,
};
};



// template specialization functors to get nan
Expand Down Expand Up @@ -463,6 +484,31 @@ struct get_component_nan<SensorShortCircuitOutput> {
}
};

template<>
struct get_component_nan<TransformerTapRegulatorOutput> {
TransformerTapRegulatorOutput operator() () const {
TransformerTapRegulatorOutput comp;
// all attributes including base class

set_nan(comp.id);
set_nan(comp.energized);
set_nan(comp.tap_pos);
return comp;
}
};

template<>
struct get_component_nan<RegulatorShortCircuitOutput> {
RegulatorShortCircuitOutput operator() () const {
RegulatorShortCircuitOutput comp;
// all attributes including base class

set_nan(comp.id);
set_nan(comp.energized);
return comp;
}
};



} // namespace power_grid_model::meta_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,30 @@ struct get_attributes_list<FaultUpdate> {
};
};

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

meta_data_gen::get_meta_attribute<RegulatorUpdate, &RegulatorUpdate::id, offsetof(RegulatorUpdate, id), []{ return "id"; }>::value,
meta_data_gen::get_meta_attribute<RegulatorUpdate, &RegulatorUpdate::status, offsetof(RegulatorUpdate, status), []{ return "status"; }>::value,
};
};

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

meta_data_gen::get_meta_attribute<TransformerTapRegulatorUpdate, &TransformerTapRegulatorUpdate::id, offsetof(TransformerTapRegulatorUpdate, id), []{ return "id"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorUpdate, &TransformerTapRegulatorUpdate::status, offsetof(TransformerTapRegulatorUpdate, status), []{ return "status"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorUpdate, &TransformerTapRegulatorUpdate::u_set, offsetof(TransformerTapRegulatorUpdate, u_set), []{ return "u_set"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorUpdate, &TransformerTapRegulatorUpdate::u_band, offsetof(TransformerTapRegulatorUpdate, u_band), []{ return "u_band"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorUpdate, &TransformerTapRegulatorUpdate::line_drop_compensation_r, offsetof(TransformerTapRegulatorUpdate, line_drop_compensation_r), []{ return "line_drop_compensation_r"; }>::value,
meta_data_gen::get_meta_attribute<TransformerTapRegulatorUpdate, &TransformerTapRegulatorUpdate::line_drop_compensation_x, offsetof(TransformerTapRegulatorUpdate, line_drop_compensation_x), []{ return "line_drop_compensation_x"; }>::value,
};
};



// template specialization functors to get nan
Expand Down Expand Up @@ -353,6 +377,34 @@ struct get_component_nan<FaultUpdate> {
}
};

template<>
struct get_component_nan<RegulatorUpdate> {
RegulatorUpdate operator() () const {
RegulatorUpdate comp;
// all attributes including base class

set_nan(comp.id);
set_nan(comp.status);
return comp;
}
};

template<>
struct get_component_nan<TransformerTapRegulatorUpdate> {
TransformerTapRegulatorUpdate operator() () const {
TransformerTapRegulatorUpdate comp;
// all attributes including base class

set_nan(comp.id);
set_nan(comp.status);
set_nan(comp.u_set);
set_nan(comp.u_band);
set_nan(comp.line_drop_compensation_r);
set_nan(comp.line_drop_compensation_x);
return comp;
}
};



} // namespace power_grid_model::meta_data
Expand Down
Loading