File size: 10,792 Bytes
f0ec570
 
 
0713efa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
license: mit
---

# PowerDiT Dataset

This repository contains processed power-system graph data for machine learning experiments on power-flow- and optimal-power-flow-related tasks.  
The data is generated with [**gridfm-datakit**](https://github.com/gridfm/gridfm-datakit) based on benchmark grid cases from [**PGLib**](https://github.com/power-grid-lib/pglib-opf), and then preprocessed into graph-structured samples.
It is intended to be stored in the folders examples/data_processed/pf and examples/data_processed/opf. 

## Overview

The dataset consists of graph representations of electric power systems under a range of operating conditions and perturbations.

Each sample corresponds to a power-grid state derived from a benchmark network case, with:

- **nodes** representing buses
- **edges** representing transmission lines
- **node features** encoding electrical state, bus metadata, and generator properties.
- **edge features** encoding electrical line parameters.

The data is split into two different datasets:

- **PF mode (Power Flow)**  
  The samples are merely physically (power-flow) consistent with non-cost-optimal generations.

- **OPF mode (Optimal Power Flow)**  
  The samples are creating using an opf-solver such that generator setpoints are cost-optimal.


## Available data

The processed dataset currently includes the following grid cases and sample counts:

| grid | #buses | #gens | #lines | pf samples | opf samples |
|---|---:|---:|---:|---:|---:|
| case3_lmbd | 3 | 3 | 6 | 1,224,988 | 934,045 |
| case5_pjm | 5 | 5 | 12 | 1,287,400 | 1,214,688 |
| case14_ieee | 14 | 5 | 40 | 1,290,095 | 1,300,186 |
| case24_ieee_rts | 24 | 33 | 76 | 1,290,126 | 1,301,982 |
| case30_ieee | 30 | 6 | 82 | 1,300,680 | 1,296,767 |
| case30_as | 30 | 6 | 82 | 1,300,200 | 1,284,562 |
| case39_epri | 39 | 10 | 92 | 1,300,211 | 1,301,635 |
| case57_ieee | 57 | 7 | 160 | 1,301,222 | 1,273,026 |
| case60_c | 60 | 23 | 176 | 1,302,069 | 1,300,858 |
| case73_ieee_rts | 73 | 99 | 240 | 1,300,405 | 1,301,531 |
| case89_pegase | 89 | 12 | 420 | 654,591 | 1,483,225 |
| case118_ieee | 118 | 54 | 372 | 1,300,742 | 1,301,781 |
| case162_ieee_dtc | 162 | 12 | 568 | 1,046,318 | 181,038 |
| case179_goc | 179 | 29 | 526 | 1,293,617 | 739,821 |
| case197_snem | 197 | 35 | 572 | 1,301,323 | 1,391,101 |
| case200_activ | 200 | 49 | 490 | 1,301,480 | 1,320,560 |
| case240_pserc | 240 | 143 | 896 | 1,011,541 | 260,102 |
| case300_ieee | 300 | 69 | 822 | 1,067,772 | 625,028 |
| case500_goc | 500 | 224 | 1,466 | 1,018,707 | 543,710 |
| case588_sdet | 588 | 167 | 1,372 | 1,427,568 | 622,209 |
| case793_goc | 793 | 214 | 1,826 | 1,414,878 | 405,521 |


## What the data consists of

At a high level, the dataset contains:

- benchmark power-grid topologies
- sampled and perturbed operating conditions
- simulated physical solutions
- graph-structured representations for ML
  
### Node features

| # | Feature | Name | PF-PQ | PF-PV | PF-REF | OPF-PQ | OPF-PV | OPF-REF | SE-PQ | SE-PV | SE-REF |
|---:|---|---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
| 0 | P_d | Active load demand | I | I | I | I | I | I | M | M | M |
| 1 | Q_d | Reactive load demand | I | I | I | I | I | I | M | M | M |
| 2 | Q_g | Reactive generation | I | O | O | I | O | O | M | M | M |
| 3 | V_m | Voltage magnitude | O | I | O | O | O | O | M | M | M |
| 4 | V_a | Voltage angle | O | O | I | O | O | I | O | O | O |
| 5 | PQ flag | PQ bus indicator | I | I | I | I | I | I | I | I | I |
| 6 | PV flag | PV bus indicator | I | I | I | I | I | I | I | I | I |
| 7 | REF flag | Slack bus indicator | I | I | I | I | I | I | I | I | I |
| 8 | V_m^min | Min. voltage magnitude | -- | -- | -- | I | I | I | I | I | I |
| 9 | V_m^max | Max. voltage magnitude | -- | -- | -- | I | I | I | I | I | I |
| 10 | Q_g^min | Min. reactive generation | -- | -- | -- | I | I | I | I | I | I |
| 11 | Q_g^max | Max. reactive generation | -- | -- | -- | I | I | I | I | I | I |
| 12 | G_s | Shunt conductance | -- | -- | -- | I | I | I | I | I | I |
| 13 | B_s | Shunt susceptance | -- | -- | -- | I | I | I | I | I | I |
| 14 | V_n (kV) | Nominal voltage | -- | -- | -- | I | I | I | I | I | I |

### Generator features

| # | Feature | Name | PF-PQ/PV | PF-REF | OPF | State Est. |
|---:|---|---|:---:|:---:|:---:|:---:|
| 0 | P_g | Active generation | I | O | O | M |
| 1 | P_g^min | Min. active generation | -- | -- | I | I |
| 2 | P_g^max | Max. active generation | -- | -- | I | I |
| 3 | c_0 | Cost constant term | -- | -- | I | I |
| 4 | c_1 | Cost linear coefficient | -- | -- | I | I |
| 5 | c_2 | Cost quadratic coefficient | -- | -- | I | I |

### Edge features

| # | Feature | Name | Power Flow | OPF | State Est. |
|---:|---|---|:---:|:---:|:---:|
| 0 | P_e | Active power flow | O | O | M |
| 1 | Q_e | Reactive power flow | O | O | M |
| 2 | Y_ff,r | From-from admittance (real) | I | I | I |
| 3 | Y_ff,i | From-from admittance (imag.) | I | I | I |
| 4 | Y_ft,r | From-to admittance (real) | I | I | I |
| 5 | Y_ft,i | From-to admittance (imag.) | I | I | I |
| 6 | tap | Transformer tap ratio | I | I | I |
| 7 | theta_min | Min. angle difference | -- | I | I |
| 8 | theta_max | Max. angle difference | -- | I | I |
| 9 | rate_A | Thermal rating (MVA) | -- | I | I |

- I = input feature
- O = output / target feature
- M = measured feature
- -- = not used


## Data source

The samples have been generated using **Gridfm-datakit** on the [**Future Technologies Partition**](https://www.nhr.kit.edu/userdocs/ftp/) on four intel sapphire rapids nodes. 
The underlying network cases (topologies and initial load and generation profiles) are based on **PGLib** benchmark systems, the perturbation framework is **Gridfm-datakit**.
The preprocessing from **Gridfm-graphkit** has been adapted to allow for larger dataset sizes.

## Perturbations applied during data generation

The data generation process in **gridfm-datakit** applies perturbations to create diverse operating conditions and topologies.

The perturbation types include:

### 1. Load perturbations
Load levels are randomly varied using a global scaling factor and local noise.

### 2. Topology and admittance perturbations
N-k perturbations are used to randomly cut off buses or edges. We used k=1.
Further, the resistance and reactance parameters are randomly scaled during the perturbation process.

### 3. Generation perturbations
The generators are perturbed by changing their cost coefficients. In OPF-mode, the generator setpoints are recalculated with an opf-solver
after topology and load perturbations have been applied. In PF-mode, an OPF-solver is only used BEFORE the perturbations. 

## Preprocessing

The raw power-system scenarios are preprocessed into a disk-backed heterogeneous graph format for efficient training and random access.

### Raw inputs

The preprocessing pipeline starts from three parquet tables per dataset split:

- `bus_data.parquet`
- `gen_data.parquet`
- `branch_data.parquet`

Each row belongs to a specific `scenario`, and each scenario corresponds to one graph sample.

### Scenario validation and filtering

Before graph construction, scenarios are validated for structural consistency.

In particular, scenarios are removed if their bus indices are invalid, i.e. if:

- bus IDs are duplicated, or
- bus IDs are not consecutive from `0` to `N-1`

This ensures that each scenario can be converted into a well-formed graph with a consistent node indexing scheme.

### Feature extraction

The preprocessing selects fixed feature subsets for buses, generators, and branches.

#### Bus features
Bus node features include electrical state, bus type indicators, and operating constraints:

- `Pd`, `Qd`
- `Qg`, `Vm`, `Va`
- `PQ`, `PV`, `REF` flags
- `min_vm_pu`, `max_vm_pu`
- `min_q_mvar`, `max_q_mvar`
- `GS`, `BS`
- `vn_kv`

#### Generator features
Generator node features include operating quantities and cost parameters:

- `p_mw`
- `min_p_mw`, `max_p_mw`
- `cp0_eur`, `cp1_eur_per_mw`, `cp2_eur_per_mw2`
- `in_service`

#### Branch features
Branch edge features include power-flow quantities, admittance terms, and branch constraints.

For each physical branch, the preprocessing creates **two directed edges**:
- one forward edge (`from_bus -> to_bus`)
- one reverse edge (`to_bus -> from_bus`)

The forward and reverse edges receive direction-specific attributes, e.g.:
- forward: `pf`, `qf`, `Yff_*`, `Yft_*`
- reverse: `pt`, `qt`, `Ytt_*`, `Ytf_*`

Shared branch attributes include:
- `tap`
- `ang_min`, `ang_max`
- `rate_a`
- `br_status`

### Bus-level aggregation of generator limits

Reactive power limits from generators are aggregated onto buses before graph construction.

For each `(scenario, bus)`, the preprocessing sums:
- `min_q_mvar`
- `max_q_mvar`

across all generators connected to that bus, and merges these totals into the bus feature table.

This enriches bus nodes with bus-level reactive capability information.

### Target construction

Task labels are derived from subsets of the selected features.

- **Bus targets** are taken from the leading subset of bus features
- **Generator targets** are taken from the leading subset of generator features
- **Branch targets** are stored separately as edge-level flow quantities

The exact interpretation of inputs and outputs depends on the downstream task (e.g. PF, OPF, state estimation, reconstruction).

### Heterogeneous graph construction

Each scenario is converted into a `HeteroData` graph with:

- **bus nodes**
- **generator nodes**
- **bus-to-bus edges** for physical branches
- **generator-to-bus edges**
- **bus-to-generator edges**

This yields a heterogeneous graph representation that preserves both the electrical network structure and generator attachment structure.

### Storage format

Instead of storing one file per scenario, the processed dataset is written into a small number of large NumPy memory-mapped arrays (`memmap`).

This avoids metadata overhead on large cluster file systems and enables efficient random access.

The processed directory contains arrays such as:

- `bus_x.npy`, `bus_y.npy`
- `gen_x.npy`, `gen_y.npy`
- `edge_index.npy`, `edge_attr.npy`, `edge_y.npy`
- `gen_bus_ei.npy`, `bus_gen_ei.npy`

along with an `index.pt` file containing per-scenario offsets.

Using these offsets, a single scenario can be loaded without materializing the full dataset in memory.

### Runtime loading and normalization

When a sample is accessed:

1. the corresponding slices are read from the memmap arrays,
2. a PyTorch Geometric `HeteroData` object is reconstructed,
3. edge indices are converted into PyG format,
4. feature normalization is applied at access time.

Normalization is therefore **not baked into the stored arrays**, but applied dynamically during dataset loading.