Power system state detection method and device based on learnable query vector

By constructing a ternary heterogeneous graph and using graph convolutional networks and learnable query vectors for information augmentation, the problems of low efficiency and insufficient accuracy in power flow calculation are solved, achieving high efficiency and accuracy in power flow calculation and supporting real-time safety early warning of the power grid.

CN122159503APending Publication Date: 2026-06-05北京怀柔实验室 +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
北京怀柔实验室
Filing Date
2026-04-21
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Existing technologies suffer from low efficiency and insufficient accuracy in power flow calculations. In particular, the traditional power flow calculation equations are complex and nonlinear, resulting in low computational efficiency. While artificial intelligence models such as GNN can improve efficiency, their accuracy is not ideal.

Method used

By constructing a ternary heterogeneous graph, using graph convolutional networks to extract feature vectors of nodes and edges, and employing learnable query vectors and cross-attention mechanisms for information enhancement, combined with feedforward neural networks for power flow calculation, the local and global accuracy of node information is improved.

Benefits of technology

It improves the accuracy and efficiency of power flow calculation, enabling more precise prediction of voltage and phase angle, and realizing a direct technical closed loop from power flow calculation to real-time safety early warning, thereby enhancing the automation level and safety response efficiency of power grid operation monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122159503A_ABST
    Figure CN122159503A_ABST
Patent Text Reader

Abstract

The application provides a power system state detection method and device based on a learnable query vector, which comprises the following steps: injecting generator node parameters, load node parameters, balance node parameters and edge parameters into nodes and edges in a topological structure; using a graph convolution network to extract feature vectors of each node, the connection edge of each node and the connection node of the connection edge in a ternary heterogeneous graph; using a learnable query vector to extract features from the local enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph; inputting the global enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph and the local enhanced feature vectors of the balance node into a feedforward neural network respectively to obtain the voltage amplitude and voltage phase angle of each node in the current power grid. The accuracy and efficiency of power flow calculation can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, and in particular to a power system state detection method based on learnable query vectors, a power system state detection device based on learnable query vectors, computer equipment, computer-readable storage medium, and computer program product. Background Technology

[0002] Power flow calculation refers to the calculation of other parameters (such as voltage magnitude and phase angle at each node) within a given power system network structure and some of its parameters (e.g., generator power and load power). The results of power flow calculations enable system planning and design, safe operation and monitoring, optimized operation and control, and accident analysis.

[0003] With the integration of artificial intelligence (AI) models into various industries, using AI models for power flow calculations has become a primary method for this purpose. Specifically, the process begins by constructing an initial Graph Neural Network (GNN) model and preparing training data. This training data can include the power grid topology, node feature data (e.g., injected active power, injected reactive power, node type encoding, reference voltage / voltage setpoint, voltage amplitude, voltage phase angle, etc.), and edge feature data (e.g., resistance, reactance, ground susceptance / charging capacitance, transformer turns ratio, etc.). Then, the training data is fed into the initial GNN model for further training, resulting in a GNN model suitable for power flow calculations. When power flow calculations are required for a power grid, the topology of the power grid, the injected active power and injected reactive power of the nodes, the node type encoding, the reference voltage / voltage setpoint, and the resistance, reactance, ground susceptance / charging capacitance, and transformer turns ratio of the edges are input into the GNN model. The GNN model can then output the voltage amplitude and voltage phase angle of each node in the power grid, thereby realizing the power flow calculation of the current power grid.

[0004] However, traditional power flow calculation equations are complex and nonlinear. The Generative Neural Network (GNN) model is essentially a universal function approximator composed of multiple layers of neurons, controlled by adjustable parameters (weights and biases). Training a GNN model can only make it as closely as possible to the true functional shape of the power flow equations. In other words, power flow calculations using GNN models are not as accurate as those using traditional power flow equations. While traditional power flow calculation equations can achieve accurate calculations, the multiple iterations involved lead to low efficiency. Therefore, there is an urgent need for a technical solution to achieve efficient and accurate power flow calculations. Summary of the Invention

[0005] The purpose of this application is to provide a power system state detection method based on learnable query vectors, a power system state detection device based on learnable query vectors, a computer device, a computer-readable storage medium, and a computer program product, so as to improve the accuracy of power grid data processing.

[0006] To address the aforementioned technical problems, the embodiments of this application provide the following technical solutions: The first aspect of this application provides a power system state detection method based on learnable query vectors. The method includes: acquiring the topology of the current power grid, different types of parameters of different nodes, and edge parameters, wherein the different types of parameters of different nodes include generator node parameters, load node parameters, and slack node parameters; injecting the generator node parameters, load node parameters, slack node parameters, and edge parameters into the nodes and edges of the topology to obtain a ternary heterogeneous graph of the current power grid; using a graph convolutional network to extract feature vectors of each node, each node's connecting edge, and the connecting nodes of the connecting edges in the ternary heterogeneous graph, and using the extracted feature vectors as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph; using learnable query vectors to extract features from the local enhancement feature vectors of each generator node and each load node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle, to obtain the global enhancement feature vectors of each generator node and each load node; inputting the global enhancement feature vectors of each generator node and each load node in the ternary heterogeneous graph, and the local enhancement feature vectors of the slack node, into a feedforward neural network to obtain the voltage amplitude and voltage phase angle of each node in the current power grid.

[0007] Compared to existing technologies, the power system state detection method based on learnable query vectors provided in the first aspect of this application generates a ternary heterogeneous graph of generator nodes, load nodes, and slack nodes, and enhances the information of each node in the graph based on its connecting edges and the nodes connected to those edges, enabling each node to know its status in the local environment. Then, the generator nodes and load nodes in the graph query based on the slack node, allowing the generator nodes and load nodes to obtain the global optimal solution. Finally, power flow calculation is performed based on the information of each node in the graph, which can improve the accuracy and efficiency of power flow calculation.

[0008] In other embodiments provided in this application, before injecting the generator node parameters, load node parameters, balancing node parameters, and edge parameters into the nodes and edges of the topology, the method further includes: performing feature orthogonalization processing on the generator node parameters, load node parameters, balancing node parameters, and edge parameters to obtain feature orthogonalized generator node parameters, load node parameters, balancing node parameters, and edge parameters; injecting the generator node parameters, load node parameters, balancing node parameters, and edge parameters into the nodes and edges of the topology, including: injecting the feature orthogonalized generator node parameters, load node parameters, balancing node parameters, and edge parameters into the nodes and edges of the topology.

[0009] The generator node parameters, load node parameters, slack node parameters, and edge parameters are orthogonalized to ensure that the meaning of each parameter is not repeated, thus avoiding repeated calculations of the same index and improving the accuracy of power flow calculation.

[0010] In other embodiments provided in this application, a graph convolutional network is used to extract the feature vectors of each node, the connecting edge of each node, and the connecting node of the connecting edge in the ternary heterogeneous graph, and the extracted feature vectors are used as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph. This includes: determining the node type of each node from the parameters corresponding to the nodes in the ternary heterogeneous graph, where the node types include generator nodes, load nodes, and balancing nodes; extracting the feature vectors of the current node, the connecting edge of the current node, and the connecting node of the connecting edge according to different node types using a graph convolutional network; and determining the feature vectors corresponding to the generator node, load node, and balancing node as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph.

[0011] By using different graph convolutional networks to compute generator nodes, load nodes, and balancing nodes, errors in feature vector extraction caused by differences in node types are avoided, thus improving the accuracy of node feature vector extraction.

[0012] In other embodiments provided in this application, the graph convolutional network includes a gating mechanism and residual connections. The parameters in the gating mechanism and residual connections are trained based on the training data of the nodes. According to different node types, the graph convolutional network is used to extract the feature vectors of the current node, the connection edge of the current node, and the connection node of the connection edge. This includes: dynamically selecting or weighting relevant information from the parameters of the current node, the connection edge of the current node, and the neighboring nodes pointed to by the connection edge through the gating mechanism; and directly passing the original conjugate input information and adding it to the processed representation through the residual connection to preserve the underlying features and promote gradient flow.

[0013] By using gating mechanisms and residual connections, the current node can selectively obtain important information from connecting edges and nodes, thereby improving the accuracy of node feature vector acquisition.

[0014] In other embodiments provided in this application, a learnable query vector is used to extract features from the local enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle. This includes: calculating the similarity with the local enhanced feature vector of the balancing node in the local enhanced feature vector of each generator node and each load node in the ternary heterogeneous graph based on the learnable query vector, using a cross-attention mechanism to obtain the attention weight of each generator node and each load node, wherein the higher the similarity, the greater the attention weight; and extracting features from the local enhanced feature vector of the balancing node in the ternary heterogeneous graph based on the attention weight of each generator node and each load node with the goal of more accurately predicting voltage and phase angle, wherein the weight is used to indicate the amount of data queried and the location of the query.

[0015] By employing a cross-attention mechanism, generator nodes and load nodes can obtain data from the balancing node that better reflects actual needs, thereby improving the accuracy of power flow calculations.

[0016] In other embodiments provided in this application, before calculating the similarity with the local enhanced feature vector of the balancing node in the local enhanced feature vector of each generator node and each load node in the ternary heterogeneous graph based on the learnable query vector using a cross-attention mechanism, the method further includes: mapping the local enhanced feature vectors of each generator node, each load node, and the balancing node to a unified feature space to obtain a unified local enhanced feature vector of each generator node, each load node, and the balancing node; performing a nonlinear transformation on the unified local enhanced feature vector of the balancing node using a multilayer perceptron; performing position encoding on the transformed unified local enhanced feature vector of the balancing node to preserve the absolute position of the balancing node in the topology; and calculating the similarity with the local enhanced feature vector of the balancing node in the local enhanced feature vector of each generator node and each load node in the ternary heterogeneous graph based on the learnable query vector using a cross-attention mechanism, which includes: calculating the similarity with the unified local enhanced feature vector of the balancing node after position encoding in the unified local enhanced feature vector of each generator node and each load node in the ternary heterogeneous graph based on the learnable query vector using a cross-attention mechanism.

[0017] By uniformly mapping the feature vectors of each node and then enhancing (enriching) the feature vectors of the slack node, generator nodes and load nodes can obtain more of the information actually needed from the slack node, thereby improving the accuracy of power flow calculation.

[0018] In other embodiments provided in this application, before obtaining the voltage amplitude and voltage phase angle of each node in the current power grid, the method further includes: obtaining the initial voltage amplitude and initial voltage phase angle of each node fed back by the feedforward neural network; calculating the active power and reactive power of each node based on the initial voltage amplitude and initial voltage phase angle of each node; comparing the calculated active power and reactive power of each node with the active power and reactive power corresponding to different types of parameters and edge parameters of each node; if the comparison result indicates that the total loss value does not exceed the preset total loss value, then the method proceeds to obtain the voltage amplitude and voltage phase angle of each node in the current power grid. The steps involve determining the voltage amplitude and voltage phase angle at a point. If the comparison result indicates that the total loss value exceeds the preset total loss value, the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are used again with a learnable query vector. Feature extraction is performed in the local enhancement feature vector of the balancing node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle, resulting in the global enhancement feature vector of each generator node and each load node. The global enhancement feature vector of each generator node and each load node in the ternary heterogeneous graph, and the local enhancement feature vector of the balancing node are then input into the feedforward neural network.

[0019] After initially calculating the voltage amplitude and phase angle, the active and reactive power of the nodes are calculated in reverse based on these values. This is then compared with the original input active and reactive power values ​​to determine the accuracy of the calculation through the total loss value. This method accurately and quickly determines the correctness of the power flow calculation results, improving the efficiency and accuracy of power flow calculation result verification, and consequently improving the accuracy of voltage amplitude and phase angle calculations. Furthermore, if an error in the voltage amplitude or phase angle calculation is determined, the erroneous result is substituted into the generator or load node, and a new query is performed based on the slack node. This allows for a rapid next cycle, improving the efficiency of calculating the correct voltage amplitude and phase angle.

[0020] In other embodiments provided in this application, if the comparison result indicates that the total loss value exceeds the preset total loss value, the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are again used as learnable query vectors to extract features in the local enhancement feature vectors of the balanced nodes of the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle. This includes: if the comparison result generated for the nth time indicates that the total loss value exceeds the preset total loss value, the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are again used as learnable query vectors to extract features in the local enhancement feature vectors of the balanced nodes of the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle, where n is a fixed integer.

[0021] When performing loss verification, by setting a preset number of times, and after the loss verification reaches the preset number of times, it can be directly determined that the current power grid is not converging, which can avoid wasting too much computing resources and achieve accurate determination of power grid non-convergence.

[0022] In other embodiments provided in this application, after obtaining the voltage amplitude and voltage phase angle of each node in the current power grid, the method further includes: converting the voltage amplitude and voltage phase angle into complex voltage vectors for each node; calculating the power flow distribution of each branch based on the complex voltage vectors and the node admittance matrix of the current power grid; identifying overloaded branches in the power flow distribution that exceed a preset safety threshold, and identifying abnormal voltage nodes in the voltage amplitude that deviate from a preset safety range; generating power grid safety status alarm information containing overloaded branches and abnormal voltage nodes, and outputting the power grid safety status alarm information to the power system dispatch control interface to instruct real-time regulation of the current power grid.

[0023] By converting power flow calculation results into safety criteria for branch power and node voltage, and automatically generating alarm information to push to the dispatch interface, a direct technical closed loop from accurate calculation to real-time safety early warning is realized, which significantly improves the automation level of power grid operation monitoring and safety response efficiency.

[0024] A second aspect of this application provides a power system state detection device based on learnable query vectors. The device includes: an acquisition module for acquiring the current power grid topology, different types of parameters for different nodes, and edge parameters, wherein the different types of parameters for different nodes include generator node parameters, load node parameters, and slack node parameters; a generation module for injecting the generator node parameters, load node parameters, slack node parameters, and edge parameters into the nodes and edges of the topology, respectively, to obtain a ternary heterogeneous graph of the current power grid; and an enhancement module for using a graph convolutional network to extract each node, the connecting edges of each node, and the connecting nodes of the connecting edges from the ternary heterogeneous graph. The system extracts feature vectors and uses them as local enhancement feature vectors for the corresponding nodes in the ternary heterogeneous graph. A global module extracts features from the local enhancement feature vectors of each generator node and each load node in the ternary heterogeneous graph using learnable query vectors, aiming to more accurately predict voltage and phase angle, thus obtaining global enhancement feature vectors for each generator node and each load node. A calculation module inputs the global enhancement feature vectors of each generator node and each load node in the ternary heterogeneous graph, and the local enhancement feature vectors of the balancing node, into a feedforward neural network to obtain the voltage amplitude and voltage phase angle of each node in the current power grid.

[0025] A third aspect of this application provides a computer device including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method of the first aspect.

[0026] The fourth aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method of the first aspect.

[0027] The fifth aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the method of the first aspect.

[0028] The power system state detection device based on learnable query vectors provided in the second aspect of this application, the computer equipment provided in the third aspect, the computer-readable storage medium provided in the fourth aspect, and the computer program product provided in the fifth aspect have the same or similar beneficial effects as the power system state detection method based on learnable query vectors provided in the first aspect. Attached Figure Description

[0029] The above and other objects, features, and advantages of exemplary embodiments of this application will become readily understood by reading the following detailed description with reference to the accompanying drawings. In the drawings, several embodiments of this application are illustrated by way of example and not limitation, with the same or corresponding reference numerals denoteing the same or corresponding parts, wherein: Figure 1This is a flowchart illustrating the power system state detection method based on learnable query vectors in the embodiments of this application. Figure 1 ; Figure 2 This is a flowchart illustrating the power system state detection method based on learnable query vectors in the embodiments of this application. Figure 2 ; Figure 3 This is a schematic diagram of the power system state detection device based on learnable query vectors in the embodiments of this application. Figure 1 ; Figure 4 This is a schematic diagram of the power system state detection device based on learnable query vectors in the embodiments of this application. Figure 2 ; Figure 5 This is a schematic diagram of the structure of the computer device in the embodiments of this application. Detailed Implementation

[0030] Exemplary embodiments of this application will now be described in more detail with reference to the accompanying drawings. While exemplary embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to enable a more thorough understanding of this application and to fully convey the scope of this application to those skilled in the art.

[0031] It should be noted that, unless otherwise stated, the technical or scientific terms used in this application shall have the ordinary meaning as understood by one of ordinary skill in the art to which this application pertains.

[0032] Currently, while using artificial intelligence models for power flow calculation can improve the efficiency of power flow calculation, the accuracy of power flow calculation is not ideal.

[0033] In view of this, embodiments of this application provide a power system state detection method, a power system state detection device, a computer device, a computer-readable storage medium, and a computer program product based on learnable query vectors. While still employing an artificial intelligence model, in the process of power flow calculation using the artificial intelligence model, a ternary heterogeneous graph is constructed to integrate various types of information involved in the power grid into node information and connection information of generator nodes, load nodes, and slack nodes. Local node information enhancement and global node information enhancement based on slack nodes are then performed in this graph before power flow calculation. This effectively improves the accuracy of voltage amplitude calculation, especially voltage phase angle calculation, thereby enhancing the accuracy and efficiency of power flow calculation.

[0034] It should be noted that all components, data, and related processing methods involved in this application are authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data comply with the relevant laws, regulations, and standards of the relevant countries and regions.

[0035] First, the power system state detection method based on learnable query vectors provided in the embodiments of this application will be described in detail.

[0036] Figure 1 This is a flowchart illustrating the power system state detection method based on learnable query vectors in the embodiments of this application. Figure 1 See Figure 1 As shown, the method may include: S11: Obtain the current power grid topology, different types of parameters of different nodes, and edge parameters. The different types of parameters of different nodes include generator node parameters, load node parameters, and balancing node parameters.

[0037] The current power grid refers to the power grid for which power flow calculations are to be performed. In practical applications, the current power grid can be a power grid already in operation, a power grid requiring power parameter optimization, or a power grid awaiting commissioning and requiring pre-commissioning testing. The specific type of the current power grid is not limited here.

[0038] The current power grid topology refers to the physical connection relationships and layout between the various components of the current power grid (such as power plants, substations, transmission lines, and electrical loads).

[0039] Different types of parameters for different nodes in the topology include generator node parameters, load node parameters, and balancing node parameters, such as active power, reactive power, and other electrical parameters.

[0040] The edge parameters in the topology are the parameters of each line in the power grid, such as line impedance, admittance parameters, and connection direction attributes.

[0041] S12: Inject the generator node parameters, load node parameters, slack node parameters, and edge parameters into the nodes and edges of the topology to obtain the current ternary heterogeneous graph of the power grid.

[0042] Since the topology only includes the nodes of the power grid and the connections between them, without any actual parameters for nodes or edges, the topology graph injects corresponding generator node parameters, load node parameters, and slack node parameters for each node. For each edge, corresponding line parameters are injected. This results in a ternary heterogeneous graph. The ternary heterogeneous graph not only contains parameters for clearly distinguishable buses and branches in the power grid but also their connections. This allows for a clear and effective representation of the current power grid.

[0043] Generator nodes, also known as PV nodes, are typically found in thermal power plants, hydroelectric power stations, and wind farms, used to inject active power into the power grid. These generators are equipped with automatic voltage regulators (AVRs) that automatically adjust the excitation current to maintain the bus voltage connected to the grid at a set level.

[0044] Load nodes, also known as PQ nodes, typically include all electricity-consuming units such as homes, factories, and commercial centers. Their electricity demand (active and reactive power) is determined by user behavior and is an "exogenous variable" that the power grid must satisfy. They cannot control the voltage of the power grid.

[0045] The slack node, also known as the reference node, is typically selected from the power plants with the largest capacity and best regulation performance in the system. Generally, there is one slack node in a ternary heterogeneous diagram.

[0046] The construction of the ternary heterogeneous graph utilizes the `torch.geometric` heterogeneous graph function. Using `HeteroData` as the structural foundation, three node types are first constructed for the ternary heterogeneous topology: generators, loads, and balancing nodes. Based on their different connection relationships, edge structures are constructed to connect each of these three node types. Since the power grid topology is undirected, reverse edges are also constructed. Considering the possibility of links between nodes of the same type in real-world scenarios, generator-generator links are also constructed. Furthermore, considering that the number of balancing nodes in the topology is always one, balancing node-balancing node edges are not constructed. Therefore, a total of eight edge types are constructed. The physical characteristic information of the three node types is added to the corresponding nodes in the heterogeneous graph based on their ID information. Finally, the physical characteristic information of the eight edge types is added to the corresponding edge information in the heterogeneous graph based on the ID information of the nodes at both ends of the link.

[0047] S13: Use graph convolutional networks to extract the feature vectors of each node, the connecting edges of each node, and the connecting nodes of the connecting edges in the ternary heterogeneous graph, and use the extracted feature vectors as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph.

[0048] Graph convolutional networks are a type of neural network that can learn features directly from graph data.

[0049] In a ternary heterogeneous graph, each node has corresponding parameters, and each edge also has corresponding parameters. A graph convolutional network is used to process the parameters of each node, its connecting edges, and the nodes connected by those edges, to obtain the local enhanced feature vector of the current node. In other words, the graph convolutional network enables each node in the ternary heterogeneous graph to learn its local information.

[0050] It's important to note that the graph convolutional network here can generate local enhancement feature vectors for each node in the ternary heterogeneous graph. This was achieved through training on a large amount of training data previously used for graph convolutional networks. In other words, the parameters in the graph convolutional network are optimized using known inputs and outputs. Here, the input can refer to the ternary heterogeneous graph, and the output can be either the local enhancement feature vectors or the power flow calculation results.

[0051] S14: Using learnable query vectors, feature extraction is performed from the local enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle, resulting in the global enhanced feature vector of each generator node and each load node.

[0052] Learnable query vectors are a set of "question outlines" or "information retrieval instructions" that are automatically learned and optimized by the model, and are obtained after training.

[0053] In a ternary heterogeneous graph, each node corresponds to a locally enhanced eigenvector. At this point, generator nodes and load nodes also need to understand global information in order to perform more accurate power flow calculations. The slack node is key to understanding this global information.

[0054] Each generator node and each load node obtains information from the balancing node through a learnable query vector that optimizes their power flow calculation results, and integrates it with their own information to obtain a global enhanced feature vector for each generator node and each load node.

[0055] S15: Input the global enhancement feature vector of each generator node and each load node in the ternary heterogeneous diagram, and the local enhancement feature vector of the balancing node into the feedforward neural network to obtain the voltage amplitude and voltage phase angle of each node in the current power grid.

[0056] A feedforward neural network is a type of neural network where information is passed unidirectionally from the input layer to the output layer, without any loops or feedback in between. The feedforward neural network here is also pre-trained. In other words, the graph convolutional network, learnable query vector, and feedforward neural network used in the above steps are all trained by processing the training data in the same way before inputting it.

[0057] The global enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph, and the local enhanced feature vectors of the balancing node are input into the feedforward neural network. The output of the feedforward neural network for each node is the power flow calculation result, namely the voltage amplitude and voltage phase angle of the current node.

[0058] As can be seen from the above, the power system state detection method based on learnable query vectors provided in this application generates a ternary heterogeneous graph of generator nodes, load nodes, and slack nodes, and enhances the information of each node in the graph based on its connecting edges and the nodes of the connecting edges, so that each node can know its status in the local environment. Then, the generator nodes and load nodes in the graph query based on the slack node, so that the generator nodes and load nodes obtain the global optimal solution. Finally, power flow calculation is performed based on the information of each node in the graph, which can improve the accuracy and efficiency of power flow calculation.

[0059] Furthermore, as a response to Figure 1 In a refinement and extension of the method shown, this application also provides a power system state detection method based on learnable query vectors.

[0060] Figure 2 This is a flowchart illustrating the power system state detection method based on learnable query vectors in the embodiments of this application. Figure 2 See Figure 2 As shown, the method may include: S21: Obtain the current power grid topology, different types of parameters of different nodes, and edge parameters. The different types of parameters of different nodes include generator node parameters, load node parameters, and balancing node parameters.

[0061] Step S21 here is implemented in the same way as step S11 in the previous embodiment. Please refer to the relevant description in the previous embodiment. It will not be repeated here.

[0062] S22: Perform feature orthogonalization on the generator node parameters, load node parameters, slack node parameters, and edge parameters to obtain the feature orthogonalized generator node parameters, load node parameters, slack node parameters, and edge parameters.

[0063] Feature orthogonalization is the process of separating multiple entangled and correlated factors, making them independent. In other words, when constructing heterogeneous graph features, it ensures that the features of the input model (such as generator parameters and load parameters) are information-rich and mutually independent. In practical applications, feature orthogonalization can be performed using algorithms such as Gram-Schmidt orthogonalization and matrix factorization-based methods.

[0064] S23: Inject the orthogonalized generator node parameters, load node parameters, slack node parameters, and edge parameters into the nodes and edges of the topology to obtain the current ternary heterogeneous graph of the power grid.

[0065] Step S23 here is implemented in the same way as step S12 in the previous embodiment. Please refer to the relevant description in the previous embodiment. It will not be repeated here.

[0066] S24: Determine the node type of each node from the parameters corresponding to the nodes in the ternary heterogeneous graph. The node types include generator nodes, load nodes, and balancing nodes.

[0067] S25: According to different node types, use graph convolutional networks to extract the feature vectors of the current node, the connecting edge of the current node, and the connecting node of the connecting edge; determine the feature vectors corresponding to the generator node, load node, and balance node as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph.

[0068] Here, different types of nodes in a ternary heterogeneous graph require different graph convolutional networks for feature extraction, while nodes of the same type can use the same graph convolutional network for feature extraction. This avoids the influence of node type on feature extraction and also prevents the node type from changing during feature extraction, thus ensuring the accuracy of feature extraction.

[0069] For extracting local augmentation feature vectors of a certain type of node, the corresponding graph convolutional network employs gating mechanisms and residual connections to improve the accuracy of feature extraction. Furthermore, the parameters in the gating mechanism and residual connections are obtained during the training of the graph convolutional network.

[0070] Specifically, step S25 above may include: S251: Through a gating mechanism, relevant information is dynamically selected or weighted from the parameters of the current node, the connecting edges of the current node, and the neighboring nodes pointed to by the connecting edges.

[0071] S252: Through residual connections, the original input information is directly passed and added to the processed representation to preserve the underlying features and promote gradient flow.

[0072] Taking a module employing a residual-gated convolutional neural network as an example, three similar modules are set up in parallel. These three modules are used to extract the enhanced feature vectors of the generator node, load node, and slack node, respectively. The parameters in the three modules are independent of each other. Two residual-gated graph convolutional neural networks are set before the three modules. After the three modules, a linear layer and an activation layer are connected, and finally a normalization layer is connected; here, spectral normalization is used.

[0073] The residual gated graph convolutional neural network is as follows:

[0074] Among them, h i (l+1) Let represent the feature vector of node i at layer (l+1). W and V represent the learned weight matrices used for linear transformation of the node features. represents the activation function, such as ReLU or Sigmoid, used to introduce non-linearity. N(i) represents the set of neighboring nodes of node i. ij β represents the attention coefficient, measuring the degree of attention node i pays to its neighbor node j. β represents the learnable residual coefficient, used to control the proportion of original features retained after the update.

[0075] The local augmented feature vectors of each node in the ternary heterogeneous graph output by the graph convolutional network are input into the QueryingTransformer module for information exchange and more powerful feature extraction. The aim is to augment the data of the slack nodes onto the generator and load nodes, thereby improving the model's accuracy in predicting phase angles.

[0076] At this point, the local enhancement feature vectors of each node in the ternary heterogeneous graph output by the graph convolutional network can be directly input into the Querying Transformer module. Alternatively, the local enhancement feature vectors of each node in the ternary heterogeneous graph output by the graph convolutional network can be unified and the balance point feature vectors enhanced before being input into the Querying Transformer module to improve the accuracy of global information extraction.

[0077] S26: Map the local augmented feature vectors of each generator node, each load node, and each balancing node to a unified feature space to obtain a unified local augmented feature vector for each generator node, each load node, and each balancing node.

[0078] Specifically, the local enhancement feature vector F of the generator node can be projected using a dimensional projection matrix. G ∈R M×d Local augmentation feature vector F of the load node L ∈R M×d The local augmentation eigenvector F of the equilibrium node S∈R M×d Mapping to a unified feature space. The dimensional projection matrix uses a linear transformation (fully connected layer) to map the input features to a unified feature space. For F G Using the generator node projection weight matrix W G ∈R d×d' Perform projection. For F L Using the load node projection weight matrix W L ∈R d×d' Perform projection. For F S Using the balanced node projection weight matrix W S ∈R d×d' Projection is performed. Here, d represents the dimension of the original feature vector, d' represents the dimension of the projected feature vector, M represents the number of nodes of the corresponding type (generator or load), and R represents the set of real numbers.

[0079] S27: A multilayer perceptron is used to perform a nonlinear transformation on the unified local augmentation feature vector of the balanced node; the transformed unified local augmentation feature vector of the balanced node is then position-encoded to preserve the absolute position of the balanced node in the topology.

[0080] Specifically, the unified local augmentation feature vector of the balanced node can be enhanced using a multilayer perceptron (MLP).

[0081] First, a 64-dimensional linear layer is applied, followed by a non-linear transformation using the SiLU activation function, and then a 128-dimensional linear layer is applied. This ensures that the dimensionality of node features is expanded while content is extracted without loss.

[0082] Then, positional encoding is added to preserve the node's position information in the graph.

[0083] Specifically as follows: MLP: y=W2(σ(W1x+b1)+b2) Where, x∈R α For input, W1∈R n×α W2∈R o×n Let be the weight matrix, o represent the output dimension, b1 and b2 be the bias terms, and σ be a non-linear activation function (SiLU).

[0084] F ' S =MLP(F S PositionalEncoding Among them, F ' SThis represents the unified local augmented feature vector of the balanced node after MLP feature extraction and positional encoding enhancement.

[0085] S28: Based on the learnable query vector, in the local augmentation feature vector of each generator node and each load node in the ternary heterogeneous graph, the similarity with the unified local augmentation feature vector after position encoding of the balance node is calculated by the cross attention mechanism to obtain the attention weight of each generator node and each load node. The higher the similarity, the greater the attention weight.

[0086] S29: Based on the attention weights of each generator node and each load node, with the goal of more accurately predicting voltage and phase angle, feature extraction is performed in the local enhanced feature vectors of the balancing nodes in the ternary heterogeneous graph. The weights are used to indicate the amount of data queried and the location of the query, resulting in the global enhanced feature vectors of each generator node and each load node.

[0087] For each generator node and each load node in the ternary heterogeneous graph, a learnable query vector is randomly initialized, with its dimensions corresponding to the dimensions of the local augmentation feature vectors of the generator node and the load node, respectively. The generator query vector and the load query vector Q are initialized. L ∈R k×d Where k represents the number of query vectors.

[0088] The learnable query vector is used as Q, and the features extracted from the balancing node are used as KV. These are input into the cross-attention model to establish a feature enhancement channel from the balancing node to the generator and a feature compensation channel from the balancing node to the load.

[0089] Feature enhancement channel from the balancing node to the generator: The learned results are fused with the unified local enhancement feature vectors of the generator and load nodes using an accumulation method, and finally the final output is obtained through layer normalization.

[0090] F ' G =LayerNorm(F G +Attn_G) Among them, Q G This is the query matrix, used to generate the query vector. F SW_K and F SW_V These are the key matrix and value matrix of the generator, respectively, typically obtained through a linear transformation of the input features. d represents the dimension of the key vector. F G F represents the unified local enhancement feature vector of the generator node. ' GThis represents the unified local enhancement feature vector of the generator node after attention mechanism enhancement.

[0091] Characteristic compensation path from the balance node to the load:

[0092] F L '=LayerNorm(F L +Attn_L) Among them, Q L This is the query matrix, used to generate the query vector. F SW_K' and F SW_V' These are the key and value matrices of the load, typically obtained through a linear transformation of the input features. d represents the dimension of the key vector. F L This represents the original characteristics of the load node. F L ' is the unified local augmentation feature vector of the load node after attention mechanism enhancement.

[0093] Finally, the output feature fusion result is the global enhanced feature vector of each generator node and each load node in the ternary heterogeneous graph.

[0094] At this point, in the ternary heterogeneous graph, each generator node and each node corresponds to a global enhanced feature vector, while the balancing node corresponds to a local enhanced feature vector (in fact, the balancing node contains global information, which enables global feature enhancement for other nodes through querying).

[0095] S210: Input the global enhancement feature vector of each generator node and each load node in the ternary heterogeneous diagram, and the local enhancement feature vector of the balancing node into the feedforward neural network to obtain the initial voltage amplitude and initial voltage phase angle of each node in the current power grid.

[0096] A feedforward neural network, consisting of a multilayer perceptron, an activation function, a Dropout layer, and a LayerNorm layer, effectively maintains the output within a suitable range. Specifically: h=LayerNorm(Dropout(σ(W1x+b1),p)) Where the input is x∈R k×d W1∈R d×d This is the weight matrix. b1∈R d Let be the bias vector, k represent the number of input query vectors, and d represent the dimension of the feature vectors. σ is the activation function. p is the probability of Dropout.

[0097] The voltage amplitude and voltage phase angle of each node obtained at this time are calculated by mathematical model and may not fully conform to the physical rules of the power grid. Therefore, it is still necessary to check the physical rules of the voltage amplitude and voltage phase angle of each node.

[0098] S211: Calculate the active power and reactive power of each node based on the initial voltage amplitude and initial voltage phase angle of each node; compare the calculated active power and reactive power of each node with the active power and reactive power corresponding to different types of parameters and edge parameters of each node.

[0099] To quickly calculate the active and reactive power of each node, the ternary heterogeneous graph can be converted into a isomorphic graph. That is, the different types of nodes in the ternary heterogeneous graph are not distinguished, and all connections between edges and nodes are preserved. The parameters of nodes and edges in the isomorphic graph are the same as those in the ternary heterogeneous graph. Then, the active and reactive power of each node are calculated in the isomorphic graph.

[0100] First, calculate the complex voltage to facilitate matrix operations and power calculations. Specifically: V = Vm·exp(Va·j) Where Vm is the node voltage magnitude, Va is the voltage phase angle (in radians), and j is a complex unit. 2 =-1.

[0101] Then, the voltage in polar coordinates is converted to complex form using Euler's formula. The phase angle is converted to complex exponential form and then multiplied by the magnitude to obtain the complex voltage vector. Specifically: V=|Vm|·e jθ Where |Vm| is the amplitude, and θ is the phase angle.

[0102] Next, the current conjugate is calculated using the admittance matrix. That is, the product of the nodal admittance matrix (a complex symmetric matrix) and the voltage vector (the complex voltage vector obtained in the previous step) is calculated to obtain the nodal injected current vector, and then the conjugate is taken. Specifically: I=Y bus ·V Among them, Y bus It is the nodal admittance matrix.

[0103] Next, the complex power is calculated as follows: S=V·I* Where I* is the current conjugate.

[0104] Finally, the active and reactive power in the complex power are separated, and the L1 loss is calculated separately. Specifically: The active power P=Re(S) corresponds to the in-phase components of voltage and current. The reactive power Q=Im(S) corresponds to the orthogonal components of voltage and current.

[0105] The P and Q results are combined with the initial P and Q results of the nodes by calculating the average absolute error, and then combined into the total loss value to obtain the total loss value.

[0106] L1 Loss is used to measure the absolute error between the calculated value and the initial value. Assume the initial active power is P. initial The initial reactive power is Q. initial Then the L1 Loss formula is: L1 Loss of Active Power:

[0107] L1 Loss of Reactive Power:

[0108] Total loss: Total Loss = Loss p +Loss Q S212: If the comparison result indicates that the total loss value does not exceed the preset total loss value, then the voltage amplitude and voltage phase angle of each node in the current power grid are obtained.

[0109] In other words, the voltage amplitude and voltage phase angle of each node obtained at this time conform to the physical rules of the power grid and can be directly output for user use.

[0110] S213: If the comparison result indicates that the total loss value exceeds the preset total loss value, then the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are again processed using the learnable query vector, and S28 is executed again.

[0111] In other words, the voltage amplitude and voltage phase angle of each node obtained at this time do not conform to the physical rules of the power grid. In order to improve the efficiency of obtaining the voltage amplitude and voltage phase angle of each node that conform to the physical rules of the power grid, the voltage amplitude and voltage phase angle of the node obtained at this time can be globally queried again based on the local enhancement feature vector of the balancing node in the ternary heterogeneous graph to obtain the global enhancement feature vector of each generator node and each load node; the global enhancement feature vector of each generator node and each load node in the ternary heterogeneous graph, and the local enhancement feature vector of the balancing node are respectively input into the feedforward neural network to obtain the voltage amplitude and voltage phase angle of the node, and then the loss verification is performed again.

[0112] To avoid infinite loops caused by continuous large losses, and to prevent misjudgments and non-convergence of power flow calculations due to insufficient global relearning, a loop threshold can be set.

[0113] Specifically, step S213 may include: if the comparison result generated in the nth time indicates that the total loss value exceeds the preset total loss value, then the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are again processed by the learnable query vector, where n is a fixed integer.

[0114] In other words, if the voltage amplitude and voltage phase angle of the node generated in the nth generation still exceed the preset total loss value, then the voltage amplitude and voltage phase angle of the node generated in this generation will not be globally learned again. Instead, it will be directly determined that the current power grid does not converge in the power flow calculation.

[0115] In practical applications, n can be 8.

[0116] S214: Based on the calculated node voltage magnitude and phase angle, calculate the power flow distribution of the power grid and identify safety over-limit situations, generate alarm information and output it to the dispatch interface to support real-time control.

[0117] At this point, the physical quantities (voltage amplitude, phase angle) output by the previous deep learning model are embedded into the specific physical constraints and safe operation rules of the power system. These are then converted into safety criteria that can directly guide engineering practice using circuit laws, ultimately generating alarm information that drives the hardware system (dispatch and control interface) to execute real-time control actions. This process constitutes a complete technical closed loop of "data → physical model → safety analysis → control command," solving the specific technical problem of "how to quickly and accurately detect safety hazards and trigger control responses" in power system operation.

[0118] Specifically, step S214 above may include: S2141: Converts voltage magnitude and voltage phase angle into complex voltage vectors for each node.

[0119] Specifically, this can be based on the node voltage magnitude Vm and voltage phase angle Va, using Euler's formula e jθ =cosθ+jsinθ converts this to a complex voltage vector. For each node i, the complex voltage Vi is calculated as: V i =Vm i ·e j · Vai That is: V i =Vm i ·(cos(Va i )+j·sin(Va i )).

[0120] The complex voltages of all nodes are combined in sequence to obtain the complex voltage vector V = [V1, V2, …, VN]T of the system. This provides a basis for complex voltage data for subsequent power flow calculations and system analysis based on the admittance matrix that can directly perform matrix operations.

[0121] S2142: Calculate the power flow distribution of each branch based on the complex voltage vector and the nodal admittance matrix of the current power grid.

[0122] First, perform matrix multiplication on the complex voltage vector V and the nodal admittance matrix Ybus of the current power grid (this matrix is a complex symmetric matrix, pre-constructed according to the power grid topology and branch impedance parameters) to obtain the injection current vector I = Ybus·V of each node. Then, according to Kirchhoff's law and circuit principles, for any branch connecting node i and node j, its current Iij can be calculated through the admittance parameter yij of this branch and the voltage difference between the two end nodes. Iij = yij·(Vi - Vj). Finally, through the formula Sij = Vi·Iij* (in* (where * represents the conjugate operation) calculate the complex power Sij of this branch. Its real part is the active power Pij of the branch, and the imaginary part is the reactive power Qij of the branch, thereby obtaining the active and reactive power flow distributions of all branches in the entire power grid.

[0123] S2143: Identify the overloaded branches in the power flow distribution that exceed the preset safety threshold, and identify the abnormal voltage nodes in the voltage amplitude that deviate from the preset safety range.

[0124] After obtaining the power flow distribution of each branch (i.e., the active power Pij and the reactive power Qij) and the voltage amplitude Vm of each node i then compare the apparent power S ij 2 = P ij 2 + Q ij 2 of each branch with the preset allowable current-carrying capacity or stability limit of this branch (denoted as Sijmax). If Sij > Sijmax, then determine that this branch is an overloaded branch. At the same time, compare the voltage amplitude Vm i of each node with the safe operating range corresponding to the voltage level of this node (usually the upper and lower limits of the per-unit value, such as Vmin and Vmax). If Vm i < Vmin or Vm i > Vmax, then determine that this node is an abnormal voltage node.

[0125] S2144: Generate grid safety status alarm information including overload branches and abnormal voltage nodes, and output the grid safety status alarm information to the power system dispatch control interface to instruct real-time regulation of the current grid.

[0126] For all identified overloaded branches and abnormal voltage nodes, the alarm information is formatted and encapsulated according to a preset alarm information template. For each overloaded branch, an alarm entry is generated containing its line number, current power flow value, over-limit ratio, and suggested handling measures. For each abnormal voltage node, an alarm entry is generated containing its node number, current voltage amplitude, deviation range, and impact level. All alarm entries are merged into a structured power grid safety status alarm message.

[0127] The generated structured alarm information is transmitted in real time to the alarm server or message middleware of the power system dispatch control interface through a preset data interface protocol (such as IEC 61850, IEC 104 or internal API), and is presented in a prominent visual manner (such as color highlighting, flashing icons, pop-up windows and sound prompts) on the dispatcher's workstation interface to ensure that dispatchers can immediately perceive abnormal power grid conditions.

[0128] Based on the specific over-limit branches and voltage anomaly nodes indicated by the alarm information, the dispatcher initiates corresponding control operations in the dispatch control interface, such as adjusting generator output, switching reactive power compensation devices, changing operating modes, or issuing load shedding commands. The suggested measures provided in the alarm information can be directly used as a control decision aid. Ultimately, the control commands are sent to execution units such as substations and power plants through the dispatch automation system, realizing real-time closed-loop control of the current power grid operating status.

[0129] As described above, the power system state detection method based on learnable query vectors provided in this application utilizes large-scale parallel computing with a graphics processing unit (GPU) to simultaneously process power flow analysis tasks across multiple cross-sections. It is independent of the number of convergence iterations and can directly output convergence results end-to-end, improving power flow calculation speed. Furthermore, the end-to-end power flow unknown value fitting method, independent of initial values ​​and other influencing factors, can ignore intermediate iterative processes and directly output the final result. The use of a formulaic loss function as a model constraint ensures convergence in all scenarios. Additionally, the Querying Transformer method explores global network topology information. By combining global and local information, and further analyzing phase angle positions and feature embedding information, comprehensive data analysis yields highly accurate data for any scenario. Finally, it is independent of any external conditions; only model data and parameters need to be input for one-click analysis and calculation, adapting to various strong fluctuation situations.

[0130] Based on the same inventive concept, embodiments of this application also provide a power system state detection device based on learnable query vectors.

[0131] Figure 3 This is a schematic diagram of the power system state detection device based on learnable query vectors in the embodiments of this application. Figure 1 See Figure 3 As shown, the device may include: The acquisition module 31 is used to acquire the current power grid topology, different types of parameters of different nodes, and edge parameters. The different types of parameters of different nodes include generator node parameters, load node parameters, and balancing node parameters. The generation module 32 is used to inject the generator node parameters, load node parameters, slack node parameters, and edge parameters into the nodes and edges of the topology to obtain the current ternary heterogeneous graph of the power grid. Enhancement module 33 is used to extract the feature vectors of each node, the connecting edge of each node, and the connecting node of the connecting edge in the ternary heterogeneous graph using a graph convolutional network, and to use the extracted feature vectors as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph. Global module 34 is used to extract features from the local enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle using learnable query vectors, and obtain the global enhanced feature vectors of each generator node and each load node. The calculation module 35 is used to input the global enhancement feature vector of each generator node and each load node in the ternary heterogeneous diagram, and the local enhancement feature vector of the balancing node into the feedforward neural network to obtain the voltage amplitude and voltage phase angle of each node in the current power grid.

[0132] Furthermore, as Figure 3 In addition to the refinement and expansion of the illustrated device, this application embodiment also provides a power system state detection device based on learnable query vectors.

[0133] Figure 4 This is a schematic diagram of the power system state detection device based on learnable query vectors in the embodiments of this application. Figure 2 See Figure 4 As shown, the device may include: The acquisition module 41 is used to acquire the current power grid topology, different types of parameters of different nodes, and edge parameters. The different types of parameters of different nodes include generator node parameters, load node parameters, and balancing node parameters.

[0134] Orthogonal module 42 is used to perform feature orthogonalization processing on generator node parameters, load node parameters, slack node parameters and edge parameters to obtain feature orthogonalized generator node parameters, load node parameters, slack node parameters and edge parameters.

[0135] The generation module 43 is used to inject the orthogonalized generator node parameters, load node parameters, slack node parameters, and edge parameters into the nodes and edges of the topology to obtain the ternary heterogeneous graph of the current power grid.

[0136] Enhancement module 44 is used to determine the node type of each node from the parameters corresponding to the nodes of the ternary heterogeneous graph. The node types include generator nodes, load nodes and balancing nodes. According to different node types, graph convolutional networks are used to extract the feature vectors of the current node, the connecting edge of the current node and the connecting node of the connecting edge. The feature vectors corresponding to the generator node, load node and balancing node are determined as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph.

[0137] In a graph convolutional network that includes gating mechanisms and residual connections, where the parameters in the gating mechanisms and residual connections are obtained based on the training data of the nodes, the enhancement module 44 is specifically used to dynamically select or weight relevant information from the parameters of the current node, the connection edges of the current node, and the neighboring nodes pointed to by the connection edges through the gating mechanism; and to directly pass the original input information and add it to the processed representation through the residual connection in order to preserve the low-level features and promote gradient flow.

[0138] Global module 45 is specifically used to calculate the similarity between the local enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph and the local enhanced feature vectors of the balancing node using a cross-attention mechanism, based on the learnable query vectors, to obtain the attention weights of each generator node and each load node. The higher the similarity, the greater the attention weight. Based on the attention weights of each generator node and each load node, with the goal of more accurately predicting voltage and phase angle, queries are performed in the local enhanced feature vectors of the balancing node in the ternary heterogeneous graph, where the weights are used to indicate the amount of data queried and the location of the query.

[0139] Global module 45 is also used to map the local augmentation feature vectors of each generator node, each load node, and each balancing node to a unified feature space to obtain a unified local augmentation feature vector for each generator node, each load node, and each balancing node; a multilayer perceptron is used to perform a nonlinear transformation on the unified local augmentation feature vector of the balancing node; the transformed unified local augmentation feature vector of the balancing node is position-encoded to preserve the absolute position of the balancing node in the topology; based on the learnable query vector, a cross-attention mechanism is used to calculate the similarity between the unified local augmentation feature vector of each generator node and each load node in the ternary heterogeneous graph and the unified local augmentation feature vector of the balancing node after position encoding.

[0140] The calculation module 46 is used to obtain the initial voltage amplitude and initial voltage phase angle of each node fed back by the feedforward neural network; calculate the active power and reactive power of each node based on the initial voltage amplitude and initial voltage phase angle of each node; compare the calculated active power and reactive power of each node with the active power and reactive power corresponding to different types of parameters and edge parameters of each node; if the comparison result indicates that the total loss value does not exceed the preset total loss value, then the voltage amplitude and voltage phase angle of each node in the current power grid are obtained; if the comparison result indicates that the total loss value exceeds the preset total loss value, then the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are used again with a learnable query vector to extract features in the local enhancement feature vector of the balancing node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle, to obtain the global enhancement feature vector of each generator node and each load node; input the global enhancement feature vector of each generator node and each load node in the ternary heterogeneous graph, and the local enhancement feature vector of the balancing node into the feedforward neural network respectively.

[0141] The calculation module 46 is specifically used to extract features from the local enhancement feature vector of the balanced node of the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle if the comparison result generated in the nth time indicates that the total loss value exceeds the preset total loss value. Here, n is a fixed integer.

[0142] The detection module 47 is used to convert voltage amplitude and voltage phase angle into complex voltage vectors for each node; calculate the power flow distribution of each branch based on the complex voltage vectors and the node admittance matrix of the current power grid; identify overloaded branches in the power flow distribution that exceed the preset safety threshold, and identify abnormal voltage nodes in the voltage amplitude that deviate from the preset safety range; generate power grid safety status alarm information containing overloaded branches and abnormal voltage nodes, and output the power grid safety status alarm information to the power system dispatch control interface to indicate real-time regulation of the current power grid.

[0143] It should be noted that the description of the above device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0144] Based on the same inventive concept, this application also provides a computer device.

[0145] Figure 5 This is a schematic diagram of the structure of the computer device in an embodiment of this application. See also... Figure 5 As shown, the computer device may include: a memory 51, a processor 52, and a computer program stored on the memory 51, wherein the processor 52 executes the computer program to implement the methods described in the foregoing embodiments.

[0146] It should be noted that the description of the above computer device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the computer device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0147] Based on the same inventive concept, embodiments of this application also provide a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the methods described in the foregoing embodiments.

[0148] It should be noted that the description of the above computer-readable storage medium embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the computer-readable storage medium embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0149] Based on the same inventive concept, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the methods described in the foregoing embodiments.

[0150] It should be noted that the descriptions of the above computer program product embodiments are similar to those of the above method embodiments, and have similar beneficial effects. For technical details not disclosed in the computer program product embodiments of this application, please refer to the descriptions of the method embodiments of this application for understanding.

[0151] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A power system state detection method based on learnable query vectors, characterized in that, The method includes: Obtain the current power grid topology, different types of parameters of different nodes, and edge parameters. The different types of parameters of different nodes include generator node parameters, load node parameters, and slack node parameters. The generator node parameters, load node parameters, slack node parameters, and edge parameters are injected into the nodes and edges of the topology to obtain the ternary heterogeneous graph of the current power grid. A graph convolutional network is used to extract the feature vectors of each node, the connecting edge of each node, and the connecting node of the connecting edge in the ternary heterogeneous graph, and the extracted feature vectors are used as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph. The learnable query vector is used to extract features from the local enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle, so as to obtain the global enhanced feature vector of each generator node and each load node. The global enhanced feature vectors of each generator node and each load node in the ternary heterogeneous diagram, and the local enhanced feature vectors of the balancing node are input into the feedforward neural network to obtain the voltage amplitude and voltage phase angle of each node in the current power grid.

2. The method according to claim 1, characterized in that, Before injecting the generator node parameters, load node parameters, balancing node parameters, and edge parameters into the nodes and edges of the topology, the method further includes: The generator node parameters, load node parameters, slack node parameters, and edge parameters are subjected to feature orthogonalization to obtain the feature orthogonalized generator node parameters, load node parameters, slack node parameters, and edge parameters. The step of injecting the generator node parameters, load node parameters, balancing node parameters, and edge parameters into the nodes and edges of the topology includes: The orthogonalized generator node parameters, load node parameters, balancing node parameters, and edge parameters are injected into the nodes and edges of the topology, respectively.

3. The method according to claim 1, characterized in that, The step involves using a graph convolutional network to extract feature vectors for each node, the connecting edges of each node, and the connecting nodes of the connecting edges in the ternary heterogeneous graph, and using the extracted feature vectors as local enhancement feature vectors for the corresponding nodes in the ternary heterogeneous graph, including: The node type of each node is determined from the parameters corresponding to the nodes of the ternary heterogeneous graph, and the node type includes generator nodes, load nodes and balancing nodes; According to different node types, graph convolutional networks are used to extract the feature vectors of the current node, the connecting edges of the current node, and the connecting nodes of the connecting edges. The feature vectors corresponding to the generator node, load node, and balancing node are determined as the local enhanced feature vectors of the corresponding nodes in the ternary heterogeneous graph.

4. The method according to claim 3, characterized in that, The graph convolutional network includes a gating mechanism and residual connections, the parameters of which are obtained based on the node's training data; the step of extracting feature vectors of the current node, the connection edges of the current node, and the connection nodes of the connection edges using the graph convolutional network according to different node types includes: Through a gating mechanism, relevant information is dynamically selected or weighted from the parameters of the current node, the connecting edges of the current node, and the neighboring nodes pointed to by the connecting edges. By using residual connections, the original input information is directly passed and added to the processed representation to preserve the underlying features and promote gradient flow.

5. The method according to claim 1, characterized in that, The step of extracting features from the local enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph using learnable query vectors, with the goal of more accurately predicting voltage and phase angle, includes: Based on the learnable query vector, the similarity between the local augmentation feature vector of each generator node and each load node in the ternary heterogeneous graph and the local augmentation feature vector of the balancing node is calculated using a cross-attention mechanism to obtain the attention weight of each generator node and each load node. The higher the similarity, the greater the attention weight. Based on the attention weights of each generator node and each load node, with the goal of more accurately predicting voltage and phase angle, feature extraction is performed on the local enhanced feature vectors of the balancing nodes in the ternary heterogeneous graph, where the weights are used to indicate the amount of data queried and the location of the query.

6. The method according to claim 5, characterized in that, Before calculating the similarity with the local augmented feature vector of the balancing node in the local augmented feature vector of each generator node and each load node in the ternary heterogeneous graph based on the learnable query vector, the method further includes: The local augmented feature vectors of each generator node, each load node, and each balancing node are mapped to a unified feature space to obtain the unified local augmented feature vectors of each generator node, each load node, and each balancing node. A multilayer perceptron is used to perform a nonlinear transformation on the unified local enhancement feature vector of the equilibrium node; Position encoding is performed on the unified local augmentation feature vector of the transformed balanced node to preserve the absolute position of the balanced node in the topology. The method of calculating the similarity between the learnable query vector and the local augmentation feature vector of the balancing node in the local augmentation feature vector of each generator node and each load node in the ternary heterogeneous graph using a cross-attention mechanism includes: Based on the learnable query vector, the similarity between the unified local augmentation feature vector of each generator node and each load node in the ternary heterogeneous graph and the unified local augmentation feature vector after position encoding of the balancing node is calculated using a cross-attention mechanism.

7. The method according to any one of claims 1 to 6, characterized in that, Before obtaining the voltage amplitude and voltage phase angle of each node in the current power grid, the method further includes: Obtain the initial voltage amplitude and initial voltage phase angle of each node fed back by the feedforward neural network; The active and reactive power of each node are calculated based on the initial voltage amplitude and initial voltage phase angle of each node. The calculated active and reactive power of each node are compared with the active and reactive power corresponding to different types of parameters and edge parameters of each node. If the comparison result indicates that the total loss value does not exceed the preset total loss value, then the step of obtaining the voltage amplitude and voltage phase angle of each node in the current power grid is executed; If the comparison result indicates that the total loss value exceeds the preset total loss value, then the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are again extracted using a learnable query vector. The extraction is performed in the local enhancement feature vector of the balancing node in the ternary heterogeneous diagram with the goal of more accurately predicting the voltage and phase angle, to obtain the global enhancement feature vector of each generator node and each load node. The global enhancement feature vector of each generator node and each load node in the ternary heterogeneous diagram, and the local enhancement feature vector of the balancing node are then input into the feedforward neural network.

8. The method according to claim 7, characterized in that, If the comparison result indicates that the total loss value exceeds the preset total loss value, then the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are again extracted using a learnable query vector from the local enhanced feature vector of the balanced node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle, including: If the comparison result generated in the nth time indicates that the total loss value exceeds the preset total loss value, then the initial voltage amplitude and initial voltage phase angle of the corresponding node fed back by the feedforward neural network are used again as learnable query vectors to extract features in the local enhancement feature vector of the balanced node of the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle, where n is a fixed integer.

9. The method according to any one of claims 1 to 6, characterized in that, After obtaining the voltage amplitude and voltage phase angle of each node in the current power grid, the method further includes: The voltage magnitude and voltage phase angle are converted into complex voltage vectors at each node; Based on the complex voltage vector and the node admittance matrix of the current power grid, the power flow distribution of each branch is calculated; Identify overloaded branches in the power flow distribution that exceed a preset safety threshold, and identify abnormal voltage nodes in the voltage amplitude that deviate from a preset safety range; A power grid safety status alarm message containing the overloaded branch and the abnormal voltage node is generated, and the power grid safety status alarm message is output to the power system dispatch and control interface to instruct real-time regulation of the current power grid.

10. A power system state detection device based on learnable query vectors, characterized in that, The device includes: The acquisition module is used to acquire the current power grid topology, different types of parameters of different nodes, and edge parameters. The different types of parameters of different nodes include generator node parameters, load node parameters, and slack node parameters. The generation module is used to inject the generator node parameters, load node parameters, slack node parameters, and edge parameters into the nodes and edges of the topology, respectively, to obtain the ternary heterogeneous graph of the current power grid. The enhancement module is used to extract the feature vectors of each node, the connecting edge of each node, and the connecting node of the connecting edge in the ternary heterogeneous graph using a graph convolutional network, and to use the extracted feature vectors as the local enhancement feature vectors of the corresponding nodes in the ternary heterogeneous graph. The global module is used to extract features from the local enhanced feature vectors of each generator node and each load node in the ternary heterogeneous graph with the goal of more accurately predicting voltage and phase angle using learnable query vectors, and obtain the global enhanced feature vectors of each generator node and each load node. The calculation module is used to input the global enhancement feature vector of each generator node and each load node in the ternary heterogeneous diagram, and the local enhancement feature vector of the balancing node into the feedforward neural network to obtain the voltage amplitude and voltage phase angle of each node in the current power grid.

11. A computer device, comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 9.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 9.

13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 9.