A batch processing method and engine for solving AC power flow in power systems
By integrating power grid data into a batch-dimensional tensor structure and generating a differentiable computation graph, and using GPU for batch processing, the efficiency and differentiability problems of traditional power flow solving techniques in high-proportion renewable energy power grids are solved, achieving efficient and accurate power flow solving.
Patent Information
- Application Number
- CN202611313861.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-27
- Publication Date
- 2026-11-17
AI Technical Summary
Traditional power flow solving techniques cannot simultaneously achieve high efficiency and differentiability in AC power flow solving for power systems, and cannot meet the complex computational needs of power grids with a high proportion of new energy sources and a high proportion of power electronic power.
By acquiring power grid data from multiple power flow scenarios, batch-dimensional tensors are concatenated into batch-dimensional tensors, generating sparse admittance matrices of batch-dimensional nodes in coordinate and compressed sparse row formats. The power flow equations are then converted into differentiable computation graphs, and batch-dimensional iterative solutions are performed using GPUs to achieve synchronous computation and accurate gradient output for massive scenarios.
It improves the efficiency of power flow solution, can output accurate gradients under massive operating conditions, and balances the solution speed with the differentiability of the physical model. It is suitable for complex scenarios with a high proportion of new energy and power electronic grids.
Smart Images

Figure CN123121633A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of power system technology, and more specifically, to a batch processing method and engine for solving AC power flow in power systems. Background Technology
[0002] With the increasing proportion of new energy sources and power electronics in new power systems, the number of operating scenarios is exploding. Planning, operation, market clearing, and safety verification all require power flow calculations for thousands of operating conditions. At the same time, power grid artificial intelligence algorithms require power flow calculations to be embedded in the training process and output accurate gradients. Traditional power flow solution techniques are difficult to meet these dual requirements.
[0003] Currently, a limited number of GPU power flow acceleration solutions only achieve basic parallel computing and cannot output power flow equations for grid parameters through automatic differentiation, resulting in a lack of accurate precision and failing to achieve true batch processing parallelism. Consequently, AC power flow solutions remain inadequate.
[0004] Therefore, how to simultaneously achieve high efficiency and differentiability in batch processing of AC power flow solutions for power systems is a problem that needs attention. Summary of the Invention
[0005] In view of the above problems, this application provides a batch processing method and engine for solving AC power flow in power systems, so as to simultaneously achieve high efficiency and differentiability of batch processing for solving AC power flow in power systems.
[0006] To achieve the above objectives, the following specific solutions are proposed:
[0007] A batch processing method for solving AC power flow in power systems, applied to GPUs, includes:
[0008] Acquire grid data of AC power grid under multiple power flow scenarios, and concatenate the grid data of each power flow scenario into a batch-dimensional tensor structure according to the batch dimension;
[0009] Based on the batch-dimensional tensor structure, a batch-dimensional node sparse admittance matrix is generated in coordinate format and compressed sparse row format.
[0010] Based on the sparse admittance matrix of the batch-dimensional nodes, the AC power flow is solved by batch-dimensional iteration to obtain the power flow solution for each power flow scenario.
[0011] Optionally, the step of concatenating power grid data from various power flow scenarios into a batch-dimensional tensor structure according to batch dimensions includes:
[0012] Identify the heterogeneous characteristics of each trend scene across various trend scenes;
[0013] The heterogeneous features of each trend scenario are standardized to obtain the standardized heterogeneous features of that trend scenario;
[0014] Based on the standardized heterogeneous characteristics of various power flow scenarios, the power grid data under each power flow scenario are spliced into a batch-dimensional tensor structure according to the batch dimension.
[0015] Optionally, the batch tensor structure is a tensor of [B, L, 4], where B is the batch size, L is the total number of branches, and 4 represents the electrical parameters of each branch, including branch resistance, branch reactance, branch susceptance to ground, and branch transformer turns ratio.
[0016] Optionally, based on the batch-dimensional tensor structure, a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format is generated, including:
[0017] Based on the batch-dimensional tensor structure, a topological mask is generated;
[0018] Based on the batch-dimensional branch parameters of the batch-dimensional tensor structure and the topological mask, a batch-dimensional node admittance matrix is generated.
[0019] By assembling the batch-dimensional node admittance matrix in batch-dimensional coordinate format and rearranging it in batch-dimensional compressed sparse row format, a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format is obtained.
[0020] Optionally, by converting the power flow equations of the batch-dimensional sparse admittance matrix of the nodes into a differentiable computation graph, batch-dimensional iterative solution of the AC power flow is performed to obtain the power flow solutions for each power flow scenario, including:
[0021] Calculate the active power injection and reactive power injection of the sparse admittance matrix of the batch-dimensional nodes. Based on the active power injection, reactive power injection, active power injection reference value and reactive power injection reference value, determine the batch-dimensional mismatch tensor of each power flow scenario, and determine the batch-dimensional norm of the batch-dimensional mismatch tensor of the power flow scenario.
[0022] Based on the sparse admittance matrix of the batch-dimensional nodes, the power flow equation for each power flow scenario is determined, and the power flow equation for that scenario is converted into a differentiable computation graph.
[0023] Construct the Pivoja cobi matrix equation corresponding to the differentiable computation graph of the power flow equation for each power flow scenario;
[0024] Based on the GPU batch direct method or the adaptive precondition batch algorithm, solve the batch Vijay-Kiobi matrix equation for each power flow scenario to obtain the power flow solution for that scenario.
[0025] Determine whether the batch dimension norm of each trend scenario is less than the preset convergence threshold;
[0026] If so, complete the iterative calculation for that trend scenario and output the current trend solution for that trend scenario;
[0027] If not, based on the power flow solution and batch dimension norm of each power flow scenario, update the batch dimension node sparse admittance matrix, and return to the steps of calculating the active power injection and reactive power injection of the batch dimension node sparse admittance matrix for the next iteration calculation.
[0028] Optionally, the method further includes:
[0029] When the batch norm of the target power flow scenario converges to a fixed point, the batch Jacobian matrix equation of the target power flow scenario in the current iteration is determined to be a linear operator.
[0030] The linear operator is cached in the shared memory of the GPU;
[0031] When updating the sparse admittance matrix of the batch dimension nodes based on the power flow solution and batch dimension norm of the target power flow scenario, the linear operator is obtained from the shared memory of the GPU.
[0032] Based on the linear operator, the adjoint equation of the power flow equation of the target power flow scenario is solved linearly using the implicit differential formula to obtain the update gradient of all parameters of the target power flow scenario.
[0033] Optionally, the method further includes:
[0034] In the process of performing batch-dimensional iterative solution of AC power flow based on the sparse admittance matrix of the batch-dimensional nodes to obtain the power flow solution for each power flow scenario, the GPU switches to half-precision mode when performing internal iteration and switches to single-precision mode when performing external iteration.
[0035] Optionally, the GPU includes shared memory, multiple thread blocks, and multiple thread bundles;
[0036] Each thread block is used to iteratively solve the power flow equations for a single power flow scenario;
[0037] Each thread bundle is used to reduce, index permutation, and broadcast branch parameters for a single power flow scenario tensor;
[0038] The shared memory adopts a combined memory access and asynchronous prefetching mode.
[0039] Optionally, the method further includes:
[0040] In the batch-dimensional node sparse admittance matrix, determine the batch-dimensional node sparse admittance submatrix for each power flow scenario;
[0041] The complexity of each power flow scenario is determined by the number of non-zero elements in the sparse admittance submatrix of the batch-dimensional nodes of each power flow scenario.
[0042] Determine the complexity ranking of each power flow scenario and the load performance ranking of each thread block;
[0043] Based on the complexity ranking and the load performance ranking, a target thread block is matched for the iterative solution task of the power flow equation for each power flow scenario.
[0044] A batch processing engine for solving AC power flow in power systems, applied to GPUs, includes:
[0045] The scenario batch assembly module is used to acquire power grid data of AC power grid under multiple power flow scenarios, and to splice the power grid data of each power flow scenario into a batch-dimensional tensor structure according to the batch dimension.
[0046] The tensor network modeling module is used to generate a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format based on the batch-dimensional tensor structure.
[0047] The iterative solution kernel is used to convert the power flow equations of the sparse admittance matrix of the batch-dimensional nodes into a differentiable computation graph, and to perform batch-dimensional iterative solution of the AC power flow to obtain the power flow solutions for each power flow scenario.
[0048] Optionally, the scene batch assembly module includes:
[0049] The heterogeneous feature determination module is used to determine the heterogeneous features of each trend scene in various trend scenes;
[0050] The standardization module is used to standardize the heterogeneous features of each trend scenario to obtain the standardized heterogeneous features of that trend scenario.
[0051] The tensor splicing module is used to splice power grid data from various power flow scenarios into batch-dimensional tensor structures based on the standardized heterogeneous characteristics of each scenario.
[0052] Optionally, the batch tensor structure is a tensor of [B, L, 4], where B is the batch size, L is the total number of branches, and 4 represents the electrical parameters of each branch, including branch resistance, branch reactance, branch susceptance to ground, and branch transformer turns ratio.
[0053] Optionally, the tensor quantization network modeling module includes:
[0054] A topology mask generation module is used to generate a topology mask based on the batch-dimensional tensor structure.
[0055] The batch-dimensional node admittance matrix generation module is used to generate a batch-dimensional node admittance matrix based on the batch-dimensional branch parameters of the batch-dimensional tensor structure and the topological mask.
[0056] The sparse processing module is used to assemble the batch-dimensional node admittance matrix in batch-dimensional coordinate format and rearrange the batch-dimensional compressed sparse row format by performing batch-dimensional coordinate format assembly and batch-dimensional compressed sparse row format rearrangement on the batch-dimensional node admittance matrix to obtain a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format.
[0057] Optionally, the iterative solution kernel includes:
[0058] The first tensor operator module is used to calculate the active power injection and reactive power injection of the sparse admittance matrix of the batch-dimensional node. Based on the active power injection, reactive power injection, active power injection reference value and reactive power injection reference value, the batch-dimensional mismatch tensor of each power flow scenario is determined, and the batch-dimensional norm of the batch-dimensional mismatch tensor of the power flow scenario is determined.
[0059] The second quantity operator module is used to determine the power flow equation for each power flow scenario based on the sparse admittance matrix of the batch-dimensional nodes, and to convert the power flow equation of the power flow scenario into a differentiable computation graph.
[0060] The third module is used to construct the Pivijacobi matrix equation corresponding to the differentiable computation graph of the power flow equation for each power flow scenario.
[0061] The fourth tensor operator module is used to solve the batch Vijay-Kiobi matrix equation for each power flow scenario based on the GPU batch direct method or the adaptive precondition batch algorithm, and obtain the power flow solution for that power flow scenario.
[0062] The fifth quantitative operator module is used to determine whether the batch dimension norm of each power flow scenario is less than the preset convergence threshold. If it is, the sixth quantitative operator module is executed; otherwise, the seventh quantitative operator module is executed.
[0063] The sixth quantity calculation module is used to complete the iterative calculation of the power flow scenario and output the current power flow solution of the power flow scenario;
[0064] The seventh tensor operator module is used to update the sparse admittance matrix of the batch dimension nodes based on the power flow solution and batch dimension norm of each power flow scenario, and return to execute the first tensor operator module for the next iteration calculation.
[0065] Optionally, the AC power flow solution batch processing engine further includes:
[0066] An automatic differential gradient engine is used to determine that the batch dimension norm of the target power flow scenario is a linear operator in the current iteration when the batch dimension norm converges to a fixed point. The linear operator is cached in the shared memory of the GPU. When updating the sparse admittance matrix of the batch dimension nodes based on the power flow solution and batch dimension norm of the target power flow scenario, the linear operator is retrieved from the shared memory of the GPU. Based on the linear operator, the adjoint equation of the power flow equation of the target power flow scenario is solved linearly using the implicit differential formula to obtain the update gradient of all parameters of the target power flow scenario.
[0067] Optionally, the AC power flow solution batch processing engine further includes:
[0068] The GPU mode switching module is used to switch to half-precision mode when the GPU is performing internal iteration and to switch to single-precision mode when the GPU is performing external iteration during the process of obtaining the power flow solution for each power flow scenario by performing batch-dimensional iteration of the sparse admittance matrix of the batch-dimensional nodes.
[0069] Optionally, the GPU includes shared memory, multiple thread blocks, and multiple thread bundles;
[0070] Each thread block is used to iteratively solve the power flow equations for a single power flow scenario;
[0071] Each thread bundle is used to reduce, index permutation, and broadcast branch parameters for a single power flow scenario tensor;
[0072] The shared memory adopts a combined memory access and asynchronous prefetching mode.
[0073] Optionally, the AC power flow solution batch processing engine further includes:
[0074] The power flow scenario complexity determination module is used to determine the batch-dimensional node sparse admittance submatrix of each power flow scenario in the batch-dimensional node sparse admittance submatrix, and determine the complexity of the power flow scenario based on the number of non-zero elements in the batch-dimensional node sparse admittance submatrix of each power flow scenario.
[0075] The sorting determination module is used to determine the complexity order of each power flow scenario and the load performance order of each thread block.
[0076] The thread block matching module is used to match target thread blocks for the iterative solution task of the power flow equation for each power flow scenario based on the complexity sorting and the load performance sorting.
[0077] By employing the aforementioned technical solution, this application acquires power grid data from multiple power flow scenarios in the AC power grid, and concatenates the power grid data from each power flow scenario into a batch-dimensional tensor structure. Based on this batch-dimensional tensor structure, it generates batch-dimensional node sparse admittance matrices represented in coordinate format and compressed sparse row format. By converting the power flow equations of the batch-dimensional node sparse admittance matrices into a differentiable computational graph, it performs batch-dimensional iterative solutions for AC power flow to obtain the power flow solutions for each power flow scenario. Thus, by integrating multi-scenario power grid data into batch-dimensional tensors, utilizing GPU parallel architecture to achieve synchronous computation across massive scenarios, and employing hypergraph masks to represent topology changes, it eliminates the need for repeated reconstruction of sparse structures, improving solution efficiency. The construction of a differentiable computational graph for the power flow equations allows for reduced GPU memory overhead through implicit differentiation, enabling the output of accurate gradients and achieving a balance between the solution speed for massive operating conditions and the differentiability of the physical model. Attached Figure Description
[0078] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the scope of this application. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:
[0079] Figure 1 A schematic flowchart illustrating a batch processing method for solving AC power flow in a power system, provided in an embodiment of this application.
[0080] Figure 2 This is a schematic diagram of a process for implementing batch-dimensional iterative solution of AC power flow according to an embodiment of this application;
[0081] Figure 3 This application provides a schematic diagram of a process for implementing parameter gradient updates based on linear operators in an embodiment of the present application.
[0082] Figure 4 This is a schematic diagram of the structure of an engine for batch processing of AC power flow solution in a power system, provided as an embodiment of this application. Detailed Implementation
[0083] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0084] This application's solution can be implemented based on a terminal with data processing capabilities, which can be a GPU with parallel batch processing capabilities. Specifically, the GPU can include shared memory, multiple thread blocks, and multiple thread bundles. The shared memory can employ merged memory access and asynchronous prefetching, enabling the GPU's high-bandwidth memory to supply data to operators at a rate close to its peak bandwidth. In the batch processing solution for AC power flow in the power system implemented in this application, each thread block can be used to iteratively solve the power flow equations for a single power flow scenario, and each thread bundle can be used to reduce, index permutate, and broadcast branch parameters to the tensor of a single power flow scenario.
[0085] Next, combined Figure 1 The batch processing method for solving AC power flow in the power system described in this application may include the following steps:
[0086] Step S110: Obtain power grid data for AC power grids under multiple power flow scenarios, and concatenate the power grid data for each power flow scenario into a batch-dimensional tensor structure according to the batch dimension.
[0087] Specifically, the process of acquiring power grid data under multiple power flow scenarios can be to collect complete AC power grid data corresponding to different operating conditions in batches, covering heterogeneous information such as active and reactive power injection, branch resistance and reactance to ground susceptance, transformer turns ratio, topology switch commissioning status, load and generator operating parameters of each scenario node, and uniformly supplementing to the maximum number of nodes and configuring validity mask tensors to address the problem of inconsistent node scale in each scenario.
[0088] Subsequently, the process of concatenating power grid data from various power flow scenarios into a batch-dimensional tensor structure can specifically include:
[0089] S111. Determine the heterogeneous characteristics of each trend scene in various trend scenes.
[0090] Among them, heterogeneous features can represent power grid data with inconsistent structures and values between different power flow scenarios, including multiple types of data such as node injected power, branch electrical parameters, topology switch status, and equipment commissioning identifiers. The number of nodes and branches varies in each scenario, and there are differences in data dimensions and effective topology. The data forms are mixed and cannot be directly parallelized. It belongs to the hybrid power grid feature data with heterogeneous structure and type.
[0091] Specifically, it can traverse all power flow scenarios to be solved, identify the multiple types of power grid data contained in a single scenario, distinguish different categories of data items such as active and reactive power injection at nodes, branch resistance, reactance, susceptance ratio, switch switching status, load and unit operating limits, and simultaneously count the total number of nodes and branches in each scenario, mark the structural differences in node size, topology, and equipment commissioning combinations between different scenarios, and fully extract all heterogeneous feature information with inconsistent dimensions and different data types in each scenario.
[0092] S112. Standardize the heterogeneous features of each trend scene to obtain the standardized heterogeneous features of that trend scene.
[0093] Specifically, a unified standardization process is carried out on various heterogeneous features extracted from single power flow scenarios. First, based on the maximum number of nodes and branches in all scenarios, zero-value padding is performed on scenarios with smaller node and branch scales, and a Boolean validity mask is generated to distinguish valid electrical components from invalid data. Then, different types of data, such as node injected power, branch electrical parameters, and topology switch status, are uniformly converted into floating-point tensor format, and a hypergraph mask is used to mark the operational status of each branch to eliminate structural differences caused by topology changes. After completing dimension alignment, format unification, and invalid region identification, scattered heterogeneous data structures are removed, and standardized heterogeneous features with regular dimensions, unified data types, and adaptability to GPU computing are output.
[0094] S113. Based on the standardized heterogeneous characteristics of various power flow scenarios, the power grid data under various power flow scenarios are spliced into a batch-dimensional tensor structure according to the batch dimension.
[0095] The batch tensor structure can be represented as a tensor of [B, L, 4]. Here, B is the batch size, L is the total number of branches, and 4 represents the electrical parameters of each branch, including branch resistance, branch reactance, branch susceptance to ground, and branch transformer turns ratio.
[0096] Specifically, based on the standardized heterogeneous characteristics processed in each power flow scenario, various types of power grid data can be stacked and spliced along the batch dimension to generate batch-dimensional node power tensors, batch-dimensional branch parameter tensors, and topology mask tensors, respectively. All tensors maintain a unified dimensional specification, using the batch number as the first dimension to encapsulate all operating condition data, eliminating the fragmentation problem caused by independent storage in a single scenario, forming a complete batch-dimensional tensor structure, and realizing integrated storage of multi-scenario data.
[0097] Step S120: Based on the batch-dimensional tensor structure, generate a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format.
[0098] Specifically, the process of generating sparse admittance matrices for batch-dimensional nodes, represented in coordinate and compressed sparse row formats, based on batch-dimensional tensor structures can include:
[0099] S121. Generate a topological mask based on a batch-dimensional tensor structure.
[0100] Specifically, a corresponding Boolean topology mask tensor can be generated based on the operational status data of each branch within the established batch-dimensional tensor structure. The mask dimension matches the batch size and the total number of branches. A true mask value represents a branch in normal operation, while a false value represents a branch disconnected or failed. This uniformly covers various topology changes such as faults and switching operations, thereby masking invalid branch parameters.
[0101] S122. Generate the batch-dimensional node admittance matrix based on the batch-dimensional branch parameters of the batch-dimensional tensor structure and the topological mask.
[0102] Specifically, the batch-dimensional branch parameter tensor, uniformly regularized within the batch-dimensional tensor structure, can be read. This tensor fully stores four types of electrical parameters for each branch in the batch dimension: resistance, reactance, ground susceptance, and transformer turns ratio. Combined with the same-dimensional Boolean topology mask tensor generated by S121, batch admittance calculations are performed synchronously. For each scenario within each batch, the branch electrical parameters are analyzed line by line. Following the AC power grid branch admittance calculation formula, the self-admittance and mutual admittance values of the branches are solved in batches. Then, the admittance components corresponding to disconnected branches are filtered out using the topology mask, eliminating invalid values caused by failed topologies. Based on the power grid node number mapping relationship, valid branch admittances can be batch-collected to the corresponding node positions, simultaneously retaining all tensor gradient tracking attributes, enabling automatic differentiation of admittance values. Finally, a dense batch-dimensional node admittance matrix, adaptable to parallel computing in multiple scenarios and carrying complete electrical information, is generated in batches.
[0103] S123. By assembling the batch-dimensional node admittance matrix in batch-dimensional coordinate format and rearranging it in batch-dimensional compressed sparse row format, a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format is obtained.
[0104] Specifically, a batch sparse format conversion operation can be performed on the dense batch-dimensional node admittance matrix. First, the batch-dimensional coordinate format is assembled. All non-zero elements of the admittance matrix for each scene are traversed, and the batch index, row node number, column node number, and admittance value corresponding to each non-zero element are recorded uniformly, forming a batch-dimensional COO (Coordinate Format) coordinate tensor. This format facilitates parallel writing across multiple scenes and topology data updates. Then, based on the batch-dimensional COO tensor, the batch-dimensional compressed sparse row format is rearranged. The non-zero elements are reordered by row number, generating three sets of tensors: row offset index, column index, and corresponding value, constructing a batch-dimensional CSR (Compressed Sparse Row) sparse matrix. It can be understood that the COO format is used to improve parallel writing efficiency during the matrix assembly stage, while the CSR format adapts to subsequent matrix-vector multiplication core calculations. The two formats are synchronously associated and stored to obtain a dual-format batch-dimensional node sparse admittance matrix, preserving the differentiability property of the tensor throughout the process.
[0105] Step S130: By converting the power flow equation of the sparse admittance matrix of batch-dimensional nodes into a differentiable computation graph, the power flow is solved by batch-dimensional iteration to obtain the power flow solution for each power flow scenario.
[0106] Differentiable computation graphs are structural representations that abstract all numerical operations in an algorithm into directed tensor computation nodes and organize the dependencies between nodes into a directed acyclic graph. Differentiable computation graphs enable the derivative of any output with respect to any input to be accurately computed in either backward or forward mode using an automatic differentiation mechanism.
[0107] Specifically, a system of nonlinear power flow equations can be constructed based on a dual-format batch-dimensional sparse admittance matrix, transforming all numerical computations into a differentiable computational graph composed of tensor operators. Then, a batch of node voltages is initialized using a flat-start approach, and batch-dimensional mismatch calculations, analytical Jacobian batch construction, batch GMRES linear solutions, and state updates are iteratively executed. A batch-dimensional convergence mask is used to shield converged scenarios and reduce redundant computations. After iterative convergence, an implicit function theorem can be combined to construct a gradient solution path, ultimately outputting complete power flow solutions for all scenarios, including node voltages and branch power.
[0108] Understandably, by transforming the entire power flow solution process into a differentiable computational graph, the limitation of traditional solvers being non-differentiable is overcome, allowing for direct output of accurate gradients. Batch dimension iteration, combined with convergence masks, fully unleashes the parallel computing power of the GPU, simultaneously processing massive amounts of data and significantly improving the throughput efficiency of batch simulations. The COO / CSR dual sparse matrix, combined with tensor operators, optimizes memory access performance and reduces GPU memory usage. Simultaneously, it uniformly adapts to various topology scenarios, incorporates convergence judgment and isolation mechanisms, and balances the accuracy, computational speed, and algorithm robustness of large-scale power grid solutions, providing a high-performance, differentiable power flow underlying operator for upper-level applications such as Monte Carlo simulation and reinforcement learning scheduling.
[0109] The batch processing method for solving AC power flow in power systems provided in this embodiment acquires grid data from multiple power flow scenarios and concatenates the grid data from each scenario into a batch-dimensional tensor structure. Based on this batch-dimensional tensor structure, a batch-dimensional node sparse admittance matrix represented in coordinate and compressed sparse row formats is generated. The power flow equations of the batch-dimensional node sparse admittance matrix are converted into a differentiable computational graph, and the AC power flow is solved iteratively in batch dimensions to obtain the power flow solutions for each scenario. Thus, by integrating grid data from multiple scenarios into a batch-dimensional tensor, utilizing a GPU parallel architecture to achieve synchronous computation across massive scenarios, and employing a hypergraph mask to represent topology changes, the solution efficiency is improved without repeatedly rebuilding the sparse structure. The power flow equations are constructed into a differentiable computational graph, thereby reducing memory overhead through implicit differentiation and outputting accurate gradients, achieving a balance between the solution speed for massive operating conditions and the differentiability of the physical model.
[0110] In some embodiments of this application, the process of step S130 above—converting the power flow equations of the batch-dimensional node sparse admittance matrix into a differentiable computational graph, performing batch-dimensional iterative solutions for AC power flow, and obtaining power flow solutions for various power flow scenarios—is described. (Refer to...) Figure 2 The process may include:
[0111] Step S210: Calculate the active power injection and reactive power injection of the batch-dimensional node sparse admittance matrix.
[0112] Among them, active power injection and reactive power injection refer to the actual AC and DC power of the node calculated based on the Bavier admittance matrix and the node voltage. They are the core calculation quantities of the power flow equation and are used to compare with the given power reference value to find the mismatch.
[0113] Specifically, based on the dual-format batch-dimensional node sparse admittance matrix and the current batch node voltage tensor, the batch-dimensional sparse matrix vector multiplication parallel operation can be used to calculate the actual active and reactive power injection of each node in all scenarios in batches. The entire operation is performed using differentiable tensor operators, preserving gradient tracking properties, and synchronously outputting batch active power injection tensors and batch reactive power injection tensors.
[0114] Step S220: Based on the active power injection, reactive power injection, active power injection reference value, and reactive power injection reference value, determine the batch dimension mismatch tensor of each power flow scenario, and determine the batch dimension norm of the batch dimension mismatch tensor of that power flow scenario.
[0115] The active power injection reference value is a preset active power setpoint for each power grid scenario, determined by the active power output of the load and generator units, and serves as a fixed constraint condition in the power flow equations. The reactive power injection reference value is a preset reactive power setpoint for each node in each scenario, including load reactive power and generator reactive power output, used to measure the deviation between the calculated reactive power and the operating setpoint. The batch mismatch tensor is a tensor constructed with the batch as the first dimension, internally storing the difference between the actual active and reactive power injections of each node in each scenario and the corresponding reference values. It is divided into active and reactive mismatch components, with the dimension matching the batch number and the total number of nodes. All operations on the tensor are performed based on differentiable tensor operators, capable of representing the power balance deviation of all power flow scenarios at once, and is the core data carrier for determining whether the power flow equations satisfy the power balance constraints. The batch norm is a one-dimensional tensor formed by independently solving the infinite norm of the batch mismatch tensor for a single scenario, with each scalar element corresponding to the overall power imbalance degree of a working condition. This tensor is obtained through batch parallel computation and can intuitively distinguish between converged and non-converged scenarios. It is used to generate Boolean convergence masks to shield converged conditions and reduce the waste of iterative computing power. It is a quantitative indicator for batch iterative convergence determination.
[0116] Specifically, the batch actual active and reactive power injection tensors obtained in step S210 can be subjected to element-wise difference operations with the preset batch active power injection reference tensors and reactive power injection reference tensors, respectively, to generate batch-dimensional active power mismatch tensors and batch-dimensional reactive power mismatch tensors. These are then merged to obtain the complete batch-dimensional mismatch tensor. For each power flow scenario in the batch dimension, the infinite norm of the corresponding mismatch tensor is calculated separately to generate a one-dimensional batch-dimensional norm tensor. Each scalar in the tensor corresponds to the overall mismatch degree of a single scenario. This batch-dimensional norm is the core indicator for determining the convergence of the operating conditions. The entire computation can be performed in parallel batches using GPU tensor operators, without the need to split single-scenario serial computations, and all computation steps retain differentiable properties.
[0117] Step S230: Based on the sparse admittance matrix of batch-dimensional nodes, determine the power flow equation for each power flow scenario, and convert the power flow equation for that scenario into a differentiable computation graph.
[0118] Specifically, the sparse admittance matrix of batch-dimensional nodes, stored in dual format under the current iteration, is read. Combined with the batch node voltage tensor, and according to the complex power balance relationship of the AC power grid, a corresponding nonlinear power flow equation set is independently constructed for each power flow scenario within the batch. The nonlinear power flow equation set can include active and reactive power balance constraints of each node, fully associating branch admittance, node voltage, and power injection variables. The equation logic is uniformly integrated for all scenarios within the batch. All mathematical operations in the power flow equations, such as admittance matrix vector multiplication, power solving, and mismatch difference calculation, are decomposed into basic tensor operators that can be executed in parallel by the GPU. These are organized into a directed acyclic differentiable computation graph according to the data dependencies between variables. The differentiable computation graph fully carries the entire forward solution process of the batch power flow, and all tensors participating in the calculation are uniformly marked with gradient tracking. The entire differentiable computation graph uses batch-dimensional tensors as a unified input and output carrier, and a single pipeline synchronously adapts to all batch operating conditions.
[0119] Step S240: Construct the Pivoja cobi matrix equation corresponding to the differentiable computation graph of the power flow equation for each power flow scenario.
[0120] The Pivijacbi matrix equation represents a set of power flow linear correction equations constructed in parallel along the batch dimension. The matrix consists of the batch partial derivatives of the power flow equations with respect to node voltage magnitude and phase angle, with each batch of scenarios stored independently in separate blocks. The Pivijacbi matrix equation is used to solve for the voltage correction in each iteration, solved in batches in parallel using a differentiable computation graph. It is the core equation for Newton's iterative update of node voltages and can also derive gradient information through implicit differentiation.
[0121] Specifically, based on a differentiable computational graph, an analytical batch solution method is used to derive the partial derivatives of the power flow equations with respect to node voltage magnitude and phase angle in parallel, generating four types of Jacobian sub-block tensors: H, N, J, and L. According to the node correspondences in each scenario, the sub-block tensors are integrated and assembled into a batch-diagonal form of a batch-dimensional Jacobian matrix. Then, combined with the batch-dimensional mismatch tensors, a unified batch-dimensional Jacobian matrix equation is constructed. The entire assembly process is completed using GPU-parallelized tensor operators, maintaining tensor gradient tracking throughout the process without any serial branching operations.
[0122] Step S250: Based on the GPU batch direct method or the adaptive precondition batch algorithm, solve the batch Vijay-Kiobi matrix equation for each power flow scenario to obtain the power flow solution for that scenario.
[0123] Specifically, during the equation solving stage, the GPU parallel solving module can be invoked to automatically select either the batch direct method or the adaptive preconditioned batch GMRES algorithm to process the batch Vijay-Kiobi matrix equations based on the power grid scale.
[0124] The GPU employs a mixed-precision strategy using Tensor Cores. During internal iterations, it can switch to half-precision mode to accelerate matrix-vector multiplication using FP16. During external iterations, it can sample single-precision mode to ensure computational accuracy using FP32, coupled with block diagonal preconditioning to optimize convergence speed. Linear solutions for each power flow scenario are independent at the batch level, with simultaneous computation achieved through GPU multithreading, synchronously outputting corrections for voltage magnitude and phase angle at each scenario node. These corrections are then superimposed onto the voltage tensor of the current batch node, updating the solution for each power flow scenario in this iteration. All computations are performed by differentiable tensor operators, fully preserving gradient paths and maintaining the structure of the differentiable computation graph.
[0125] Step S260: Determine whether the batch dimension norm of each trend scenario is less than the preset convergence threshold. If yes, proceed to step S270; otherwise, proceed to step S280.
[0126] Understandably, the batch norm is a one-dimensional tensor, with each element corresponding to the infinite norm of a power flow scenario mismatch tensor, quantifying the overall power imbalance degree of a single scenario. By quantifying the power imbalance degree of each scenario using the batch norm, convergence determination is completed in batches and in parallel, eliminating the need for sequential verification of each scenario and significantly reducing iterative determination overhead. By comparing the batch norm with the convergence threshold, converged and non-converged scenarios are quickly distinguished, generating a batch convergence mask. During iterative calculations, converged scenarios are masked and no longer participate in subsequent Jacobian assembly and linear solutions, reducing unnecessary computational power consumption and improving GPU hardware utilization. Simultaneously, a unified quantification convergence standard ensures consistent accuracy in power flow solutions across multiple scenarios.
[0127] Step S270: Complete the iterative calculation of the current trend scenario and output the current trend solution of the current trend scenario.
[0128] Specifically, for power flow scenarios where the batch dimension norm is less than a preset convergence threshold, it is determined that the power balance constraint has met the iteration accuracy requirements, and subsequent iterations for that scenario are terminated. The complete power flow state data, including node voltage and branch power, updated in the current iteration, is cached and saved. The corresponding power flow solution tensor for that scenario is extracted separately, and invalid padding dimensions and redundant information in the topology mask are removed. Standardized single-scenario power flow results are output. This condition is simultaneously marked as a convergence complete state, and a convergence mask is generated for the next iteration. It no longer participates in power calculations, Jacobian assembly, or other operations, saving GPU computing power. The tensor's differentiability is preserved throughout the process, supporting subsequent gradient backpropagation.
[0129] Step S280: Based on the power flow solution and batch dimension norm of each power flow scenario, update the sparse admittance matrix of the batch dimension nodes, and return to execute step S210 for the next iteration calculation.
[0130] Specifically, based on the batch power flow solution tensor updated in this iteration, combined with the branch topology mask and batch-dimensional branch parameter tensor of each scenario, the iterative update operation of the sparse admittance matrix of the batch-dimensional nodes is completed synchronously. This corrects the equivalent ground susceptance and transformer turns ratio-related admittance components caused by voltage changes, and simultaneously updates the COO coordinate index and CSR row offset array, maintaining the synchronous effectiveness of the dual sparse format. After the update is completed, the iterative calculation cache is reset, and the process jumps back to step S210 to start a new round of batch iteration loop, recalculating the active and reactive power injection of each scenario. The GPU batch tensor operator completes all update operations, uniformly retaining the gradient tracking identifier. Unconverged scenarios continue to participate in the iteration, while converged scenarios are shielded by convergence masks to reduce redundant calculations. While ensuring the integrity of the synchronous iteration logic of multiple scenarios, the computational cost of a single iteration is continuously compressed, and the convergence of each unconverged condition towards the accuracy threshold is steadily promoted.
[0131] In addition, the iterative solution process incorporates a fault diagnosis and rollback mechanism. When a power flow scenario in the batch processing experiences severe non-convergence (such as voltage collapse or islanding), the scenario is automatically marked as ill-conditioned and isolated to prevent it from affecting the solution of other scenarios. Simultaneously, structured diagnostic information is returned for easier identification and handling by higher layers. Through automatic switching logic between various robust solution strategies such as the continuation method, optimal multiplier method, and damped Newton's method, it can maintain a convergence rate of over 95% even under weakened operating conditions such as high proportion of renewable energy.
[0132] In some embodiments of this application, the process of implementing parameter gradient update based on linear operators in the iterative solution of the foregoing embodiments is described, with reference to... Figure 3 The process may include:
[0133] Step S310: When the batch norm of the target power flow scenario converges to a fixed point, determine that the batch Jacobian matrix equation of the target power flow scenario in the current iteration is a linear operator.
[0134] Specifically, all target power flow scenarios that have completed convergence can be traversed, and the following conditions can be selected: the batch Vijayanobis norm is stable, consistently less than the preset convergence threshold, and the iteration state no longer changes significantly, reaching the convergence fixed point. The batch Vijayanobis matrix equation constructed in the final iteration of this target scenario is extracted. The matrix, mismatch term, and correction variable in this equation are all composed of differentiable tensor operators, without any non-differentiable operations such as truncation or rounding, satisfying the definition conditions of a linear operator. This batch Vijayanobis matrix is abstracted into an implicit linear operator corresponding to the power flow equation. This operator fully represents the linear mapping relationship between node voltage correction and power mismatch, covering all partial derivative mapping logic brought about by branch admittance, topological constraints, and node type. Only the conditions that converge to the fixed point are selected to extract linear operators, avoiding gradient calculation bias caused by the distortion of the non-converged iteration matrix, thereby ensuring numerical stability and calculation accuracy when performing implicit differential gradient solutions.
[0135] Step S320: Cache the linear operator in the shared memory of the GPU.
[0136] Understandably, storing linear operators in GPU shared memory significantly reduces latency compared to global memory access, thus accelerating operator retrieval during subsequent gradient calculations. Shared memory offers high-speed on-chip read / write capabilities, reducing GPU memory throughput pressure during batch parallel reads, improving the computational efficiency of implicit differential linear solutions, and reducing the overhead of repeated data copying, thereby shortening the overall time required for parameter gradient updates.
[0137] Step S330: When updating the sparse admittance matrix of the batch dimension nodes based on the power flow solution and batch dimension norm of the target power flow scenario, obtain the linear operator from the shared memory of the GPU.
[0138] Specifically, during the iteration process of updating the sparse admittance matrix of batch-dimensional nodes, the gradient solution chain is started simultaneously, eliminating the need to reassemble the Jacobian matrix. Pre-cached linear operators are read directly from the GPU's high-speed shared memory, saving the time spent on repeatedly constructing and transferring operators to GPU memory. The reading process can use batch tensors to read operator indices and values in parallel, synchronously matching the batch dimension of the current convergence scenario to ensure a one-to-one correspondence between operators and power flow equation dimensions.
[0139] Step S340: Based on the linear operator, the adjoint equation of the power flow equation of the target power flow scenario is solved linearly using the implicit differential formula to obtain the update gradient of all parameters of the target power flow scenario.
[0140] Specifically, the GPU's batch linear solver unit can be invoked to read linear operators cached in shared memory. Power flow adjoint equations are constructed based on implicit differential theorems, and a single batch linear solver operation is performed on the target power flow scenario. The partial derivatives of the reverse-propagation power mismatch with respect to various grid parameters are calculated using the batch Jacobian linear operator, allowing for the simultaneous solution of the gradient tensors corresponding to all model parameters, including branch resistance, reactance, load power, and generator output. Converged linear operators are reused throughout the process, eliminating the need for repeated assembly of the Jacobian matrix and thus reducing the matrix construction overhead for gradient solving.
[0141] The batch processing method for solving AC power flow in power systems provided in this embodiment determines the batch Vijay-Karbavis matrix equation of the target power flow scenario as a linear operator when the batch dimension norm converges to a fixed point in the current iteration. This linear operator is cached in the shared memory of the GPU. When updating the sparse admittance matrix of the batch dimension nodes based on the power flow solution and batch dimension norm of the target power flow scenario, the linear operator is retrieved from the shared memory of the GPU. Finally, based on the linear operator, the adjoint equation of the power flow equation of the target power flow scenario is solved linearly using implicit differential formulas to obtain the updated gradients of all parameters of the target power flow scenario. Therefore, this power flow calculation becomes a trainable deep learning fundamental operator, enabling AI algorithms such as reinforcement learning, differentiable programming, and Bayesian optimization to obtain accurate gradients for the power flow results.
[0142] In some embodiments of this application, to make more efficient use of the GPU, corresponding GPU thread blocks can be allocated for each power flow scenario, specifically including:
[0143] S1. In the batch-dimensional node sparse admittance matrix, determine the batch-dimensional node sparse admittance submatrix for each power flow scenario, and determine the complexity of the power flow scenario based on the number of non-zero elements in the batch-dimensional node sparse admittance submatrix for each power flow scenario.
[0144] Specifically, by traversing the batch-dimensional node sparse admittance matrix, each power flow scenario can be independently decomposed into a batch-dimensional node sparse admittance submatrix according to the batch dimension. Each batch-dimensional node sparse admittance submatrix contains all branch admittance non-zero elements, node indices, and topological constraint information for that operating condition. The total number of non-zero admittance elements within each batch-dimensional node sparse admittance submatrix is counted. The number of non-zero elements directly reflects the computational cost of operations such as matrix-vector multiplication and Jacobian assembly, and this is used as a quantitative indicator to define the computational complexity of a single power flow scenario. It is understandable that the more non-zero elements, the larger the scale of the power grid nodes and branches, the higher the computational power consumption during the iteration process, and the higher the scenario complexity. The complexity values of all scenarios are uniformly organized into a batch complexity tensor, fully preserving the scale characteristics of each operating condition.
[0145] S2. Determine the complexity ranking of each power flow scenario and the load performance ranking of each thread block.
[0146] Specifically, based on the complexity values of each trend scenario, all operating conditions are sorted from high to low complexity to generate an ordered index sequence of scenarios. At the same time, based on hardware indicators such as the cache capacity of each thread block of the GPU, peak floating-point operation, and memory bandwidth, the upper limit of parallel processing of each thread block is calculated, and the thread block load performance is sorted from strong to weak.
[0147] S3. Sort by complexity and load performance, and match the target thread block for the iterative solution of the power flow equation for each power flow scenario.
[0148] Specifically, by combining scenario complexity ranking and thread block load performance ranking, a greedy matching strategy is adopted to assign high-complexity power flow tasks to more powerful GPU thread blocks, and low-complexity tasks to less powerful thread blocks. Each power flow solving task is bound to a target thread block, and computation tasks are allocated in batches to balance the computational load of each thread block, eliminate idle computing power, and maximize the throughput efficiency of GPU parallel computing.
[0149] The following describes the engine for batch processing of AC power flow solution in power systems provided in the embodiments of this application. The engine for batch processing of AC power flow solution in power systems described below can be referred to in correspondence with the method for batch processing of AC power flow solution in power systems described above.
[0150] See Figure 4 , Figure 4 This is a schematic diagram of the structure of an engine for batch processing of AC power flow solution in a power system, as disclosed in an embodiment of this application.
[0151] like Figure 4 As shown, the engine may include:
[0152] The scenario batch assembly module 11 is used to acquire power grid data of AC power grid under multiple power flow scenarios, and to splice the power grid data under each power flow scenario into a batch dimension tensor structure according to the batch dimension.
[0153] The tensor network modeling module 12 is used to generate a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format based on the batch-dimensional tensor structure.
[0154] The iterative solution kernel 13 is used to convert the power flow equation of the sparse admittance matrix of the batch-dimensional nodes into a differentiable computation graph, and to perform batch-dimensional iterative solution of the AC power flow to obtain the power flow solution for each power flow scenario.
[0155] Optionally, the scene batch assembly module includes:
[0156] The heterogeneous feature determination module is used to determine the heterogeneous features of each trend scene in various trend scenes;
[0157] The standardization module is used to standardize the heterogeneous features of each trend scenario to obtain the standardized heterogeneous features of that trend scenario.
[0158] The tensor splicing module is used to splice power grid data from various power flow scenarios into batch-dimensional tensor structures based on the standardized heterogeneous characteristics of each scenario.
[0159] Optionally, the batch tensor structure is a tensor of [B, L, 4], where B is the batch size, L is the total number of branches, and 4 represents the electrical parameters of each branch, including branch resistance, branch reactance, branch susceptance to ground, and branch transformer turns ratio.
[0160] Optionally, the tensor quantization network modeling module includes:
[0161] A topology mask generation module is used to generate a topology mask based on the batch-dimensional tensor structure.
[0162] The batch-dimensional node admittance matrix generation module is used to generate a batch-dimensional node admittance matrix based on the batch-dimensional branch parameters of the batch-dimensional tensor structure and the topological mask.
[0163] The sparse processing module is used to assemble the batch-dimensional node admittance matrix in batch-dimensional coordinate format and rearrange the batch-dimensional compressed sparse row format by performing batch-dimensional coordinate format assembly and batch-dimensional compressed sparse row format rearrangement on the batch-dimensional node admittance matrix to obtain a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format.
[0164] Optionally, the iterative solution kernel includes:
[0165] The first tensor operator module is used to calculate the active power injection and reactive power injection of the sparse admittance matrix of the batch-dimensional node. Based on the active power injection, reactive power injection, active power injection reference value and reactive power injection reference value, the batch-dimensional mismatch tensor of each power flow scenario is determined, and the batch-dimensional norm of the batch-dimensional mismatch tensor of the power flow scenario is determined.
[0166] The second quantity operator module is used to determine the power flow equation for each power flow scenario based on the sparse admittance matrix of the batch-dimensional nodes, and to convert the power flow equation of the power flow scenario into a differentiable computation graph.
[0167] The third module is used to construct the Pivijacobi matrix equation corresponding to the differentiable computation graph of the power flow equation for each power flow scenario.
[0168] The fourth tensor operator module is used to solve the batch Vijay-Kiobi matrix equation for each power flow scenario based on the GPU batch direct method or the adaptive precondition batch algorithm, and obtain the power flow solution for that power flow scenario.
[0169] The fifth quantitative operator module is used to determine whether the batch dimension norm of each power flow scenario is less than the preset convergence threshold. If it is, the sixth quantitative operator module is executed; otherwise, the seventh quantitative operator module is executed.
[0170] The sixth quantity calculation module is used to complete the iterative calculation of the power flow scenario and output the current power flow solution of the power flow scenario;
[0171] The seventh tensor operator module is used to update the sparse admittance matrix of the batch dimension nodes based on the power flow solution and batch dimension norm of each power flow scenario, and return to execute the first tensor operator module for the next iteration calculation.
[0172] Optionally, the AC power flow solution batch processing engine further includes:
[0173] An automatic differential gradient engine is used to determine that the batch dimension norm of the target power flow scenario is a linear operator in the current iteration when the batch dimension norm converges to a fixed point. The linear operator is cached in the shared memory of the GPU. When updating the sparse admittance matrix of the batch dimension nodes based on the power flow solution and batch dimension norm of the target power flow scenario, the linear operator is retrieved from the shared memory of the GPU. Based on the linear operator, the adjoint equation of the power flow equation of the target power flow scenario is solved linearly using the implicit differential formula to obtain the update gradient of all parameters of the target power flow scenario.
[0174] Optionally, the AC power flow solution batch processing engine further includes:
[0175] The GPU mode switching module is used to switch to half-precision mode when the GPU is performing internal iteration and to switch to single-precision mode when the GPU is performing external iteration during the process of obtaining the power flow solution for each power flow scenario by performing batch-dimensional iteration of the sparse admittance matrix of the batch-dimensional nodes.
[0176] Optionally, the GPU includes shared memory, multiple thread blocks, and multiple thread bundles;
[0177] Each thread block is used to iteratively solve the power flow equations for a single power flow scenario;
[0178] Each thread bundle is used to reduce, index permutation, and broadcast branch parameters for a single power flow scenario tensor;
[0179] The shared memory adopts a combined memory access and asynchronous prefetching mode.
[0180] Optionally, the AC power flow solution batch processing engine further includes:
[0181] The power flow scenario complexity determination module is used to determine the batch-dimensional node sparse admittance submatrix of each power flow scenario in the batch-dimensional node sparse admittance submatrix, and determine the complexity of the power flow scenario based on the number of non-zero elements in the batch-dimensional node sparse admittance submatrix of each power flow scenario.
[0182] The sorting determination module is used to determine the complexity order of each power flow scenario and the load performance order of each thread block.
[0183] The thread block matching module is used to match target thread blocks for the iterative solution task of the power flow equation for each power flow scenario based on the complexity sorting and the load performance sorting.
[0184] Furthermore, this application also provides an AI interface integration layer, which serves as the interface for providing services to the outside world. This layer encapsulates the entire engine into standard operators of mainstream deep learning frameworks such as PyTorch, JAX, and TensorFlow, enabling seamless embedding into any AI training loop. At the PyTorch level, the engine is registered as the `DifferentiablePowerFlow` module, inheriting from `nn.Module`. It receives tensor-quantized injected power, line parameters, and control variables forward, and outputs tensor-quantized node voltage magnitudes, phase angles, and branch power flows. In reverse, it automatically provides accurate gradients for all inputs through implicit differentiation. At the JAX level, the engine is registered as the `custom_vjp` primitive, supporting advanced JAX features such as `jit` compilation, `vmap` vectorization, and `pmap` multi-GPU parallelism, allowing for seamless expansion in multi-GPU, multi-machine environments.
[0185] Understandably, the engine plays a central role in the AI training loop. Various AI components, such as reinforcement learning policy networks, Bayesian optimizers, and differentiable programming layers, can input batches of scenarios into the differentiable power flow operator. Internally, the engine utilizes a combination of GPU batch processing kernels and Tensor Cores for mixed-precision computation, solving hundreds or thousands of scenarios within milliseconds and outputting tensorized power flow solutions. After calculating the loss value using downstream safety constraint loss, the gradient is backpropagated to the policy network via implicit differentiation, completing end-to-end differentiable training.
[0186] The engine also provides a variety of advanced features at the AI interface integration layer to meet the needs of different application scenarios. It supports semi-differential mode, allowing upper-layer tasks to differentiate only a portion of the input, saving computational overhead in the reverse engineering phase. The engine also supports sensitivity heatmap output, enabling power grid dispatchers to intuitively view the impact of arbitrary operating variables on power flow. Furthermore, it supports an automatic constraint loss weighting mechanism, adaptively balancing the weights of multiple constraint losses during end-to-end training to prevent training divergence. Finally, the engine supports power flow perturbation injection, allowing upper-layer tasks to inject perturbations during the solution process to train robust policies.
[0187] In terms of performance benchmarks, this embodiment uses the NVIDIA A100 GPU as an example. On this GPU, a batch of 1024 power flow scenarios were tested on an IEEE 1354-node power system. A single end-to-end power flow solution (including gradient backpropagation) took only about 80 milliseconds, compared to approximately 45 seconds for MATPOWER to serially solve 1024 power flow scenarios on a CPU, representing a speedup of over 560 times. On a larger-scale 8000-node power grid model, the engine on the A100 can still complete differentiable solutions for a batch of 256 scenarios in approximately 350 milliseconds, demonstrating its scalability on industrial-grade power grids. The engine also provides a complete MPI multi-card, multi-machine expansion interface, enabling it to process millions of running scenarios on clusters of thousands of cards, meeting the extreme operating condition scanning requirements of new power systems.
[0188] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0189] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0190] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A batch processing method for solving AC power flow in a power system, characterized in that, Applied to GPUs, the method includes: Acquire grid data of AC power grid under multiple power flow scenarios, and concatenate the grid data of each power flow scenario into a batch-dimensional tensor structure according to the batch dimension; Based on the batch-dimensional tensor structure, a batch-dimensional node sparse admittance matrix is generated in coordinate format and compressed sparse row format. By converting the power flow equations of the sparse admittance matrix of the batch-dimensional nodes into a differentiable computation graph, the power flow solutions for each power flow scenario are obtained through batch-dimensional iterative solution.
2. The method according to claim 1, characterized in that, The process of concatenating power grid data from various power flow scenarios into a batch-dimensional tensor structure includes: Identify the heterogeneous characteristics of each trend scene across various trend scenes; The heterogeneous features of each trend scenario are standardized to obtain the standardized heterogeneous features of that trend scenario; Based on the standardized heterogeneous characteristics of various power flow scenarios, the power grid data under each power flow scenario are spliced into a batch-dimensional tensor structure according to the batch dimension.
3. The method according to claim 2, characterized in that, The batch tensor structure is a tensor of [B, L, 4], where B is the batch size, L is the total number of branches, and 4 represents the electrical parameters of each branch, including branch resistance, branch reactance, branch susceptance to ground, and branch transformer turns ratio.
4. The method according to claim 3, characterized in that, Based on the batch-dimensional tensor structure, a batch-dimensional node sparse admittance matrix is generated, represented in coordinate format and compressed sparse row format, including: Based on the batch-dimensional tensor structure, a topological mask is generated; Based on the batch-dimensional branch parameters of the batch-dimensional tensor structure and the topological mask, a batch-dimensional node admittance matrix is generated. By assembling the batch-dimensional node admittance matrix in batch-dimensional coordinate format and rearranging it in batch-dimensional compressed sparse row format, a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format is obtained.
5. The method according to claim 1, characterized in that, By converting the power flow equations of the batch-dimensional sparse admittance matrix of the nodes into a differentiable computation graph, and performing batch-dimensional iterative solutions for the AC power flow, power flow solutions for various power flow scenarios are obtained, including: Calculate the active power injection and reactive power injection of the sparse admittance matrix of the batch-dimensional nodes. Based on the active power injection, reactive power injection, active power injection reference value and reactive power injection reference value, determine the batch-dimensional mismatch tensor of each power flow scenario, and determine the batch-dimensional norm of the batch-dimensional mismatch tensor of the power flow scenario. Based on the sparse admittance matrix of the batch-dimensional nodes, the power flow equation for each power flow scenario is determined, and the power flow equation for that scenario is converted into a differentiable computation graph. Construct the Pivoja cobi matrix equation corresponding to the differentiable computation graph of the power flow equation for each power flow scenario; Based on the GPU batch direct method or the adaptive precondition batch algorithm, solve the batch Vijay-Kiobi matrix equation for each power flow scenario to obtain the power flow solution for that scenario. Determine whether the batch dimension norm of each trend scenario is less than the preset convergence threshold; If so, complete the iterative calculation for that trend scenario and output the current trend solution for that trend scenario; If not, based on the power flow solution and batch dimension norm of each power flow scenario, update the batch dimension node sparse admittance matrix, and return to the steps of calculating the active power injection and reactive power injection of the batch dimension node sparse admittance matrix for the next iteration calculation.
6. The method according to claim 5, characterized in that, Also includes: When the batch norm of the target power flow scenario converges to a fixed point, the batch Jacobian matrix equation of the target power flow scenario in the current iteration is determined to be a linear operator. The linear operator is cached in the shared memory of the GPU; When updating the sparse admittance matrix of the batch dimension nodes based on the power flow solution and batch dimension norm of the target power flow scenario, the linear operator is obtained from the shared memory of the GPU. Based on the linear operator, the adjoint equation of the power flow equation of the target power flow scenario is solved linearly using the implicit differential formula to obtain the update gradient of all parameters of the target power flow scenario.
7. The method according to claim 5, characterized in that, Also includes: In the process of performing batch-dimensional iterative solution of AC power flow based on the sparse admittance matrix of the batch-dimensional nodes to obtain the power flow solution for each power flow scenario, the GPU switches to half-precision mode when performing internal iteration and switches to single-precision mode when performing external iteration.
8. The method according to any one of claims 1-7, characterized in that, The GPU includes shared memory, multiple thread blocks, and multiple thread bundles; Each thread block is used to iteratively solve the power flow equations for a single power flow scenario; Each thread bundle is used to reduce, index permutation, and broadcast branch parameters for a single power flow scenario tensor; The shared memory adopts a combined memory access and asynchronous prefetching mode.
9. The method according to claim 8, characterized in that, Also includes: In the batch-dimensional node sparse admittance matrix, determine the batch-dimensional node sparse admittance submatrix for each power flow scenario; The complexity of a power flow scenario is determined by the number of non-zero elements in the sparse admittance submatrix of the batch-dimensional nodes of each power flow scenario. Determine the complexity ranking of each power flow scenario and the load performance ranking of each thread block; Based on the complexity ranking and the load performance ranking, a target thread block is matched for the iterative solution task of the power flow equation for each power flow scenario.
10. A batch processing engine for solving AC power flow in a power system, characterized in that, Applied to GPUs, the engine includes: The scenario batch assembly module is used to acquire power grid data of AC power grid under multiple power flow scenarios, and to splice the power grid data of each power flow scenario into a batch-dimensional tensor structure according to the batch dimension. The tensor network modeling module is used to generate a batch-dimensional node sparse admittance matrix represented in coordinate format and compressed sparse row format based on the batch-dimensional tensor structure. The iterative solution kernel is used to convert the power flow equations of the sparse admittance matrix of the batch-dimensional nodes into a differentiable computation graph, and to perform batch-dimensional iterative solution of the AC power flow to obtain the power flow solutions for each power flow scenario.
