A method for evaluating transient voltage stability in power systems based on GAF-SWIN transformers

By combining Gram angle field and improved Swin Transformer, the patented technology achieves efficient and accurate voltage stability assessment, which is suitable for real-time power system monitoring and early warning. It also solves the problems of excessive computing resource consumption and topological distortion of time-series correlation features in the prior art.

CN120782296BActive Publication Date: 2026-06-30CHINA THREE GORGES UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA THREE GORGES UNIV
Filing Date
2025-07-07
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

The existing Transformer architecture consumes excessive computational resources when processing long-sequence data sampled at high frequency by the PMU. Traditional heatmap methods cause distortion of the topology of time-series correlation features, affecting the accuracy of power system transient stability assessment.

Method used

By combining Gram angle field (GAF) and Swin Transformer, and by improving the feature extraction module, transient voltage data of power systems are converted into two-dimensional images. Furthermore, by utilizing shift window attention and cross-window attention mechanisms, the computational complexity and efficiency issues are resolved, and the feature extraction capability is enhanced.

Benefits of technology

It achieves efficient and accurate voltage stability assessment, suitable for real-time power system monitoring and early warning, solves the problems of traditional methods, and improves the efficiency of the patent.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120782296B_ABST
    Figure CN120782296B_ABST
Patent Text Reader

Abstract

A power system transient voltage stability assessment method based on GAF-Swin transformer includes the following steps: Step 1: Collect historical online data and simulation data of the power system to construct an initial sample set; convert multivariate time-series data into a GAF transient integrated image that retains time features; generate unstable or stable labels for each sample image, and randomly divide the training and test sets according to a certain ratio; Step 2: Improve the feature extraction module of the Swin Transformer model, extracting multi-scale spatiotemporal features through shift window attention and cross-window attention mechanisms. During offline training, obtain the optimal transient voltage stability assessment model. Step 3: Deploy the optimal model to the online assessment system, monitor transient voltage data in real time, and perform stability assessment. When power system instability occurs, the model can also locate critical buses. Compared with traditional methods, this invention can achieve efficient and accurate voltage stability assessment in large-scale power systems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of power system safety and stability analysis, and particularly to power system transient voltage stability assessment technology, specifically to a real-time power system transient voltage stability assessment method based on Gram angle field (GAF) and Swin Transformer. Background Technology

[0002] Transient stability assessment of power systems is a key technical component of the power grid security defense system. Its goal is to determine whether all generating units can maintain synchronous operation and preserve voltage and frequency stability after a large disturbance. With the large-scale integration of new energy sources and the increasing complexity of power grid structures, transient stability assessment faces the dual constraints of response speed and assessment accuracy. Rapid and accurate assessment methods are of great significance for preventing cascading failures and optimizing control strategies.

[0003] Traditional evaluation methods are mainly divided into two categories: time-domain simulation methods and direct methods. The former simulates the dynamic process of the system through numerical integration. Although it has high accuracy, it is computationally time-consuming and cannot meet the needs of online real-time evaluation. The latter (such as the energy function method) has the advantage of computational efficiency, but it relies on idealized mathematical models to construct energy functions, making it difficult to adapt to the variable operating scenarios of modern complex power grids. With the large-scale deployment of Wide Area Measurement Systems (WAMS) and Phasor Measurement Units (PMUs), data-driven methods have become a new research direction. Traditional machine learning methods, represented by Support Vector Machines (SVM), achieve rapid evaluation by establishing a mapping relationship between historical data and steady state. However, their feature engineering is highly dependent on human experience, and their ability to extract deep features from high-dimensional time-series data is limited. In contrast, deep learning automatically mines data features through multi-level nonlinear transformations, significantly improving model performance. For example, convolutional neural networks (CNNs) perform excellently in image-based time-series data processing due to their local connectivity and weight sharing characteristics. However, the translation invariance assumption of CNNs may lead to the neglect of global spatiotemporal correlations in the dynamic process of power systems, and their local perception characteristics are difficult to effectively capture long sequence dependencies. The Transformer architecture achieves global spatiotemporal dependency modeling through a self-attention mechanism, showing significant advantages in contextual correlation analysis of transient processes such as power angle swing and voltage drop, as shown in Fang Jiashu, Liu Chongru, Su Chenbo, et al., "A Multi-stage Power System Transient Stability Assessment Method Based on Self-Attention Transformer Encoder". However, its computational complexity is proportional to the square of the sequence length (O(N²)). When faced with long sequence data generated by the high sampling rate of the PMU, computational resource consumption becomes a bottleneck.

[0004] Furthermore, efficient representation of power grid transient time-series data remains a core challenge: traditional heatmap methods convert one-dimensional time-series signals into two-dimensional images through color gradient mapping, as shown in Peng Xin, Liu Jun, Liu Jiacheng, et al., "Image-based Data-driven Online Assessment Method for Transient Stability of Power Systems." While these methods can intuitively present numerical fluctuation trends, they disrupt the temporal continuity of the original data, leading to the loss of temporal dependencies and dynamic details. This deficiency severely restricts the accuracy of subsequent models in extracting key features of transient stability. Summary of the Invention

[0005] This invention aims to overcome the computational resource constraints faced by the existing Transformer architecture in processing high-frequency sampled long-sequence data of PMUs in power system transient stability assessment. At the same time, it solves the problem of topological distortion of time-series correlation features caused by the traditional heatmap method in realizing two-dimensional visualization of one-dimensional time-series signals through multi-dimensional tensor mapping. Although the latter can realize the gradient representation of numerical fluctuations, it will lead to the decay of time continuity and the annihilation of dynamic evolution features, which will seriously weaken the identification efficiency of key transient stability features. Therefore, this invention is proposed.

[0006] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:

[0007] A method for evaluating transient voltage stability in a power system based on a GAF-SWIN transformer includes the following steps:

[0008] Step 1: Collect historical online data and simulation data of the power system to construct a two-dimensional transient image sample set;

[0009] Step 2: Improve the model feature extraction module and train the optimal transient voltage stability evaluation model;

[0010] Step 3: Deploy the optimal model into the online evaluation system to evaluate voltage stability in real time and monitor critical unstable buses.

[0011] In step 1, specifically: historical online monitoring data and simulation data of the power system are acquired to establish an initial sample set; Gram angle field and vertical image stitching algorithm are used to realize the time-domain feature preservation mapping from multivariate time series data to two-dimensional transient integrated image; then, stability state labeling is performed on each sample image, and finally, the training set and test set are randomly divided according to a preset ratio.

[0012] Step 1 includes the following sub-steps:

[0013] Step 1-1: Obtain the initial dataset;

[0014] Step 1-2: Process the transient voltage time series Perform normalization;

[0015] Steps 1-3: Normalize the voltage time series Convert to polar coordinates;

[0016] Steps 1-4: Use the GAF algorithm to process the polar coordinate data Convert to a two-dimensional image;

[0017] Steps 1-5: Generate stitched image data;

[0018] Steps 1-6: Divide the image data into stable and unstable datasets using the TVSI index;

[0019] Steps 1-7: Randomly divide the processed image dataset into training and test sets according to a certain ratio.

[0020] Specifically:

[0021] In step 1-1, when obtaining the initial dataset, specifically: historical online data is obtained by online recording through the PMU synchronous measurement device, and then simulation calculations are performed based on power system simulation software such as PSASP. By setting different operating modes and fault modes, the voltage data of the simulated nodes are obtained to form the initial dataset.

[0022] In steps 1-2, the transient voltage time series is processed. When performing normalization, specifically: Let the first power system be... The voltage time series of each node is as follows ,in Indicates the first Each node at time... t The voltage value, where T is the length of the time series, for the voltage time series of each node. Normalization is performed, and the normalized time series is obtained. for:

[0023] (1);

[0024] in, and Representing voltage time series respectively The minimum and maximum values;

[0025] In steps 1-3, the normalized voltage-time series is... Converting to polar coordinates, specifically: the amplitude of the normalized voltage signal is encoded as an angle cosine, and the time axis is encoded as a radius, thus obtaining the radius and angle of each data point;

[0026] Time series Mapped to radius ,Right now:

[0027] (2);

[0028] in, t For a point in time, T This represents the total length of the time series.

[0029] Encode amplitude as angle ,Right now:

[0030] (3);

[0031] Voltage data points Converted into corresponding polar coordinate data ;

[0032] In steps 1-4, the GAF algorithm is used to process the polar coordinate data. Converting to a two-dimensional image, specifically: In GAF, the value of each pixel in the image is calculated using the following formula:

[0033] (4);

[0034] in, G ij Indicates the first i and the j The cosine of the angle difference at time points is used as an element in the GAF image;

[0035] In steps 1-5, when generating the stitched image data, specifically: for multiple nodes... i =1,2,…,N, each node generates a GAF image. G i Finally, the GAF images of all nodes are vertically stitched together to form an integrated image;

[0036] (5);

[0037] in, G integrated To integrate the images, the stitching method involves arranging each image in a row; each G i For the first i GAF image of each node;

[0038] In steps 1-6, the image data is divided into stable and unstable datasets using the TVSI metric; specifically, the TVSI metric is:

[0039] (6);

[0040] In the formula, This represents the minimum load node voltage after the disturbance occurs. To set the voltage value, The duration for which the load node voltage is lower than the set voltage value. TVSI = 1 indicates that the power system is in a transient voltage stability state, representing the maximum allowable time for the voltage to drop below the set value. This indicates that the power system is in a transient voltage instability state; accordingly, stable and unstable samples are labeled as 1 and -1, respectively.

[0041] In step 2, specifically: the Swing Transformer feature extraction module is improved by extracting multi-scale spatiotemporal features through shift window attention and cross-window attention mechanisms, and the optimal transient voltage stability evaluation model is obtained during offline training.

[0042] In step 2, the improved Swin Transformer module includes the following steps:

[0043] Step 2-1: Adjust the model position encoding;

[0044] Step 2-2: Adjust the window size and the step size;

[0045] Steps 2-3: Divide the window;

[0046] Steps 2-4: Determine if windows are adjacent;

[0047] Steps 2-5: Obtain and output the fused features.

[0048] In step 2-1, interpolation is used to adjust the position encoding to ensure that each position in the stitched image correctly corresponds to the spatial information of the original image; specifically:

[0049] Let the height of the original image be... H img,init Width is W img,init The height of the stitched image is H img,new Width is W img,new The original location is encoded as follows: After interpolation, the new position code Adjustments are made using bilinear interpolation (Interp):

[0050] (7);

[0051] Among them, the nearest integer points:

[0052] (8);

[0053] Interpolation weights:

[0054] (9);

[0055] , , and These represent the scaling ratios of the height of the stitched image relative to the height and width of the original image, respectively. This adjustment method ensures that the stitched image retains the positional information of the original image. and : Represents the nearest integer coordinate in the height direction. It is less than or equal to the interpolation point height. The largest integer. It is greater than or equal to the interpolation point height. The smallest integer that satisfies the following constraints: . and : Represents the nearest integer coordinates in the width direction. It is less than or equal to the interpolation point width. The largest integer. It is greater than or equal to the interpolation point width. The smallest integer that satisfies the following constraints:

[0056] In step 2-2, the window size adjustment is specifically performed as follows:

[0057] Let the original window size be W size,init The size of the stitched image window W size,new The window size should be consistent with the original window (the window before splicing):

[0058] (10);

[0059] in, H img,init The height of the original image. iH This represents the height of the stitched image. round Indicates rounding down;

[0060] Adjust your stride length, specifically: original stride length S init The dimensions of the stitched image should be adjusted according to the size of the image as shown in equation (11):

[0061] (11);

[0062] in,S init This is the original stride length. S new The adjusted stride ensures that the window's sliding motion adapts to the new image size, preventing information loss due to an unsuitable stride.

[0063] In steps 2-4, if windows are adjacent, a window shifting attention mechanism is implemented;

[0064] The window shifting attention mechanism is specifically as follows:

[0065] Let the input feature map be X Height is H img,new Width is W img,new Window size is W size,new = M×M shift step In the window shifting layer, the feature map is shifted as follows:

[0066] First, perform a cyclic shift (Roll) operation on X to obtain the shifted feature map. :

[0067] (12);

[0068] The shift parameter represents the horizontal and vertical translation of the input feature map X. S new Units;

[0069] For any pixel position Its new coordinates after shifting are:

[0070] (13):

[0071] (14);

[0072] Here, mod represents the modulo operation, which restricts out-of-bounds index values ​​to a range using the modulo operation. or This allows for the cyclic shifting of data at the edges of the feature map;

[0073] The shifted feature map according to M×M Non-overlapping window partitioning; defining window sets Each window is:

[0074] (15);

[0075] in r,c These are the vertical and horizontal indices of the window, respectively. and ;

[0076] If the windows are not adjacent, a cross-window connection attention mechanism is used;

[0077] The cross-window connection attention mechanism is specifically as follows:

[0078] By calculating attention scores between windows and performing weighted aggregation, information interaction is facilitated.

[0079] (16);

[0080] in, A ij Display window w i and window w j Attention scores between them Q i and K j These are windows w i and window w j Query (Q) and key (K) matrix:

[0081] (17);

[0082] in, O i For window W i The output, V j For window W j The value (Value, V).

[0083] In step 3, the transient voltage stability assessment GAF-SwT model obtained after training in step 2 is used to perform real-time stability assessment of the transient voltage, and the critical busbars with instability in the weak nodes of the system are identified; this includes the following steps:

[0084] Step 3-1: Perform online dynamic evaluation of the transient process;

[0085] Step 3-2: Locate the critical busbar under unstable conditions;

[0086] In step 3-1, the dynamic data of the power grid is first collected in real time based on the synchronous phasor measurement device (PMU). After standardization preprocessing according to the process described in step 1, the data is input into the iteratively optimized GAF-SwT evaluation model. The model completes the transient stability determination within a certain time window through its unique hierarchical feature extraction architecture and outputs the system's "stable / instable" binary classification result.

[0087] In step 3-2, let the attention weight matrix output by the last layer of the Swing Transformer network be... ,in N This represents the total number of busbar nodes. H For the number of attention heads, T The sampling time window length for the transient process; the voltage instability impact factor is calculated using a spatiotemporal attention fusion mechanism:

[0088] (18);

[0089] (19);

[0090] : No. h The attention head is in the first L Layer to busbar i At any moment t Attention weights;

[0091] Busbar i In the h The temporal average attention intensity of each attention head;

[0092] : Represents the learnable attention head fusion weights;

[0093] : No. h Trainable scalar parameters corresponding to each attention head;

[0094] Busbar i The normalized voltage instability influence factor satisfies ;

[0095] The criteria for determining critical busbars are as follows:

[0096] (20);

[0097] Where the dynamic threshold parameter is taken as λ =1.28, which corresponds to the 90% confidence interval. and Generator power angle influence factors βi Standard deviation and mean N The total number of generators. i Indicates the first i One generator; noise interference is suppressed using a standard deviation weighting mechanism; and the set of key source buses causing system instability is obtained through dynamic threshold criterion screening. C ,in β i The higher the value of the busbar, the greater its contribution to transient instability.

[0098] The Swing Transformer network is specifically configured as follows: the input image of the Swing Transformer network is input to the Patch Partition module; the output of the Patch Partition module is connected to the input of the Linear Embedding module; the output of the Linear Embedding module is connected to the input of the first Swing Transformer Block module group; the output of the first Swing Transformer Block module group is connected to the input of the first Patch Merging module; the output of the first Patch Merging module is connected to the input of the second Swing Transformer Block module group; the output of the second Swing Transformer Block module group is connected to the input of the second Patch Merging module; the output of the second Patch Merging module is connected to the input of the third Swing Transformer Block module group; the output of the third Swing Transformer Block module group is connected to the input of the third Patch Merging module; the output of the third Patch Merging module is connected to the input of the fourth Swing Transformer Block module group; the output of the fourth Swing Transformer Block module group is connected to the input of Layer Norm; and the output of Layer Norm is connected to the input of Global Average Pooling. The output of Pooling is connected to the input of FullyConnectedLayer, and the output of Fully ConnectedLayer is used to output the output features of the SwinTransformer network.

[0099] The Swin Transformer Block module group includes multiple Swin Transformer Block modules, such as Figure 5As shown, the Swin Transformer Block module is specifically as follows:

[0100] The input feature of the Swin Transformer Block module is Z. The input feature Z is input to the first LayerNorm module. The output of the first LayerNorm module is connected to the input of the window self-attention module W-MSA. The output feature of the window self-attention module W-MSA is added to the input feature Z to obtain the summed output feature Z1.

[0101] The output feature Z1 is input to the second LayerNorm module. The output of the second LayerNorm module is connected to the input of the first MLP module. The output of the first MLP module is added to the output feature Z1 to obtain the summed output feature Z2.

[0102] The output feature Z2 is then input to the input terminals of the third LayerNorm module and the fourth LayerNorm module, respectively. The output terminal of the third LayerNorm module is connected to the input terminal of the SW-MSA module; the output terminal of the fourth LayerNorm module is connected to the input terminal of the CW-MSA module; the outputs of the SW-MSA module, the CW-MSA module, and the output feature Z2 are then added together.

[0103] The summed output feature Z3 is input to the fifth LayerNorm module. The output of the LayerNorm module is connected to the input of the second MLP module. The input of the second MLP module is added to the output feature Z2. The summed feature is the output feature of the Swing Transformer Block module.

[0104] Compared with the prior art, the present invention has the following technical effects:

[0105] 1) This invention can achieve efficient and accurate voltage stability assessment in large-scale power systems, with excellent real-time performance and robustness, and is suitable for real-time power system monitoring and early warning.

[0106] 2) This invention maps transient voltage time-series data into a two-dimensional image using the GAF algorithm, enhancing the separability of sample features while preserving the spatiotemporal correlation of the original sequence. Subsequently, based on the improved Swing Transformer model's shift window attention and cross-window attention coordination mechanism, the computational complexity of self-attention is reduced from quadratic to linear, while achieving fine-grained capture of local transient features and global dynamic correlation modeling. This method effectively solves the common problems of lost time-series information in traditional heatmaps, local perception bias in CNNs, and overload of Transformer computational resources, improving the accuracy of transient voltage stability assessment in high-noise and data-missing scenarios. Attached Figure Description

[0107] The present invention will be further described below with reference to the accompanying drawings and embodiments:

[0108] Figure 1 This is a flowchart of the present invention;

[0109] Figure 2 A schematic diagram of converting a Gram angle field time series into a two-dimensional image;

[0110] Figure 3 The flowchart for the improved Swin Transformer model feature extraction of this invention is shown below;

[0111] Figure 4 Here is the network structure diagram of the Swin Transformer model;

[0112] Figure 5 This is a diagram of the improved Swing Transformer Block feature extraction network structure of the present invention;

[0113] Figure 6 Heatmap of factors influencing bus voltage instability under different instability scenarios. Detailed Implementation

[0114] Figure 1 This invention provides a flowchart of a real-time power system transient voltage stability assessment method based on Gramian Angular Field (GAF) and SwinTransformer. The invention offers a GAF image conversion method considering power system node voltage data. By normalizing the voltage time series of power system nodes and converting it to polar coordinates, transient images are generated using the GAF algorithm to extract spatiotemporal features between nodes. Subsequently, by stitching together GAF transient images of multiple node voltages, a transient integrated image dataset is formed to improve the system feature representation capability. Finally, unstable or stable labels are generated for each sample image, and the images are randomly divided into training and test sets according to a certain ratio.

[0115] Specifically, the following steps are included:

[0116] Step 1: Collect historical online data and simulation data of the power system to construct a two-dimensional transient image sample set;

[0117] Step 1-1: Obtain the initial dataset; First, collect historical online monitoring data of the power grid through PMU, and then perform simulation calculations based on power system simulation software such as PSASP. By setting different operating and fault modes, obtain the voltage time-series response data of the simulated nodes, and finally form the initial dataset.

[0118] Step 1-2: Process the transient voltage time series Normalization is performed. Let the first power in the power system be... The voltage time series of each node is as follows ,in Indicates the first Each node at time... t The voltage value, where T is the length of the time series, for the voltage time series of each node. Normalization is performed, and the normalized time series is obtained. for:

[0119] (1);

[0120] in, and Representing voltage time series respectively The minimum and maximum values.

[0121] In steps 1-3, the normalized voltage-time series is... Converting to polar coordinates, specifically: the amplitude of the normalized voltage signal is encoded as an angle cosine, and the time axis is encoded as a radius, thus obtaining the radius and angle of each data point;

[0122] Time series Mapped to radius ,Right now:

[0123] (2);

[0124] in, t For a point in time, T This represents the total length of the time series.

[0125] Encode amplitude as angle ,Right now:

[0126] (3);

[0127] Voltage data points Converted into corresponding polar coordinate data .

[0128] Steps 1-4: Use the GAF algorithm to process the polar coordinate data Converted to a two-dimensional image, in GAF, the value of each pixel in the image is calculated using the following formula:

[0129] (4);

[0130] in, G ij Indicates the first i and the j The cosine of the angle difference at time is used as an element in the GAF image.

[0131] Steps 1-5: Generate stitched image data, for multiple nodes i =1,2,…,N, each node generates a GAF image. G i Finally, the GAF images of all nodes are vertically stitched together to form an integrated image:

[0132] (5);

[0133] in, G integrated To integrate the images, the stitching method involves arranging each image in a row. Each G i For the first i GAF image of each node.

[0134] Steps 1-6: Divide the image data into stable and unstable datasets using the TVSI metric. The TVSI metric is:

[0135] (6);

[0136] In the formula, This represents the minimum load node voltage after the disturbance occurs. To set the voltage value, The duration for which the load node voltage is lower than the set voltage value. TVSI = 1 indicates that the power system is in a transient voltage stability state, representing the maximum allowable time for the voltage to drop below the set value. This indicates that the power system is in a transient voltage instability state. Accordingly, stable and unstable samples are labeled as 1 and -1, respectively.

[0137] Steps 1-7: Randomly divide the processed image dataset into training and test sets in an 8:2 ratio.

[0138] like Figure 3As shown, step 2: This invention proposes an improved Swing Transformer method, which can effectively improve the feature extraction capability of stitched images through parameterized reconstruction of position encoding, dynamic optimization of window configuration, window shifting and cross-window connection, and multi-scale feature extraction.

[0139] The improved Swin Transformer method specifically includes the following steps:

[0140] Step 2-1: Adjust the model position encoding;

[0141] Step 2-2: Adjust the window size and the step size;

[0142] Steps 2-3: Divide the window;

[0143] Steps 2-4: Determine if windows are adjacent;

[0144] Steps 2-5: Obtain and output the fused features;

[0145] Step 2-1: Adjust the model's positional encoding. Image stitching requires adjusting the positional encoding to fit the size of the stitched image. The positional information of the original image is typically represented by a two-dimensional positional encoding matrix. In the stitched image, the positional encoding is adjusted through interpolation to ensure that each position in the stitched image correctly corresponds to the spatial information of the original image.

[0146] Let the height of the original image be... H img,init Width is W img,init The height of the stitched image is H img,new Width is W img,new The original location is encoded as follows: After interpolation, the new position code Adjustments are made using bilinear interpolation (Interp):

[0147] (7);

[0148] Among them, the nearest integer points:

[0149] (8);

[0150] Interpolation weights:

[0151] (9);

[0152] , , and These represent the scaling ratios of the height of the stitched image relative to the height and width of the original image, respectively. This adjustment method ensures that the stitched image retains the positional information of the original image. and : Represents the nearest integer coordinate in the height direction. It is less than or equal to the interpolation point height. The largest integer. It is greater than or equal to the interpolation point height. The smallest integer that satisfies the following constraints: . and : Represents the nearest integer coordinates in the width direction. It is less than or equal to the interpolation point width. The largest integer. It is greater than or equal to the interpolation point width. The smallest integer that satisfies the following constraints:

[0153] Adjust the window size:

[0154] Let the original window size be W size,init The size of the stitched image window W size,new The window size should be consistent with the original window (the window before splicing):

[0155] (10);

[0156] in, H img,init The height of the original image. iH This represents the height of the stitched image. round Indicates rounding down.

[0157] Adjust your stride length, specifically: original stride length S orig The dimensions of the stitched image should be adjusted according to the size of the image as shown in equation (11):

[0158] (11);

[0159] in, S init This is the original stride length. S new The adjusted stride ensures that the window's sliding motion adapts to the new image size, preventing information loss due to an unsuitable stride.

[0160] Steps 2-4: Integrating window shifting and cross-window connection mechanisms. To efficiently utilize local and global information and balance computational complexity and performance, this invention combines window shifting and cross-window connection mechanisms.

[0161] Window shifting: Between adjacent windows, the original window boundaries are broken by shifting the window, allowing adjacent windows to share information. Assume the input feature map... X Height is H img,new Width is W img,new Window size is W size,new = M×M shift step In the window shifting layer, the feature map is shifted as follows:

[0162] First, perform a cyclic shift (Roll) operation on X to obtain the shifted feature map. :

[0163] (12);

[0164] The shift parameter represents the horizontal and vertical translation of the input feature map X. S new Units.

[0165] For any pixel position Its new coordinates after shifting are:

[0166] (13);

[0167] (14);

[0168] Here, mod represents the modulo operation, which restricts out-of-bounds index values ​​to a range using the modulo operation. or This allows for the cyclic shifting of data at the edges of the feature map.

[0169] The shifted feature map according to M×M Non-overlapping window partitioning. Define window set. Each window is:

[0170] (15);

[0171] in r,c These are the vertical and horizontal indices of the window, respectively. and .

[0172] Cross-window connectivity: For non-adjacent windows, a cross-window connectivity mechanism is used. This mechanism calculates and weights the attention scores between windows to promote information exchange.

[0173] (16);

[0174] in, A ij Display window w i and window w j Attention scores between them Q i and K j These are windows w i and window w j The query (Q) and key (K) matrix.

[0175] (17);

[0176] in, O i For window W i The output, V j For window W j The value (Value, V) is used. Through cross-window attention, the model can directly capture global dependencies over long distances, avoiding the information isolation problem of local windows and enhancing the model's ability to understand the global structure. However, the computational complexity is high.

[0177] Combining window-shifting attention and cross-window attention mechanisms, using window-shifting attention in adjacent windows and cross-window attention in non-adjacent windows, has the following advantages: efficient use of local and global information to improve model expressiveness; balancing computational complexity and performance, making it suitable for large-scale tasks; reducing information redundancy and improving computational efficiency.

[0178] Offline training model and optimization

[0179] During model training, a hierarchical K-fold cross-validation strategy is employed to ensure data distribution consistency. First, the original dataset is divided into a pre-allocated training set (70%), a development set (20%), and an independent test set (10%) in a 7:2:1 ratio. The pre-allocated training set uses a K=5 cross-validation mechanism: the training data is evenly divided into five mutually exclusive subsets, and in each round of training, one subset is selected as the validation set, while the remaining four subsets are combined into the training set. This design ensures that the validation set comprises 20% of the original training data while improving evaluation reliability through multiple rounds of cyclical validation.

[0180] During the training phase, forward propagation is used to calculate the cross-entropy loss, combined with backpropagation for parameter updates. During the validation phase, the macro-F1 score and accuracy metrics on the development set are monitored in real time. An early stopping mechanism is triggered when the validation loss fails to improve after five consecutive epochs, while simultaneously saving a snapshot of the optimal model. The cross-validation mechanism significantly reduces model variance through multi-dimensional data utilization, resulting in a 4.1% improvement in test set accuracy to 99.23% compared to the baseline.

[0181] The optimizer configuration employs the AdamW algorithm, whose parameter update formula integrates L2 regularization and adaptive moment estimation, where the weight decay coefficient λ = 0.05. The dynamic learning rate adjustment strategy includes:

[0182] 1. Initial learning rate ;

[0183] 2. Cosine annealing scheduling: ;in: , , T max This represents the total number of epochs.

[0184] The regularization strategy employs a dual mechanism:

[0185]

[0186] The hardware environment was configured with an NVIDIA RTX-2080 GPU (8GB VRAM) for accelerated computing, and CUDA 11.1 to drive parallel operations. The training batch size was set to 64 to balance VRAM utilization and gradient stability. The complete training cycle took approximately 2.5 hours (150±50 epochs) on a 2.9GHz Intel Core i5-9400F / 32GB RAM platform, with peak VRAM usage controlled at 6.8GB.

[0187] Step 3: Based on the offline training in Step 2, the optimal GAF-SwT model is obtained and applied to the real-time stability assessment of transient voltage. Simultaneously, the critical busbars prone to instability are identified. The specific steps are as follows:

[0188] Step 3-1: Online dynamic evaluation of transient processes.

[0189] Real-time power grid dynamic data is collected by the PMU and preprocessed according to the standardization procedure described in step 1. The data is then input into the optimal GAF-SwT evaluation model after training. The model, through its unique hierarchical feature extraction architecture, completes the transient stability determination within 20ms and outputs a binary classification result of "stable / unstable" for the system.

[0190] Step 3-2: Locating the critical busbar under unstable conditions.

[0191] When the model determines that the system is in an unstable state, the feature source tracing module based on the attention mechanism is automatically triggered. Let the attention weight matrix output by the last layer of the Swing Transformer network be... ,in N This represents the total number of busbar nodes. H For the number of attention heads, T The sampling time window length for the transient process is given. The voltage instability impact factor is calculated using a spatiotemporal attention fusion mechanism.

[0192] (18);

[0193] (19);

[0194] : No. h The attention head is in the first L Layer to busbar i At any moment t Attention weights.

[0195] Busbar i In the h The temporal average attention intensity of each attention head.

[0196] : Represents the learnable attention head fusion weights.

[0197] : No. h Each attention head corresponds to a trainable scalar parameter.

[0198] Busbar i The normalized voltage instability influence factor satisfies .

[0199] The criteria for determining critical busbars are as follows:

[0200] (20);

[0201] The dynamic threshold parameter is set to λ=1.28, which corresponds to the 90% confidence interval. and Generator power angle influence factors Standard deviation and mean N The total number of generators. i Indicates the first i One generator. Noise interference is suppressed using a standard deviation weighting mechanism. A set of key source buses causing system instability is obtained through dynamic threshold criterion screening. C ,in β i The higher the value of the busbar, the greater its contribution to transient instability.

[0202] like Figure 4 As shown, the Swing Transformer network used is specifically as follows:

[0203] The input image of the Swin Transformer network is fed into the Patch Partition module. The output of the Patch Partition module is connected to the input of the Linear Embedding module. The output of the Linear Embedding module is connected to the input of the first Swin Transformer Block module group. The output of the first Swin Transformer Block module group is connected to the input of the first Patch Merging module. The output of the first Patch Merging module is connected to the input of the second Swin Transformer Block module group. The output of the second Swin Transformer Block module group is connected to the input of the second Patch Merging module. The output of the second Patch Merging module is connected to the input of the third Swin Transformer Block module group. The output of the third Swin Transformer Block module group is connected to the input of the third Patch Merging module. The output of the third Patch Merging module is connected to the input of the fourth Swin Transformer Block module group. The output of the fourth Swin Transformer Block module group is connected to the input of the Layer Norm module. The output of the Layer Norm module is connected to the input of the Global Average Pooling module. The output of Pooling is connected to the input of FullyConnectedLayer, and the output of Fully ConnectedLayer is used to output the output features of the SwinTransformer network.

[0204] The Swin Transformer Block module group includes multiple Swin Transformer Block modules, such as Figure 5 As shown, the Swin Transformer Block module is specifically as follows:

[0205] The input feature of the Swin Transformer Block module is Z. The input feature Z is input to the first LayerNorm module. The output of the first LayerNorm module is connected to the input of the window self-attention module W-MSA. The output feature of the window self-attention module W-MSA is added to the input feature Z to obtain the summed output feature Z1.

[0206] The output feature Z1 is input to the second LayerNorm module. The output of the second LayerNorm module is connected to the input of the first MLP module. The output of the first MLP module is added to the output feature Z1 to obtain the summed output feature Z2.

[0207] The output feature Z2 is then input to the input terminals of the third LayerNorm module and the fourth LayerNorm module, respectively. The output terminal of the third LayerNorm module is connected to the input terminal of the SW-MSA module; the output terminal of the fourth LayerNorm module is connected to the input terminal of the CW-MSA module; the outputs of the SW-MSA module, the CW-MSA module, and the output feature Z2 are then added together.

[0208] The summed output feature Z3 is input to the fifth LayerNorm module. The output of the LayerNorm module is connected to the input of the second MLP module. The input of the second MLP module is added to the output feature Z2. The summed feature is the output feature of the Swing Transformer Block module.

[0209] Example:

[0210] This invention validates the model's effectiveness using the China Electric Power Research Institute (CEPRI) 36-bus standard test system and the IEEE 2383-bus actual system. The CEPRI-36 system comprises 36 bus nodes, 8 generators (G1~G8), 10 transformers, 24 transmission lines, and 6 load nodes; the Polish-2383 system comprises 2383 bus nodes, 327 generators, 2896 transmission lines, and 1561 load nodes. Time-domain simulations were conducted using PSASP7 software. The load level was adjusted incrementally within the range of 0%-120% in 2% increments, based on an initial value, while generator output was dynamically adjusted to maintain system power balance. The fault setting was a three-phase ground fault applied at 1 second, with fault points located at the beginning of the line and at distances of 25%, 50%, and 75% from the beginning. The duration varied within the range of [0.05, 0.25] seconds in 0.05-second increments, and the total simulation time was set to 10 seconds. Through parameter combination iterations, the CEPRI-36 system generated 10,315 samples, while the Polish-2383 system obtained 24,840 samples. The experimental environment used the PyTorch deep learning framework (Python 3.8), with hardware configurations including an Intel Core i7-10750H processor (2.6GHz), 16GB of RAM, and an NVIDIA RTX-2060 graphics card.

[0211] When a fault occurs in the power system, the PMU records and transmits data online. After graphical processing, the data is input to the optimal model at the control center. Based on the set parameters, the transient stability of the power system is continuously evaluated, and operators take timely emergency control measures based on the evaluation results. This paper measures the model's evaluation performance using the following four indicators, as shown in the formulas below.

[0212] (twenty one)

[0213] (twenty two)

[0214] (twenty three)

[0215] (twenty four)

[0216] Where TP and FN represent the number of stable samples assessed as stable and unstable, respectively, and FP and TN represent the number of unstable samples assessed as stable and unstable, respectively. Recall and precision represent the proportion of correctly predicted unstable samples among actual unstable samples and predicted unstable samples, respectively; Ac reflects the overall accuracy of the evaluation model; and F1 is the harmonic mean of recall and precision.

[0217] To verify the advantages of the method of this invention, the samples were divided into training and test sets in an 8:2 ratio, and compared with commonly used data-driven power system transient stability assessment models, including SVM, CNN, ResNet, and ViT. The test results of different models on the two systems are shown in Tables 1 and 2.

[0218] Table 1 Comparison of model performance in the 36-node system.

[0219]

[0220] As shown in Figure 1, the experimental data demonstrate that the method of this invention performs best in terms of comprehensive evaluation indicators. Its accuracy of 99.23% and F1 score of 98.57% are on average 1.8-3.8 percentage points higher than the benchmark model ResNet, showing a significant advantage in classification performance and effectively supporting online decision-making for emergency control strategies after power system faults.

[0221] Table 2. Performance Comparison of Models in the 2383-Node System

[0222]

[0223] As shown in Table 2, when the system scaled up to 2383 nodes, all models experienced varying degrees of performance degradation, but the method of this invention still maintained the best performance level, with an accuracy of 99.21% and an F1 score of 98.56%, verifying the strong adaptability of the model to large-scale complex systems.

[0224] Instruction manual attached Figure 6 Heatmap of factors affecting bus voltage instability under different instability scenarios

[0225] Appendix Figure 6 The diagram presents heatmaps of bus node voltage instability influencing factors under different voltage instability scenarios. The larger the influencing factor value for a node, the brighter the corresponding area in the heatmap, indicating a higher risk of voltage collapse for that bus during system instability. Therefore, emergency voltage control measures should be prioritized in that area.

[0226] Table 3 Performance of all test systems under PMU data loss and noise conditions

[0227]

[0228] As shown in Table 3, although the evaluation metrics systematically degrade with increasing noise intensity, the proposed method still maintains an accuracy of over 93% under extreme noise conditions. Furthermore, even with a 15% loss rate, the proposed method maintains an F1 score of 93.24%, demonstrating its fault tolerance. This characteristic significantly enhances the robustness of power system transient stability assessment in complex electromagnetic environments, effectively addressing the dual interference of PMU measurement noise and communication link data packet loss.

[0229] In summary, compared with traditional methods, the method of this invention can achieve efficient and accurate voltage stability assessment in large-scale power systems, and has excellent real-time performance and robustness, providing reliable technical support for real-time monitoring and early warning of power systems.

[0230] As per the instruction manual Figure 5 As shown, the Swin Transformer model adapts to dense prediction tasks through a four-stage hierarchical architecture. Its core architectural principle is to progressively expand the receptive field and fuse multi-scale features. The input image is first segmented into 4×4 non-overlapping image blocks, which are then mapped to feature vectors through a linear embedding layer. Subsequently, it enters a processing flow consisting of four stages: each stage contains stacked Swin Transformer blocks and inter-stage Patch Merging downsampling layers. The former extracts local and global features, while the latter reduces spatial resolution and increases channel dimension by merging adjacent blocks, ultimately outputting feature maps of different scales to support multi-level feature fusion.

[0231] Each stage of the Swin Transformer block balances computational efficiency and global modeling capability through two innovative mechanisms. Window Multi-Head Self-Attention (W-MSA) divides the feature map into 7×7 local windows and calculates self-attention only within the window, significantly reducing computational complexity. Shift Window Multi-Head Self-Attention (SW-MSA) breaks the window boundary by cyclically shifting half a window in the lower right corner, enabling information exchange channels between adjacent windows.

[0232] Meanwhile, the Swin Transformer block employs a standardized residual structure to enhance training robustness. Layer normalization (LayerNorm) is applied before each self-attention module and feedforward network (FFN), and the original input and processing result are fused through residual connections. The FFN part consists of two fully connected layers, with a non-linear mapping achieved through the GELU activation function in between. This structural design ensures the integrity of gradient propagation while enhancing the model's expressive power through multi-layer feature transformation.

[0233] This invention replaces the original module with an improved Swing Transformer Block, further enhancing the feature extraction capability of the original network. This improvement, in turn, improves the prediction accuracy of the optimal transient voltage stability evaluation model in step 2 of this invention.

[0234] This invention significantly enhances the network's feature extraction capabilities by replacing the original module with an improved Swing Transformer Block. This improvement is reflected in step 2 of this invention: when the upgraded feature extraction module is applied to the transient voltage stability assessment model, the model's prediction accuracy reaches a better level, demonstrating the beneficial effect of structural improvement on the assessment task.

Claims

1. A method for evaluating transient voltage stability in a power system based on a GAF-SWIN transformer, characterized in that, Includes the following steps: Step 1: Collect historical online data and simulation data of the power system to construct a two-dimensional transient image sample set; Step 2: Improve the model feature extraction module and train the optimal transient voltage stability evaluation model; Step 3: Deploy the optimal model into the online evaluation system to evaluate voltage stability in real time and monitor key unstable buses; In step 3, the transient voltage stability assessment GAF-SwT model obtained after training in step 2 is used to perform real-time stability assessment of the transient voltage, and the critical busbars with instability in the weak nodes of the system are identified; this includes the following steps: Step 3-1: Perform online dynamic evaluation of the transient process; Step 3-2: Locate the critical busbar under unstable conditions; In step 3-1, the dynamic data of the power grid is first collected in real time based on the synchronous phasor measurement device (PMU). After standardization preprocessing according to the process described in step 1, the data is input into the iteratively optimized GAF-SwT evaluation model. The model completes the transient stability determination within a certain time window through its unique hierarchical feature extraction architecture and outputs the binary classification result of "stable / unstable" of the system. In step 3-2, let the attention weight matrix output by the last layer of the Swing Transformer network be... ,in N This represents the total number of busbar nodes. H For the number of attention heads, T The sampling time window length for the transient process; the voltage instability impact factor is calculated using a spatiotemporal attention fusion mechanism: (18); (19); : No. h The attention head is in the first L Layer to busbar i At any moment t Attention weights; Busbar i In the h The temporal average attention intensity of each attention head; : Represents the learnable attention head fusion weights; : No. h Trainable scalar parameters corresponding to each attention head; Busbar i The normalized voltage instability influence factor satisfies ; The criteria for determining critical busbars are as follows: (20); in, λ For dynamic thresholds, and Generator power angle influence factors β i Standard deviation and mean N The total number of generators. i Indicates the first i One generator; noise interference is suppressed using a standard deviation weighting mechanism; and the set of key source buses causing system instability is obtained through dynamic threshold criterion screening. C ,in β i The higher the value of the busbar, the greater its contribution to transient instability.

2. The method according to claim 1, characterized in that, In step 1, specifically: historical online monitoring data and simulation data of the power system are acquired to establish an initial sample set; Gram angle field and vertical image stitching algorithm are used to realize the time-domain feature preservation mapping from multivariate time series data to two-dimensional transient integrated image; then, stability state labeling is performed on each sample image, and finally, the training set and test set are randomly divided according to a preset ratio.

3. The method according to claim 1 or 2, characterized in that, Step 1 includes the following sub-steps: Step 1-1: Obtain the initial dataset; Step 1-2: Process the transient voltage time series Perform normalization; Steps 1-3: Normalize the voltage time series Convert to polar coordinates; Steps 1-4: Use the GAF algorithm to process the polar coordinate data Convert to a two-dimensional image; Steps 1-5: Generate stitched image data; Steps 1-6: Divide the image data into stable and unstable datasets using the TVSI index; Steps 1-7: Randomly divide the processed image dataset into training and test sets according to a certain ratio.

4. The method according to claim 3, characterized in that, Specifically: In step 1-1, when obtaining the initial dataset, specifically: historical online data is obtained by online recording through the PMU synchronous measurement device, and then simulation calculations are performed based on power system simulation software such as PSASP. By setting different operating modes and fault modes, the voltage data of the simulated nodes are obtained to form the initial dataset. In steps 1-2, the transient voltage time series is processed. When performing normalization, specifically: Let the first power system be... The voltage time series of each node is as follows ,in Indicates the first Each node at time... t The voltage value, where T is the length of the time series, for the voltage time series of each node. Normalization is performed, and the normalized time series is obtained. for: (1); in, and Representing voltage time series respectively The minimum and maximum values; In steps 1-3, the normalized voltage-time series is... Converting to polar coordinates, specifically: the amplitude of the normalized voltage signal is encoded as an angle cosine, and the time axis is encoded as a radius, thus obtaining the radius and angle of each data point; Time series Mapped to radius ,Right now: (2); in, t For a point in time, T This represents the total length of the time series. Encode amplitude as angle ,Right now: (3); Voltage data points Converted into corresponding polar coordinate data ; In steps 1-4, the GAF algorithm is used to process the polar coordinate data. Converting to a two-dimensional image, specifically: In GAF, the value of each pixel in the image is calculated using the following formula: (4); in, G ij Indicates the first i and the j The cosine of the angle difference at time points is used as an element in the GAF image; In steps 1-5, when generating the stitched image data, specifically: for multiple nodes... i =1,2,…,N, each node generates a GAF image. G i Finally, the GAF images of all nodes are vertically stitched together to form an integrated image; (5); in, G integrated To integrate the images, the stitching method involves arranging each image in a row; each G i For the first i GAF image of each node; In steps 1-6, the image data is divided into stable and unstable datasets using the TVSI metric; specifically, the TVSI metric is: (6); In the formula, This represents the minimum load node voltage after the disturbance occurs. To set the voltage value, The duration for which the load node voltage is lower than the set voltage value. TVSI = 1 indicates that the power system is in a transient voltage stability state, representing the maximum allowable time for the voltage to drop below the set value. This indicates that the power system is in a transient voltage instability state; accordingly, stable and unstable samples are labeled as 1 and -1, respectively.

5. The method according to claim 4, characterized in that, In step 2, the improved Swin Transformer module includes the following steps: Step 2-1: Adjust the model position encoding; Step 2-2: Adjust the window size and the step size; Steps 2-3: Divide the window; Steps 2-4: Determine if windows are adjacent; Steps 2-5: Obtain and output the fused features.

6. The method according to claim 5, characterized in that, In step 2-1, interpolation is used to adjust the position encoding to ensure that each position in the stitched image correctly corresponds to the spatial information of the original image; specifically: Let the height of the original image be... H img,init Width is W img,init The height of the stitched image is H img,new Width is W img,new The original location is encoded as follows: After interpolation, the new position code Adjustment is made using bilinear interpolation: (7); Among them, the nearest integer points: (8); Interpolation weights: (9); , , and These represent the scaling ratios of the height of the stitched image relative to the height and width of the original image, respectively. This adjustment method ensures that the stitched image retains the positional information of the original image; where, and : Represents the nearest integer coordinates in the height direction. It is less than or equal to the interpolation point height. The largest integer, It is greater than or equal to the interpolation point height. The smallest integer that satisfies the following constraints: ; and : Represents the nearest integer coordinates in the width direction. It is less than or equal to the interpolation point width. The largest integer, It is greater than or equal to the interpolation point width. The smallest integer that satisfies the following constraints: .

7. The method according to claim 5, characterized in that, In step 2-2, the window size adjustment is specifically performed as follows: Let the original window size be W size,init The size of the stitched image window W size,new It should be the same size as the original window: (10); in, H img,init The height of the original image. iH This represents the height of the stitched image. round Indicates rounding down; Make stride adjustments, specifically: Original stride S init The dimensions of the stitched image should be adjusted according to the size of the image as shown in equation (11): (11); in, S init This is the original stride length. S new The adjusted stride ensures that the window's sliding motion adapts to the new image size, preventing information loss due to an unsuitable stride.

8. The method according to claim 5, characterized in that, In steps 2-4, if windows are adjacent, a window shifting attention mechanism is implemented; The window shifting attention mechanism is specifically as follows: Let the input feature map be X Height is H img,new Width is W img,new Window size is W size,new = M×M shift step In the window shifting layer, the feature map is shifted as follows: First, perform a cyclic shift (Roll) operation on X to obtain the shifted feature map. : (12); The shift parameter represents the horizontal and vertical translation of the input feature map X. S new Units; For any pixel position Its new coordinates after shifting are: (13): (14); Here, mod represents the modulo operation, which restricts out-of-bounds index values ​​to a range using the modulo operation. or This allows for the cyclic shifting of data at the edges of the feature map; The shifted feature map according to M×M Non-overlapping window partitioning; defining window sets Each window is: (15); in r,c These are the vertical and horizontal indices of the window, respectively. and ; If the windows are not adjacent, a cross-window connection attention mechanism is used; The cross-window connection attention mechanism is specifically as follows: By calculating attention scores between windows and performing weighted aggregation, information interaction is facilitated. (16); in, A ij Display window w i and window w j Attention scores between them Q i and K j These are windows w i and window w j Query and key matrix: (17); in, O i For window W i The output, V j For window W j The value of .