power-grid-model 1.10.74__py3-none-win_amd64.whl → 1.12.119__py3-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of power-grid-model might be problematic. Click here for more details.
- power_grid_model/__init__.py +54 -29
- power_grid_model/_core/__init__.py +3 -3
- power_grid_model/_core/buffer_handling.py +507 -478
- power_grid_model/_core/data_handling.py +195 -141
- power_grid_model/_core/data_types.py +142 -0
- power_grid_model/_core/dataset_definitions.py +109 -109
- power_grid_model/_core/enum.py +226 -0
- power_grid_model/_core/error_handling.py +215 -202
- power_grid_model/_core/errors.py +134 -0
- power_grid_model/_core/index_integer.py +17 -17
- power_grid_model/_core/options.py +71 -69
- power_grid_model/_core/power_grid_core.py +577 -597
- power_grid_model/_core/power_grid_dataset.py +545 -528
- power_grid_model/_core/power_grid_meta.py +262 -244
- power_grid_model/_core/power_grid_model.py +1025 -692
- power_grid_model/_core/power_grid_model_c/__init__.py +3 -0
- power_grid_model/_core/power_grid_model_c/bin/power_grid_model_c.dll +0 -0
- power_grid_model/_core/power_grid_model_c/get_pgm_dll_path.py +63 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/basics.h +251 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/buffer.h +108 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset.h +332 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/dataset_definitions.h +1060 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/handle.h +111 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/meta_data.h +189 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/model.h +130 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/options.h +142 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c/serialization.h +118 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_c.h +36 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/basics.hpp +65 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/buffer.hpp +61 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/dataset.hpp +224 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/handle.hpp +108 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/meta_data.hpp +84 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/model.hpp +63 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/options.hpp +52 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/serialization.hpp +124 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp/utils.hpp +81 -0
- power_grid_model/_core/power_grid_model_c/include/power_grid_model_cpp.hpp +19 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfig.cmake +37 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelConfigVersion.cmake +65 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets-release.cmake +19 -0
- power_grid_model/_core/power_grid_model_c/lib/cmake/power_grid_model/power_grid_modelTargets.cmake +144 -0
- power_grid_model/_core/power_grid_model_c/lib/power_grid_model_c.lib +0 -0
- power_grid_model/_core/power_grid_model_c/share/LICENSE +292 -0
- power_grid_model/_core/power_grid_model_c/share/README.md +15 -0
- power_grid_model/_core/serialization.py +319 -317
- power_grid_model/_core/typing.py +20 -0
- power_grid_model/{_utils.py → _core/utils.py} +798 -783
- power_grid_model/data_types.py +321 -319
- power_grid_model/enum.py +27 -214
- power_grid_model/errors.py +37 -123
- power_grid_model/typing.py +43 -48
- power_grid_model/utils.py +529 -400
- power_grid_model/validation/__init__.py +25 -14
- power_grid_model/validation/_rules.py +1167 -904
- power_grid_model/validation/_validation.py +1172 -980
- power_grid_model/validation/assertions.py +93 -92
- power_grid_model/validation/errors.py +602 -520
- power_grid_model/validation/utils.py +313 -318
- {power_grid_model-1.10.74.dist-info → power_grid_model-1.12.119.dist-info}/METADATA +162 -171
- power_grid_model-1.12.119.dist-info/RECORD +65 -0
- {power_grid_model-1.10.74.dist-info → power_grid_model-1.12.119.dist-info}/WHEEL +1 -1
- power_grid_model-1.12.119.dist-info/entry_points.txt +3 -0
- power_grid_model/_core/_power_grid_core.dll +0 -0
- power_grid_model-1.10.74.dist-info/RECORD +0 -32
- power_grid_model-1.10.74.dist-info/top_level.txt +0 -1
- {power_grid_model-1.10.74.dist-info → power_grid_model-1.12.119.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,692 +1,1025 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
-
#
|
|
3
|
-
# SPDX-License-Identifier: MPL-2.0
|
|
4
|
-
|
|
5
|
-
"""
|
|
6
|
-
Main power grid model class
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
from
|
|
11
|
-
|
|
12
|
-
import
|
|
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
|
-
def
|
|
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
|
-
def
|
|
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
|
-
self
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
output_component_types: ComponentAttributeMapping,
|
|
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
|
-
batch_size=batch_size,
|
|
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
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
-
|
|
650
|
-
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
-
|
|
656
|
-
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
1
|
+
# SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MPL-2.0
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
Main power grid model class
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import itertools
|
|
10
|
+
from enum import IntEnum
|
|
11
|
+
from math import prod
|
|
12
|
+
from typing import Any, overload
|
|
13
|
+
|
|
14
|
+
import numpy as np
|
|
15
|
+
|
|
16
|
+
from power_grid_model._core.data_handling import (
|
|
17
|
+
create_output_data,
|
|
18
|
+
get_output_type,
|
|
19
|
+
prepare_input_view,
|
|
20
|
+
prepare_output_view,
|
|
21
|
+
prepare_update_view,
|
|
22
|
+
)
|
|
23
|
+
from power_grid_model._core.data_types import (
|
|
24
|
+
BatchDataset,
|
|
25
|
+
Dataset,
|
|
26
|
+
DenseBatchColumnarOutputDataset,
|
|
27
|
+
DenseBatchOutputDataset,
|
|
28
|
+
DenseBatchRowBasedOutputDataset,
|
|
29
|
+
SingleColumnarOutputDataset,
|
|
30
|
+
SingleDataset,
|
|
31
|
+
SingleOutputDataset,
|
|
32
|
+
SingleRowBasedDataset,
|
|
33
|
+
SingleRowBasedOutputDataset,
|
|
34
|
+
)
|
|
35
|
+
from power_grid_model._core.dataset_definitions import (
|
|
36
|
+
ComponentType,
|
|
37
|
+
ComponentTypeLike,
|
|
38
|
+
ComponentTypeVar,
|
|
39
|
+
_map_to_component_types,
|
|
40
|
+
_str_to_component_type,
|
|
41
|
+
)
|
|
42
|
+
from power_grid_model._core.enum import (
|
|
43
|
+
CalculationMethod,
|
|
44
|
+
CalculationType,
|
|
45
|
+
ComponentAttributeFilterOptions,
|
|
46
|
+
ShortCircuitVoltageScaling,
|
|
47
|
+
TapChangingStrategy,
|
|
48
|
+
_ExperimentalFeatures,
|
|
49
|
+
)
|
|
50
|
+
from power_grid_model._core.error_handling import PowerGridBatchError, assert_no_error, handle_errors
|
|
51
|
+
from power_grid_model._core.index_integer import IdNp, IdxNp
|
|
52
|
+
from power_grid_model._core.options import Options
|
|
53
|
+
from power_grid_model._core.power_grid_core import (
|
|
54
|
+
ConstDatasetPtr,
|
|
55
|
+
IDPtr,
|
|
56
|
+
IdxPtr,
|
|
57
|
+
ModelPtr,
|
|
58
|
+
get_power_grid_core as get_pgc,
|
|
59
|
+
)
|
|
60
|
+
from power_grid_model._core.typing import ComponentAttributeMapping, ComponentAttributeMappingDict
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class PowerGridModel:
|
|
64
|
+
"""
|
|
65
|
+
Main class for Power Grid Model
|
|
66
|
+
"""
|
|
67
|
+
|
|
68
|
+
_model_ptr: ModelPtr
|
|
69
|
+
_all_component_count: dict[ComponentType, int] | None
|
|
70
|
+
_batch_error: PowerGridBatchError | None
|
|
71
|
+
|
|
72
|
+
@property
|
|
73
|
+
def batch_error(self) -> PowerGridBatchError | None:
|
|
74
|
+
"""
|
|
75
|
+
Get the batch error object, if present, after a batch calculation with errors.
|
|
76
|
+
|
|
77
|
+
Also works when continue_on_batch_error was set to True during the calculation.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
Batch error object, or None
|
|
81
|
+
"""
|
|
82
|
+
return self._batch_error
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def _model(self):
|
|
86
|
+
if not self._model_ptr:
|
|
87
|
+
raise TypeError("You have an empty instance of PowerGridModel!")
|
|
88
|
+
return self._model_ptr
|
|
89
|
+
|
|
90
|
+
@property
|
|
91
|
+
def all_component_count(self) -> dict[ComponentType, int]:
|
|
92
|
+
"""
|
|
93
|
+
Get amount of elements per component type.
|
|
94
|
+
If the count for a component type is zero, it will not be in the returned dictionary.
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
A dictionary with
|
|
98
|
+
|
|
99
|
+
- key: Component type name
|
|
100
|
+
- value: Integer count of elements of this type
|
|
101
|
+
"""
|
|
102
|
+
if self._all_component_count is None:
|
|
103
|
+
raise TypeError("You have an empty instance of PowerGridModel!")
|
|
104
|
+
return self._all_component_count
|
|
105
|
+
|
|
106
|
+
def copy(self) -> "PowerGridModel":
|
|
107
|
+
"""
|
|
108
|
+
Copy the current model
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
A copy of PowerGridModel
|
|
112
|
+
"""
|
|
113
|
+
new_model = PowerGridModel.__new__(PowerGridModel)
|
|
114
|
+
new_model._model_ptr = get_pgc().copy_model(self._model)
|
|
115
|
+
assert_no_error()
|
|
116
|
+
new_model._all_component_count = self._all_component_count
|
|
117
|
+
return new_model
|
|
118
|
+
|
|
119
|
+
def __copy__(self) -> "PowerGridModel":
|
|
120
|
+
return self.copy()
|
|
121
|
+
|
|
122
|
+
def __deepcopy__(self, memo: dict[int, Any]) -> "PowerGridModel":
|
|
123
|
+
# PowerGridModel.copy makes already a deepcopy
|
|
124
|
+
new_model = self.copy()
|
|
125
|
+
|
|
126
|
+
# memorize that this object (self) has been deepcopied
|
|
127
|
+
memo[id(self)] = new_model
|
|
128
|
+
|
|
129
|
+
return new_model
|
|
130
|
+
|
|
131
|
+
def __repr__(self) -> str:
|
|
132
|
+
"""Return a string representation of the current model.
|
|
133
|
+
|
|
134
|
+
This includes the total number of components and the number of components per component type of the model.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
String representation of the model
|
|
138
|
+
"""
|
|
139
|
+
try:
|
|
140
|
+
component_count = self.all_component_count
|
|
141
|
+
except TypeError:
|
|
142
|
+
component_count = {}
|
|
143
|
+
|
|
144
|
+
message = f"{self.__class__.__name__} ({sum(component_count.values())} components)\n"
|
|
145
|
+
|
|
146
|
+
for component_type, number in component_count.items():
|
|
147
|
+
message += f" - {component_type.value}: {number}\n"
|
|
148
|
+
|
|
149
|
+
return message
|
|
150
|
+
|
|
151
|
+
def __new__(cls, *_args, **_kwargs):
|
|
152
|
+
instance = super().__new__(cls)
|
|
153
|
+
instance._model_ptr = ModelPtr()
|
|
154
|
+
instance._all_component_count = None
|
|
155
|
+
return instance
|
|
156
|
+
|
|
157
|
+
def __init__(self, input_data: SingleDataset, system_frequency: float = 50.0):
|
|
158
|
+
"""
|
|
159
|
+
Initialize the model from an input data set.
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
input_data: Input data dictionary
|
|
163
|
+
|
|
164
|
+
- key: Component type
|
|
165
|
+
- value: Component data with the correct type :class:`SingleComponentData`
|
|
166
|
+
|
|
167
|
+
system_frequency: Frequency of the power system, default 50 Hz
|
|
168
|
+
"""
|
|
169
|
+
# destroy old instance
|
|
170
|
+
get_pgc().destroy_model(self._model_ptr)
|
|
171
|
+
self._all_component_count = None
|
|
172
|
+
# create new
|
|
173
|
+
prepared_input = prepare_input_view(_map_to_component_types(input_data))
|
|
174
|
+
self._model_ptr = get_pgc().create_model(system_frequency, input_data=prepared_input.get_dataset_ptr())
|
|
175
|
+
assert_no_error()
|
|
176
|
+
self._all_component_count = {k: v for k, v in prepared_input.get_info().total_elements().items() if v > 0}
|
|
177
|
+
|
|
178
|
+
def update(self, *, update_data: Dataset):
|
|
179
|
+
"""
|
|
180
|
+
Update the model with changes.
|
|
181
|
+
|
|
182
|
+
The model will be in an invalid state if the update fails and should be discarded.
|
|
183
|
+
|
|
184
|
+
Args:
|
|
185
|
+
update_data: Update data dictionary
|
|
186
|
+
|
|
187
|
+
- key: Component type
|
|
188
|
+
- value: Component data with the correct type :class:`ComponentData` (single scenario or batch)
|
|
189
|
+
|
|
190
|
+
Raises:
|
|
191
|
+
PowerGridError if the update fails. The model is left in an invalid state and should be discarded.
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
None
|
|
195
|
+
"""
|
|
196
|
+
prepared_update = prepare_update_view(_map_to_component_types(update_data))
|
|
197
|
+
get_pgc().update_model(self._model, prepared_update.get_dataset_ptr())
|
|
198
|
+
assert_no_error()
|
|
199
|
+
|
|
200
|
+
def get_indexer(self, component_type: ComponentTypeLike, ids: np.ndarray):
|
|
201
|
+
"""
|
|
202
|
+
Get array of indexers given array of ids for component type.
|
|
203
|
+
|
|
204
|
+
This enables syntax like input_data[ComponentType.node][get_indexer(ids)]
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
component_type: Type of component
|
|
208
|
+
ids: Array of ids
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
Array of indexers, same shape as input array ids
|
|
212
|
+
"""
|
|
213
|
+
component_type = _str_to_component_type(component_type)
|
|
214
|
+
ids_c = np.ascontiguousarray(ids, dtype=IdNp).ctypes.data_as(IDPtr)
|
|
215
|
+
indexer = np.empty_like(ids, dtype=IdxNp, order="C")
|
|
216
|
+
indexer_c = indexer.ctypes.data_as(IdxPtr)
|
|
217
|
+
size = ids.size
|
|
218
|
+
# call c function
|
|
219
|
+
get_pgc().get_indexer(self._model, component_type, size, ids_c, indexer_c)
|
|
220
|
+
assert_no_error()
|
|
221
|
+
return indexer
|
|
222
|
+
|
|
223
|
+
def _get_output_component_count(self, calculation_type: CalculationType):
|
|
224
|
+
exclude_types = {
|
|
225
|
+
CalculationType.power_flow: [
|
|
226
|
+
ComponentType.sym_voltage_sensor,
|
|
227
|
+
ComponentType.asym_voltage_sensor,
|
|
228
|
+
ComponentType.sym_power_sensor,
|
|
229
|
+
ComponentType.asym_power_sensor,
|
|
230
|
+
ComponentType.fault,
|
|
231
|
+
],
|
|
232
|
+
CalculationType.state_estimation: [ComponentType.fault],
|
|
233
|
+
CalculationType.short_circuit: [
|
|
234
|
+
ComponentType.sym_voltage_sensor,
|
|
235
|
+
ComponentType.asym_voltage_sensor,
|
|
236
|
+
ComponentType.sym_power_sensor,
|
|
237
|
+
ComponentType.asym_power_sensor,
|
|
238
|
+
],
|
|
239
|
+
}.get(calculation_type, [])
|
|
240
|
+
|
|
241
|
+
def include_type(component_type: ComponentType):
|
|
242
|
+
return all(exclude_type.value not in component_type.value for exclude_type in exclude_types)
|
|
243
|
+
|
|
244
|
+
return {ComponentType[k]: v for k, v in self.all_component_count.items() if include_type(k)}
|
|
245
|
+
|
|
246
|
+
def _construct_output(
|
|
247
|
+
self,
|
|
248
|
+
output_component_types: ComponentAttributeMapping,
|
|
249
|
+
calculation_type: CalculationType,
|
|
250
|
+
symmetric: bool,
|
|
251
|
+
is_batch: bool,
|
|
252
|
+
batch_size: int,
|
|
253
|
+
):
|
|
254
|
+
all_component_count = self._get_output_component_count(calculation_type=calculation_type)
|
|
255
|
+
return create_output_data(
|
|
256
|
+
output_component_types=output_component_types,
|
|
257
|
+
output_type=get_output_type(calculation_type=calculation_type, symmetric=symmetric),
|
|
258
|
+
all_component_count=all_component_count,
|
|
259
|
+
is_batch=is_batch,
|
|
260
|
+
batch_size=batch_size,
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
@staticmethod
|
|
264
|
+
def _options(**kwargs) -> Options:
|
|
265
|
+
def as_enum_value(key_enum: str, type_: type[IntEnum]):
|
|
266
|
+
if key_enum in kwargs:
|
|
267
|
+
value_enum = kwargs[key_enum]
|
|
268
|
+
if isinstance(value_enum, str):
|
|
269
|
+
kwargs[key_enum] = type_[value_enum] # NOSONAR(S5864) IntEnum has __getitem__
|
|
270
|
+
|
|
271
|
+
as_enum_value("calculation_method", CalculationMethod)
|
|
272
|
+
as_enum_value("tap_changing_strategy", TapChangingStrategy)
|
|
273
|
+
as_enum_value("short_circuit_voltage_scaling", ShortCircuitVoltageScaling)
|
|
274
|
+
as_enum_value("experimental_features", _ExperimentalFeatures)
|
|
275
|
+
|
|
276
|
+
opt = Options()
|
|
277
|
+
for key, value in kwargs.items():
|
|
278
|
+
setattr(opt, key, value.value if isinstance(value, IntEnum) else value)
|
|
279
|
+
return opt
|
|
280
|
+
|
|
281
|
+
def _handle_errors(self, continue_on_batch_error: bool, batch_size: int, decode_error: bool):
|
|
282
|
+
self._batch_error = handle_errors(
|
|
283
|
+
continue_on_batch_error=continue_on_batch_error,
|
|
284
|
+
batch_size=batch_size,
|
|
285
|
+
decode_error=decode_error,
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
def _calculate_impl( # noqa: PLR0913
|
|
289
|
+
self,
|
|
290
|
+
calculation_type: CalculationType,
|
|
291
|
+
symmetric: bool,
|
|
292
|
+
update_data: Dataset | list[Dataset] | None,
|
|
293
|
+
output_component_types: ComponentAttributeMapping,
|
|
294
|
+
options: Options,
|
|
295
|
+
continue_on_batch_error: bool,
|
|
296
|
+
decode_error: bool,
|
|
297
|
+
experimental_features: _ExperimentalFeatures | str, # NOSONAR # noqa: ARG002
|
|
298
|
+
) -> Dataset:
|
|
299
|
+
"""
|
|
300
|
+
Core calculation routine
|
|
301
|
+
|
|
302
|
+
Args:
|
|
303
|
+
calculation_type:
|
|
304
|
+
symmetric:
|
|
305
|
+
update_data:
|
|
306
|
+
output_component_types:
|
|
307
|
+
options:
|
|
308
|
+
continue_on_batch_error:
|
|
309
|
+
decode_error:
|
|
310
|
+
|
|
311
|
+
Returns:
|
|
312
|
+
"""
|
|
313
|
+
self._batch_error = None
|
|
314
|
+
if update_data is None:
|
|
315
|
+
is_batch = False
|
|
316
|
+
update_data = []
|
|
317
|
+
else:
|
|
318
|
+
is_batch = True
|
|
319
|
+
if not isinstance(update_data, list):
|
|
320
|
+
update_data = [update_data]
|
|
321
|
+
update_data = [_map_to_component_types(x) for x in update_data]
|
|
322
|
+
prepared_update = [prepare_update_view(x) for x in update_data]
|
|
323
|
+
for this_dataset, next_dataset in itertools.pairwise(prepared_update):
|
|
324
|
+
this_dataset.set_next_cartesian_product_dimension(next_dataset)
|
|
325
|
+
update_ptr: ConstDatasetPtr = prepared_update[0].get_dataset_ptr() if prepared_update else ConstDatasetPtr()
|
|
326
|
+
batch_size = prod(x.get_info().batch_size() for x in prepared_update)
|
|
327
|
+
|
|
328
|
+
output_data = self._construct_output(
|
|
329
|
+
output_component_types=output_component_types,
|
|
330
|
+
calculation_type=calculation_type,
|
|
331
|
+
symmetric=symmetric,
|
|
332
|
+
is_batch=is_batch,
|
|
333
|
+
batch_size=batch_size,
|
|
334
|
+
)
|
|
335
|
+
prepared_result = prepare_output_view(
|
|
336
|
+
output_data=output_data,
|
|
337
|
+
output_type=get_output_type(calculation_type=calculation_type, symmetric=symmetric),
|
|
338
|
+
)
|
|
339
|
+
|
|
340
|
+
# run calculation
|
|
341
|
+
get_pgc().calculate(
|
|
342
|
+
# model and options
|
|
343
|
+
self._model,
|
|
344
|
+
options.opt,
|
|
345
|
+
output_data=prepared_result.get_dataset_ptr(),
|
|
346
|
+
update_data=update_ptr,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
self._handle_errors(
|
|
350
|
+
continue_on_batch_error=continue_on_batch_error,
|
|
351
|
+
batch_size=batch_size,
|
|
352
|
+
decode_error=decode_error,
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
return output_data
|
|
356
|
+
|
|
357
|
+
def _calculate_power_flow( # noqa: PLR0913
|
|
358
|
+
self,
|
|
359
|
+
*,
|
|
360
|
+
symmetric: bool = True,
|
|
361
|
+
error_tolerance: float = 1e-8,
|
|
362
|
+
max_iterations: int = 20,
|
|
363
|
+
calculation_method: CalculationMethod | str = CalculationMethod.newton_raphson,
|
|
364
|
+
update_data: Dataset | list[Dataset] | None = None,
|
|
365
|
+
threading: int = -1,
|
|
366
|
+
output_component_types: ComponentAttributeMapping = None,
|
|
367
|
+
continue_on_batch_error: bool = False,
|
|
368
|
+
decode_error: bool = True,
|
|
369
|
+
tap_changing_strategy: TapChangingStrategy | str = TapChangingStrategy.disabled,
|
|
370
|
+
experimental_features: _ExperimentalFeatures | str = _ExperimentalFeatures.disabled,
|
|
371
|
+
) -> Dataset:
|
|
372
|
+
calculation_type = CalculationType.power_flow
|
|
373
|
+
options = self._options(
|
|
374
|
+
calculation_type=calculation_type,
|
|
375
|
+
symmetric=symmetric,
|
|
376
|
+
error_tolerance=error_tolerance,
|
|
377
|
+
max_iterations=max_iterations,
|
|
378
|
+
calculation_method=calculation_method,
|
|
379
|
+
tap_changing_strategy=tap_changing_strategy,
|
|
380
|
+
threading=threading,
|
|
381
|
+
experimental_features=experimental_features,
|
|
382
|
+
)
|
|
383
|
+
return self._calculate_impl(
|
|
384
|
+
calculation_type=calculation_type,
|
|
385
|
+
symmetric=symmetric,
|
|
386
|
+
update_data=update_data,
|
|
387
|
+
output_component_types=output_component_types,
|
|
388
|
+
options=options,
|
|
389
|
+
continue_on_batch_error=continue_on_batch_error,
|
|
390
|
+
decode_error=decode_error,
|
|
391
|
+
experimental_features=experimental_features,
|
|
392
|
+
)
|
|
393
|
+
|
|
394
|
+
def _calculate_state_estimation( # noqa: PLR0913
|
|
395
|
+
self,
|
|
396
|
+
*,
|
|
397
|
+
symmetric: bool = True,
|
|
398
|
+
error_tolerance: float = 1e-8,
|
|
399
|
+
max_iterations: int = 20,
|
|
400
|
+
calculation_method: CalculationMethod | str = CalculationMethod.iterative_linear,
|
|
401
|
+
update_data: Dataset | list[Dataset] | None = None,
|
|
402
|
+
threading: int = -1,
|
|
403
|
+
output_component_types: ComponentAttributeMapping = None,
|
|
404
|
+
continue_on_batch_error: bool = False,
|
|
405
|
+
decode_error: bool = True,
|
|
406
|
+
experimental_features: _ExperimentalFeatures | str = _ExperimentalFeatures.disabled,
|
|
407
|
+
) -> Dataset:
|
|
408
|
+
calculation_type = CalculationType.state_estimation
|
|
409
|
+
options = self._options(
|
|
410
|
+
calculation_type=calculation_type,
|
|
411
|
+
symmetric=symmetric,
|
|
412
|
+
error_tolerance=error_tolerance,
|
|
413
|
+
max_iterations=max_iterations,
|
|
414
|
+
calculation_method=calculation_method,
|
|
415
|
+
threading=threading,
|
|
416
|
+
experimental_features=experimental_features,
|
|
417
|
+
)
|
|
418
|
+
return self._calculate_impl(
|
|
419
|
+
calculation_type=calculation_type,
|
|
420
|
+
symmetric=symmetric,
|
|
421
|
+
update_data=update_data,
|
|
422
|
+
output_component_types=output_component_types,
|
|
423
|
+
options=options,
|
|
424
|
+
continue_on_batch_error=continue_on_batch_error,
|
|
425
|
+
decode_error=decode_error,
|
|
426
|
+
experimental_features=experimental_features,
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
def _calculate_short_circuit( # noqa: PLR0913
|
|
430
|
+
self,
|
|
431
|
+
*,
|
|
432
|
+
calculation_method: CalculationMethod | str = CalculationMethod.iec60909,
|
|
433
|
+
update_data: Dataset | list[Dataset] | None = None,
|
|
434
|
+
threading: int = -1,
|
|
435
|
+
output_component_types: ComponentAttributeMapping = None,
|
|
436
|
+
continue_on_batch_error: bool = False,
|
|
437
|
+
decode_error: bool = True,
|
|
438
|
+
short_circuit_voltage_scaling: ShortCircuitVoltageScaling | str = ShortCircuitVoltageScaling.maximum,
|
|
439
|
+
experimental_features: _ExperimentalFeatures | str = _ExperimentalFeatures.disabled,
|
|
440
|
+
) -> Dataset:
|
|
441
|
+
calculation_type = CalculationType.short_circuit
|
|
442
|
+
symmetric = False
|
|
443
|
+
|
|
444
|
+
options = self._options(
|
|
445
|
+
calculation_type=calculation_type,
|
|
446
|
+
symmetric=symmetric,
|
|
447
|
+
calculation_method=calculation_method,
|
|
448
|
+
threading=threading,
|
|
449
|
+
short_circuit_voltage_scaling=short_circuit_voltage_scaling,
|
|
450
|
+
experimental_features=experimental_features,
|
|
451
|
+
)
|
|
452
|
+
return self._calculate_impl(
|
|
453
|
+
calculation_type=calculation_type,
|
|
454
|
+
symmetric=symmetric,
|
|
455
|
+
update_data=update_data,
|
|
456
|
+
output_component_types=output_component_types,
|
|
457
|
+
options=options,
|
|
458
|
+
continue_on_batch_error=continue_on_batch_error,
|
|
459
|
+
decode_error=decode_error,
|
|
460
|
+
experimental_features=experimental_features,
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
@overload
|
|
464
|
+
def calculate_power_flow(
|
|
465
|
+
self,
|
|
466
|
+
*,
|
|
467
|
+
symmetric: bool = ...,
|
|
468
|
+
error_tolerance: float = ...,
|
|
469
|
+
max_iterations: int = ...,
|
|
470
|
+
calculation_method: CalculationMethod | str = ...,
|
|
471
|
+
threading: int = ...,
|
|
472
|
+
output_component_types: None | set[ComponentTypeVar] | list[ComponentTypeVar] = ...,
|
|
473
|
+
continue_on_batch_error: bool = ...,
|
|
474
|
+
decode_error: bool = ...,
|
|
475
|
+
tap_changing_strategy: TapChangingStrategy | str = ...,
|
|
476
|
+
) -> SingleRowBasedDataset: ...
|
|
477
|
+
@overload
|
|
478
|
+
def calculate_power_flow(
|
|
479
|
+
self,
|
|
480
|
+
*,
|
|
481
|
+
symmetric: bool = ...,
|
|
482
|
+
error_tolerance: float = ...,
|
|
483
|
+
max_iterations: int = ...,
|
|
484
|
+
calculation_method: CalculationMethod | str = ...,
|
|
485
|
+
update_data: None = ...,
|
|
486
|
+
threading: int = ...,
|
|
487
|
+
output_component_types: None | set[ComponentTypeVar] | list[ComponentTypeVar] = ...,
|
|
488
|
+
continue_on_batch_error: bool = ...,
|
|
489
|
+
decode_error: bool = ...,
|
|
490
|
+
tap_changing_strategy: TapChangingStrategy | str = ...,
|
|
491
|
+
) -> SingleRowBasedDataset: ...
|
|
492
|
+
@overload
|
|
493
|
+
def calculate_power_flow(
|
|
494
|
+
self,
|
|
495
|
+
*,
|
|
496
|
+
symmetric: bool = ...,
|
|
497
|
+
error_tolerance: float = ...,
|
|
498
|
+
max_iterations: int = ...,
|
|
499
|
+
calculation_method: CalculationMethod | str = ...,
|
|
500
|
+
update_data: None = ...,
|
|
501
|
+
threading: int = ...,
|
|
502
|
+
output_component_types: ComponentAttributeFilterOptions = ...,
|
|
503
|
+
continue_on_batch_error: bool = ...,
|
|
504
|
+
decode_error: bool = ...,
|
|
505
|
+
tap_changing_strategy: TapChangingStrategy | str = ...,
|
|
506
|
+
) -> SingleColumnarOutputDataset: ...
|
|
507
|
+
@overload
|
|
508
|
+
def calculate_power_flow(
|
|
509
|
+
self,
|
|
510
|
+
*,
|
|
511
|
+
symmetric: bool = ...,
|
|
512
|
+
error_tolerance: float = ...,
|
|
513
|
+
max_iterations: int = ...,
|
|
514
|
+
calculation_method: CalculationMethod | str = ...,
|
|
515
|
+
update_data: None = ...,
|
|
516
|
+
threading: int = ...,
|
|
517
|
+
output_component_types: ComponentAttributeMappingDict = ...,
|
|
518
|
+
continue_on_batch_error: bool = ...,
|
|
519
|
+
decode_error: bool = ...,
|
|
520
|
+
tap_changing_strategy: TapChangingStrategy | str = ...,
|
|
521
|
+
) -> SingleOutputDataset: ...
|
|
522
|
+
@overload
|
|
523
|
+
def calculate_power_flow(
|
|
524
|
+
self,
|
|
525
|
+
*,
|
|
526
|
+
symmetric: bool = ...,
|
|
527
|
+
error_tolerance: float = ...,
|
|
528
|
+
max_iterations: int = ...,
|
|
529
|
+
calculation_method: CalculationMethod | str = ...,
|
|
530
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
531
|
+
threading: int = ...,
|
|
532
|
+
output_component_types: None | set[ComponentTypeVar] | list[ComponentTypeVar] = ...,
|
|
533
|
+
continue_on_batch_error: bool = ...,
|
|
534
|
+
decode_error: bool = ...,
|
|
535
|
+
tap_changing_strategy: TapChangingStrategy | str = ...,
|
|
536
|
+
) -> DenseBatchRowBasedOutputDataset: ...
|
|
537
|
+
@overload
|
|
538
|
+
def calculate_power_flow(
|
|
539
|
+
self,
|
|
540
|
+
*,
|
|
541
|
+
symmetric: bool = ...,
|
|
542
|
+
error_tolerance: float = ...,
|
|
543
|
+
max_iterations: int = ...,
|
|
544
|
+
calculation_method: CalculationMethod | str = ...,
|
|
545
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
546
|
+
threading: int = ...,
|
|
547
|
+
output_component_types: ComponentAttributeFilterOptions = ...,
|
|
548
|
+
continue_on_batch_error: bool = ...,
|
|
549
|
+
decode_error: bool = ...,
|
|
550
|
+
tap_changing_strategy: TapChangingStrategy | str = ...,
|
|
551
|
+
) -> DenseBatchColumnarOutputDataset: ...
|
|
552
|
+
@overload
|
|
553
|
+
def calculate_power_flow(
|
|
554
|
+
self,
|
|
555
|
+
*,
|
|
556
|
+
symmetric: bool = ...,
|
|
557
|
+
error_tolerance: float = ...,
|
|
558
|
+
max_iterations: int = ...,
|
|
559
|
+
calculation_method: CalculationMethod | str = ...,
|
|
560
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
561
|
+
threading: int = ...,
|
|
562
|
+
output_component_types: ComponentAttributeMappingDict = ...,
|
|
563
|
+
continue_on_batch_error: bool = ...,
|
|
564
|
+
decode_error: bool = ...,
|
|
565
|
+
tap_changing_strategy: TapChangingStrategy | str = ...,
|
|
566
|
+
) -> DenseBatchOutputDataset: ...
|
|
567
|
+
def calculate_power_flow( # noqa: PLR0913
|
|
568
|
+
self,
|
|
569
|
+
*,
|
|
570
|
+
symmetric: bool = True,
|
|
571
|
+
error_tolerance: float = 1e-8,
|
|
572
|
+
max_iterations: int = 20,
|
|
573
|
+
calculation_method: CalculationMethod | str = CalculationMethod.newton_raphson,
|
|
574
|
+
update_data: BatchDataset | list[BatchDataset] | None = None,
|
|
575
|
+
threading: int = -1,
|
|
576
|
+
output_component_types: ComponentAttributeMapping = None,
|
|
577
|
+
continue_on_batch_error: bool = False,
|
|
578
|
+
decode_error: bool = True,
|
|
579
|
+
tap_changing_strategy: TapChangingStrategy | str = TapChangingStrategy.disabled,
|
|
580
|
+
) -> Dataset:
|
|
581
|
+
"""
|
|
582
|
+
Calculate power flow once with the current model attributes.
|
|
583
|
+
Or calculate in batch with the given update dataset in batch.
|
|
584
|
+
|
|
585
|
+
Args:
|
|
586
|
+
symmetric (bool, optional): Whether to perform a three-phase symmetric calculation.
|
|
587
|
+
|
|
588
|
+
- True: Three-phase symmetric calculation, even for asymmetric loads/generations (Default).
|
|
589
|
+
- False: Three-phase asymmetric calculation.
|
|
590
|
+
error_tolerance (float, optional): Error tolerance for voltage in p.u., applicable only when the
|
|
591
|
+
calculation method is iterative.
|
|
592
|
+
max_iterations (int, optional): Maximum number of iterations, applicable only when the calculation method
|
|
593
|
+
is iterative.
|
|
594
|
+
calculation_method (an enumeration or string): The calculation method to use.
|
|
595
|
+
|
|
596
|
+
- newton_raphson: Use Newton-Raphson iterative method (default).
|
|
597
|
+
- linear: Use linear method.
|
|
598
|
+
update_data (dict, list of dict, optional):
|
|
599
|
+
None: Calculate power flow once with the current model attributes.
|
|
600
|
+
|
|
601
|
+
Or a dictionary for batch calculation with batch update.
|
|
602
|
+
|
|
603
|
+
- key: Component type name to be updated in batch.
|
|
604
|
+
- value:
|
|
605
|
+
|
|
606
|
+
- For homogeneous update batch (a 2D numpy structured array):
|
|
607
|
+
|
|
608
|
+
- Dimension 0: Each batch.
|
|
609
|
+
- Dimension 1: Each updated element per batch for this component type.
|
|
610
|
+
- For inhomogeneous update batch (a dictionary containing two keys):
|
|
611
|
+
|
|
612
|
+
- indptr: A 1D numpy int64 array with length n_batch + 1. Given batch number k, the
|
|
613
|
+
update array for this batch is data[indptr[k]:indptr[k + 1]]. This is the concept of
|
|
614
|
+
compressed sparse structure.
|
|
615
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html
|
|
616
|
+
- data: 1D numpy structured array in flat.
|
|
617
|
+
Or a list of such dictionaries (batch datasets) to represent multiple dimensions of cartesian product.
|
|
618
|
+
The calculation core will interpret these datasets as a cartesian product of all the scenarios.
|
|
619
|
+
Each batch dataset in the list represents one dimension of the cartesian product.
|
|
620
|
+
The output will then have row size equal to the product of the batch sizes of all these datasets,
|
|
621
|
+
in 1D flat structure.
|
|
622
|
+
E.g., if you have three batch datasets with batch sizes 2, 3, and 4 respectively,
|
|
623
|
+
and the number of nodes is 5, the final output for nodes will have shape (2*3*4, 5).
|
|
624
|
+
threading (int, optional): Applicable only for batch calculation.
|
|
625
|
+
|
|
626
|
+
- < 0: Sequential
|
|
627
|
+
- = 0: Parallel, use number of hardware threads
|
|
628
|
+
- > 0: Specify number of parallel threads
|
|
629
|
+
output_component_types (ComponentAttributeMapping):
|
|
630
|
+
|
|
631
|
+
- None: Row based data for all component types.
|
|
632
|
+
- set[ComponentTypeVar] or list[ComponentTypeVar]: Row based data for the specified component types.
|
|
633
|
+
- ComponentAttributeFilterOptions: Columnar data for all component types.
|
|
634
|
+
- ComponentAttributeMappingDict:
|
|
635
|
+
key: ComponentType
|
|
636
|
+
value:
|
|
637
|
+
- None: Row based data for the specified component types.
|
|
638
|
+
- ComponentAttributeFilterOptions: Columnar data for the specified component types.
|
|
639
|
+
- set[str] | list[str]: Columnar data for the specified component types and attributes.
|
|
640
|
+
continue_on_batch_error (bool, optional):
|
|
641
|
+
Continue the program (instead of throwing error) if some scenarios fail.
|
|
642
|
+
You can still retrieve the errors and succeeded/failed scenarios via the batch_error.
|
|
643
|
+
decode_error (bool, optional):
|
|
644
|
+
Decode error messages to their derived types if possible.
|
|
645
|
+
|
|
646
|
+
Returns:
|
|
647
|
+
Dictionary of results of all components.
|
|
648
|
+
|
|
649
|
+
- key: Component type name to be updated in batch.
|
|
650
|
+
- value:
|
|
651
|
+
|
|
652
|
+
- For single calculation: 1D numpy structured array for the results of this component type.
|
|
653
|
+
- For batch calculation: 2D numpy structured array for the results of this component type.
|
|
654
|
+
|
|
655
|
+
- Dimension 0: Each batch.
|
|
656
|
+
- Dimension 1: The result of each element for this component type.
|
|
657
|
+
|
|
658
|
+
Raises:
|
|
659
|
+
Exception: In case an error in the core occurs, an exception will be thrown.
|
|
660
|
+
"""
|
|
661
|
+
return self._calculate_power_flow(
|
|
662
|
+
symmetric=symmetric,
|
|
663
|
+
error_tolerance=error_tolerance,
|
|
664
|
+
max_iterations=max_iterations,
|
|
665
|
+
calculation_method=calculation_method,
|
|
666
|
+
update_data=update_data,
|
|
667
|
+
threading=threading,
|
|
668
|
+
output_component_types=output_component_types,
|
|
669
|
+
continue_on_batch_error=continue_on_batch_error,
|
|
670
|
+
decode_error=decode_error,
|
|
671
|
+
tap_changing_strategy=tap_changing_strategy,
|
|
672
|
+
)
|
|
673
|
+
|
|
674
|
+
@overload
|
|
675
|
+
def calculate_state_estimation(
|
|
676
|
+
self,
|
|
677
|
+
*,
|
|
678
|
+
symmetric: bool = ...,
|
|
679
|
+
error_tolerance: float = ...,
|
|
680
|
+
max_iterations: int = ...,
|
|
681
|
+
calculation_method: CalculationMethod | str = ...,
|
|
682
|
+
update_data: None = ...,
|
|
683
|
+
threading: int = ...,
|
|
684
|
+
output_component_types: None | set[ComponentTypeVar] | list[ComponentTypeVar] = ...,
|
|
685
|
+
continue_on_batch_error: bool = ...,
|
|
686
|
+
decode_error: bool = ...,
|
|
687
|
+
) -> SingleRowBasedOutputDataset: ...
|
|
688
|
+
@overload
|
|
689
|
+
def calculate_state_estimation(
|
|
690
|
+
self,
|
|
691
|
+
*,
|
|
692
|
+
symmetric: bool = ...,
|
|
693
|
+
error_tolerance: float = ...,
|
|
694
|
+
max_iterations: int = ...,
|
|
695
|
+
calculation_method: CalculationMethod | str = ...,
|
|
696
|
+
update_data: None = ...,
|
|
697
|
+
threading: int = ...,
|
|
698
|
+
output_component_types: ComponentAttributeFilterOptions = ...,
|
|
699
|
+
continue_on_batch_error: bool = ...,
|
|
700
|
+
decode_error: bool = ...,
|
|
701
|
+
) -> SingleColumnarOutputDataset: ...
|
|
702
|
+
@overload
|
|
703
|
+
def calculate_state_estimation(
|
|
704
|
+
self,
|
|
705
|
+
*,
|
|
706
|
+
symmetric: bool = ...,
|
|
707
|
+
error_tolerance: float = ...,
|
|
708
|
+
max_iterations: int = ...,
|
|
709
|
+
calculation_method: CalculationMethod | str = ...,
|
|
710
|
+
update_data: None = ...,
|
|
711
|
+
threading: int = ...,
|
|
712
|
+
output_component_types: ComponentAttributeMappingDict = ...,
|
|
713
|
+
continue_on_batch_error: bool = ...,
|
|
714
|
+
decode_error: bool = ...,
|
|
715
|
+
) -> SingleOutputDataset: ...
|
|
716
|
+
@overload
|
|
717
|
+
def calculate_state_estimation(
|
|
718
|
+
self,
|
|
719
|
+
*,
|
|
720
|
+
symmetric: bool = ...,
|
|
721
|
+
error_tolerance: float = ...,
|
|
722
|
+
max_iterations: int = ...,
|
|
723
|
+
calculation_method: CalculationMethod | str = ...,
|
|
724
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
725
|
+
threading: int = ...,
|
|
726
|
+
output_component_types: None | set[ComponentTypeVar] | list[ComponentTypeVar] = ...,
|
|
727
|
+
continue_on_batch_error: bool = ...,
|
|
728
|
+
decode_error: bool = ...,
|
|
729
|
+
) -> DenseBatchRowBasedOutputDataset: ...
|
|
730
|
+
@overload
|
|
731
|
+
def calculate_state_estimation(
|
|
732
|
+
self,
|
|
733
|
+
*,
|
|
734
|
+
symmetric: bool = ...,
|
|
735
|
+
error_tolerance: float = ...,
|
|
736
|
+
max_iterations: int = ...,
|
|
737
|
+
calculation_method: CalculationMethod | str = ...,
|
|
738
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
739
|
+
threading: int = ...,
|
|
740
|
+
output_component_types: ComponentAttributeFilterOptions = ...,
|
|
741
|
+
continue_on_batch_error: bool = ...,
|
|
742
|
+
decode_error: bool = ...,
|
|
743
|
+
) -> DenseBatchColumnarOutputDataset: ...
|
|
744
|
+
@overload
|
|
745
|
+
def calculate_state_estimation(
|
|
746
|
+
self,
|
|
747
|
+
*,
|
|
748
|
+
symmetric: bool = ...,
|
|
749
|
+
error_tolerance: float = ...,
|
|
750
|
+
max_iterations: int = ...,
|
|
751
|
+
calculation_method: CalculationMethod | str = ...,
|
|
752
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
753
|
+
threading: int = ...,
|
|
754
|
+
output_component_types: ComponentAttributeMappingDict = ...,
|
|
755
|
+
continue_on_batch_error: bool = ...,
|
|
756
|
+
decode_error: bool = ...,
|
|
757
|
+
) -> DenseBatchOutputDataset: ...
|
|
758
|
+
def calculate_state_estimation( # noqa: PLR0913
|
|
759
|
+
self,
|
|
760
|
+
*,
|
|
761
|
+
symmetric: bool = True,
|
|
762
|
+
error_tolerance: float = 1e-8,
|
|
763
|
+
max_iterations: int = 20,
|
|
764
|
+
calculation_method: CalculationMethod | str = CalculationMethod.iterative_linear,
|
|
765
|
+
update_data: BatchDataset | list[BatchDataset] | None = None,
|
|
766
|
+
threading: int = -1,
|
|
767
|
+
output_component_types: ComponentAttributeMapping = None,
|
|
768
|
+
continue_on_batch_error: bool = False,
|
|
769
|
+
decode_error: bool = True,
|
|
770
|
+
) -> Dataset:
|
|
771
|
+
"""
|
|
772
|
+
Calculate state estimation once with the current model attributes.
|
|
773
|
+
Or calculate in batch with the given update dataset in batch.
|
|
774
|
+
|
|
775
|
+
Args:
|
|
776
|
+
symmetric (bool, optional): Whether to perform a three-phase symmetric calculation.
|
|
777
|
+
|
|
778
|
+
- True: Three-phase symmetric calculation, even for asymmetric loads/generations (Default).
|
|
779
|
+
- False: Three-phase asymmetric calculation.
|
|
780
|
+
error_tolerance (float, optional): error tolerance for voltage in p.u., only applicable when the
|
|
781
|
+
calculation method is iterative.
|
|
782
|
+
max_iterations (int, optional): Maximum number of iterations, applicable only when the calculation method
|
|
783
|
+
is iterative.
|
|
784
|
+
calculation_method (an enumeration): Use iterative linear method.
|
|
785
|
+
update_data (dict, optional):
|
|
786
|
+
None: Calculate state estimation once with the current model attributes.
|
|
787
|
+
|
|
788
|
+
Or a dictionary for batch calculation with batch update.
|
|
789
|
+
|
|
790
|
+
- key: Component type name to be updated in batch.
|
|
791
|
+
- value:
|
|
792
|
+
|
|
793
|
+
- For homogeneous update batch (a 2D numpy structured array):
|
|
794
|
+
|
|
795
|
+
- Dimension 0: Each batch.
|
|
796
|
+
- Dimension 1: Each updated element per batch for this component type.
|
|
797
|
+
- For inhomogeneous update batch (a dictionary containing two keys):
|
|
798
|
+
|
|
799
|
+
- indptr: A 1D numpy int64 array with length n_batch + 1. Given batch number k, the
|
|
800
|
+
update array for this batch is data[indptr[k]:indptr[k + 1]]. This is the concept of
|
|
801
|
+
compressed sparse structure.
|
|
802
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html
|
|
803
|
+
- data: 1D numpy structured array in flat.
|
|
804
|
+
Or a list of such dictionaries (batch datasets) to represent multiple dimensions of cartesian product.
|
|
805
|
+
The calculation core will interpret these datasets as a cartesian product of all the scenarios.
|
|
806
|
+
Each batch dataset in the list represents one dimension of the cartesian product.
|
|
807
|
+
The output will then have row size equal to the product of the batch sizes of all these datasets,
|
|
808
|
+
in 1D flat structure.
|
|
809
|
+
E.g., if you have three batch datasets with batch sizes 2, 3, and 4 respectively,
|
|
810
|
+
and the number of nodes is 5, the final output for nodes will have shape (2*3*4, 5).
|
|
811
|
+
threading (int, optional): Applicable only for batch calculation.
|
|
812
|
+
|
|
813
|
+
- < 0: Sequential
|
|
814
|
+
- = 0: Parallel, use number of hardware threads
|
|
815
|
+
- > 0: Specify number of parallel threads
|
|
816
|
+
output_component_types (ComponentAttributeMapping):
|
|
817
|
+
|
|
818
|
+
- None: Row based data for all component types.
|
|
819
|
+
- set[ComponentTypeVar] or list[ComponentTypeVar]: Row based data for the specified component types.
|
|
820
|
+
- ComponentAttributeFilterOptions: Columnar data for all component types.
|
|
821
|
+
- ComponentAttributeMappingDict:
|
|
822
|
+
key: ComponentType
|
|
823
|
+
value:
|
|
824
|
+
- None: Row based data for the specified component types.
|
|
825
|
+
- ComponentAttributeFilterOptions: Columnar data for the specified component types.
|
|
826
|
+
- set[str] | list[str]: Columnar data for the specified component types and attributes.
|
|
827
|
+
continue_on_batch_error (bool, optional):
|
|
828
|
+
Continue the program (instead of throwing error) if some scenarios fail.
|
|
829
|
+
You can still retrieve the errors and succeeded/failed scenarios via the batch_error.
|
|
830
|
+
decode_error (bool, optional):
|
|
831
|
+
Decode error messages to their derived types if possible.
|
|
832
|
+
|
|
833
|
+
Returns:
|
|
834
|
+
Dictionary of results of all components.
|
|
835
|
+
|
|
836
|
+
- key: Component type name to be updated in batch.
|
|
837
|
+
- value:
|
|
838
|
+
|
|
839
|
+
- For single calculation: 1D numpy structured array for the results of this component type.
|
|
840
|
+
- For batch calculation: 2D numpy structured array for the results of this component type.
|
|
841
|
+
|
|
842
|
+
- Dimension 0: Each batch.
|
|
843
|
+
- Dimension 1: The result of each element for this component type.
|
|
844
|
+
|
|
845
|
+
Raises:
|
|
846
|
+
Exception: In case an error in the core occurs, an exception will be thrown.
|
|
847
|
+
"""
|
|
848
|
+
return self._calculate_state_estimation(
|
|
849
|
+
symmetric=symmetric,
|
|
850
|
+
error_tolerance=error_tolerance,
|
|
851
|
+
max_iterations=max_iterations,
|
|
852
|
+
calculation_method=calculation_method,
|
|
853
|
+
update_data=update_data,
|
|
854
|
+
threading=threading,
|
|
855
|
+
output_component_types=output_component_types,
|
|
856
|
+
continue_on_batch_error=continue_on_batch_error,
|
|
857
|
+
decode_error=decode_error,
|
|
858
|
+
)
|
|
859
|
+
|
|
860
|
+
@overload
|
|
861
|
+
def calculate_short_circuit(
|
|
862
|
+
self,
|
|
863
|
+
*,
|
|
864
|
+
calculation_method: CalculationMethod | str = ...,
|
|
865
|
+
update_data: None = ...,
|
|
866
|
+
threading: int = ...,
|
|
867
|
+
output_component_types: None | set[ComponentTypeVar] | list[ComponentTypeVar] = ...,
|
|
868
|
+
continue_on_batch_error: bool = ...,
|
|
869
|
+
decode_error: bool = ...,
|
|
870
|
+
short_circuit_voltage_scaling: ShortCircuitVoltageScaling | str,
|
|
871
|
+
) -> SingleRowBasedDataset: ...
|
|
872
|
+
@overload
|
|
873
|
+
def calculate_short_circuit(
|
|
874
|
+
self,
|
|
875
|
+
*,
|
|
876
|
+
calculation_method: CalculationMethod | str = ...,
|
|
877
|
+
update_data: None = ...,
|
|
878
|
+
threading: int = ...,
|
|
879
|
+
output_component_types: ComponentAttributeFilterOptions = ...,
|
|
880
|
+
continue_on_batch_error: bool = ...,
|
|
881
|
+
decode_error: bool = ...,
|
|
882
|
+
short_circuit_voltage_scaling: ShortCircuitVoltageScaling | str,
|
|
883
|
+
) -> SingleColumnarOutputDataset: ...
|
|
884
|
+
@overload
|
|
885
|
+
def calculate_short_circuit(
|
|
886
|
+
self,
|
|
887
|
+
*,
|
|
888
|
+
calculation_method: CalculationMethod | str = ...,
|
|
889
|
+
update_data: None = ...,
|
|
890
|
+
threading: int = ...,
|
|
891
|
+
output_component_types: ComponentAttributeMappingDict = ...,
|
|
892
|
+
continue_on_batch_error: bool = ...,
|
|
893
|
+
decode_error: bool = ...,
|
|
894
|
+
short_circuit_voltage_scaling: ShortCircuitVoltageScaling | str,
|
|
895
|
+
) -> SingleOutputDataset: ...
|
|
896
|
+
@overload
|
|
897
|
+
def calculate_short_circuit(
|
|
898
|
+
self,
|
|
899
|
+
*,
|
|
900
|
+
calculation_method: CalculationMethod | str = ...,
|
|
901
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
902
|
+
threading: int = ...,
|
|
903
|
+
output_component_types: None | set[ComponentTypeVar] | list[ComponentTypeVar] = ...,
|
|
904
|
+
continue_on_batch_error: bool = ...,
|
|
905
|
+
decode_error: bool = ...,
|
|
906
|
+
short_circuit_voltage_scaling: ShortCircuitVoltageScaling | str,
|
|
907
|
+
) -> DenseBatchRowBasedOutputDataset: ...
|
|
908
|
+
@overload
|
|
909
|
+
def calculate_short_circuit(
|
|
910
|
+
self,
|
|
911
|
+
*,
|
|
912
|
+
calculation_method: CalculationMethod | str = ...,
|
|
913
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
914
|
+
threading: int = ...,
|
|
915
|
+
output_component_types: ComponentAttributeFilterOptions = ...,
|
|
916
|
+
continue_on_batch_error: bool = ...,
|
|
917
|
+
decode_error: bool = ...,
|
|
918
|
+
short_circuit_voltage_scaling: ShortCircuitVoltageScaling | str,
|
|
919
|
+
) -> DenseBatchColumnarOutputDataset: ...
|
|
920
|
+
@overload
|
|
921
|
+
def calculate_short_circuit(
|
|
922
|
+
self,
|
|
923
|
+
*,
|
|
924
|
+
calculation_method: CalculationMethod | str = ...,
|
|
925
|
+
update_data: BatchDataset | list[BatchDataset] = ...,
|
|
926
|
+
threading: int = ...,
|
|
927
|
+
output_component_types: ComponentAttributeMappingDict = ...,
|
|
928
|
+
continue_on_batch_error: bool = ...,
|
|
929
|
+
decode_error: bool = ...,
|
|
930
|
+
short_circuit_voltage_scaling: ShortCircuitVoltageScaling | str,
|
|
931
|
+
) -> DenseBatchOutputDataset: ...
|
|
932
|
+
def calculate_short_circuit( # noqa: PLR0913
|
|
933
|
+
self,
|
|
934
|
+
*,
|
|
935
|
+
calculation_method: CalculationMethod | str = CalculationMethod.iec60909,
|
|
936
|
+
update_data: BatchDataset | list[BatchDataset] | None = None,
|
|
937
|
+
threading: int = -1,
|
|
938
|
+
output_component_types: ComponentAttributeMapping = None,
|
|
939
|
+
continue_on_batch_error: bool = False,
|
|
940
|
+
decode_error: bool = True,
|
|
941
|
+
short_circuit_voltage_scaling: ShortCircuitVoltageScaling | str = ShortCircuitVoltageScaling.maximum,
|
|
942
|
+
) -> Dataset:
|
|
943
|
+
"""
|
|
944
|
+
Calculate a short circuit once with the current model attributes.
|
|
945
|
+
Or calculate in batch with the given update dataset in batch
|
|
946
|
+
|
|
947
|
+
Args:
|
|
948
|
+
calculation_method (an enumeration): Use the iec60909 standard.
|
|
949
|
+
update_data:
|
|
950
|
+
None: calculate a short circuit once with the current model attributes.
|
|
951
|
+
|
|
952
|
+
Or a dictionary for batch calculation with batch update
|
|
953
|
+
|
|
954
|
+
- key: Component type name to be updated in batch
|
|
955
|
+
- value:
|
|
956
|
+
|
|
957
|
+
- For homogeneous update batch (a 2D numpy structured array):
|
|
958
|
+
|
|
959
|
+
- Dimension 0: each batch
|
|
960
|
+
- Dimension 1: each updated element per batch for this component type
|
|
961
|
+
- For inhomogeneous update batch (a dictionary containing two keys):
|
|
962
|
+
|
|
963
|
+
- indptr: A 1D numpy int64 array with length n_batch + 1. Given batch number k, the
|
|
964
|
+
update array for this batch is data[indptr[k]:indptr[k + 1]]. This is the concept of
|
|
965
|
+
compressed sparse structure.
|
|
966
|
+
https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html
|
|
967
|
+
- data: 1D numpy structured array in flat.
|
|
968
|
+
Or a list of such dictionaries (batch datasets) to represent multiple dimensions of cartesian product.
|
|
969
|
+
The calculation core will interpret these datasets as a cartesian product of all the scenarios.
|
|
970
|
+
Each batch dataset in the list represents one dimension of the cartesian product.
|
|
971
|
+
The output will then have row size equal to the product of the batch sizes of all these datasets,
|
|
972
|
+
in 1D flat structure.
|
|
973
|
+
E.g., if you have three batch datasets with batch sizes 2, 3, and 4 respectively,
|
|
974
|
+
and the number of nodes is 5, the final output for nodes will have shape (2*3*4, 5).
|
|
975
|
+
threading (int, optional): Applicable only for batch calculation.
|
|
976
|
+
|
|
977
|
+
- < 0: Sequential
|
|
978
|
+
- = 0: Parallel, use number of hardware threads
|
|
979
|
+
- > 0: Specify number of parallel threads
|
|
980
|
+
output_component_types (ComponentAttributeMapping):
|
|
981
|
+
|
|
982
|
+
- None: Row based data for all component types.
|
|
983
|
+
- set[ComponentTypeVar] or list[ComponentTypeVar]: Row based data for the specified component types.
|
|
984
|
+
- ComponentAttributeFilterOptions: Columnar data for all component types.
|
|
985
|
+
- ComponentAttributeMappingDict:
|
|
986
|
+
key: ComponentType
|
|
987
|
+
value:
|
|
988
|
+
- None: Row based data for the specified component types.
|
|
989
|
+
- ComponentAttributeFilterOptions: Columnar data for the specified component types.
|
|
990
|
+
- set[str] | list[str]: Columnar data for the specified component types and attributes.
|
|
991
|
+
continue_on_batch_error (bool, optional):
|
|
992
|
+
Continue the program (instead of throwing error) if some scenarios fail.
|
|
993
|
+
You can still retrieve the errors and succeeded/failed scenarios via the batch_error.
|
|
994
|
+
decode_error (bool, optional):
|
|
995
|
+
Decode error messages to their derived types if possible.
|
|
996
|
+
short_circuit_voltage_scaling ({ShortCircuitVoltageSaling, str}, optional):
|
|
997
|
+
Whether to use the maximum or minimum voltage scaling.
|
|
998
|
+
By default, the maximum voltage scaling is used to calculate the short circuit.
|
|
999
|
+
|
|
1000
|
+
Returns:
|
|
1001
|
+
Dictionary of results of all components.
|
|
1002
|
+
|
|
1003
|
+
- key: Component type name to be updated in batch.
|
|
1004
|
+
- value:
|
|
1005
|
+
|
|
1006
|
+
- For single calculation: 1D numpy structured array for the results of this component type.
|
|
1007
|
+
- For batch calculation: 2D numpy structured array for the results of this component type.
|
|
1008
|
+
|
|
1009
|
+
- Dimension 0: Each batch.
|
|
1010
|
+
- Dimension 1: The result of each element for this component type.
|
|
1011
|
+
Raises:
|
|
1012
|
+
Exception: In case an error in the core occurs, an exception will be thrown.
|
|
1013
|
+
"""
|
|
1014
|
+
return self._calculate_short_circuit(
|
|
1015
|
+
calculation_method=calculation_method,
|
|
1016
|
+
update_data=update_data,
|
|
1017
|
+
threading=threading,
|
|
1018
|
+
output_component_types=output_component_types,
|
|
1019
|
+
continue_on_batch_error=continue_on_batch_error,
|
|
1020
|
+
decode_error=decode_error,
|
|
1021
|
+
short_circuit_voltage_scaling=short_circuit_voltage_scaling,
|
|
1022
|
+
)
|
|
1023
|
+
|
|
1024
|
+
def __del__(self):
|
|
1025
|
+
get_pgc().destroy_model(self._model_ptr)
|