-
Notifications
You must be signed in to change notification settings - Fork 5
/
Transformer3WInput.java
375 lines (349 loc) · 11.9 KB
/
Transformer3WInput.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
/*
* © 2021. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.models.input.connector;
import static edu.ie3.util.quantities.PowerSystemUnits.PU;
import edu.ie3.datamodel.io.extractor.HasType;
import edu.ie3.datamodel.models.OperationTime;
import edu.ie3.datamodel.models.input.NodeInput;
import edu.ie3.datamodel.models.input.OperatorInput;
import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput;
import java.util.*;
import tech.units.indriya.quantity.Quantities;
/**
* Describes a three winding transformer, that is connected to three {@link
* edu.ie3.datamodel.models.input.NodeInput}s
*/
public class Transformer3WInput extends TransformerInput implements HasType {
/** Type of this 3W transformer, containing default values for transformers of this kind */
private final Transformer3WTypeInput type;
/** The lower voltage node */
private final NodeInput nodeC;
/** Internal node of the transformers T equivalent circuit */
private final NodeInput nodeInternal;
/**
* Constructor for an operated three winding transformer
*
* @param uuid of the input entity
* @param id of the asset
* @param operator of the asset
* @param operationTime Time for which the entity is operated
* @param nodeA The higher voltage node
* @param nodeB The middle voltage node
* @param nodeC The lower voltage node
* @param parallelDevices overall amount of parallel transformers to automatically construct (e.g.
* parallelDevices = 2 will build a total of two transformers using the specified parameters)
* @param type of 3W transformer
* @param tapPos Tap Position of this transformer
* @param autoTap true, if there is an automated regulation activated for this transformer
*/
public Transformer3WInput(
UUID uuid,
String id,
OperatorInput operator,
OperationTime operationTime,
NodeInput nodeA,
NodeInput nodeB,
NodeInput nodeC,
int parallelDevices,
Transformer3WTypeInput type,
int tapPos,
boolean autoTap) {
this(
uuid,
id,
operator,
operationTime,
nodeA,
nodeB,
nodeC,
parallelDevices,
type,
tapPos,
autoTap,
false);
if (nodeB.getVoltLvl().getNominalVoltage().isGreaterThan(nodeA.getVoltLvl().getNominalVoltage())
|| nodeC
.getVoltLvl()
.getNominalVoltage()
.isGreaterThan(nodeB.getVoltLvl().getNominalVoltage())) {
throw new IllegalArgumentException(
"NodeA must be greater than nodeB and nodeB must be greater than nodeC");
}
}
/**
* Constructor for an operated three winding transformer that allows setting the internal node as
* slack node. This is normally needed if a larger grid is split up into subgrids and the three
* winding transformer is located in a subgrid that does not hold the highest voltage side of the
* transformer (here: that not holds node A in its grid).
*
* <p>Then, the internal node becomes a virtual representation of a slack node for the grid and
* allows for power flow calculations based on it's 'close-to-T-equivalent' representation
*
* @param uuid of the input entity
* @param id of the asset
* @param operator of the asset
* @param operationTime Time for which the entity is operated
* @param nodeA The higher voltage node
* @param nodeB The middle voltage node
* @param nodeC The lower voltage node
* @param parallelDevices overall amount of parallel transformers to automatically construct (e.g.
* parallelDevices = 2 will build a total of two transformers using the specified parameters)
* @param type of 3W transformer
* @param tapPos Tap Position of this transformer
* @param autoTap true, if there is an automated regulation activated for this transformer
* @param internalNodeAsSlack true, if the internal node is a slack node, false otherwise
*/
public Transformer3WInput(
UUID uuid,
String id,
OperatorInput operator,
OperationTime operationTime,
NodeInput nodeA,
NodeInput nodeB,
NodeInput nodeC,
int parallelDevices,
Transformer3WTypeInput type,
int tapPos,
boolean autoTap,
boolean internalNodeAsSlack) {
this(
uuid,
id,
operator,
operationTime,
nodeA,
nodeB,
nodeC,
parallelDevices,
type,
tapPos,
autoTap,
new NodeInput(
UUID.randomUUID(),
"internal_node_" + id,
operator,
operationTime,
Quantities.getQuantity(1d, PU),
internalNodeAsSlack,
null,
nodeA.getVoltLvl(),
nodeA.getSubnet()));
if (nodeB.getVoltLvl().getNominalVoltage().isGreaterThan(nodeA.getVoltLvl().getNominalVoltage())
|| nodeC
.getVoltLvl()
.getNominalVoltage()
.isGreaterThan(nodeB.getVoltLvl().getNominalVoltage())) {
throw new IllegalArgumentException(
"NodeA must be greater than nodeB and nodeB must be greater than nodeC");
}
}
/**
* Constructor for an operated, always on three winding transformer
*
* @param uuid of the input entity
* @param id of the asset
* @param nodeA The higher voltage node
* @param nodeB The middle voltage node
* @param nodeC The lower voltage node
* @param parallelDevices overall amount of parallel transformers to automatically construct (e.g.
* parallelDevices = 2 will build a total of two transformers using the specified parameters)
* @param type of 3W transformer
* @param tapPos Tap Position of this transformer
* @param autoTap true, if there is an automated regulation activated for this transformer
*/
public Transformer3WInput(
UUID uuid,
String id,
NodeInput nodeA,
NodeInput nodeB,
NodeInput nodeC,
int parallelDevices,
Transformer3WTypeInput type,
int tapPos,
boolean autoTap) {
super(uuid, id, nodeA, nodeB, parallelDevices, tapPos, autoTap);
if (nodeB.getVoltLvl().getNominalVoltage().isGreaterThan(nodeA.getVoltLvl().getNominalVoltage())
|| nodeC
.getVoltLvl()
.getNominalVoltage()
.isGreaterThan(nodeB.getVoltLvl().getNominalVoltage())) {
throw new IllegalArgumentException(
"NodeA must be greater than nodeB and nodeB must be greater than nodeC");
}
this.type = type;
this.nodeC = nodeC;
this.nodeInternal =
new NodeInput(
UUID.randomUUID(),
"internal_node_" + id,
getOperator(),
getOperationTime(),
Quantities.getQuantity(1d, PU),
false,
null,
nodeA.getVoltLvl(),
nodeA.getSubnet());
}
/**
* Private constructor to be used for create copies using {@link Transformer3WInputCopyBuilder}
*
* @param uuid of the input entity
* @param id of the asset
* @param operator of the asset
* @param operationTime Time for which the entity is operated
* @param nodeA The higher voltage node
* @param nodeB The middle voltage node
* @param nodeC The lower voltage node
* @param parallelDevices overall amount of parallel transformers to automatically construct (e.g.
* parallelDevices = 2 will build a total of two transformers using the specified parameters)
* @param type of 3W transformer
* @param tapPos Tap Position of this transformer
* @param autoTap true, if there is an automated regulation activated for this transformer
*/
private Transformer3WInput(
UUID uuid,
String id,
OperatorInput operator,
OperationTime operationTime,
NodeInput nodeA,
NodeInput nodeB,
NodeInput nodeC,
int parallelDevices,
Transformer3WTypeInput type,
int tapPos,
boolean autoTap,
NodeInput internalNode) {
super(uuid, operationTime, operator, id, nodeA, nodeB, parallelDevices, tapPos, autoTap);
if (nodeB.getVoltLvl().getNominalVoltage().isGreaterThan(nodeA.getVoltLvl().getNominalVoltage())
|| nodeC
.getVoltLvl()
.getNominalVoltage()
.isGreaterThan(nodeB.getVoltLvl().getNominalVoltage())) {
throw new IllegalArgumentException(
"NodeA must be greater than nodeB and nodeB must be greater than nodeC");
}
this.type = type;
this.nodeC = nodeC;
this.nodeInternal = internalNode;
}
@Override
public Transformer3WTypeInput getType() {
return type;
}
/** @return the node with the highest voltage level */
@Override
public NodeInput getNodeA() {
return super.getNodeA();
}
/** @return the node with the "medium" voltage level */
@Override
public NodeInput getNodeB() {
return super.getNodeB();
}
/** @return the node with the lowest voltage level */
public NodeInput getNodeC() {
return nodeC;
}
/** @return The internal node of the T equivalent circuit */
public NodeInput getNodeInternal() {
return nodeInternal;
}
public Transformer3WInputCopyBuilder copy() {
return new Transformer3WInputCopyBuilder(this);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Transformer3WInput that)) return false;
if (!super.equals(o)) return false;
return Objects.equals(type, that.type) && Objects.equals(nodeC, that.nodeC);
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), type, nodeC);
}
@Override
public String toString() {
return "Transformer3WInput{"
+ "uuid="
+ getUuid()
+ ", id="
+ getId()
+ ", operationTime="
+ getOperationTime()
+ ", operator="
+ getOperator().getUuid()
+ ", noOfParallelDevices="
+ getParallelDevices()
+ ", nodeA="
+ getNodeA().getUuid()
+ ", nodeB="
+ getNodeB().getUuid()
+ ", nodeC="
+ nodeC.getUuid()
+ ", type="
+ type.getUuid()
+ '}';
}
@Override
public List<NodeInput> allNodes() {
return List.of(getNodeA(), getNodeB(), nodeC);
}
/**
* A builder pattern based approach to create copies of {@link Transformer3WInput} entities with
* altered field values. For detailed field descriptions refer to java docs of {@link
* Transformer3WInput}
*
* @version 0.1
* @since 05.06.20
*/
public static class Transformer3WInputCopyBuilder
extends TransformerInputCopyBuilder<Transformer3WInputCopyBuilder> {
private Transformer3WTypeInput type;
private NodeInput nodeC;
private boolean internSlack;
private final NodeInput internalNode;
private Transformer3WInputCopyBuilder(Transformer3WInput entity) {
super(entity);
this.type = entity.getType();
this.nodeC = entity.getNodeC();
this.internalNode = entity.getNodeInternal();
this.internSlack = entity.getNodeInternal().isSlack();
}
@Override
public Transformer3WInput build() {
return new Transformer3WInput(
getUuid(),
getId(),
getOperator(),
getOperationTime(),
super.getNodeA(),
super.getNodeB(),
nodeC,
getParallelDevices(),
type,
getTapPos(),
isAutoTap(),
internalNode.copy().slack(internSlack).build());
}
public Transformer3WInputCopyBuilder type(Transformer3WTypeInput type) {
this.type = type;
return this;
}
public Transformer3WInputCopyBuilder nodeC(NodeInput nodeC) {
this.nodeC = nodeC;
return this;
}
public Transformer3WInputCopyBuilder internalSlack(boolean internalNodeIsSlack) {
this.internSlack = internalNodeIsSlack;
return this;
}
@Override
protected Transformer3WInputCopyBuilder childInstance() {
return this;
}
}
}