@@ -35,13 +35,6 @@ template <symmetry_tag sym_type> struct BranchCalcParam {
35
35
ComplexTensor<sym> const & ytt () const { return value[3 ]; }
36
36
};
37
37
38
- struct TransformerTapRegulatorCalcParam {
39
- double u_set{};
40
- double u_band{};
41
- DoubleComplex z_compensation{};
42
- IntS status{};
43
- };
44
-
45
38
template <symmetry_tag sym_type> struct BranchMathOutput {
46
39
using sym = sym_type;
47
40
@@ -117,15 +110,28 @@ template <symmetry_tag sym_type> struct PowerSensorCalcParam {
117
110
118
111
template <typename T>
119
112
concept sensor_calc_param_type =
120
- std::same_as<T, VoltageSensorCalcParam<symmetric_t >> || std::same_as<T, VoltageSensorCalcParam<asymmetric_t >> ||
121
- std::same_as<T, PowerSensorCalcParam<symmetric_t >> || std::same_as<T, PowerSensorCalcParam<asymmetric_t >>;
113
+ std::derived_from<T, VoltageSensorCalcParam<symmetric_t >> ||
114
+ std::derived_from<T, VoltageSensorCalcParam<asymmetric_t >> ||
115
+ std::derived_from<T, PowerSensorCalcParam<symmetric_t >> || std::derived_from<T, PowerSensorCalcParam<asymmetric_t >>;
122
116
123
117
static_assert (sensor_calc_param_type<VoltageSensorCalcParam<symmetric_t >>);
124
118
static_assert (sensor_calc_param_type<VoltageSensorCalcParam<asymmetric_t >>);
125
119
static_assert (sensor_calc_param_type<PowerSensorCalcParam<symmetric_t >>);
126
120
static_assert (sensor_calc_param_type<PowerSensorCalcParam<asymmetric_t >>);
127
121
128
- // from, to side
122
+ struct TransformerTapRegulatorCalcParam {
123
+ double u_set{};
124
+ double u_band{};
125
+ DoubleComplex z_compensation{};
126
+ IntS status{};
127
+ };
128
+ template <symmetry_tag sym_type> struct TransformerTapRegulatorMathOutput {
129
+ using sym = sym_type;
130
+
131
+ IntS tap_pos{na_IntS};
132
+ };
133
+
134
+ // from side, to side
129
135
// in case of indices for math model, -1 means the branch is not connected to that side
130
136
using BranchIdx = std::array<Idx, 2 >;
131
137
// node 0, 1, 2 side
@@ -221,7 +227,7 @@ struct ShortCircuitInput {
221
227
222
228
template <typename T>
223
229
concept symmetric_calculation_input_type =
224
- std::same_as <T, PowerFlowInput<symmetric_t >> || std::same_as <T, StateEstimationInput<symmetric_t >>;
230
+ std::derived_from <T, PowerFlowInput<symmetric_t >> || std::derived_from <T, StateEstimationInput<symmetric_t >>;
225
231
226
232
static_assert (symmetric_calculation_input_type<PowerFlowInput<symmetric_t >>);
227
233
static_assert (symmetric_calculation_input_type<StateEstimationInput<symmetric_t >>);
@@ -231,8 +237,8 @@ static_assert(!symmetric_calculation_input_type<ShortCircuitInput>);
231
237
232
238
template <typename T>
233
239
concept asymmetric_calculation_input_type =
234
- std::same_as <T, PowerFlowInput<asymmetric_t >> || std::same_as <T, StateEstimationInput<asymmetric_t >> ||
235
- std::same_as <T, ShortCircuitInput>;
240
+ std::derived_from <T, PowerFlowInput<asymmetric_t >> || std::derived_from <T, StateEstimationInput<asymmetric_t >> ||
241
+ std::derived_from <T, ShortCircuitInput>;
236
242
237
243
static_assert (!asymmetric_calculation_input_type<PowerFlowInput<symmetric_t >>);
238
244
static_assert (!asymmetric_calculation_input_type<StateEstimationInput<symmetric_t >>);
@@ -249,7 +255,10 @@ static_assert(calculation_input_type<PowerFlowInput<asymmetric_t>>);
249
255
static_assert (calculation_input_type<StateEstimationInput<asymmetric_t >>);
250
256
static_assert (calculation_input_type<ShortCircuitInput>);
251
257
258
+ struct math_output_t {};
259
+
252
260
template <symmetry_tag sym_type> struct MathOutput {
261
+ using type = math_output_t ;
253
262
using sym = sym_type;
254
263
255
264
std::vector<ComplexValue<sym>> u;
@@ -258,9 +267,11 @@ template <symmetry_tag sym_type> struct MathOutput {
258
267
std::vector<ApplianceMathOutput<sym>> source;
259
268
std::vector<ApplianceMathOutput<sym>> shunt;
260
269
std::vector<ApplianceMathOutput<sym>> load_gen;
270
+ std::vector<TransformerTapRegulatorMathOutput<sym>> transformer_tap_regulator;
261
271
};
262
272
263
273
template <symmetry_tag sym_type> struct ShortCircuitMathOutput {
274
+ using type = math_output_t ;
264
275
using sym = sym_type;
265
276
266
277
std::vector<ComplexValue<sym>> u_bus;
@@ -271,26 +282,31 @@ template <symmetry_tag sym_type> struct ShortCircuitMathOutput {
271
282
};
272
283
273
284
template <typename T>
274
- concept symmetric_math_output_type =
275
- std::same_as<T, MathOutput<symmetric_t >> || std::same_as<T, ShortCircuitMathOutput<symmetric_t >>;
285
+ concept math_output_type = std::derived_from<typename T::type, math_output_t >;
286
+
287
+ static_assert (math_output_type<MathOutput<symmetric_t >>);
288
+ static_assert (math_output_type<MathOutput<asymmetric_t >>);
289
+ static_assert (math_output_type<ShortCircuitMathOutput<symmetric_t >>);
290
+ static_assert (math_output_type<ShortCircuitMathOutput<asymmetric_t >>);
291
+
292
+ template <typename T>
293
+ concept symmetric_math_output_type = math_output_type<T> && is_symmetric_v<typename T::sym>;
276
294
277
295
static_assert (symmetric_math_output_type<MathOutput<symmetric_t >>);
278
296
static_assert (!symmetric_math_output_type<MathOutput<asymmetric_t >>);
279
297
static_assert (symmetric_math_output_type<ShortCircuitMathOutput<symmetric_t >>);
280
298
static_assert (!symmetric_math_output_type<ShortCircuitMathOutput<asymmetric_t >>);
281
299
282
300
template <typename T>
283
- concept asymmetric_math_output_type =
284
- std::same_as<T, MathOutput<asymmetric_t >> || std::same_as<T, ShortCircuitMathOutput<asymmetric_t >>;
301
+ concept asymmetric_math_output_type = math_output_type<T> && is_asymmetric_v<typename T::sym>;
285
302
286
303
static_assert (!asymmetric_math_output_type<MathOutput<symmetric_t >>);
287
304
static_assert (asymmetric_math_output_type<MathOutput<asymmetric_t >>);
288
305
static_assert (!asymmetric_math_output_type<ShortCircuitMathOutput<symmetric_t >>);
289
306
static_assert (asymmetric_math_output_type<ShortCircuitMathOutput<asymmetric_t >>);
290
307
291
308
template <typename T>
292
- concept steady_state_math_output_type =
293
- std::same_as<T, MathOutput<symmetric_t >> || std::same_as<T, MathOutput<asymmetric_t >>;
309
+ concept steady_state_math_output_type = math_output_type<T> && std::derived_from<T, MathOutput<typename T::sym>>;
294
310
295
311
static_assert (steady_state_math_output_type<MathOutput<symmetric_t >>);
296
312
static_assert (steady_state_math_output_type<MathOutput<asymmetric_t >>);
@@ -299,22 +315,13 @@ static_assert(!steady_state_math_output_type<ShortCircuitMathOutput<asymmetric_t
299
315
300
316
template <typename T>
301
317
concept short_circuit_math_output_type =
302
- std::same_as<T, ShortCircuitMathOutput< symmetric_t >> || std::same_as <T, ShortCircuitMathOutput<asymmetric_t >>;
318
+ math_output_type<T> && std::derived_from <T, ShortCircuitMathOutput<typename T::sym >>;
303
319
304
320
static_assert (!short_circuit_math_output_type<MathOutput<symmetric_t >>);
305
321
static_assert (!short_circuit_math_output_type<MathOutput<asymmetric_t >>);
306
322
static_assert (short_circuit_math_output_type<ShortCircuitMathOutput<symmetric_t >>);
307
323
static_assert (short_circuit_math_output_type<ShortCircuitMathOutput<asymmetric_t >>);
308
324
309
- template <typename T>
310
- concept math_output_type = (symmetric_math_output_type<T> || asymmetric_math_output_type<T>) &&
311
- (steady_state_math_output_type<T> || short_circuit_math_output_type<T>);
312
-
313
- static_assert (math_output_type<MathOutput<symmetric_t >>);
314
- static_assert (math_output_type<MathOutput<asymmetric_t >>);
315
- static_assert (math_output_type<ShortCircuitMathOutput<symmetric_t >>);
316
- static_assert (math_output_type<ShortCircuitMathOutput<asymmetric_t >>);
317
-
318
325
// component indices at physical model side
319
326
// from, to node indices for branches
320
327
// node1, node2, node3 indices for 3-way branches
@@ -328,12 +335,13 @@ struct ComponentTopology {
328
335
IdxVector load_gen_node_idx;
329
336
std::vector<LoadGenType> load_gen_type;
330
337
IdxVector voltage_sensor_node_idx;
331
- IdxVector power_sensor_object_idx; // the index is relative to branch, source, shunt, or load_gen
338
+ IdxVector power_sensor_object_idx; // the index is relative to branch, source, shunt or load_gen
332
339
std::vector<MeasuredTerminalType> power_sensor_terminal_type;
333
- IdxVector regulated_object_idx; // the index is relative to branch
340
+ std::vector<ComponentType> regulator_type;
341
+ IdxVector regulated_object_idx; // the index is relative to branch or branch3
334
342
std::vector<ComponentType> regulated_object_type;
335
343
336
- inline Idx n_node_total () const { return n_node + static_cast <Idx>(branch3_node_idx.size ()); }
344
+ Idx n_node_total () const { return n_node + static_cast <Idx>(branch3_node_idx.size ()); }
337
345
};
338
346
339
347
// connection property
@@ -392,14 +400,4 @@ struct TopologicalComponentToMathCoupling {
392
400
std::vector<Idx2D> regulator;
393
401
};
394
402
395
- // change of update cause topology and param change, or just param change
396
- struct UpdateChange {
397
- bool topo{};
398
- bool param{};
399
-
400
- friend constexpr UpdateChange operator ||(UpdateChange const & x, UpdateChange const & y) {
401
- return UpdateChange{x.topo || y.topo , x.param || y.param };
402
- }
403
- };
404
-
405
403
} // namespace power_grid_model
0 commit comments