Solving the alternating current power flow equations in real time is essential for secure grid operation, yet classical Newton-Raphson solvers can be slow under stressed conditions. Existing graph neural networks for power flow are typically trained on a single system and often degrade on different systems. We present PowerModelsGAT-AI, a physics-informed graph attention network that predicts bus voltages and generator injections. The model uses bus-type-aware masking to handle different bus types and balances multiple loss terms, including a power-mismatch penalty, using learned weights. We evaluate the model on 14 benchmark systems (4 to 6,470 buses) and train a unified model on 13 of these under N-2 (two-branch outage) conditions, achieving an average normalized mean absolute error of 0.89% for voltage magnitudes and R^2 > 0.99 for voltage angles. We also show continual learning: when adapting a base model to a new 1,354-bus system, standard fine-tuning causes severe forgetting with error increases exceeding 1000% on base systems, while our experience replay and elastic weight consolidation strategy keeps error increases below 2% and in some cases improves base-system performance. Interpretability analysis shows that learned attention weights correlate with physical branch parameters (susceptance: r = 0.38; thermal limits: r = 0.22), and feature importance analysis supports that the model captures established power flow relationships.
Figures & tables
Bus Type
Known in yi
Unknown Targets
Mask [Vm,δ,Pg,Qg]
PQ (Load)
Pg,Qg
Vm,δ
[1, 1, 0, 0]
PV (Generator)
Pg,Vm
δ,Qg
[0, 1, 0, 1]
Slack
Vm,δ
Pg,Qg
[0, 0, 1, 1]
TABLE I: Bus-Type Unknown Targets and Supervision Masks.
Fig. 1: PowerModelsGAT-AI Architecture. The framework comprises (1) a bus-type-aware input stage with a supervision mask, (2) an encoder stack of 4 Pre-Norm Residual GATv2 blocks, (3) a shared decoding trunk, (4) multi-head outputs for Vm,δ,Pg,Qg , and (5) a physics-informed loss Lphy . Red dashed lines indicate how predicted outputs and the supervision mask feed into the physics-informed loss Lphy .
Fig. 2: PowerModelsGAT-AI Performance across 13 Power Systems. Parity plots compare model predictions (y-axis) against the Newton–Raphson reference solution (x-axis) for all unknown variables in the unified 13-system training and test sets; color intensity represents point density.
Base (Unadapted)
Naive
EWC+Replay
Target
NMAE%
R 2
NMAE%
R 2
NMAE%
R 2
Vm
12.98
−2.36
1.44
0.945
1.90
0.907
δ
11.96
−0.01
0.61
0.99
0.68
0.99
Pg
20.79
0.01
0.42
0.99
0.45
0.99
Qg
1.61
0.02
0.15
0.994
0.17
0.994
TABLE II: Target System ( case1354pegase ) Performance After Fine-Tuning.
State Variable
Naive
EWC+Replay
Voltage Magnitude ( Vm )
12.00
0.26
Voltage Angle ( δ )
138.23
0.12
Active Power ( Pg )
1891.82
1.25
Reactive Power ( Qg )
103.79
1.54
TABLE III: Average Knowledge Loss ( KˉτNMAE ) on Base Systems.
Fig. 3: Learned Branch Importance Maps. Darker edges indicate higher importance. (a) case14 : the model assigns higher importance to key branches. (b) case57 : importance scores vary across the system.
Fig. 4: Analysis of Branch Importance Scores. (a) Correlation between branch importance and physical branch parameters. (b) Distribution of branch importance scores across benchmark systems.
Fig. 5: Global Stability of Bus Feature Sensitivity. Boxplots show the distribution of normalized bus feature sensitivity scores across 13 systems for (a) Vm , (b) δ , (c) Pg , and (d) Qg .
Figure 20Figure 21Figure 22Figure 23
Appendix figures & tables11 assets
Supplementary material from the paper’s appendix.
Appendix
Feature
Symbol
Description
Unit
Electrical Properties
Nominal Voltage
Vn
Rated voltage level of the bus
kV
Active Load
Pd
Active power demand at the bus
p.u.
Reactive Load
Qd
Reactive power demand at the bus
p.u.
Active Generation Setpoint
Pgset
Scheduled active power generation
p.u.
Voltage Setpoint
Vmset
Voltage magnitude setpoint (PV and Slack buses)
p.u.
Appendix
TABLE IV: Node Feature Definitions ( xi∈R23 + one-hot bus type). Complete specification of bus-level input features used by PowerModelsGAT-AI. See Sec. II-C for details.
Feature
Symbol
Description
Unit
Series Admittance (Edge Terms)
Conductance
G
Real part of the series-admittance edge term
p.u.
Susceptance
B
Imaginary part of the series-admittance edge term
p.u.
Branch Type (One-Hot)
Line
—
Transmission line
{0,1}
Transformer
—
Power transformer
{0,1}
Appendix
TABLE V: Edge Feature Definitions ( eij∈R7 ). Branch-level attributes for each directed branch edge, encoding series admittance (implemented as directed off-diagonal branch-admittance edge terms), one-hot branch type, and thermal limit.
System
Total
PQ (Load)
PV (Gen)
Slack
case4gs
4
2
1
1
case5
5
1
3
1
case6ww
6
3
2
1
case9
9
6
2
1
case14
14
9
4
1
case30
30
24
5
1
Appendix
TABLE VI: Bus Type Distribution by System. Breakdown of bus counts per system, classified by bus type (PQ, PV, and Slack).
N-0 (%)
N-1 (%)
N-2 (%)
System
Train
Test
Train
Test
Train
Test
case4gs
49.5
50.1
50.5
49.9
—
—
case5
36.1
33.7
35.7
34.4
28.2
31.9
case6ww
35.0
32.1
33.1
33.2
31.9
34.7
case9
60.5
60.0
39.5
40.0
—
—
case14
36.3
35.4
33.7
34.4
30.0
30.2
Appendix
TABLE VII: Contingency Distribution for System-Specific Models ( N−2 Training and Test Sets).
N-0 (%)
N-1 (%)
N-2 (%)
Model
Train
Test
Train
Test
Train
Test
Unified (13 Systems)
40.3
41.8
36.2
35.1
23.5
23.1
Base (12 Systems)
39.5
41.5
37.3
35.6
23.2
22.8
Appendix
TABLE VIII: Contingency Distribution for Unified Models ( N−2 Training and Test Sets). Each system contributes 2,000 scenarios. Comparisons show the stability of the contingency distribution across training and test sets.
System
Target
MSE
RMSE
MAE
R 2
NMAE%
case4gs
Vm [ p.u. ]
1.134\times10−07
3.368\times10−04
2.672\times10−04
0.9996
0.2652
δ [ \SIUnitSymbolDegree ]
4.121\times10−04
0.02030
0.01481
0.9999
0.1274
Pg [ p.u. ]
6.434\times10−04
0.02536
0.01849
0.9996
0.2794
Qg [ p.u. ]
5.654\times10−04
0.02378
0.01832
0.9995
0.3571
case5
Vm [ p.u. ]
1.290\times10−07
3.592\times10−04
3.017\times10−04
0.9996
0.3619
δ [ \SIUnitSymbolDegree ]
0.001159
0.03405
0.02628
0.9998
0.2556
Appendix
TABLE IX: System-Specific Baseline Performance ( N−0 ). Per-system metrics for system-specific models described in Sec. VI-A . Each model is trained and evaluated on its respective system under normal operating conditions (no element outages).
System
Target
MSE
RMSE
MAE
R 2
NMAE%
case4gs
Vm [ p.u. ]
2.597\times10−07
5.096\times10−04
3.502\times10−04
0.9997
0.1353
δ [ \SIUnitSymbolDegree ]
0.002268
0.04762
0.03280
0.9999
0.0763
Pg [ p.u. ]
3.522\times10−04
0.01877
0.01517
0.9998
0.2552
Qg [ p.u. ]
3.339\times10−04
0.01827
0.01441
0.9997
0.2031
case5
Vm [ p.u. ]
2.116\times10−07
4.600\times10−04
3.145\times10−04
0.9996
0.2614
δ [ \SIUnitSymbolDegree ]
0.03161
0.1778
0.09841
0.9987
0.2410
Appendix
TABLE X: System-Specific Contingency Performance ( N−2 ). Per-system metrics for system-specific models described in Sec. VI-B . Each model is trained and evaluated on scenarios with up to two simultaneous branch outages, testing robustness under severe ( N−2 ) contingencies.
System
Target
MSE
RMSE
MAE
R 2
NMAE%
case4gs
Vm [ p.u. ]
2.147\times10−06
0.001465
0.001032
0.9978
0.5636
δ [ \SIUnitSymbolDegree ]
0.1484
0.3852
0.2606
0.9938
0.6885
Pg [ p.u. ]
0.006864
0.08285
0.05996
0.9953
1.0250
Qg [ p.u. ]
0.009688
0.09843
0.07650
0.9914
1.2720
case5
Vm [ p.u. ]
2.283\times10−06
0.001511
0.001147
0.9946
1.1010
δ [ \SIUnitSymbolDegree ]
0.4478
0.6692
0.4484
0.9832
1.0560
Appendix
TABLE XI: Unified PowerModelsGAT-AI Performance Across All 13 Systems ( N−2 Contingencies). Per-system breakdown for results discussed in Sec. VI-C .
N-0 (Normal)
N-1 Contingency
N-2 Contingency
System
Target
MSE
MAE
R 2
MSE
MAE
R 2
MSE
MAE
R 2
case4gs
Vm [ p.u. ]
8.439\times10−07
0.000726
0.9972
3.296\times10−06
0.001300
0.9975
–
–
–
δ [ \SIUnitSymbolDegree ]
0.05531
0.1771
0.9873
0.2326
0.3360
0.9944
–
–
–
Pg [ p.u. ]
0.006174
0.05699
0.9955
0.007497
0.06261
0.9951
–
–
–
Qg [ p.u. ]
0.007493
0.06966
0.9927
0.01166
0.08261
0.9902
–
–
–
case5
Vm [ p.u. ]
1.123\times10−06
0.000845
0.9964
2.462\times10−06
0.001220
0.9940
3.641\times10−06
0.001473
0.9930
Appendix
TABLE XII: Unified PowerModelsGAT-AI Performance Across Systems under N−0 , N−1 , and N−2 Contingencies. Comparison of Mean Squared Error (MSE), Mean Absolute Error (MAE), and Coefficient of Determination ( R2 ) for voltage magnitude, voltage angle, and power generation.
System
KVmNMAE
KδNMAE
KPgNMAE
KQgNMAE
Naive
EWC+Replay
Naive
EWC+Replay
Naive
EWC+Replay
Naive
EWC+Replay
case4gs
19.53
0.05
258.30
−0.05
1433.74
1.14
40.41
1.25
case5
9.91
0.69
219.00
0.04
721.58
1.21
12.90
0.80
case6ww
18.37
0.24
245.35
0.20
2887.41
1.62
121.43
1.88
case9
10.38
0.21
41.72
0.10
1493.63
1.58
110.11
3.20
case14
7.50
0.29
59.09
0.14
2912.61
2.26
303.94
2.32
Appendix
TABLE XIII: Per-System Knowledge Loss ( KτNMAE ) After Fine-Tuning on case1354pegase . Per-system values are reported for Naive and EWC+Replay across all base systems.
System
KVmMAE [ p.u. ]
KδMAE [ \SIUnitSymbolDegree ]
KPgMAE [ p.u. ]
KQgMAE [ p.u. ]
Naive
EWC+Replay
Naive
EWC+Replay
Naive
EWC+Replay
Naive
EWC+Replay
case4gs
0.04
0.00
97.77
−0.02
83.87
0.07
2.43
0.08
case5
0.01
0.00
92.95
0.02
72.30
0.12
3.65
0.23
case6ww
0.05
0.00
77.70
0.06
67.03
0.04
4.39
0.07
case9
0.03
0.00
38.91
0.10
56.05
0.06
1.96
0.06
case14
0.02
0.00
36.21
0.08
82.02
0.06
10.61
0.08
Appendix
TABLE XIV: Per-System Knowledge Loss ( KτMAE ) in Physical Units After Fine-Tuning on case1354pegase . Per-system values are reported for Naive and EWC+Replay across all base systems.
Pattern Recognition Lab, Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany · Institute of Electrical Energy Systems, Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany
Pattern Recognition Lab, Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany · Institute of Electrical Energy Systems, Friedrich-Alexander-Universität Erlangen-Nürnberg, Germany