1. Introduction
Modern power grids are intricate, critical infrastructures that ensure the stability and efficiency of energy supply across vast regions, even the entire society [
1,
2,
3]. The complexity of these systems, characterized by their dynamic nature and the interdependence of various components, poses significant challenges for traditional analysis methods [
4]. As the global demand for energy continues to rise and the shift towards renewable and decentralized energy sources accelerates, such as solar and wind power, traditional power grids face significant operational challenges and the need for advanced analytical tools becomes increasingly urgent. Renewable sources introduce fluctuations, intermittency, and reduced inertia into the grid, complicating the task of maintaining stable power flow and frequency synchronization. These complexities are exacerbated by the integration of diverse, Distributed Energy Resources (DERs) and heightened susceptibility to cascading failures, which can trigger extensive blackouts and severely disrupt daily life and economic activities [
5].
Traditional power flow analysis methods, such as the numerical techniques based on Newton–Raphson or Gauss–Seidel algorithms and the solutions to power flow equations and deterministic stability analyses, increasingly struggle to meet the dynamic and uncertain nature of contemporary grids [
6,
7,
8,
9,
10]. Traditional numerical techniques require detailed system parameters and precise modeling of operating conditions, which can become inaccurate or unavailable due to aging infrastructure, incomplete information on DERs, and rapidly changing grid configurations. Furthermore, numerical approaches, which rely heavily on iterative solutions of complex nonlinear equations, can be computationally prohibitive for real-time monitoring and assessment of large-scale grid stability. Thus, there is an urgent need for innovative, robust methods that leverage data-driven and computationally efficient approaches to ensure the reliability and resilience of modern power grids under diverse operational conditions and potential disturbances. Under these circumstances, Graph Neural Networks (GNNs) have emerged as promising tools for analyzing and modeling power grid phenomena and complexities [
11,
12,
13,
14,
15]. GNNs are particularly well suited for power grid analysis due to their ability to model complex relationships and interactions between components in a graph structure, where nodes represent power system elements (e.g., generators, transformers, loads) and edges represent the physical connections between them. GNNs follow the message-passing paradigm, where information is exchanged between neighboring nodes to update their representations iteratively [
15,
16,
17].
For example, ref. [
18] presents a GNN-based model that learns to iteratively refine power flow solutions, providing a fast and accurate alternative to traditional numerical solvers for solving the nonlinear AC power flow equations. To address the problem that the optimal power flow problem is non-convex and not scalable to large power networks, while the DC optimal power flow approximation fails for heavily loaded grids, ref. [
19] uses IPOPT to compute optimal solutions for training set network states as labels, enabling GNNs to learn the mapping from network states to optimal power generation outputs for efficient inference. Ref. [
20] introduces a physics-informed neural network framework to approximate optimal power flow solutions while ensuring physical feasibility, thereby reducing computational cost and improving generalization. Ref. [
21] uses GNNs to learn mappings from power system states to optimal power flow solutions, aiming to provide fast, scalable approximations that can generalize across different grid topologies and loading conditions. Ref. [
22] proposes a method to solve the AC power flow problem using GNNs that are trained to approximate the solution efficiently while incorporating realistic operational constraints such as generator limits and voltage bounds. Ref. [
23] proposes techniques to improve GNN performance in predicting power flow by incorporating physical constraints and domain-specific augmentations, thereby increasing both prediction accuracy and generalization across different grid conditions. Ref. [
24] proposes PowerFlowNet, a GNN-based architecture, which transforms power flow into a node regression task, integrating a mask encoder (to distinguish known/unknown features) and stacked PowerFlowConv layers (combining message passing and TAGConv to aggregate node and edge features), and training with MSE or mixed loss functions to achieve fast and accurate power flow approximation.
Although these studies demonstrate the potential of GNNs in power grid analysis, they often focus on static or simplified models that do not fully capture the dynamic nature of modern power systems. Specifically, the failures of some critical components, such as transmission lines or transformers, can lead to cascading failures, i.e., cascading outages, and significant disruptions in power supply, which results in the topological changes of the power grid [
25,
26,
27]. Additionally, the changes in the power grid topology can significantly affect the power flow and stability of the system, making it crucial to develop GNN models that can adapt to these changes [
28,
29,
30,
31]. Most existing GNN-based methods for power grid analysis, however, still assume a fixed network topology throughout the computation, and thus completely ignore the intrinsically dynamic behavior of real-world grids. Only a few recent studies attempt to incorporate certain forms of dynamics, for example by modeling time-varying operating conditions or pre-defined switching events, but even these approaches rely on externally specified topology changes rather than enabling the GNN itself to autonomously learn and adapt the underlying graph structure from data. For instance, ref. [
32] proposes a physics-informed unsupervised power flow solver based on Typed Graph Neural Networks, which minimizes the power balance violations on different static power grid scenarios, including perturbed load/generation injections, adjusted branch parameters (e.g., resistance and reactance), and random single-branch outages designed to simulate topological variations. Yet, the “topological variations” it incorporates are merely independent, pre-defined static perturbations rather than the sequential, cascading topological changes that occur in real grid failures. Furthermore, many existing GNN-based methods suffers from the limitations of over-smoothing, where the node representations become indistinguishable after multiple layers of aggregation, leading to a loss of important local information, especially in the context of power grid analysis where local interactions and dependencies are crucial for accurate predictions [
33,
34,
35,
36].
To overcome the above limitations of existing GNN-based approaches, we propose a novel, dynamical GNN framework that explicitly integrates the evolution of grid topology into the learning process. Our main ideas can be summarized as follows:
Dynamic Topological Learning (DTL). We design a DTL module that enables the network to autonomously infer and update a data-driven adjacency structure conditioned on the current system state, instead of relying on a pre-specified, static network model or manually defined switching patterns. In this way, the GNN can directly learn how grid topology should evolve from data, rather than being constrained by externally imposed topology changes.
Adaptive Message-Passing (AMP). Based on the dynamically updated graph, we introduce an AMP module that performs representation learning while adaptively adjusting the strength and range of information propagation according to the learned topology and operating conditions. This allows the model to modulate message passing under different grid configurations and operating regimes.
Model-agnostic dynamical enhancement. The proposed design is model-agnostic: DTL and AMP can be seamlessly plugged into a wide range of existing GNN architectures, turning them into dynamic variants without altering their core design. This provides a generic way to endow conventional GNNs with topology-adaptive capabilities. By continuously reshaping the effective neighborhood structure and regulating the aggregation process, our framework naturally mitigates the over-smoothing effect and preserves critical local distinctions that are essential for accurate power system prediction and control.
Extensive experiments on multiple benchmark power grid datasets demonstrate that, compared with strong GNN baselines, our method enables them to consistently achieve lower errors on both power flow and optimal power flow tasks. The rest of the paper is organized as follows. In
Section 2, we briefly introduce the background of power grid analysis and the common GNNs. In
Section 3, we present our proposed GNN framework with dynamic message-passing mechanisms. In
Section 4, we describe the experimental setup and datasets used in our experiments, and we present the experimental results and analysis. Finally, we conclude the paper in
Section 5.
2. Related Work
In this section, we first explain the background of power grid analysis, including the power flow and optimal power flow problems, and then we introduce GNNs that follow the message-passing paradigm generally.
2.1. Power Flow Analysis
Power flow analysis (also known as load flow analysis) is a fundamental computational technique for determining the steady-state voltage magnitudes, angles, and branch power flows in electrical power systems [
37,
38,
39,
40,
41,
42]. It involves solving a set of nonlinear algebraic equations derived from Kirchhoff’s current and voltage laws, given specified generator outputs, load demands, and the network topology and electrical parameters (e.g., line admittances and impedances). Once solved, power flow analysis provides critical insights into the distribution of electrical power within the network.
Mathematically, the steady-state power flow equations for an
N-bus system can be expressed as:
where
represents the complex voltage at bus
i, and
denotes the elements of the bus admittance matrix. Solving this nonlinear equation system typically involves iterative numerical algorithms such as the Newton–Raphson or Gauss–Seidel methods. However, these conventional techniques can be computationally intensive, especially for large-scale networks, and their convergence performance heavily depends on accurate initial guesses and system conditions. Such limitations underscore the need for more computationally efficient and robust methods for modern, dynamic power grids.
Mathematically, the steady-state AC power flow of an
N-bus system can be written in compact complex form as a nodal power balance. At each bus
i, the net complex power injection equals the power delivered to the network through the bus admittance matrix:
where
and
denote the complex generated and demanded powers at bus
i,
is the complex bus voltage, and
is the
-th entry of the bus admittance matrix. Equation (
2) is the standard complex power flow equation obtained from
with
. For practical computation, the complex equation in (
2) is usually split into its real and imaginary parts, leading to the active and reactive power balance equations:
where
is the voltage angle difference between buses
i and
k. Together with the bus type specifications (slack, PV, and PQ buses), Equations (
3) and () define the full set of nonlinear equality constraints that must be satisfied by any physically feasible power flow solution. Solving these equations typically relies on iterative numerical algorithms such as the Newton–Raphson or Gauss–Seidel methods. However, these conventional techniques can be computationally intensive for large-scale networks, and their convergence performance heavily depends on accurate initial guesses and system conditions. These limitations motivate the search for more data-driven and computationally efficient alternatives for modern, dynamic power grids.
The optimal power flow (OPF) extends traditional power flow analysis by formulating a constrained optimization problem [
43,
44,
45]. Instead of only finding a feasible operating point, OPF seeks operating conditions that optimize an objective function, such as generation cost, losses, or emissions. A typical AC OPF formulation can be written as
subject to the power balance constraints at each bus
and the usual operational constraints:
Here, denotes the set of generator buses and denotes the set of transmission lines. These constraints enforce generator capability limits, bus voltage bounds, and thermal limits on line flows, respectively. Due to the nonlinear and non-convex nature, solving large-scale OPF problems in real time remains challenging, which has stimulated growing interest in fast, learning-based approximators such as GNNs.
2.2. Graph Neural Networks
We first introduce the notations used in this paper. We denote a graph as , where is the set of nodes, is the set of edges, and is the node feature matrix. Each node has a feature vector , where d is the dimension of the feature space. The adjacency matrix of the graph is denoted as A, where if there is an edge between nodes i and j, and 0 otherwise. Each edge may also have associated features, denoted as .
GNNs are a class of neural networks specifically designed to operate on graph-structured data, where the relationships between entities are represented as edges connecting nodes [
46]. GNNs have gained significant attention in recent years due to their ability to learn complex representations of graph-structured data and their applicability in various domains, including social networks, molecular chemistry, and power systems. Most GNNs follow the message-passing paradigm, where information is exchanged between neighboring nodes to update their representations iteratively. The message-passing process typically consists of two main steps: message aggregation and node update. In the message aggregation step, each node collects messages from its neighbors, which can be formulated as:
where
is the aggregated message for node
i at
t-th iteration,
and
are the hidden representations of neighboring node
j and node
i at the previous iteration, respectively, and
represents the edge features between nodes
i and
j. The aggregation function
can be a simple sum, mean, or more complex neural network-based function. In the node update step, each node updates its hidden representation based on the aggregated messages and its previous representation:
where
is typically a neural network function that combines the previous representation and the aggregated message to produce the new representation. The process of message aggregation and node update is repeated for multiple iterations, allowing nodes to exchange information with their neighbors and learn rich representations of the graph structure [
47,
48]. Based on this message-passing framework, various GNN architectures have been proposed, such as Graph Convolutional Networks (GCN) [
49], Graph Attention Networks (GAT) [
50], and Graph Isomorphism Networks (GIN) [
13], each with its own specific design choices for the aggregation and update functions.
4. Experiments
In this section, we conduct extensive experiments to evaluate the performance of our proposed GNN framework with dynamic message-passing mechanisms and compare it with existing GNN methods. Specifically, we design two groups of experiments. In the first group of experiments, we equip several representative GNN architectures with our DTL and AMP modules, and evaluate whether their performance on power flow and optimal power flow tasks can be consistently improved. This part aims to verify the effectiveness and generality of the proposed dynamic message-passing mechanisms. In the second group of experiments, we apply our framework to larger and more realistic power grid datasets, and retrofit different state-of-the-art baselines with our dynamic modules. This part is designed to assess the scalability and practical applicability of our approach under real-world-like operating conditions. We first describe the experimental setup, including the datasets used and the evaluation metrics. Then, we present the experimental results and analysis. In addition, we conducted experiments on the 19 test cases provided in the general PGLib-OPF repository [
54], which offers a curated benchmark set for the AC Optimal Power Flow problem. These cases cover networks ranging from a few dozen nodes to several thousand nodes. Our results, measured by MSE, MAE, and R
2, show that the proposed module improves the performance of the baseline GNN across a wide range of datasets. A more detailed set of results can be found in
Figure A1,
Figure A2 and
Figure A3 in the
Appendix A.
4.1. Experimental Setup
The first group of experiments is conducted on four power grid datasets following [
55]: IEEE24, IEEE39, IEEE118, and UK. These selected datasets mirror real-world-based power grids, offering a diverse array of scales, topologies, and operational characteristics. They provide comprehensive data essential for conducting cascading failure analysis. The second group of experiments is performed on a larger power grid dataset, RTE6470, which represents the French transmission system operated by RTE [
56]. This dataset encompasses 6470 buses and 9005 branches, reflecting a more complex and realistic power grid scenario. It includes detailed information on network topology, line parameters, generation capacities, and load profiles, making it suitable for evaluating the performance of GNNs in large-scale power flow and optimal power flow tasks. More detailed information about the datasets can be found in [
55,
56], and we provide a brief summary of the datasets in
Table 1.
For comprehensive evaluation, we compare our proposed framework with existing GNNs, including GCN [
49], GIN [
13], GAT [
50], TransformerConv [
51], and GATv2 [
13] in the first group of experiments. Note that these GNNs are are compatible with our proposed framework, and we call them as D-GCN, D-GIN, D-GAT, D-TransformerConv, and D-GATv2, respectively. All GNNs have two layers and are implemented using the PyTorch Geometric library. We use the Adam optimizer with a learning rate of 0.005 and a weight decay of 0.00005. The batch size is set to 128, and the number of epochs is set to 50 for training. We split the datasets into training, validation, and test sets with a ratio of 80:10:10. The performance of the models is evaluated using the Mean Absolute Error (MAE) and R-squared (R
2) regression metrics. We run the experiments five times with different random seeds and report the average results with standard deviations.
Then, we conduct the second group of experiments on the RTE6470 dataset. We compare our proposed framework with the SOTA baseline PowerFlowNet [
24], the classic GCN [
49], and the traditional numerical method Newton–Raphson (NR), Newton–Raphson with Iwamoto multiplier (Iwamoto) [
57], DC Power Flow (DCPF) [
58], Tikhonov regularization (Tikhonov) [
59]. We retrofit these baselines with our DTL and AMP modules, resulting in D-PowerFlowNet and D-GCN, respectively. The experimental settings are similar to those in the first group of experiments, with the same optimizer, learning rate, weight decay, batch size, number of epochs, and data split ratio. The performance is also evaluated using Mean squared error (MSE), MAE, and R
2 metrics. We run the experiments ten times with different random seeds and report the average results with standard deviations.
4.2. Effective Analysis of Dynamic Message-Passing Mechanisms
The results of the experiments are shown in
Table 2,
Table 3,
Table 4 and
Table 5. Among these tables,
Table 2 shows the MAE metric for different GNNs on power grid datasets with respect to power flow tasks,
Table 3 shows the R
2 metric for different GNNs on power grid datasets with respect to power flow tasks,
Table 4 shows the MAE metric for different GNNs on power grid datasets with respect to optimal power flow tasks, and
Table 5 shows the R
2 metric for different GNNs on power grid datasets with respect to optimal power flow tasks. All MAE values are scaled by a factor of 100 for easier comparison. The lower the MAE value, the better the performance of the model, while the higher the R
2 value, the better the performance of the model.
For the power flow tasks, we can see that our proposed framework boosts the performance of all GNNs almost on all cases, achieving lower MAE and higher R2 values compared to the baseline GNNs. Specifically, D-TransformerConv achieves the best performance on IEEE24, IEEE118, and UK datasets with lowest MAE of 9.3 × 10−3, 2.05 × 10−3, and 1.128 × 10−3, respectively, while D-GATv2 achieves the best performance on IEEE39 with lowest MAE of 1.268 × 10−3. Moreover, D-GATv2 achieves the best R2 values on IEEE39 with 97.7062, and D-TransformerConv achieves the best R2 values on UK with 98.4741 with 0.2737% and 0.0222% improvements compared to the baseline GNNs, respectively.
In addition, we visualize the performance of different GNNs on power grid datasets with respect to power flow tasks in
Figure 2 and
Figure 3. From these figures, we can observe that all GNNs perform worse on larger datasets, such as IEEE118, compared to smaller datasets, such as IEEE24. But our proposed framework consistently improves the performance of all GNNs across different datasets, indicating its effectiveness in enhancing the performance of GNNs in power grid analysis tasks.
For the optimal power flow tasks, we can also see the similar trend that our proposed framework improves the performance of all GNNs on almost all cases, achieving lower MAE and higher R2 values compared to the baseline GNNs. Specifically, D-TransformerConv achieves the best performance on IEEE24 with lowest MAE of 2.1440 × 10−2, while D-GATv2 achieves the best performance on IEEE39 with lowest MAE of 1.119 × 10−3, D-GATv2 achieves the best performance on IEEE39 and IEEE118 with lowest MAE of 1.643 × 10−3 and 3.896 × 10−3, respectively. Furthermore, D-GAT achieves the best R2 values on IEEE39 with 87.6967, and D-GATv2 achieves the best R2 values on IEEE118 with 71.5982. Notably, the D-GIN over four datasets improves the R2 values by 1.4074%, 1.3643%, 5.2347%, and 2.5480% respectively, and the D-GAT achieves the improvements of 0.7297%, 0.8699%, 22.8165%, and 1.9489% respectively, which demonstrates the effectiveness of our proposed framework in enhancing the performance of GNNs in optimal power flow tasks.
On the other hand, we can find that the performance of our proposed framework always exhibited lower standard deviations compared to the baseline GNNs, which indicates that our proposed framework is more stable and robust across different runs. This is particularly important in real-world applications where the performance of the model should be consistent and reliable.
4.3. Scalability and Practical Applicability
The experimental results on the large-scale RTE6470 system, i.e.,
Table 6, further highlight the computational behavior and practical value of different solvers when the network size increases. Numerical methods based on full AC equations, such as Newton–Raphson and the Iwamoto-accelerated variant, remain the reference for accuracy. However, their computation time grows rapidly with network dimension due to repeated factorization of large sparse Jacobian matrices. On the 6470-bus system, both solvers require more than 1100 s per evaluation, which limits their use in real-time decision tasks, large-scale contingency analysis, or fast what-if assessment. Linearized DC power flow demonstrates better scalability because it reduces the problem to a single linear system. Its computation time stays below 35 s even at this scale, but the larger loss leads to systematic errors. This gap becomes more pronounced when the network is heavily loaded or exhibits strong voltage coupling, reducing its practical reliability. Tikhonov-based reconstruction is conceptually appealing because it integrates graph smoothness into the solution process. However, in large networks its main computation involves the inversion of graph Laplacian matrices. As the matrix dimension grows, this operation becomes a major bottleneck, resulting in the highest runtime among all tested baselines. The method’s accuracy also degrades in heterogeneous loading conditions, indicating limited robustness to variations in physical operating points.
The MLP shows fast inference because all computations are fully vectorized and independent of the network’s topology. However, the absence of structural information restricts its ability to generalize across diverse loading patterns. GCN improves structural modeling through graph convolutions but suffers from fixed neighbor aggregation and excessive smoothing, which reduces accuracy when the system exhibits heterogeneous impedance patterns and diverse operational regimes. PowerFlowNet and its dynamic variant show better scalability characteristics. PowerFlowNet integrates edge attributes, multi-hop propagation, and a mask-aware design, allowing the model to capture the electrical interactions of large networks without a substantial increase in computation time. Its runtime remains on the order of a few seconds even for the 6470-bus case, much faster than numerical solvers and significantly more accurate than linearized or purely data-driven baselines. The dynamic version, D-PowerFlowNet, further enhances applicability by adjusting message weights according to the current operating point. This adaptive mechanism improves the model’s ability to reflect load variations, line flow redistribution, and the heterogeneous role of branches in different scenarios. The RTE6470 results confirm that this flexibility yields consistent improvements in both MAE and MSE while keeping the computation overhead modest. These properties indicate that dynamic message passing provides a more responsive representation of large grids compared to static graph convolutions.
To further verify how the dynamic module affects the optimization behavior of different models, we plot the full training trajectories of GCN and PowerFlowNet before and after adding the dynamic module. Specifically, we record the training loss, validation loss, and cumulative training time for 100 epochs, shown in
Figure 4. The training curves further demonstrate the effect of introducing the dynamic module into both GCN and PowerFlowNet. For each architecture, the dynamic variant achieves a faster decrease in training loss during the early epochs and reaches a lower validation loss overall. This indicates that the dynamic module provides more informative and adaptive structural signals, enabling the model to optimize more efficiently and generalize more reliably. Although the dynamic module introduces a slight increase in computation per epoch, the cumulative training time grows linearly and remains well controlled. The additional cost is therefore acceptable relative to the improvement in convergence speed and final accuracy.
Overall, the results suggest that the proposed dynamic message-passing mechanisms offer a favorable balance between accuracy, scalability, and computational efficiency, making them suitable for large-scale power flow approximation and real-time operational applications. Their ability to exploit network structure while maintaining low inference cost underscores their practical value in modern power systems with increasing size and variability.