With the rise of renewable energy sources and their high variability in generation, the management of power grids becomes increasingly complex and computationally demanding. Conventional AC-power-flow simulations, which use the Newton-Raphson (NR) method, suffer from poor scalability, making them impractical for emerging use cases such as joint transmission-distribution modeling and global grid analysis. At the same time, purely data-driven surrogate models lack physical guarantees and may violate fundamental constraints. In this work, we propose Differentiable Power-Flow (DPF), a reformulation of the AC power-flow problem as a differentiable simulation. DPF enables end-to-end gradient propagation from the physical power mismatches to the underlying simulation parameters, thereby allowing these parameters to be identified efficiently using gradient-based optimization. We demonstrate that DPF provides a scalable alternative to NR by leveraging GPU acceleration, sparse tensor representations, and batching capabilities available in modern machine-learning frameworks such as PyTorch. DPF is especially suited as a tool for time-series analyses due to its efficient reuse of previous solutions, for N-1 contingency-analyses due to its ability to process cases in batches, and as a screening tool by leveraging its speed and early stopping capability. The code is available in the authors' code repository.
Figures & tables
Figure 1: Schematic view of the components of the energy grid and the current applications of power flow calculations.
Name
Description
Usage
Direct methods
DC approx. ( Qi et al., 2012 )
Remove nonlinearities and solve linear system
Screening
HELM ( Trias, 2012 )
Embed power-flow equation into holomorphic function
Guaranteed solution
Iterative methods based on fix-point-iterations
GS ( Grainger, 1999 )
Rewrite power equation as a fix-point iteration and update buses sequentially
Educational
SA ( Giraldo et al., 2022 )
Rewrite power equation as fix-point iteration and update buses simultaneously
Figure 2: The figure depicts the operational graph of the power balance equation. The calculated power Scalc (depending on the current voltage vector) and the actual power Sbus are formed and their active/reactive components are used in ycalc and y to create the loss function. The green colored variables, namely the voltage magnitude of PV-buses and the voltage angle of PV and PQ buses, are trainable and are used as the voltage solution after training.
IEEE118
Case9241pegase
Optimizer
Adam
Optimizer parameters
lr ( η )
0.0034
0.0001
decay ( β )
(0.979,0.963)
Scheduler
Reduce lr on plateau
Scheduler parameters
factor
0.547
patience
41
Table 2: Hyperparameters for DPF on the small 118-bus and the large 9,241-bus grid.
IEEE118 t=0
IEEE118 t>0
Optimizer
Adam
Optimizer parameters
lr ( η )
0.03564
0.00027
decay ( β )
(0.9802,0.9440)
(0.7847,0.6624)
Scheduler
Step lr
Reduce lr on plateau
Scheduler parameters
step
100
γ
0.773
Table 3: Hyperparameter settings for Time Series on IEEE118 with time step t .
Figure 3: Comparison of our Differentiable Simulation (blue), NR (red) and the DC-approximation (green) on CPU without data loading time. Left: the IEEE-118 grid, right: case9241pegase grid. In both cases our differentiable simulation is slower than NR but the solution quality lies between NR and DC.
Figure 4: Scaling behavior of DPF (braces show the number of iterations), NR and DC. While on CPU (left) the scaling seems similar between the different approaches, on GPU (right) the better scaling behavior becomes apparent. Yet for a grid size of 9,241 NR is still faster, as our gradient-based approach needs about 1,000 iterations in its base form for convergence.
Figure 5: Solution distance of previous solutions (or initialization) to the solution of the next time step for the IEEE-118 grid. Subsequent time-steps have very similar grids, and as a result, very similar solutions.
Figure 6: Training curves for a time series application use case for the IEEE-118 grid. The first time step (left) needs a full fitting of roughly 1,000 iterations. Albeit slow, needs to be performed only once per grid and can possibly be replaced by Newton-Raphson. Subsequent time steps (right), using the first as initial guess, only require 100 iterations to reach a plateau in solution quality.
Figure 7: Normalized time per power-flow using batching on the case9241pegase grid. Without batching, a time of about 2ms per iteration and power-flow is needed while a time of 0.45ms per iteration and power-flow is achieved at a batch size of 64.
Figure 8: Scaling behavior with respect to grid characteristics. For node scaling (left), we increase the number of nodes in the grid by copying the case9241pegase grid and making few ( 20∗#copies ) random connections throughout the combined grid. In case of edge scaling (right), we insert an increasing amount of random connections to the case9241pegase grid, adding two new non-zero entries (due to symmetry) per connection into the Ybus matrix consisting of 37,655 non-zero entries. DPF is almost unaffected (rises from 4.7s to 5.2s ) while the runtime of NR increases significantly.
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
Power-flow times using NR in ms
Grid
Size
RC
No RC
TS
CA
case14
14
0.0204
0.0491
0.00790
0.0171
case118
118
0.1180
0.3206
0.0506
0.0746
case_illinois200
200
0.2447
0.5842
0.1032
0.1705
case300
300
0.4501
0.9606
0.2521
0.3341
case1354pegase
1,354
2.3303
4.0754
1.2324
1.5423
Appendix
Table 4: LightSim2Grid times on our device in ms . Compared are times of power-flows for changing grids with and without recycling (RC), power-flows for fixed grids on time series (TS) and times for contingency analysis (TS). The runtime scaling appears to be between linear and quadratic. The fastest times are achieved for time series as the grid (and therefore the admittance matrix and the sparsity structure of the Jacobian) stays the same and can be reused.