Power system forced oscillation positioning method based on space-time attention mechanism
Patent Information
- Application Number
- CN202610212560.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-13
- Publication Date
- 2026-08-18
- Estimated Expiration
- 2046-02-13
AI Technical Summary
[0015]本发明通过提供一种基于时空注意力机制的电力系统强迫振荡定位方法,解决了现有技术中在复杂时空关联建模上不足、依赖于精确模型、对噪声敏感、在多源或复杂振荡场景下定位精度不足的问题,实现了高精度的单源强迫振荡定位,同时具备处理多源振荡场景的能力,显著提升定位的鲁棒性与泛化性能
本发明通过获取电力系统各节点的运行时序数据,并对各节点的运行时序数据进行预处理,得到标准化的时空输入数据。预处理步骤包括缺失值填补、异常值修正、归一化或标准化等操作,其有益效果在于:消除不同量纲对数据分布的影响,提高不同节点、不同时刻数据之间的可比性,保证后续模型输入的数值稳定性与一致性,为模型有效学习时空模式奠定干净、规范的数据基础。基于电网拓扑结构构建加权归一化的邻接矩阵。根据实际电力线路的阻抗、导纳或电气距离等物理参数设定边权重,并对权重进行归一化处理,得到邻接矩阵。此步骤的有益效果在于:将电网拓扑结构及其电气特性编码为紧凑的矩阵形式,使图神经网络能够显式利用空间连接信息;加权归一化不仅保留了节点间关联强度的差异性,还避免了邻接矩阵数值过大导致的梯度爆炸问题,增强了模型训练的稳定性。将标准化的时空输入数据和加权归一化的邻接矩阵输入至预训练的时空注意力模型中。预训练过程利用大量历史振荡案例使模型充分学习振荡模式,有益效果在于:模型已具备对振荡源特征的先验认知,后续使用时仅需微调或直接推断,大幅提高定位效率与泛化能力,降低了对在线标注样本的依赖。时空注意力模型首先通过输入投影层将时空输入数据经线性变换映射至高维特征空间,得到高维特征张量。此步骤的有益效果在于:通过可学习的线性投影,将原始低维观测数据嵌入到更丰富的高维表示空间,增强特征的表达能力,为后续复杂时空依赖关系的捕获提供足够的维度容量。接着,嵌入增强层对高维特征张量进行节点属性与时序属性的联合嵌入增强,生成时空嵌入特征张量。该层通常引入可学习的节点嵌入向量和时间位置编码,并将其与高维特征相加或拼接。有益效果在于:使模型能够显式区分不同节点的固有特性和不同时刻的时间位置信息,强化时空上下文感知能力,避免将异质节点混为一谈,同时保留时序先后关系,从而提升振荡模式辨识的准确性。
Smart Images

Figure CN122112818B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power system stability analysis and fault location technology, and in particular to a method for locating forced oscillations in power systems based on a spatiotemporal attention mechanism. Background Technology
[0002] Forced oscillations in power systems refer to system oscillations caused by external periodic disturbances, such as improper control strategies of new energy units like wind turbines and photovoltaic power plants, periodic load fluctuations, and sudden changes in transmission line parameters. Their frequency is typically close to the system's natural frequency. If the disturbance source is not located and eliminated in a timely manner, the oscillation amplitude may continue to amplify, leading to serious accidents such as voltage collapse and power angle instability, threatening the safe and stable operation of the power grid. Therefore, quickly and accurately locating the source of forced oscillations is one of the key technologies for ensuring the safe operation of the power system.
[0003] Power systems are typical complex spatiotemporally coupled systems, and the propagation of forced oscillations exhibits significant spatial correlations, depending on the power grid topology and temporal dynamics, such as the evolution of oscillation amplitude and frequency over time. Existing forced oscillation localization methods are mainly divided into three categories: Signal processing-based methods, such as Prony analysis, wavelet transform, and Hilbert-Huang transform (HHT), locate oscillation sources by extracting features such as frequency, amplitude, and phase of the oscillating signal. These methods are simple in principle and have low computational cost, but they are weak in noise immunity, have difficulty processing multimodal oscillation signals, and do not consider the spatial correlation characteristics of the power grid topology, resulting in limited location accuracy.
[0004] Model-based reasoning methods, such as the energy function method and dominant oscillation mode identification method, analyze the propagation path of oscillation energy and locate the oscillation source by establishing an electromechanical transient model of the power system. However, these methods rely on precise system model parameters, while actual power system parameters are time-varying and difficult to obtain accurately, resulting in poor generalization and unsuitability for complex power grids.
[0005] Traditional machine learning methods, such as Support Vector Machines (SVM) and Random Forests (RF), locate oscillation sources by extracting signal features and training classification models. However, these methods do not fully exploit the spatiotemporal coupling characteristics of oscillation signals, lack adaptability to multi-source oscillations and complex operating conditions, and their location accuracy needs improvement.
[0006] In recent years, deep learning technology has made groundbreaking progress in the field of spatiotemporal sequence analysis (such as traffic flow prediction and weather forecasting). Its powerful feature extraction capabilities have provided new ideas for dealing with the spatiotemporal coupling problem of forced oscillations in power systems. Attention mechanisms, as one of the core technologies of deep learning, can adaptively focus on key information: spatial attention can capture the strong and weak correlations between nodes in the power grid, highlighting the characteristics of nodes near the oscillation source; temporal attention can focus on the critical periods of oscillation development, suppressing interference from invalid time-series information. Applying spatiotemporal attention mechanisms to forced oscillation localization can fully utilize the spatial characteristics of the power grid topology and the temporal characteristics of the oscillation signal, providing a theoretical basis for improving positioning accuracy and anti-interference capabilities.
[0007] Currently, research on deep learning in power system oscillation analysis is gradually increasing, and related technical solutions mainly focus on the following directions: A CNN-LSTM hybrid model is proposed based on a simple method of fusing spatiotemporal features. This model uses CNN to extract spatial features and LSTM to extract temporal features to achieve oscillation source localization. However, this method employs a simple feature concatenation approach to fuse spatiotemporal information, failing to consider the dynamic coupling relationship between spatiotemporal features and lacking an adaptive mechanism for focusing on key information. It also exhibits weak noise resistance and its localization performance degrades significantly in low signal-to-noise ratio scenarios.
[0008] Spatial feature extraction method based on graph neural network (GNN): Reference [2] proposes an oscillation source localization method based on graph convolutional neural network (GCN), which models the power grid topology as a graph structure and extracts the spatial correlation features of nodes through graph convolution. Such methods emphasize spatial correlation, but do not fully explore the time dynamic evolution features of oscillation signals, and are not adaptable to dynamic scenarios such as sudden changes in oscillation frequency and amplitude fluctuations. Moreover, the local feature aggregation capability of GCN is limited, making it difficult to focus on key oscillation propagation paths.
[0009] Improved methods based on attention mechanisms: Reference [3] introduces the attention mechanism into power system analysis and uses self-attention (Transformer) to capture long-term dependencies on time series. However, this method only focuses on a single dimension (time) and lacks a unified spatiotemporal attention framework to collaboratively model the dynamic spatiotemporal patterns of oscillations propagating in the power grid.
[0010] Based on the research and analysis of existing methods, their core shortcomings can be summarized as follows: Insufficient extraction of spatiotemporal features: Existing methods either use simple splicing to fuse spatiotemporal features or only focus on spatial features, or use attention mechanisms that only focus on a single dimension (time or space), failing to fully explore the spatiotemporal coupling relationship of oscillation signals, making it difficult to accurately characterize the propagation law and dynamic evolution process of oscillations.
[0011] Insufficient ability to focus key information: It lacks a unified adaptive attention mechanism that takes into account both time and space, and cannot focus on key nodes near the oscillation source and key periods of oscillation development. It is susceptible to interference from power grid noise and irrelevant node signals, resulting in low positioning accuracy.
[0012] It is difficult to balance single-source and multi-source scenarios: Most existing methods are designed for single-source oscillations, and localization fails in multi-source scenarios; or they are optimized for multi-source oscillations, but the models are complex, have poor real-time performance, and lack versatility in single-source scenarios.
[0013] Weak generalization and noise resistance: Relying on accurate system model parameters or a large amount of labeled data, it is not adaptable enough to complex operating conditions such as changes in power grid topology, fluctuations in oscillation frequency, and noise interference, thus limiting its practical application.
[0014] Insufficient real-time performance: Some deep learning methods, such as complex GNN models and multi-stage clustering methods, have a large number of parameters and high computational complexity, making it difficult to meet the needs of real-time monitoring of power systems. Summary of the Invention
[0015] This invention provides a power system forced oscillation localization method based on a spatiotemporal attention mechanism, which solves the problems of insufficient modeling of complex spatiotemporal correlations, reliance on accurate models, sensitivity to noise, and insufficient localization accuracy in multi-source or complex oscillation scenarios in existing technologies. It achieves high-precision single-source forced oscillation localization and has the ability to handle multi-source oscillation scenarios, significantly improving the robustness and generalization performance of localization.
[0016] This invention provides a method for locating forced oscillations in power systems based on a spatiotemporal attention mechanism. The method includes: The runtime sequence data of each node in the power system is acquired, and the runtime sequence data of each node is preprocessed to obtain standardized spatiotemporal input data. Meanwhile, a weighted normalized adjacency matrix is constructed based on the power grid topology. ; The spatiotemporal input data and the adjacency matrix The input is fed into a pre-trained spatiotemporal attention model to obtain the probability distribution of the oscillation source nodes. And according to the probability distribution Obtain the probability distribution of each node as an oscillation source. The location of the oscillation source is then obtained; wherein, the spatiotemporal attention model includes: an input projection layer, an embedding enhancement layer, a spatial attention module, a temporal attention module, and a classifier; The input projection layer is used to project the spatiotemporal input data. By mapping to a high-dimensional feature space through a linear transformation, a high-dimensional feature tensor is obtained. ; The embedding enhancement layer is used to enhance the high-dimensional feature tensor. Joint embedding enhancement of node attributes and temporal attributes is performed to obtain the spatiotemporal embedding feature tensor. ; The spatial attention module is used to perform tasks based on the weighted normalized adjacency matrix. For the spatiotemporal embedding feature tensor Attention calculation and feature aggregation are performed between nodes to obtain the spatially augmented feature tensor. ; The temporal attention module is used to process the spatial augmentation feature tensor. Attention calculation and feature aggregation are performed in the time dimension to obtain the spatiotemporal fusion feature tensor. ; The classifier is used to process the spatiotemporal fusion feature tensor. Perform global average pooling and fully connected classification to output the probability distribution of each node as an oscillation source. .
[0017] In one possible implementation, the runtime sequence data of each node is preprocessed to obtain standardized spatiotemporal input data. ,include: Missing and outlier detection is performed on the runtime sequence data of each node, and interpolation methods are used to complete the missing data. Four types of features—oscillation amplitude, oscillation frequency, oscillation phase, and damping ratio—are extracted from the runtime sequence data of each node to form the feature vector of each node; The feature vectors are Z-score standardized to eliminate dimensional differences, and the standardized feature vectors are arranged in chronological order to construct spatiotemporal input data. Wherein: the spatiotemporal input data The dimension is N×F×L, where N is the number of nodes, F is the number of features, and L is the length of the time series.
[0018] In one possible implementation, the weighted normalized adjacency matrix is constructed based on the power grid topology. ,include: Map the actual power grid node numbers to consecutive indices to construct a node mapping table; The initial node mapping table and the branch connection relationship of the power grid topology are used to construct the initial node mapping table. ; Combined with the branch parameters, the initial adjacency matrix We perform weighted adjacency calculations to obtain the weighted adjacency matrix. ; For the weighted adjacency matrix Symmetric normalization is performed to obtain a weighted normalized adjacency matrix. .
[0019] In one possible implementation, the embedding enhancement layer includes: a node embedding layer and a temporal embedding layer; The node embedding layer is used for processing the high-dimensional feature tensor. Add a learnable node embedding vector to each node in the algorithm. The node embedding feature tensor is obtained. ; The temporal embedding layer is used to embed feature tensors into the nodes. Add a learnable temporal embedding vector to each time step. The spatiotemporal embedding feature tensor is obtained. .
[0020] In one possible implementation, the spatial attention module includes: a spatial QKV projection layer, a spatial attention computation layer, a spatial topology constraint weighting layer, and a spatial attention aggregation layer; The adjacency matrix based on the weighted normalization For the spatiotemporal embedding feature tensor Attention calculation and feature aggregation are performed between nodes to obtain the spatially augmented feature tensor. ,include: The spatiotemporal embedding feature tensors are respectively projected through the spatial QKV projection layer. Projection as a spatial query matrix Space bond matrix and spatial value matrix ; The spatial query matrix is calculated through the spatial attention calculation layer. With the spatial bond matrix The dot product of the two numbers, divided by the scaling factor, yields the attention score matrix. ; The weighted and normalized adjacency matrix is obtained through the spatial topological constraint weighting layer. With the attention score matrix Adding them together yields the spatial attention score matrix after topological constraints. ; The spatial attention score matrix after topological constraints is obtained through the spatial attention aggregation layer. Softmax normalization is performed sequentially, and then the spatial value matrix is... Weighted summation, multi-head concatenation and linear projection, and the spatiotemporal embedding feature tensor of the input. Residual connections yield spatially enhanced feature tensors. .
[0021] In one possible implementation, the time attention module includes: a time QKV projection layer, a time attention calculation layer, a time topology constraint weighting layer, and a time attention aggregation layer; The spatial enhancement feature tensor Attention calculation and feature aggregation are performed in the time dimension to obtain the spatiotemporal fusion feature tensor. ,include: The spatially enhanced feature tensor is projected through the time-QKV projection layer. Projection as a time query matrix Time key matrix and time value matrix ; The time query matrix is calculated through the time attention calculation layer. With the time key matrix The dot product of these values, divided by the scaling factor, yields the temporal attention score matrix. ; The time attention score matrix is weighted by the time topology constraint weighting layer. Middle overlay lower triangular mask The time attention score matrix after topological constraints is obtained. ; The time attention score matrix after topological constraints is processed by the time attention aggregation layer. Softmax normalization is performed sequentially, and then compared with the time value matrix. Weighted summation, multi-head stitching and linear projection, and the input spatial augmentation feature tensor Residual connections yield spatiotemporal fusion feature tensors. .
[0022] In one possible implementation, the classifier includes: a global average pooling layer, a feature flattening layer, and a fully connected layer; The spatiotemporal fusion feature tensor Perform global average pooling and fully connected classification to output the probability distribution of each node as an oscillation source. ,include: The spatiotemporal fusion feature tensor is processed by the global average pooling layer. Average pooling is performed on the time dimension to compress the temporal dimension and obtain key spatiotemporal features. ; The key spatiotemporal features are flattened using the feature flattening layer. Flattened into a one-dimensional feature vector ; The one-dimensional feature vector is processed through the fully connected layer. Perform classification processing and output the probability distribution of each node as an oscillation source. .
[0023] In one possible implementation, the training process of the spatiotemporal attention model includes: Construct a labeled dataset containing single-source oscillation scenarios and multi-source oscillation scenarios, and divide it into training set, validation set and test set according to the proportions; Initialize the spatiotemporal attention model parameters, setting hyperparameters including batch size, hidden layer dimension, number of attention heads, number of spatiotemporal attention layers, initial learning rate, weight decay, number of training epochs, early stopping patience value, and Dropout probability. The difference between the predicted probability distribution and the true label is calculated using the cross-entropy loss function. Gradient descent optimization is performed using the AdamW optimizer, and gradient clipping is applied. An early stopping mechanism is introduced: training is stopped and the optimal model parameters are saved when the accuracy of the validation set does not improve for several consecutive rounds. The trained model is evaluated on the test set.
[0024] In one possible implementation, the probability distribution is... Obtain the probability distribution of each node as an oscillation source. This allows us to determine the location of the oscillation source, including: If the probability distribution of each node as an oscillation source If the maximum value in the value is greater than the first preset threshold, it is determined to be a single-source oscillation scenario, and the node corresponding to the maximum value is taken as the oscillation source location result. If the probability distribution If the maximum value in the data is less than or equal to the first preset threshold, it is determined to be a multi-source oscillation scenario, and all nodes with a probability greater than the second preset threshold are taken as the oscillation source location results.
[0025] In one possible implementation, the preprocessing of the runtime sequence data of each node further includes: The 3σ criterion is used to detect outliers in the runtime sequence data and remove outliers. Linear interpolation was used to complete the detected missing data.
[0026] One or more technical solutions provided in this invention have at least the following technical effects or advantages: This invention obtains standardized spatiotemporal input data by acquiring the runtime sequence data of each node in a power system and preprocessing this data. The preprocessing steps include missing value imputation, outlier correction, and normalization or standardization. The beneficial effects are: eliminating the influence of different units on data distribution, improving the comparability of data between different nodes and at different times, ensuring the numerical stability and consistency of subsequent model inputs, and laying a clean and standardized data foundation for the model to effectively learn spatiotemporal patterns. A weighted normalized adjacency matrix is constructed based on the power grid topology. Edge weights are set according to physical parameters such as impedance, admittance, or electrical distance of actual power lines, and the weights are normalized to obtain the adjacency matrix. The beneficial effects of this step are: encoding the power grid topology and its electrical characteristics into a compact matrix form, enabling graph neural networks to explicitly utilize spatial connectivity information; weighted normalization not only preserves the differences in the strength of associations between nodes but also avoids the gradient explosion problem caused by excessively large adjacency matrix values, enhancing the stability of model training. Standardized spatiotemporal input data and a weighted normalized adjacency matrix are input into a pre-trained spatiotemporal attention model. The pre-training process utilizes a large number of historical oscillation cases to allow the model to fully learn oscillation patterns. The beneficial effect is that the model already possesses prior knowledge of the oscillation source characteristics, requiring only fine-tuning or direct inference in subsequent use, significantly improving localization efficiency and generalization ability, and reducing dependence on online labeled samples. The spatiotemporal attention model first maps the spatiotemporal input data to a high-dimensional feature space through a linear transformation using an input projection layer, obtaining a high-dimensional feature tensor. The beneficial effect of this step is that, through learnable linear projection, the original low-dimensional observation data is embedded into a richer high-dimensional representation space, enhancing the expressive power of the features and providing sufficient dimensionality for capturing complex spatiotemporal dependencies. Next, an embedding enhancement layer jointly embeds and enhances the high-dimensional feature tensor with node attributes and temporal attributes, generating a spatiotemporal embedded feature tensor. This layer typically introduces learnable node embedding vectors and temporal position codes, adding or concatenating them with the high-dimensional features. The beneficial effects are: enabling the model to explicitly distinguish the inherent characteristics of different nodes and the temporal location information at different times, strengthening the spatiotemporal context awareness, avoiding the confusion of heterogeneous nodes, and preserving the temporal sequence relationship, thereby improving the accuracy of oscillation pattern identification.
[0027] The spatial attention module performs attention calculations and feature aggregation on the spatiotemporal embedded feature tensor based on a weighted normalized adjacency matrix, resulting in a spatially enhanced feature tensor. This module adaptively assigns attention weights to neighboring nodes using a graph attention mechanism, combined with prior topological constraints provided by the adjacency matrix. The benefits include: capturing not only direct electrical connection effects but also uncovering indirect spatial dependencies between non-adjacent nodes, dynamically focusing on neighborhood information that contributes most to the current node's state, effectively simulating the spatial diffusion process of oscillation signals along the power grid, and enhancing the model's perception of the oscillation source region and its propagation path. The temporal attention module performs attention calculations and feature aggregation on the spatially enhanced feature tensor along the temporal dimension, resulting in a spatiotemporally fused feature tensor. This module calculates the importance weights of features at each time step along the time axis and aggregates the weighted temporal features. The benefits include: capturing the long-range dependencies of oscillation signals in the temporal dimension, highlighting key time steps related to the oscillation onset and duration, suppressing the influence of noisy or steady-state periods, thereby accurately locating the onset time features of oscillations and providing temporal basis for identifying the oscillation source. The classifier performs global average pooling and fully connected layer classification on the spatiotemporal fusion feature tensor, outputting the probability distribution of each node as an oscillation source. Global average pooling compresses the temporal features of each node into a single vector, and the fully connected layer maps this to a node-level probability output. The benefits are: global average pooling significantly reduces the number of parameters, lowers the risk of overfitting, while preserving the global spatiotemporal response of each node; the fully connected layer, combined with the softmax function, outputs a normalized probability distribution, intuitively presenting the likelihood of each node being an oscillation source. Finally, the location of the oscillation source can be determined based on the maximum probability or a threshold, achieving accurate end-to-end localization. Attached Figure Description
[0028] Figure 1 A flowchart illustrating the steps of a forced oscillation localization method for power systems based on a spatiotemporal attention mechanism, as provided in this embodiment of the invention. Figure 2 This is a structural diagram of the spatial attention module provided in an embodiment of the present invention; Figure 3 A structural diagram of the time attention module provided in an embodiment of the present invention; Figure 4 This is a flowchart of the spatiotemporal attention model training process provided in an embodiment of the present invention; Figure 5 The inference flowchart provided for embodiments of the present invention. Detailed Implementation
[0029] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0030] This invention provides a method for locating forced oscillations in power systems based on a spatiotemporal attention mechanism. (See also...) Figure 1 The method includes the following steps S101 to S102.
[0031] S101: Acquire the runtime sequence data of each node in the power system, and preprocess the runtime sequence data of each node to obtain standardized spatiotemporal input data. Meanwhile, a weighted normalized adjacency matrix is constructed based on the power grid topology. ; Specifically, in step S101, the runtime sequence data of each node is preprocessed to obtain standardized spatiotemporal input data. ,include: (1) Perform missing value detection and outlier detection on the runtime sequence data of each node, and use interpolation methods to complete the missing data; (2) Extract four types of features from the runtime sequence data of each node: oscillation amplitude, oscillation frequency, oscillation phase and damping ratio, to form the feature vector of each node; (3) Perform Z-score standardization on the feature vectors to eliminate dimensional differences, and arrange the standardized feature vectors in chronological order to construct spatiotemporal input data. Among them: spatiotemporal input data The dimension is N×F×L, where N is the number of nodes, F is the number of features, and L is the length of the time series.
[0032] Here, the preprocessing of the runtime sequence data for each node also includes: The 3σ criterion is used to detect and remove outliers from runtime sequence data. Linear interpolation was used to complete the detected missing data.
[0033] For example, the input data includes two types: (1) Operation status data of each node in the power system (such as bus voltage amplitude, phase angle, active power and reactive power of branches, etc.), with a sampling frequency of 30Hz and a time series length of L (default 200); (2) Power grid topology data (node number, branch connection relationship, branch parameters such as resistance R, reactance X, susceptance B).
[0034] The preprocessing steps are as follows: Data cleaning: Remove missing values and outliers (detected using the 3σ criterion), and complete missing data using linear interpolation; Feature extraction: Extract four core features (oscillation amplitude, frequency, phase, and damping ratio) from the operating status data of each node to form the feature vector of each node; Standardization: Z-score standardization is applied to the feature data to eliminate dimensional differences. The formula is: ; in, The characteristic mean, The characteristic standard deviation; Sequence construction: Arrange the standardized features of each node in chronological order to form spatiotemporal input data with dimensions (number of nodes N, number of features F, sequence length L), with default values of N=17, F=4, and L=200.
[0035] Specifically, in step S101, a weighted normalized adjacency matrix is constructed based on the power grid topology. The steps include S1011 to S1014.
[0036] S1011, map the actual power grid node numbers to consecutive indices and construct a node mapping table; S1012, construct the initial branch connection relationship based on the node mapping table and the power grid topology. ; S1013, combining branch parameters with the initial adjacency matrix We perform weighted adjacency calculations to obtain the weighted adjacency matrix. ; S1014, for the weighted adjacency matrix Symmetric normalization is performed to obtain a weighted normalized adjacency matrix. .
[0037] For example, the steps for power grid topology modeling are as follows: Node mapping: Map the actual power grid node numbers to consecutive indices (0~N-1) and construct a node mapping table; Adjacency Matrix Construction: Constructing an initial adjacency matrix based on branch connectivity. ,in Represents a node With nodes Directly connected; otherwise, 0. Topology weighted optimization: The adjacency matrix is weighted based on branch parameters (R, X, B), and the weights are calculated as follows: ; in, , For nodes and The resistance and reactance of the branches between them, and the weighted adjacency matrix. It can reflect the influence of branch transmission characteristics on oscillation propagation; Symmetric normalization: Symmetric normalization is applied to the weighted adjacency matrix to avoid gradient vanishing or exploding during training. The formula is: ; in, For degree matrix, , This is the normalized adjacency matrix ultimately used for training the spatiotemporal attention model.
[0038] S102, input spatiotemporal data and adjacency matrix The input is fed into a pre-trained spatiotemporal attention model to obtain the probability distribution of the oscillation source nodes. And according to the probability distribution Obtain the probability distribution of each node as an oscillation source. This allows us to determine the location of the oscillation source.
[0039] The spatiotemporal attention model includes: an input projection layer, an embedding enhancement layer, a spatial attention module, a temporal attention module, and a classifier.
[0040] Input projection layer, used to project spatiotemporal input data By mapping to a high-dimensional feature space through a linear transformation, a high-dimensional feature tensor is obtained. ; For example, the preprocessed spatiotemporal input data (dimension: batch_size×N×F×L) is transformed into high-dimensional features that the model can process through linear transformation: ,in, (B is the batch size), the Linear layer maps the feature dimension F to the hidden layer dimension H (default H=64), and outputs... .
[0041] Embedded enhancement layers are used for high-dimensional feature tensors Joint embedding enhancement of node attributes and temporal attributes is performed to obtain the spatiotemporal embedding feature tensor. ; Specifically, the embedding enhancement layer includes: a node embedding layer and a time embedding layer; Node embedding layer, used for processing high-dimensional feature tensors Add a learnable node embedding vector to each node in the algorithm. The node embedding feature tensor is obtained. ; Temporal embedding layer, used to embed feature tensors into nodes. Add a learnable temporal embedding vector to each time step. The spatiotemporal embedding feature tensor is obtained. .
[0042] For example, node embedding: A learnable embedding vector is added to each node to capture its inherent properties (such as node type and region), as shown in the formula: ,in, Parameters for node embedding can be optimized through training. Temporal embedding: A learnable embedding vector is added to each time step to capture global features in the time dimension (such as differences in oscillation characteristics across different time periods). The formula is as follows: ,in, The time-embedded parameters are used to output the final result. .
[0043] Spatial attention module for using weighted normalized adjacency matrices spatiotemporal embedding feature tensor Attention calculation and feature aggregation are performed between nodes to obtain the spatially augmented feature tensor. ; Specifically, the spatial attention module includes: a spatial QKV projection layer, a spatial attention computation layer, a spatial topology constraint weighting layer, and a spatial attention aggregation layer; Adjacency matrix based on weighted normalization spatiotemporal embedding feature tensor Attention calculation and feature aggregation are performed between nodes to obtain the spatially augmented feature tensor. ,include: The spatiotemporal embedding feature tensors are respectively projected through a spatial QKV projection layer. Projection as a spatial query matrix Space bond matrix and spatial value matrix ; The spatial query matrix is calculated using the spatial attention computation layer. With spatial bond matrix The dot product of the two numbers, divided by the scaling factor, yields the attention score matrix. ; The adjacency matrix is weighted and normalized through a spatial topological constraint weighting layer. With attention score matrix Adding them together yields the spatial attention score matrix after topological constraints. ; The spatial attention score matrix after topological constraints is obtained through the spatial attention aggregation layer. Softmax normalization and spatial value matrix are performed sequentially. Weighted summation, multi-head concatenation and linear projection, and spatiotemporal embedding feature tensors of the input. Residual connections yield spatially enhanced feature tensors. .
[0044] For example, the core of the spatial attention module is to adaptively capture the oscillation propagation correlation between nodes, focusing on key nodes near the oscillation source. See [link to relevant documentation]. Figure 2 As shown. In Figure 2 In this process, the input features are weighted by QKV projection, attention calculation, and topological constraints, and the output space-enhanced features are then processed.
[0045] The specific steps are as follows: QKV projection: Transforms input features into a spatial query matrix Space bond matrix and spatial value matrix The formula is: ; To improve parallel computing efficiency, a multi-head attention mechanism (number of heads = 8) is adopted to evenly distribute the H dimension among the heads.
[0046] Attention score calculation: Calculate the attention score between nodes, which reflects the strength of the association between nodes. ; in, (Here, 64 / 8=8) represents the single-head attention dimension, to avoid excessively large scores that could lead to softmax saturation.
[0047] Topological constraint weighting: Introducing a normalized adjacency matrix Constrain the attention score to ensure that the attention distribution conforms to the power grid topology: .
[0048] Attention weighting and output: The attention score is normalized using softmax, the V vector is weighted and summed, and then the output space is enhanced by linear projection. Residual connections improve training stability. .
[0049] Temporal attention module, used for spatial augmentation feature tensors Attention calculation and feature aggregation are performed in the time dimension to obtain the spatiotemporal fusion feature tensor. ; Specifically, the temporal attention module includes: a temporal QKV projection layer, a temporal attention computation layer, a temporal topology constraint weighting layer, and a temporal attention aggregation layer; Spatial augmentation feature tensor Attention calculation and feature aggregation are performed in the time dimension to obtain the spatiotemporal fusion feature tensor. ,include: Spatial augmentation feature tensors are projected using a time-QKV projection layer. Projection as a time query matrix Time key matrix and time value matrix ; The time query matrix is calculated through the time attention computation layer. With time key matrix The dot product of these values, divided by the scaling factor, yields the temporal attention score matrix. ; The temporal attention score matrix is weighted by a time topological constraint weighting layer. Middle overlay lower triangular mask The time attention score matrix after topological constraints is obtained. ; The time attention score matrix after topological constraints is processed through the time attention aggregation layer. Softmax normalization and time value matrix are performed sequentially. Weighted summation, multi-head stitching and linear projection, and spatial augmentation feature tensors of the input. Residual connections yield spatiotemporal fusion feature tensors. .
[0050] For example, the core of the time attention module is to focus on the key periods of oscillation development, suppressing noise and invalid timing information. See [link to relevant documentation]. Figure 3 The input features are processed by QKV projection, causal masking, and attention calculation to output temporally enhanced features.
[0051] The specific steps are as follows: QKV projection: Consistent with the spatial attention module, it transforms the input features into a temporal query matrix. Time key matrix and time value matrix .
[0052] Causal masking: Using a lower triangular mask ensures that the current time step only focuses on historical and current information, which conforms to the temporal causality of oscillation propagation. , The mask position is set to a minimum value, and the weights approach 0 after softmax.
[0053] Attention score calculation and weighting: Consistent with the spatial attention module, the attention score in the temporal dimension is calculated and normalized, and the temporal value matrix is weighted. Weighted summation.
[0054] Residual Connections and Output: Output time enhancement features after linear projection and residual connection: Residual connections improve training stability. .
[0055] A classifier for spatiotemporal fusion feature tensors Perform global average pooling and fully connected classification to output the probability distribution of each node as an oscillation source. .
[0056] Specifically, the classifier includes: a global average pooling layer, a feature flattening layer, and a fully connected layer; spatiotemporal fusion feature tensor Perform global average pooling and fully connected classification to output the probability distribution of each node as an oscillation source. ,include: The spatiotemporal fusion feature tensor is processed through a global average pooling layer. Average pooling is performed on the time dimension to compress the temporal dimension and obtain key spatiotemporal features. ; Key spatiotemporal features are flattened using a feature flattening layer. Flattened into a one-dimensional feature vector ; One-dimensional feature vectors are processed through fully connected layers. Perform classification processing and output the probability distribution of each node as an oscillation source. .
[0057] Specifically, in step S102, according to the probability distribution Obtain the probability distribution of each node as an oscillation source. The location of the oscillation source is then obtained, including the following steps S1021 to S1022.
[0058] S10121, if the probability distribution of each node as an oscillation source is... If the maximum value in the value is greater than the first preset threshold, it is determined to be a single-source oscillation scenario, and the node corresponding to the maximum value is taken as the oscillation source location result. S1022, if the probability distribution If the maximum value in the data is less than or equal to the first preset threshold, it is determined to be a multi-source oscillation scenario, and all nodes with a probability greater than the second preset threshold are taken as the oscillation source location results.
[0059] For example, the classification and localization of oscillation source nodes can be achieved through global average pooling and a fully connected layer: Global average pooling: Performs average pooling on the time dimension to compress the temporal dimension while preserving key spatiotemporal features. .
[0060] Feature flattening: Flattening the spatial and feature dimensions to form a global feature vector. .
[0061] Fully connected layer: The classification result is output through two fully connected layers and a Dropout layer (to prevent overfitting). ; ; ; in, The probability distribution of each node as an oscillation source is given, and the node with the highest probability is the location result.
[0062] In the embodiments provided by this invention, the training process of the spatiotemporal attention model includes: (1) Construct a labeled dataset containing single-source oscillation scenarios and multi-source oscillation scenarios, and divide it into training set, validation set and test set according to the proportion; (2) Initialize the parameters of the spatiotemporal attention model, and set hyperparameters including batch size, hidden layer dimension, number of attention heads, number of spatiotemporal attention layers, initial learning rate, weight decay, number of training rounds, early stopping patience value, and Dropout probability. (3) The difference between the predicted probability distribution and the true label is calculated using the cross-entropy loss function; (4) Use the AdamW optimizer for gradient descent optimization and apply gradient clipping; (5) Introduce an early stopping mechanism: stop training when the accuracy of the validation set does not improve for several consecutive rounds and save the optimal model parameters. (6) Evaluate the trained model on the test set.
[0063] For example, see the spatiotemporal attention model training process. Figure 4 The training process includes data loading, model forward propagation, loss calculation, and backpropagation optimization, using an early stopping mechanism to avoid overfitting. The specific steps are as follows: Dataset construction: Collect power system operation data under different oscillation source locations, different oscillation frequencies, and different noise levels, label the oscillation source nodes, and construct training set, validation set, and test set (ratio: 6:2:2); Data loading: Load data through a custom dataset class to achieve data preprocessing, topology modeling, and batch partitioning; Model initialization: Initialize the spatiotemporal attention model and set the hyperparameters: batch size: 16; hidden layer dimension (H): 64; number of attention heads (num_heads): 8; number of spatiotemporal attention layers: 3; initial learning rate: 0.001; weight decay: 1e-4; number of training epochs (max_epochs): 450; early stopping patience value (patience): 23; dropout probability: 0.1; optimizer (AdamW); loss function: cross-entropy loss.
[0064] Spatiotemporal attention model training: Forward propagation: Input training data and adjacency matrix, and output the predicted probability distribution through the model; Loss calculation: The difference between the predicted value and the true label is calculated using the cross-entropy loss function; Backpropagation: Optimize model parameters through gradient descent, and use gradient clipping (max_norm=1.0) to prevent gradient explosion; Learning rate strategy: Adaptive learning rate, maintaining the learning rate when there is no significant performance improvement during training; Early stopping mechanism: If the accuracy on the validation set does not improve for 23 consecutive rounds, stop training and save the optimal model parameters; Model evaluation: The model performance is evaluated through the validation set, and metrics such as accuracy, precision, recall, and F1 score are calculated to ensure the model's generalization ability.
[0065] The reasoning process is as follows Figure 5 As shown, the inference process includes real-time data acquisition, preprocessing, model prediction, and result output. The real-time performance throughout the process meets the requirements. The specific steps are as follows: Real-time data acquisition: The operating status data of each node is acquired through the power system PMU (Phasor Measurement Unit), with a time series length of 200. Real-time preprocessing: The collected data is cleaned, features are extracted, and standardized, following the same preprocessing procedure as the training phase. Topology loading: Load the current power grid topology data and construct a normalized adjacency matrix; Model prediction: Input the preprocessed data and adjacency matrix into the trained model, and output the probability distribution of each node as an oscillation source; Result determination: Single-source oscillation: Select the node with the highest probability as the oscillation source location result. If the maximum probability is greater than the threshold (default 0.7), output the location result; otherwise, it is judged as a suspected multi-source oscillation. Multi-source oscillation: Select all nodes with a probability greater than the threshold (default 0.5) as the oscillation source localization results, and output a list of multi-source oscillation sources; Output results: The location results (oscillation source node number, confidence level, oscillation type) are fed back to the power system monitoring platform in real time.
[0066] In one embodiment provided by the present invention, the following is pseudocode for the training process: 1. Data preparation: - Load time series data -> Extract features (shape: [number of samples, number of nodes, 4 features, 200 time steps]); - Parse the topology file -> Construct the normalized adjacency matrix [17, 17]; - Standardize data according to feature dimensions; 2. Model forward propagation: - Input projection: [B, 17, 200, 4]->Linear(4, 64)->[B, 17, 200, 64]; -Enhanced embedding: Add node embedding + time embedding; - Spatiotemporal attention stacking (3 layers): *Spatial Attention*: Uses an adjacency matrix to constrain attention between nodes; *Temporal Attention*: Applying causal masks to capture temporal dependencies; -Temporal average pooling -> Feature flattening -> [B, 1088]; - Classifier: LayerNorm->Linear(1088, 64)->ReLU->Linear(64, 4); 3. Training cycle: -For each epoch: - Batch training: Forward propagation -> Calculate loss (CrossEntropyLoss) -> Backpropagation -> Gradient clipping -> Optimizer (AdamW) update; - Validation set evaluation; - Early stop check: If the verification accuracy does not improve, increment the counter by 1; if the threshold (23) is reached, stop training and save the best model; 4. Model Evaluation: - Load the best model for test set prediction; - Generate results: accuracy / precision / recall / F1 score, and identify the source of oscillation.
[0067] In a simulation embodiment provided by this invention, the IEEE 39-node power system was used as the test grid. The proposed method, compared with classic deep learning models, Long Short-Term Memory (LSTM) networks, and Graph Convolutional Networks (GCNs), demonstrated superior performance under Gaussian white noise interference and no noise interference conditions with signal-to-noise ratios of 20, 25, 30, 35, and 40 dB. The following metrics represent localization accuracy, with a single-oscillator to multi-oscillator sample ratio of 4:1. The results are shown in the table below.
[0068] Table 1 Performance Comparison of Different Deep Learning Models
[0069] The method provided by this invention has higher positioning accuracy: the spatiotemporal attention mechanism can fully exploit the spatiotemporal coupling characteristics of oscillations. Combined with power grid topology constraints, the oscillation positioning accuracy is 99.0% when the signal-to-noise ratio is 40dB and the ratio of single oscillation source to multiple oscillation source samples is 4:1, which is significantly better than existing methods such as GCN (93.6%) and LSTM (83.3%).
[0070] Single-source and multi-source compatibility: Without adjusting the model architecture, the accurate localization of single-source and multi-source oscillations can be achieved simply by adaptively extracting features through the attention mechanism, which solves the contradiction in existing methods that "single-source is better than multi-source, and multi-source is better than single-source".
[0071] Enhanced noise resistance: Time attention focuses on key time periods and spatial attention focuses on key nodes. The dual-focusing mechanism effectively suppresses noise interference. The positioning accuracy is still ≥88.0% when SNR=20dB, which is more than 10% higher than existing methods on average.
[0072] Better real-time performance: The lightweight model architecture (≤190,000 parameters) makes the single-sample inference time ≤3ms, which meets the real-time monitoring requirements of the power system, and the FPGA deployment consumes low resources and is easy to implement in engineering. Greater generalization: It does not rely on precise system model parameters, but combines data-driven and topological constraints to be applicable to power systems with different topologies and oscillation frequencies. Its generalization is better than that of model-based reasoning methods. Greater physical interpretability: Spatial attention weights can reflect the intensity of oscillation propagation between nodes, while temporal attention weights can reflect the importance of critical time periods. The positioning results can be interpreted in combination with the power grid topology and oscillation timing characteristics, thereby improving the credibility of engineering applications.
[0073] The various embodiments described in this specification are presented in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on its differences from other embodiments. All or part of this invention can be used in numerous general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, mobile communication terminals, multiprocessor systems, microprocessor-based systems, programmable electronic devices, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices, etc.
[0074] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features therein. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the present invention.
Claims
1. A method for locating forced oscillations in a power system based on a spatiotemporal attention mechanism, characterized in that, include: The runtime sequence data of each node in the power system is acquired, and the runtime sequence data of each node is preprocessed to obtain standardized spatiotemporal input data. Meanwhile, a weighted normalized adjacency matrix is constructed based on the power grid topology. ; The spatiotemporal input data and the adjacency matrix The input is fed into a pre-trained spatiotemporal attention model to obtain the probability distribution of the oscillation source nodes. And according to the probability distribution Obtain the probability distribution of each node as an oscillation source. The location of the oscillation source is then obtained; wherein, the spatiotemporal attention model includes: an input projection layer, an embedding enhancement layer, a spatial attention module, a temporal attention module, and a classifier; The input projection layer is used to project the spatiotemporal input data. By mapping to a high-dimensional feature space through a linear transformation, a high-dimensional feature tensor is obtained. ; The embedding enhancement layer is used to enhance the high-dimensional feature tensor. Joint embedding enhancement of node attributes and temporal attributes is performed to obtain the spatiotemporal embedding feature tensor. ; The spatial attention module is used to perform tasks based on the weighted normalized adjacency matrix. For the spatiotemporal embedding feature tensor Attention calculation and feature aggregation are performed between nodes to obtain the spatially augmented feature tensor. The spatial attention module includes: a spatial QKV projection layer, a spatial attention computation layer, a spatial topological constraint weighting layer, and a spatial attention aggregation layer; the adjacency matrix is based on the weighted normalization. For the spatiotemporal embedding feature tensor Attention calculation and feature aggregation are performed between nodes to obtain the spatially augmented feature tensor. This includes: projecting the spatiotemporal embedding feature tensors through the spatial QKV projection layer. Projection as a spatial query matrix Space bond matrix and spatial value matrix The spatial query matrix is calculated through the spatial attention computation layer. With the spatial bond matrix The dot product of the two numbers, divided by the scaling factor, yields the attention score matrix. The weighted and normalized adjacency matrix is obtained through the spatial topological constraint weighting layer. With the attention score matrix Adding them together yields the spatial attention score matrix after topological constraints. The spatial attention score matrix after topological constraints is obtained through the spatial attention aggregation layer. Softmax normalization is performed sequentially, and then the spatial value matrix is... Weighted summation, multi-head concatenation and linear projection, and the spatiotemporal embedding feature tensor of the input. Residual connections yield spatially enhanced feature tensors. ; The temporal attention module is used to process the spatial augmentation feature tensor. Attention calculation and feature aggregation are performed in the time dimension to obtain the spatiotemporal fusion feature tensor. The temporal attention module includes: a temporal QKV projection layer, a temporal attention computation layer, a temporal topological constraint weighting layer, and a temporal attention aggregation layer; the spatial enhancement feature tensor... Attention calculation and feature aggregation are performed in the time dimension to obtain the spatiotemporal fusion feature tensor. This includes: projecting the spatially enhanced feature tensor through the temporal QKV projection layer. Projection as a time query matrix Time key matrix and time value matrix The time query matrix is calculated through the time attention calculation layer. With the time key matrix The dot product of these values, divided by the scaling factor, yields the temporal attention score matrix. The temporal attention score matrix is weighted by the temporal topology constraint layer. Middle overlay lower triangular mask The time attention score matrix after topological constraints is obtained. The temporal attention score matrix after topological constraints is processed through the temporal attention aggregation layer. Softmax normalization is performed sequentially, and then compared with the time value matrix. Weighted summation, multi-head stitching and linear projection, and the input spatial augmentation feature tensor Residual connections yield spatiotemporal fusion feature tensors. ; The classifier is used to process the spatiotemporal fusion feature tensor. Perform global average pooling and fully connected classification to output the probability distribution of each node as an oscillation source. .
2. The method for locating forced oscillations in power systems based on a spatiotemporal attention mechanism according to claim 1, characterized in that, The runtime sequence data of each node is preprocessed to obtain standardized spatiotemporal input data. ,include: Missing and outlier detection is performed on the runtime sequence data of each node, and interpolation methods are used to complete the missing data. Four types of features—oscillation amplitude, oscillation frequency, oscillation phase, and damping ratio—are extracted from the runtime sequence data of each node to form the feature vector of each node; The feature vectors are Z-score standardized to eliminate dimensional differences, and the standardized feature vectors are arranged in chronological order to construct spatiotemporal input data. Wherein: the spatiotemporal input data The dimension is N×F×L, where N is the number of nodes, F is the number of features, and L is the length of the time series.
3. The power system forced oscillation localization method based on spatiotemporal attention mechanism according to claim 1, characterized in that, The adjacency matrix is constructed based on the power grid topology and weighted normalization. ,include: Map the actual power grid node numbers to consecutive indices to construct a node mapping table; An initial adjacency matrix is constructed based on the node mapping table and the branch connection relationships of the power grid topology. ; Combined with the branch parameters, the initial adjacency matrix We perform weighted adjacency calculations to obtain the weighted adjacency matrix. ; For the weighted adjacency matrix Symmetric normalization is performed to obtain a weighted normalized adjacency matrix. .
4. The method for locating forced oscillations in power systems based on a spatiotemporal attention mechanism according to claim 1, characterized in that, The embedding enhancement layer includes: a node embedding layer and a time embedding layer; The node embedding layer is used for processing the high-dimensional feature tensor. Add a learnable node embedding vector to each node in the algorithm. The node embedding feature tensor is obtained. ; The temporal embedding layer is used to embed feature tensors into the nodes. Add a learnable temporal embedding vector to each time step. The spatiotemporal embedding feature tensor is obtained. .
5. The forced oscillation localization method for power systems based on spatiotemporal attention mechanism according to claim 1, characterized in that, The classifier includes: a global average pooling layer, a feature flattening layer, and a fully connected layer; The spatiotemporal fusion feature tensor Perform global average pooling and fully connected classification to output the probability distribution of each node as an oscillation source. ,include: The spatiotemporal fusion feature tensor is processed by the global average pooling layer. Average pooling is performed on the time dimension to compress the temporal dimension and obtain key spatiotemporal features. ; The key spatiotemporal features are flattened using the feature flattening layer. Flattened into a one-dimensional feature vector ; The one-dimensional feature vector is processed through the fully connected layer. Perform classification processing and output the probability distribution of each node as an oscillation source. .
6. The method for locating forced oscillations in power systems based on a spatiotemporal attention mechanism according to claim 1, characterized in that, The training process of the spatiotemporal attention model includes: Construct a labeled dataset containing single-source oscillation scenarios and multi-source oscillation scenarios, and divide it into training set, validation set and test set according to the proportions; Initialize the spatiotemporal attention model parameters, setting hyperparameters including batch size, hidden layer dimension, number of attention heads, number of spatiotemporal attention layers, initial learning rate, weight decay, number of training epochs, early stopping patience value, and Dropout probability. The difference between the predicted probability distribution and the true label is calculated using the cross-entropy loss function. Gradient descent optimization is performed using the AdamW optimizer, and gradient clipping is applied. An early stopping mechanism is introduced: training is stopped and the optimal model parameters are saved when the accuracy of the validation set does not improve for several consecutive rounds. The trained model is evaluated on the test set.
7. The method for locating forced oscillations in power systems based on a spatiotemporal attention mechanism according to claim 1, characterized in that, According to the probability distribution Obtain the probability distribution of each node as an oscillation source. This allows us to determine the location of the oscillation source, including: If the probability distribution of each node as an oscillation source If the maximum value in the value is greater than the first preset threshold, it is determined to be a single-source oscillation scenario, and the node corresponding to the maximum value is taken as the oscillation source location result. If the probability distribution If the maximum value in the data is less than or equal to the first preset threshold, it is determined to be a multi-source oscillation scenario, and all nodes with a probability greater than the second preset threshold are taken as the oscillation source location results.
8. The method for locating forced oscillations in power systems based on a spatiotemporal attention mechanism according to claim 1, characterized in that, The preprocessing of the runtime sequence data of each node further includes: The 3σ criterion is used to detect outliers in the runtime sequence data and remove outliers. Linear interpolation was used to complete the detected missing data.
Citation Information
Patent Citations
Electric power system multi-source forced oscillation positioning method based on graph attention network and variational mode decomposition
CN121186511A
Detection method using fusion network based on attention mechanism, and terminal device
US11222217B1