Skip to content

Commit c1fbef5

Browse files
authored
Merge pull request #612 from PowerGridModel/feature/auto-tap-single-transformer
[Feature] - set line drop compensation to 0 by default
2 parents 7785700 + c422472 commit c1fbef5

File tree

20 files changed

+218
-25
lines changed

20 files changed

+218
-25
lines changed

power_grid_model_c/power_grid_model/include/power_grid_model/common/three_phase_tensor.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,9 @@ inline std::pair<DoubleComplex, DoubleComplex> inv_sym_param(DoubleComplex const
287287
// is nan
288288
template <class Derived> inline bool is_nan(Eigen::ArrayBase<Derived> const& x) { return x.isNaN().all(); }
289289
inline bool is_nan(std::floating_point auto x) { return std::isnan(x); }
290+
template <std::floating_point T> inline bool is_nan(std::complex<T> const& x) {
291+
return is_nan(x.real()) || is_nan(x.imag());
292+
}
290293
inline bool is_nan(ID x) { return x == na_IntID; }
291294
inline bool is_nan(IntS x) { return x == na_IntS; }
292295
template <class Enum>

power_grid_model_c/power_grid_model/include/power_grid_model/component/transformer_tap_regulator.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ class TransformerTapRegulator : public Regulator {
7373
param.u_set = u_set_ / u_rated_;
7474
param.u_band = u_band_ / u_rated_;
7575
double const z_base = u_rated_ * u_rated_ / base_power<sym>;
76-
DoubleComplex const z_compensation{line_drop_compensation_r_, line_drop_compensation_x_};
76+
DoubleComplex const z_compensation{is_nan(line_drop_compensation_r_) ? 0.0 : line_drop_compensation_r_,
77+
is_nan(line_drop_compensation_x_) ? 0.0 : line_drop_compensation_x_};
7778
param.z_compensation = z_compensation / z_base;
7879
param.status = static_cast<IntS>(Regulator::status());
7980
return param;

tests/cpp_unit_tests/test_transformer_tap_regulator.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,22 @@ TEST_CASE("Test transformer tap regulator") {
197197
CHECK(cabs(param.z_compensation - z_compensation_expected) < numerical_tolerance);
198198
CHECK(param.status);
199199
}
200+
201+
SUBCASE("Test default line drop compensation") {
202+
TransformerTapRegulator regulator{{.id = 1,
203+
.regulated_object = 2,
204+
.status = true,
205+
.control_side = ControlSide::from,
206+
.u_set = 10.0e3,
207+
.u_band = 1.0e3},
208+
ComponentType::branch,
209+
u_rated};
210+
211+
TransformerTapRegulatorCalcParam const param = regulator.calc_param<symmetric_t>();
212+
CHECK(!is_nan(param.z_compensation));
213+
CHECK(param.z_compensation.real() == doctest::Approx(0.0));
214+
CHECK(param.z_compensation.imag() == doctest::Approx(0.0));
215+
}
200216
}
201217

202218
} // namespace power_grid_model

tests/data/power_flow/automatic-tap-regulator/single-trafo-any-valid-tap/sym_output.json

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"version": "1.0",
3+
"type": "sym_output",
4+
"is_batch": true,
5+
"attributes": {},
6+
"data": [
7+
{
8+
"node": [
9+
{"id": 2, "energized": 1, "u_pu": 0.9999994897958192, "u": 9999.994897958191, "u_angle": -4.976276188195561e-08, "p": 1002.829609258255, "q": 5027.202969858203},
10+
{"id": 4, "energized": 1, "u_pu": 0.9751874571379635, "u": 390.0749828551854, "u_angle": -2.618511710996588, "p": -1000, "q": -5000.000000000176}
11+
],
12+
"transformer": [
13+
{"id": 3, "energized": 1, "loading": 0.05126249791549004, "p_from": 1002.829609258255, "q_from": 5027.202969858203, "i_from": 0.2959643207106418, "s_from": 5126.249791549004, "p_to": -1000, "q_to": -5000.000000000176, "i_to": 7.547062534561395, "s_to": 5099.019513592958}
14+
],
15+
"sym_load": [
16+
{"id": 5, "energized": 1, "p": 1000, "q": 5000, "i": 7.547062534561141, "s": 5099.019513592785, "pf": 0.196116135138184}
17+
],
18+
"source": [
19+
{"id": 1, "energized": 1, "p": 1002.829609193285, "q": 5027.202968741678, "i": 0.2959643206466909, "s": 5126.249790441341, "pf": 0.1956263643381582}
20+
],
21+
"transformer_tap_regulator": [
22+
{"id": 7, "energized": 1, "tap_pos": 2}
23+
]
24+
},
25+
{
26+
"node": [
27+
{"id": 2, "energized": 1, "u_pu": 0.9999994899030393, "u": 9999.994899030393, "u_angle": -4.976309478422389e-08, "p": 1002.726233800649, "q": 5026.135759975151},
28+
{"id": 4, "energized": 1, "u_pu": 0.9948984008982722, "u": 397.9593603593089, "u_angle": -2.618491503137831, "p": -999.9999999998167, "q": -5000.000000000037}
29+
],
30+
"transformer": [
31+
{"id": 3, "energized": 1, "loading": 0.05125182979919158, "p_from": 1002.726233800649, "q_from": 5026.135759975151, "i_from": 0.2959027282493237, "s_from": 5125.182979919158, "p_to": -999.9999999998167, "q_to": -5000.000000000037, "i_to": 7.397540005386348, "s_to": 5099.019513592785}
32+
],
33+
"sym_load": [
34+
{"id": 5, "energized": 1, "p": 1000, "q": 5000, "i": 7.397540005386347, "s": 5099.019513592785, "pf": 0.196116135138184}
35+
],
36+
"source": [
37+
{"id": 1, "energized": 1, "p": 1002.726233846283, "q": 5026.135758488603, "i": 0.295902728165672, "s": 5125.182978470267, "pf": 0.1956469140825818}
38+
],
39+
"transformer_tap_regulator": [
40+
{"id": 7, "energized": 1, "tap_pos": 0}
41+
]
42+
}
43+
]
44+
}
File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "1.0",
3+
"type": "update",
4+
"is_batch": true,
5+
"attributes": {},
6+
"data": [
7+
{},
8+
{
9+
"transformer": [
10+
{"id": 3, "tap_pos": 0}
11+
]
12+
}
13+
]
14+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
3+
SPDX-License-Identifier: MPL-2.0
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"version": "1.0",
3+
"type": "input",
4+
"is_batch": false,
5+
"attributes": {},
6+
"data": {
7+
"node": [
8+
{"id": 2, "u_rated": 10000},
9+
{"id": 4, "u_rated": 400}
10+
],
11+
"transformer": [
12+
{"id": 3, "from_node": 2, "to_node": 4, "from_status": 1, "to_status": 1, "u1": 10000, "u2": 400, "sn": 100000, "uk": 0.1, "pk": 1000, "i0": 1e-06, "p0": 0.1, "winding_from": 2, "winding_to": 1, "clock": 5, "tap_side": 0, "tap_pos": 3, "tap_min": -11, "tap_max": 9, "tap_size": 100}
13+
],
14+
"sym_load": [
15+
{"id": 5, "node": 4, "status": 1, "type": 0, "p_specified": 1000, "q_specified": 5000}
16+
],
17+
"source": [
18+
{"id": 1, "node": 2, "status": 1, "u_ref": 1}
19+
],
20+
"transformer_tap_regulator": [
21+
{"id": 7, "regulated_object": 3, "status": 1, "control_side": 1, "u_set": 400, "u_band": 20}
22+
]
23+
}
24+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <[email protected]>
2+
3+
SPDX-License-Identifier: MPL-2.0

0 commit comments

Comments
 (0)