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
#!/usr/bin/env python3
"""Runs VeraGrid (https://github.com/SanPen/VeraGrid) directly on a
MATPOWER case file and times its `PowerFlowDriver`, for comparison against
gridoxide, PGM, lightsim2grid, pypowsybl, and pandapower on the same
underlying case.
Usage: python3 bench_veragrid.py <case_name> <input.m-or-.mat>
`case_name` is only used for log messages; `input.m-or-.mat` is the
MATPOWER case file (see cases.py / matpower_to_pgm.py). VeraGrid's own
`parse_matpower_file` reads MATPOWER's `bus`/`gen`/`branch` matrices
directly (both `.m` and `.mat`), including each bus's `type` column
(1=PQ, 2=PV, 3=ref) and each generator's `Vg` voltage setpoint — so PV-bus
handling comes for free from the raw case file, the same way it does for
gridoxide (via PGM's `voltage_regulator`) and pypowsybl (via its own
MATPOWER importer), with no extra conversion step needed here.
Requires `VeraGridEngine` (the headless engine package — not `VeraGrid`,
which pulls in its Qt-based desktop GUI and its far heavier dependency
set): pip install VeraGridEngine
Uses `SolverType.NR` (Newton-Raphson, the same algorithm gridoxide/PGM/
lightsim2grid/pandapower all use here) with every automatic-control
feature this benchmark's other tools also disable for comparability
turned off: `retry_with_other_methods=False` (no automatic fallback to a
different algorithm if NR itself struggles — this script reports NR's own
result, unmodified, the same way bench_pypowsybl.py reports
powsybl-open-loadflow's raw, unmodified result), `distributed_slack=False`
(single slack, already VeraGrid's own default), `control_q=False`
(already VeraGrid's own default — no reactive-limit enforcement, matching
every other tool in this suite), and `control_taps_modules=False`/
`control_taps_phase=False`/`control_remote_voltage=False` (VeraGrid's own
defaults for these are all `True` — automatic tap-changer and remote
voltage regulation during the power-flow solve itself, the same category
of feature bench_pypowsybl.py explicitly disables via
`phase_shifter_regulation_on=False`/`transformer_voltage_control_on=False`
for the same reason: a fixed-topology, no-extra-control Newton-Raphson is
what every other tool here is being compared against).
VeraGrid's numerical kernels are numba-JIT-compiled — like pandapower, the
*first* solve call pays a one-off JIT-compilation cost (seconds, not
milliseconds) that has nothing to do with the actual power-flow algorithm;
the warm-up call below absorbs that before any timed run.
"""
=
=
=
, =
=
=
=
=
# Warm-up (first-call overhead, including numba JIT compilation), then timed runs.
=
=
=
=
# Also time full cold construction+calc, comparable to gridoxide's "total"
# (parse + build + solve) figure.
=
, =
=
=