Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 @@ -78,6 +78,21 @@
"base": "BaseOutput",
"is_template": true,
"attributes": [
{
"data_type": "double",
"names": "loading_1",
"description": "loading of the branch at side 1"
},
{
"data_type": "double",
"names": "loading_2",
"description": "loading of the branch at side 2"
},
{
"data_type": "double",
"names": "loading_3",
"description": "loading of the branch at side 3"
},
{
"data_type": "double",
"names": "loading",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,14 @@ template <symmetry_tag sym_type>
struct get_attributes_list<Branch3Output<sym_type>> {
using sym = sym_type;

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

meta_data_gen::get_meta_attribute<&Branch3Output<sym>::id>(offsetof(Branch3Output<sym>, id), "id"),
meta_data_gen::get_meta_attribute<&Branch3Output<sym>::energized>(offsetof(Branch3Output<sym>, energized), "energized"),
meta_data_gen::get_meta_attribute<&Branch3Output<sym>::loading_1>(offsetof(Branch3Output<sym>, loading_1), "loading_1"),
meta_data_gen::get_meta_attribute<&Branch3Output<sym>::loading_2>(offsetof(Branch3Output<sym>, loading_2), "loading_2"),
meta_data_gen::get_meta_attribute<&Branch3Output<sym>::loading_3>(offsetof(Branch3Output<sym>, loading_3), "loading_3"),
meta_data_gen::get_meta_attribute<&Branch3Output<sym>::loading>(offsetof(Branch3Output<sym>, loading), "loading"),
meta_data_gen::get_meta_attribute<&Branch3Output<sym>::p_1>(offsetof(Branch3Output<sym>, p_1), "p_1"),
meta_data_gen::get_meta_attribute<&Branch3Output<sym>::q_1>(offsetof(Branch3Output<sym>, q_1), "q_1"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ struct Branch3Output {

ID id{na_IntID}; // ID of the object
IntS energized{na_IntS}; // whether the object is energized
double loading_1{nan}; // loading of the branch at side 1
double loading_2{nan}; // loading of the branch at side 2
double loading_3{nan}; // loading of the branch at side 3
double loading{nan}; // loading of the branch
RealValue<sym> p_1{nan}; // power flow at side 1
RealValue<sym> q_1{nan}; // power flow at side 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,12 @@ class Branch3 : public Base {
virtual double base_i_1() const = 0;
virtual double base_i_2() const = 0;
virtual double base_i_3() const = 0;
virtual double loading(double s_1, double s_2, double s_3) const = 0;
virtual double loading_1(double s_1) const = 0;
virtual double loading_2(double s_2) const = 0;
virtual double loading_3(double s_3) const = 0;
double loading(double s_1, double s_2, double s_3) const {
return std::max({loading_1(s_1), loading_2(s_2), loading_3(s_3)});
}
virtual std::array<double, 3> phase_shift() const = 0;

template <symmetry_tag sym>
Expand Down Expand Up @@ -123,6 +128,9 @@ class Branch3 : public Base {
output.s_3 = base_power<sym> * cabs(branch_solver_output3.s_f);

output.loading = loading(sum_val(output.s_1), sum_val(output.s_2), sum_val(output.s_3));
output.loading_1 = loading_1(sum_val(output.s_1));
output.loading_2 = loading_2(sum_val(output.s_2));
output.loading_3 = loading_3(sum_val(output.s_3));

return output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class ThreeWindingTransformer : public Branch3 {
double base_i_1() const final { return base_i_1_; }
double base_i_2() const final { return base_i_2_; }
double base_i_3() const final { return base_i_3_; }
double loading(double s_1, double s_2, double s_3) const final {
return std::max({s_1 / sn_1_, s_2 / sn_2_, s_3 / sn_3_});
}
double loading_1(double s_1) const final { return s_1 / sn_1_; }
double loading_2(double s_2) const final { return s_2 / sn_2_; }
double loading_3(double s_3) const final { return s_3 / sn_3_; }
// 3-way branch, phase shift = phase_node_x - phase_internal_node
// the clock_12 and clock_13 is reverted
// because clock_12 is the phase shift node_1 - node_2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ PGM_API extern PGM_MetaComponent const* const PGM_def_sym_output_three_winding_t
// attributes of sym_output three_winding_transformer
PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_id;
PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_energized;
PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_loading_1;
PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_loading_2;
PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_loading_3;
PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_loading;
PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_p_1;
PGM_API extern PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_q_1;
Expand Down Expand Up @@ -640,6 +643,9 @@ PGM_API extern PGM_MetaComponent const* const PGM_def_asym_output_three_winding_
// attributes of asym_output three_winding_transformer
PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_id;
PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_energized;
PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_loading_1;
PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_loading_2;
PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_loading_3;
PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_loading;
PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_p_1;
PGM_API extern PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_q_1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ PGM_MetaComponent const* const PGM_def_sym_output_three_winding_transformer = PG
// attributes of sym_output three_winding_transformer
PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_id = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "three_winding_transformer", "id");
PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_energized = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "three_winding_transformer", "energized");
PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_loading_1 = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "three_winding_transformer", "loading_1");
PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_loading_2 = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "three_winding_transformer", "loading_2");
PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_loading_3 = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "three_winding_transformer", "loading_3");
PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_loading = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "three_winding_transformer", "loading");
PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_p_1 = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "three_winding_transformer", "p_1");
PGM_MetaAttribute const* const PGM_def_sym_output_three_winding_transformer_q_1 = PGM_meta_get_attribute_by_name(nullptr, "sym_output", "three_winding_transformer", "q_1");
Expand Down Expand Up @@ -629,6 +632,9 @@ PGM_MetaComponent const* const PGM_def_asym_output_three_winding_transformer = P
// attributes of asym_output three_winding_transformer
PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_id = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "three_winding_transformer", "id");
PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_energized = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "three_winding_transformer", "energized");
PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_loading_1 = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "three_winding_transformer", "loading_1");
PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_loading_2 = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "three_winding_transformer", "loading_2");
PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_loading_3 = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "three_winding_transformer", "loading_3");
PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_loading = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "three_winding_transformer", "loading");
PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_p_1 = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "three_winding_transformer", "p_1");
PGM_MetaAttribute const* const PGM_def_asym_output_three_winding_transformer_q_1 = PGM_meta_get_attribute_by_name(nullptr, "asym_output", "three_winding_transformer", "q_1");
Expand Down
17 changes: 13 additions & 4 deletions tests/cpp_unit_tests/test_three_winding_transformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ TEST_CASE("Test three winding transformer") {
double const out_q_3 = base_power<symmetric_t> * 1;
double const out_i_3 = base_i_3 * cabs(b3_output.i_f);
double const out_s_3 = base_power<symmetric_t> * cabs(b3_output.s_f);
// max loading is at branch 3
double const out_loading = 0.316227766;
double const out_loading_1 = 0.037267800;
double const out_loading_2 = 0.072111026;
double const out_loading_3 = 0.316227766;

CHECK(sym_output.id == 1);
CHECK(sym_output.energized);
Expand All @@ -359,7 +360,11 @@ TEST_CASE("Test three winding transformer") {
CHECK(sym_output.q_3 == doctest::Approx(out_q_3));
CHECK(sym_output.i_3 == doctest::Approx(out_i_3));
CHECK(sym_output.s_3 == doctest::Approx(out_s_3));
CHECK(sym_output.loading == doctest::Approx(out_loading));
CHECK(sym_output.loading_1 == doctest::Approx(out_loading_1));
CHECK(sym_output.loading_2 == doctest::Approx(out_loading_2));
CHECK(sym_output.loading_3 == doctest::Approx(out_loading_3));
// max loading is at branch 3
CHECK(sym_output.loading == doctest::Approx(out_loading_3));

BranchSolverOutput<asymmetric_t> const asym_b1_output{.s_f = {(1.0 - 2.0i), (1.0 - 2.0i), (1.0 - 2.0i)},
.s_t = {(2.0 - 3.0i), (2.0 - 3.0i), (2.0 - 3.0i)},
Expand Down Expand Up @@ -390,7 +395,11 @@ TEST_CASE("Test three winding transformer") {
CHECK(asym_output.q_3(0) == doctest::Approx(out_q_3 / 3));
CHECK(asym_output.i_3(1) == doctest::Approx(out_i_3));
CHECK(asym_output.s_3(2) == doctest::Approx(out_s_3 / 3));
CHECK(asym_output.loading == doctest::Approx(out_loading));
CHECK(asym_output.loading_1 == doctest::Approx(out_loading_1));
CHECK(asym_output.loading_2 == doctest::Approx(out_loading_2));
CHECK(asym_output.loading_3 == doctest::Approx(out_loading_3));
// max loading is at branch 3
CHECK(asym_output.loading == doctest::Approx(out_loading_3));
}

SUBCASE("Check asym short circuit output of branch 3") {
Expand Down
Loading
Loading