Method and apparatus for generating training samples based on power flow calculation model
By synchronously perturbing the linkage index and optimizing the basic examples in the power flow calculation model, the problem of low training sample generation efficiency is solved, and efficient and accurate generation of training samples is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 北京怀柔实验室
- Filing Date
- 2026-04-13
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies suffer from computational convergence issues when generating training samples for power flow calculation models, resulting in low generation efficiency.
When perturbing the index parameters, the linked indexes are perturbed together. If the power flow calculation results do not meet the standards, the basic sample is optimized through optimal power flow calculation to improve the accuracy and efficiency of the perturbed sample.
By avoiding interference from interconnected indicators that violates the physical rules of the power grid, the efficiency and accuracy of training sample generation are improved, ensuring that the power flow calculation results can converge.
Smart Images

Figure CN122020184B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method for generating training samples based on a power flow calculation model, a device for generating training samples based on a power flow calculation model, a computer device, a computer-readable storage medium, and a computer program product. Background Technology
[0002] Power flow calculation refers to the process of calculating the steady-state distribution of voltage at all nodes and power in all branches of the entire power grid, based on a given power grid structure (where power plants are located, where users are located, and how the power lines are connected) and operating conditions (how much electricity power plants generate and how much electricity users consume), using complex mathematical formulas.
[0003] With the development of smart grids, power flow calculation using deep learning models has become a hot topic. Before using deep learning models for power flow calculation, the models need to be trained. Training the model requires a large number of training samples. Different training samples correspond to different grid structures and operating conditions. Each training sample includes a grid structure and its corresponding operating conditions, as well as the calculated voltage of all nodes and the power of all branches in the grid structure. Currently, the main method for generating training samples is as follows: obtain a specified grid structure and its operating conditions, and randomly perturb the parameters of one or more indicators in the operating conditions. Each random perturbation yields an operating condition. Based on the specified grid structure and the obtained operating conditions, the power flow calculation equation is used to calculate the voltage of all nodes and the power of all branches in the grid structure. The specified grid structure, the current operating conditions, and the calculated voltage of all nodes and the power of all branches constitute a training sample. After multiple perturbations and corresponding power flow calculations, multiple training samples can be obtained. By changing the grid structure and using the above method again, more training samples can be obtained.
[0004] However, generating operating conditions by randomly perturbing the parameters of the indicators for power flow calculations often results in convergence issues. To obtain a specified number of training samples, more parameter perturbations are needed for the operating conditions. This reduces the efficiency of generating a specified number of training samples in the power flow calculation model training. Summary of the Invention
[0005] The purpose of this application is to provide a method for generating training samples based on a power flow calculation model, a device for generating training samples based on a power flow calculation model, a computer device, a computer-readable storage medium, and a computer program product, so as to improve the efficiency of generating training samples for a power flow calculation model.
[0006] To address the aforementioned technical problems, this application provides the following technical solutions: The first aspect of this application provides a method for generating training samples based on a power flow calculation model. The method includes: obtaining basic samples, which include the power grid structure and its operating conditions; randomly perturbing the parameters of the indicators in the operating conditions and correspondingly perturbing the parameters of the linked indicators in the operating conditions, and determining the power grid structure and the perturbed operating conditions as perturbed samples; performing power flow calculation on the perturbed samples using a power flow calculation algorithm to obtain power flow calculation results; when the power flow calculation results reach the sample generation termination condition, determining the voltage and power of all nodes in the perturbed samples and the power flow calculation results as training samples of the power flow calculation model; when the power flow calculation results do not reach the sample generation termination condition, performing optimal power flow calculation using the basic samples and the power grid optimization objective to obtain the optimal operating conditions of the power grid structure, and determining the power grid structure and the optimal operating conditions as new basic samples, so as to generate power flow calculation results based on the new basic samples, until the generated power flow calculation results reach the sample generation termination condition.
[0007] Compared to existing technologies, the training sample generation method based on a power flow calculation model provided in the first aspect of this application perturbs linked indicators together when perturbing indicator parameters. That is, it randomly perturbs the parameters of one indicator and correspondingly perturbs the parameters of linked indicators. This avoids perturbing parameters of linked indicators in a way that violates the physical rules of the power grid, improving the accuracy of perturbation examples. Furthermore, after performing power flow calculations on the perturbation examples, if the calculation results are not satisfactory, the basic examples are further optimized to make subsequent generated perturbation examples more accurate, thereby enabling the power flow calculation results to converge and ultimately improving the generation efficiency of training samples in the power flow calculation model.
[0008] In other embodiments provided in this application, random perturbation of the parameters of the indicators in the operating conditions includes: random perturbation of the parameters of the key indicators in the operating conditions, wherein the key indicators are the indicators used in the operating conditions to indicate the boundary conditions for power flow calculation.
[0009] By perturbing only the parameters of key indicators, perturbed samples can be effectively distinguished from basic samples in power flow calculations, thereby improving the accuracy and efficiency of perturbations.
[0010] In other embodiments provided in this application, the parameters of key indicators in the operating conditions are randomly disturbed, including: randomly disturbing one or more parameters of node load, node admittance, and branch parameters in the operating conditions; and disturbing the parameters of the linkage indicators of the indicators in the operating conditions accordingly, including: when the node load is disturbed under a first preset condition, the node admittance is disturbed under a second preset condition; when the node admittance is disturbed under a second preset condition, the node load is disturbed under a first preset condition, wherein the first preset condition and the second preset condition are opposites of each other, and the value of the first preset condition is greater than the value of the second preset condition; and when the resistance or reactance in the branch parameters is disturbed, the reactance or resistance in the branch parameters is disturbed accordingly, wherein the ratio of the disturbed resistance to the reactance is within a preset range.
[0011] Simulations of various conditions in the power grid structure can be achieved by considering node load, node admittance, and branch parameters. This not only improves disturbance efficiency but also enables effective disturbances, thereby enhancing the efficiency and accuracy of training sample generation.
[0012] In other embodiments provided in this application, after perturbing the parameters of the linkage indicators in the operating conditions, the method further includes: determining whether the indicator parameters in the perturbed operating conditions conform to the physical rules of the power grid structure; if yes, then performing a step of using a power flow calculation algorithm to calculate the power flow of the perturbed sample; if no, then determining that the perturbed operation has failed.
[0013] Performing physical rule verification after perturbation can further ensure the rationality of perturbation examples, thereby ensuring that power flow calculation can converge and improving the efficiency of training sample acquisition.
[0014] In other embodiments provided in this application, determining whether the index parameters in the operating conditions after the disturbance conform to the physical rules of the power grid structure includes: when the node load is disturbed, determining whether the total change in the load of all nodes is less than the total load of all nodes under the preset percentage before the disturbance; when the node admittance is disturbed, determining whether the admittance matrix is symmetrical; when the resistance or reactance in the branch parameters is disturbed, determining whether the branch power flow does not exceed the line capacity limit.
[0015] Physical rules can be quickly verified by using node load, node admittance, and branch parameters, thus improving the efficiency of physical rule verification.
[0016] In other embodiments provided in this application, the parameter perturbation of the indicators and their linked indicators uses the same random number generator, while the parameter perturbation of indicators that do not have a linkage relationship uses different random number generators. Each random number generator has a fixed seed, and the random number generator generates random numbers uniformly within a set perturbation range based on the fixed seed. Randomly perturbing the parameters of the indicators in the operating conditions, and correspondingly perturbing the parameters of the linked indicators in the operating conditions, includes: using the random number generator corresponding to the indicator to generate a first random number and a second random number based on the fixed seed; using the first random number to calculate a first perturbation value of the indicator, and using the first perturbation value to perturb the parameters of the indicator; using the second random number to calculate a second perturbation value of the linked indicator, and using the second perturbation value to perturb the parameters of the linked indicator.
[0017] The parameters of linked indicators are perturbed using the same fixed seed in the same random number generator, while the parameters of non-linked indicators are perturbed using fixed seeds in different random number generators. This ensures the consistency of the parameters of linked indicators and the independence of the parameters of non-linked indicators, thus achieving accurate and random perturbation of parameters.
[0018] In other embodiments provided in this application, the method further includes: in response to the number of branch faults input in the configuration file, randomly selecting a target branch from the power grid structure according to the number of branch faults; determining a target fault scenario including the target branch from multiple fault scenarios, wherein each fault scenario includes at least two branches with fault association; and performing fault processing on the target branch in the operating conditions and other branches outside the target branch in the target fault scenario to obtain a disturbance sample.
[0019] In the disturbance of branch faults, the associated branches are also subjected to fault disturbances, making the simulation of abnormal power grid conditions more realistic, improving the accuracy of fault simulation, and thus improving the accuracy of training samples.
[0020] In other embodiments provided in this application, before randomly perturbing the parameters of the indicators in the operating conditions, the method further includes: obtaining the total number of nodes in the power grid structure; and configuring a corresponding number of processes for parameter perturbation, power flow calculation, and sample storage in the generation process of each training sample based on the total number of nodes, wherein the sample storage is used to store training samples, and the more total nodes there are, the greater the proportion of parameter perturbation and sample storage compared to power flow calculation.
[0021] Based on the total number of nodes in the power grid structure, different proportions of processes can be configured for parameter disturbance, power flow calculation, and sample storage, which can achieve effective allocation of processes and thus improve sample generation efficiency.
[0022] In other embodiments provided in this application, the method further includes: determining the generation speed of training samples; if the generation speed is less than a preset speed, allocating parameter perturbation and a preset number of processes in sample storage to power flow calculation to improve the generation speed of the next training sample.
[0023] Adjusting the process allocation during the generation of the next training sample based on the generation speed of the previous training sample can improve the generation efficiency of the next training sample, achieving adaptive adjustment during the training sample generation process and improving the overall generation efficiency of training samples.
[0024] In other embodiments provided in this application, the parameter perturbation process is allocated by the parameter perturbation process pool, the power flow calculation process is allocated by the power flow calculation process pool, and the sample storage process is allocated by the sample storage process pool. The power flow calculation process pool is an independent central processing unit (CPU) core process pool. During the generation of each training sample, a corresponding number of processes are configured for parameter perturbation, power flow calculation, and sample storage, including: during the generation of each training sample, the process with the maximum number of processes obtained from the parameter perturbation process pool is allocated to parameter perturbation, the process with the maximum number of processes obtained from the power flow calculation process pool is allocated to power flow calculation, and the process with the maximum number of processes obtained from the sample storage process pool is allocated to sample storage.
[0025] Different process pools allocate processes to different processing procedures, and the power flow calculation adopts the CPU core process pool, which ensures that the complex power flow calculation is not disturbed and that different processing procedures do not affect each other, thus achieving accurate generation of training samples.
[0026] In other embodiments provided in this application, the method further includes: obtaining the current CPU utilization and memory usage; adjusting the maximum number of processes in the perturbation process pool, the power flow calculation process pool, and the sample storage process pool according to the CPU utilization and memory usage, wherein the CPU utilization and memory usage are negatively correlated with the maximum number of processes.
[0027] The maximum number of processes in the process pool can be adjusted in real time, enabling adaptive adjustment of the time-consuming and large-scale training sample generation process, ultimately achieving orderly and stable generation of a large number of training samples in the power flow calculation model.
[0028] In other embodiments provided in this application, the number of disturbance samples is multiple; power flow calculation is performed on the disturbance samples using a power flow calculation algorithm to obtain power flow calculation results, including: performing power flow calculation on each disturbance sample using the power flow calculation algorithm to obtain multiple power flow calculation results; the method further includes: determining the number of converged results and the number of non-converged results from the multiple power flow calculation results; calculating the convergence rate of the multiple power flow calculation results based on the number of converged results and the number of non-converged results; when the convergence rate is greater than a preset rate value, determining that the multiple power flow calculation results have reached the sample generation termination condition; when the convergence rate is less than or equal to the preset rate value, determining that the multiple power flow calculation results have not reached the sample generation termination condition.
[0029] Determining whether to optimize the basic sample based on the convergence rate enables rapid determination of case optimization, thereby improving the efficiency of basic sample optimization.
[0030] The second aspect of this application provides a device for generating training samples based on a power flow calculation model. The device includes: an acquisition module for acquiring basic samples, including the power grid structure and its operating conditions; a disturbance module for randomly disturbing the parameters of the indicators in the operating conditions and correspondingly disturbing the parameters of the linked indicators in the operating conditions, and determining the power grid structure and the disturbed operating conditions as disturbance samples; a calculation module for performing power flow calculation on the disturbance samples using a power flow calculation algorithm to obtain power flow calculation results; a generation module for determining the voltage and power of all nodes in the disturbance samples and the power flow calculation results as training samples for the power flow calculation model when the power flow calculation results reach the sample generation termination condition; and a generation module for performing optimal power flow calculation using the basic samples and the power grid optimization objective when the power flow calculation results do not reach the sample generation termination condition, obtaining the optimal operating conditions of the power grid structure, and determining the power grid structure and the optimal operating conditions as new basic samples to generate power flow calculation results based on the new basic samples, until the generated power flow calculation results reach the sample generation termination condition.
[0031] 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.
[0032] A 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.
[0033] 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.
[0034] The apparatus for generating training samples based on the power flow calculation model 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 flow calculation method provided in the first aspect. Attached Figure Description
[0035] 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 1 This is a flowchart illustrating the method for generating training samples based on the power flow calculation model in this application embodiment. Figure 1 ; Figure 2 This is a flowchart illustrating the method for generating training samples based on the power flow calculation model in this application embodiment. Figure 2 ; Figure 3 This is a schematic diagram of the structure of the device for generating training samples based on the power flow calculation model in the embodiments of this application. Figure 1 ; Figure 4 This is a schematic diagram of the structure of the device for generating training samples based on the power flow calculation model 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
[0036] 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.
[0037] 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.
[0038] Currently, the main problem with randomly generating training samples for power flow calculation models is that the power flow calculation often fails to converge when generating training samples, requiring repeated random generation processes. This reduces the efficiency of generating a specified number of training samples in the power flow calculation model training.
[0039] In view of this, embodiments of this application provide a method for generating training samples based on a power flow calculation model, a device for generating training samples based on a power flow calculation model, a computer device, a computer-readable storage medium, and a computer program product. When randomly perturbing the index parameters in the basic samples, the parameters of indices that are linked to the perturbed index are also perturbed accordingly to improve the realism of the perturbation. Furthermore, after performing power flow calculations on the perturbed samples, the optimization of the basic samples is determined based on the power flow calculation results. The optimized basic samples represent the optimal effect of power grid operation, and the perturbed samples obtained after perturbation will not deviate significantly, thus enabling most power flow calculations to converge, ultimately improving the generation efficiency of a specified number of training samples in the training of the power flow calculation model.
[0040] 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.
[0041] First, the method for generating training samples based on the power flow calculation model provided in the embodiments of this application will be described in detail.
[0042] Figure 1 This is a flowchart illustrating the method for generating training samples based on the power flow calculation model in this application embodiment. Figure 1 See Figure 1 As shown, the method may include: S11: Obtain the basic sample, which includes the power grid structure and its operating conditions.
[0043] The base example is a complete, executable digital model of a power system, containing all the raw data needed to perform power flow calculations at a specific moment. This data accurately describes the grid structure and operating conditions of a power system.
[0044] The power grid structure refers to the physical composition and connection relationships of a power system, describing what components (such as nodes, lines, transformers, generators, and loads) are in the system and how these components are physically connected together.
[0045] Operating conditions refer to the operating state and power balance of a power system at a specific moment, representing the constantly changing electrical quantities applied to a fixed power grid structure. Operating conditions directly determine the current power flow distribution of the system. Operating conditions may include, but are not limited to: generator output (active and reactive power generated by each generator), load demand (active and reactive power consumed by loads at each node), node voltage (voltage amplitude and phase angle at each node, which is the result of power flow calculation and also reflects the operating state), and network losses (active and reactive power losses generated on lines and transformers), etc.
[0046] Basic examples can be obtained from publicly available benchmark systems, open-source simulation platforms and databases, synthetic models based on real power grids, or even built independently. The method for obtaining basic examples is not limited here.
[0047] S12: Randomly disturb the parameters of the indicators in the operating conditions, and correspondingly disturb the parameters of the linked indicators in the operating conditions, and determine the power grid structure and the operating conditions after the disturbance as disturbance examples.
[0048] The indicators in the operating conditions can be one or multiple indicators. There are no restrictions here on the type and number of indicators used for random parameter perturbation.
[0049] Interlocking indicators refer to indicators in a power system that are related to and mutually constrain the aforementioned indicators. When these indicators change, in order to maintain system balance, stability, or logical consistency, the interlocking indicators must also undergo predefined and coordinated changes. For example, nodal load and nodal admittance are a set of interlocking indicators.
[0050] Randomly perturbing the index parameters in the operating conditions can be done by adding a value to the index parameter or by multiplying it by a value. These values are generated randomly.
[0051] To perturb the parameters of the linkage indicators in the operating conditions, the corresponding perturbation value is applied to the linkage indicator parameters based on the previously targeted indicator parameters. For example, if the node load increases by 10%, the node admittance decreases by 5%.
[0052] In this way, the power grid structure, the index parameters after random disturbance, the associated index parameters after corresponding disturbance, and other index parameters that are not disturbed in the operating conditions constitute the disturbance sample.
[0053] S13: The power flow calculation algorithm is used to perform power flow calculation on the disturbance sample to obtain the power flow calculation results.
[0054] The power flow calculation algorithm here can be a power flow calculation equation or an iterative nonlinear algorithm. In short, anything that can perform power flow calculation can be used as a power flow calculation algorithm.
[0055] The disturbance example includes the power grid structure and operating conditions. Power flow calculation results can be obtained using power flow calculation algorithms. Since power flow calculation is a well-known technique in this field, the specific process of power flow calculation will not be elaborated here.
[0056] When the power flow calculation converges, the voltage of all nodes and the power of all branches can be obtained. This is one type of power flow calculation result. When the power flow calculation fails to converge, the voltage of all nodes and the power of all branches cannot be obtained, i.e., there is no calculation result. This is also one type of power flow calculation result.
[0057] The other part of the training sample data corresponding to the disturbance examples consists of the voltages of all nodes and the power of all branches obtained after convergence. Therefore, it is necessary to select the power flow calculation results corresponding to the disturbance examples.
[0058] S14: When the power flow calculation results reach the sample generation termination condition, the voltage of all nodes and the power of all nodes in the disturbance sample and the power flow calculation results are determined as training samples for the power flow calculation model.
[0059] In other words, when the power flow calculation results table converges and contains the voltage of all nodes and the power of all branches, the disturbance examples and the voltage and power of all nodes in the power flow calculation results are the training samples.
[0060] The termination condition for sample generation here can be either that the converged power flow calculation results reach the required number of training samples, or that the convergence rate of the power flow calculation results reaches the preset convergence rate.
[0061] S15: When the power flow calculation result does not meet the sample generation termination condition, the optimal power flow calculation is performed using the basic sample and the power grid optimization objective to obtain the optimal operating conditions of the power grid structure. The power grid structure and the optimal operating conditions are then determined as the new basic sample. Power flow calculation results are generated based on the new basic sample until the generated power flow calculation result meets the sample generation termination condition.
[0062] In other words, the power flow calculation results do not converge. At this point, the disturbance has already caused random parameter changes within a very small range, which generally does not directly lead to non-convergence in the power flow calculation. Therefore, it is possible that the base example is not an optimal power system. In this case, optimization can be performed on the base example, i.e., optimal power flow calculation.
[0063] Optimal power flow calculation refers to a mathematical optimization problem that, under the premise of satisfying the physical operation constraints and equipment safety constraints of the power system, adjusts controllable variables to achieve the optimal state of one or more specific objective functions. Simply put, conventional power flow calculation asks: "How will the power grid operate under the current conditions?" Optimal power flow calculation, on the other hand, asks: "How should the power grid operate to achieve both safety and maximum economy / optimal performance?" In optimal power flow calculations, besides using basic examples, another key factor is the grid optimization objective. In practical applications, the grid optimization objective can be the lowest cost (minimizing total generation cost, minimizing network losses, etc.), the safest operation (maximizing static voltage stability margin, minimizing load shedding, etc.), and so on.
[0064] Since optimal power flow calculation is a well-known technique in this field, the specific process of optimal power flow calculation will not be described in detail here.
[0065] After obtaining the optimal operating conditions of the power grid structure, the power grid structure and optimal operating conditions can be determined as new base samples. Then, based on the new base samples, the index parameters are perturbed to obtain perturbed samples. Power flow calculations are then performed based on the perturbed samples to obtain power flow calculation results. Judgments are then made based on the power flow calculation results until the generated power flow calculation results meet the sample generation termination condition.
[0066] As described above, the training sample generation method based on the power flow calculation model provided in this application perturbs the index parameters by perturbing the linked indices together. Specifically, it randomly perturbs the parameters of one index and correspondingly perturbs the parameters of its linked indices. This avoids perturbing the parameters of linked indices in a way that violates the physical rules of the power grid, thus improving the accuracy of the perturbation samples. Furthermore, after performing power flow calculations on the perturbation samples, if the calculation results are not satisfactory, the basic samples are further optimized to make the subsequently generated perturbation samples more accurate, thereby enabling the power flow calculation results to converge and ultimately improving the generation efficiency of training samples in the power flow calculation model.
[0067] Furthermore, as a response to Figure 1 In a refinement and extension of the method shown, this application embodiment also provides a method for generating training samples based on a power flow calculation model.
[0068] Figure 2 This is a flowchart illustrating the method for generating training samples based on the power flow calculation model in this application embodiment. Figure 2 See Figure 2 As shown, the method may include: S21: Obtain the basic sample, which includes the power grid structure and its operating conditions.
[0069] After obtaining the base sample, a full copy can be performed. This results in two base samples: one for backup and the other for subsequent processing.
[0070] In this training sample generation process, it's not just about generating a single training sample, but a large number of training samples. Each training sample generation is a separate task, involving parameter perturbation, power flow calculation, and sample storage. Therefore, each task contains multiple subtasks. Given the limited total resources, it's necessary to allocate resources, i.e., processes, rationally to each subtask.
[0071] S22: Obtain the total number of nodes in the power grid structure; based on the total number of nodes, configure the corresponding number of processes for parameter perturbation, power flow calculation, and sample storage during the generation of each training sample.
[0072] Here, parameter perturbation refers to the process of randomly perturbing the index parameters in the base sample and correspondingly perturbing the linked index parameters to generate perturbation samples. Power flow calculation is the process of performing power flow calculations based on the perturbation samples. Sample storage is used to store training samples, which is the process of formatting and storing the generated training samples.
[0073] The more nodes there are, the greater the proportion of parameter perturbation and sample storage compared to power flow calculation.
[0074] Generally, when the total number of nodes in the power grid is ≤500, a 1:N:1 ratio of processes is used for parameter disturbance, power flow calculation, and sample storage. Specifically, this can be 1 process for parameter disturbance, N processes for power flow calculation, and 1 process for sample storage. When the total number of nodes in the power grid is >500, an M:N:M ratio of processes is used for parameter disturbance, power flow calculation, and sample storage. Specifically, this can be M processes for parameter disturbance, N processes for power flow calculation, and M processes for sample storage. M and N are both positive integers greater than 1.
[0075] The allocation of processes is managed by process pools. To prevent resource contention between subtasks and to ensure that the demanding task of power flow calculation is not interrupted and that the task is successfully completed, different process pools can be used to allocate processes for different subtasks.
[0076] Specifically, the parameter perturbation process is allocated by the parameter perturbation process pool, the power flow calculation process by the power flow calculation process pool, and the sample storage process by the sample storage process pool. The power flow calculation process pool is an independent CPU core process pool. Furthermore, lightweight processes can be used in both the parameter perturbation process pool and the sample storage process pool.
[0077] Step S22 above may include: during the generation of each training sample, the process with the maximum number of processes obtained from the parameter perturbation process pool is allocated to parameter perturbation, the process with the maximum number of processes obtained from the power flow calculation process pool is allocated to power flow calculation, and the process with the maximum number of processes obtained from the sample storage process pool is allocated to sample storage.
[0078] Within the process pool, there is another crucial parameter: the maximum number of processes. The maximum number of processes refers to the upper limit of the number of processes that can run concurrently in a parallel computing environment. To ensure the stable operation of the entire training sample generation process, the maximum number of processes in each process pool can be adjusted based on the current CPU utilization and memory usage.
[0079] Specifically, before step S22 above, the method may further include: obtaining the current CPU utilization and memory usage; adjusting the maximum number of processes in the perturbation process pool, the power flow calculation process pool, and the sample storage process pool based on the CPU utilization and memory usage.
[0080] Among these, CPU utilization and memory usage are negatively correlated with the maximum number of processes. In other words, high CPU utilization or memory usage indicates a shortage of overall resources. To avoid resource contention between the training sample generation process and other programs, which could lead to system crashes, the number of processes used for training sample generation can be appropriately reduced. That is, the number of processes allocated for parameter perturbation, power flow calculation, and sample storage at the same time should be reduced. When CPU utilization or memory usage decreases, the number of processes allocated for parameter perturbation, power flow calculation, and sample storage at the same time can be increased again, thereby ensuring the efficiency of training sample generation.
[0081] It should be noted that the number of processes allocated to each process pool for parameter perturbation, power flow calculation, and sample storage at the same time still needs to be in accordance with the predetermined ratio, but the specific number may increase or decrease depending on the CPU utilization and memory usage.
[0082] Once the processes are allocated, each subtask can be executed according to its assigned process. The completion of all subtasks within the same task constitutes the generation of a training sample.
[0083] Sometimes, the allocation ratio of processes for different subtasks under the same task is not perfect. It needs to be improved based on the completion results of each or several training sample generation tasks to improve the efficiency of subsequent training sample generation.
[0084] Specifically, after step S22 above, or even after generating one or more training samples, the method may further include: determining the generation speed of training samples; if the generation speed is less than a preset speed, allocating parameter perturbation and a preset number of processes in sample storage to power flow calculation in order to improve the generation speed of the next training sample.
[0085] The training sample generation rate can be characterized by the number of samples generated per unit time. The preset rate can be set according to actual needs. When the training sample generation rate is lower than the preset rate, it indicates that the previous training sample generation rate did not meet expectations. To ensure that the subsequent training sample generation rate reaches the expected level, more processes can be temporarily allocated to the computationally intensive power flow calculations. To avoid consuming other resources, parameter perturbation and a preset number of processes for sample storage can be used.
[0086] It's important to note that processes need to be retained during parameter perturbation and sample storage to ensure their operation. Therefore, the preset number cannot be greater than or equal to the existing number of processes for parameter perturbation and sample storage. Both parameter perturbation and sample storage require allocating a preset number of processes to the power flow calculation. Once the generation rate of training samples in a subsequent iteration exceeds or equals the preset rate, the processes previously allocated to the power flow calculation can be returned to parameter perturbation and sample storage.
[0087] At this point, the allocation of processes for parameter perturbation, power flow calculation, and sample storage involved in the training sample generation process, as well as the dynamic adjustment of process allocation, have all been explained. Next, the detailed process of generating a single training sample will be described.
[0088] Furthermore, a message queue mechanism is used to achieve data synchronization and result merging between processes, ensuring data consistency and integrity. Specifically, a message queue is created in the main process to store the simulation data generated by each child process. After all child processes complete their tasks, the main process retrieves data from the message queue and merges it into a complete result set.
[0089] S23: Randomly disturb the parameters of key indicators in the operating conditions, and correspondingly disturb the parameters of the linked indicators in the operating conditions, and determine the power grid structure and the operating conditions after the disturbance as disturbance examples.
[0090] Among them, the key indicators are those used in the operating conditions to indicate the boundary conditions for power flow calculation.
[0091] In other words, for all indicators under the operating conditions, only the parameters of those indicators that signify the boundary conditions for power flow calculation are perturbed. This achieves effective parameter perturbation while reducing the number of perturbations, thus improving the efficiency and accuracy of parameter perturbation.
[0092] In practical applications, key indicators may include node injected power (load, generator), network parameters (branch R / X / B, transformer turns ratio), and controller status (capacitor, reactor), etc.
[0093] Step S23 may include: randomly perturbing one or more parameters in the operating conditions, such as node load, node admittance, and branch parameters; when the node load is perturbed under a first preset condition, the node admittance is perturbed under a second preset condition; when the node admittance is perturbed under a second preset condition, the node load is perturbed under a first preset condition, wherein the first preset condition and the second preset condition are opposites of each other, and the value of the first preset condition is greater than the value of the second preset condition; when the resistance or reactance in the branch parameters is perturbed, the reactance or resistance in the branch parameters is perturbed accordingly, wherein the ratio of the perturbed resistance to the reactance is within a preset range.
[0094] In a power grid structure, there are multiple nodes and multiple branches. One or more nodes and one or more branches can be randomly selected to perform parameter perturbations.
[0095] If the node load parameters are disturbed, the corresponding linkage parameter is the node admittance. For example, if the node load (PD, QD) increases by 10% randomly, the node admittance (GS, BS) should be reduced by 5% simultaneously to balance the power injection change and avoid voltage collapse. If the disturbance amplitude of the node load (PD, QD) is large, the admittance disturbance amplitude needs to be adjusted synchronously (e.g., δG=-0.5·δP, δB=-0.5·δQ) to maintain system stability. Here, PD is the node active load, QD is the node reactive load, GS is the node parallel conductance, BS is the node parallel susceptance, δG is the disturbance amount of admittance conductance, δP is the disturbance amount of active load, δB is the disturbance amount of admittance susceptance, and δQ is the disturbance amount of reactive load.
[0096] If the node admittance is perturbed by parameters, the corresponding linkage index parameter is the node load.
[0097] If branch parameters are disturbed, such as branch resistance, the corresponding linkage parameter is branch reactance. Specifically, impedance ratio constraints are used to keep the ratio of branch resistance (R) to branch reactance (X) within a reasonable range (e.g., 0.1 ≤ R / X ≤ 0.5) to avoid power flow non-convergence caused by abnormal line impedance.
[0098] Parameter perturbation can be performed using a random number generator. In practical applications, `numpy.random.RandomState` can be used as the random number generator, ensuring a uniform distribution of perturbation patterns within a defined range, thus guaranteeing the consistency of the number of perturbation data types. Simultaneously, a fixed seed should be set for the random number generator to ensure the repeatability of the random perturbation.
[0099] When perturbing the index parameters and their linkage parameters, the specific parameter values of the perturbation can use the same random number generator. This is because, in actual power grids, load fluctuations (such as peak industrial electricity consumption) directly lead to changes in line admittance (such as changes in resistance caused by temperature rise). A shared random number generator ensures that the two are strictly synchronized in the time dimension. For example, the load perturbation value and admittance perturbation value at time t are determined by the same random number, avoiding physically unreasonable combinations that may be caused by independent random numbers (such as a surge in load but no change in admittance), thereby improving the accuracy of parameter perturbation.
[0100] For parameter perturbations of indicators that are not correlated, different random number generators are used. That is, an independent random number generation engine is configured for each process. Statistical methods are used to verify whether the random number sequences generated by each process meet the requirements of independence and uniformity, ensuring that the data generated by different processes have different randomness.
[0101] Each random number generator has a fixed seed. The random number generator generates random numbers uniformly within a set perturbation range based on the fixed seed.
[0102] Step S23 above may include: using a random number generator corresponding to the indicator to generate a first random number and a second random number based on a fixed seed; using the first random number to calculate a first perturbation value of the indicator, and using the first perturbation value to perturb the parameters of the indicator; using the second random number to calculate a second perturbation value of the linked indicator, and using the second perturbation value to perturb the parameters of the linked indicator.
[0103] Here, the first perturbation value is calculated based on the first random number, and the second perturbation value is calculated based on the second random number. The algorithms used for the same random number generator are all the same.
[0104] At this point, parameter perturbation based on normal conditions is complete. Simultaneously, parameter perturbation for abnormal conditions can also be performed to achieve comprehensive parameter perturbation processing.
[0105] S24: In response to the number of branch faults input in the configuration file, randomly select a target branch from the power grid structure according to the number of branch faults; determine the target fault scenario including the target branch from multiple fault scenarios; perform fault processing on the target branch in the operating conditions and other branches outside the target branch in the target fault scenario to obtain disturbance samples.
[0106] Users can input the desired branch fault type, i.e., the number of branch faults, into the configuration file. For example, inputting N-1 fault means randomly disconnecting 1 branch to simulate a 1-branch fault; inputting N-2 fault means randomly disconnecting 2 branches to simulate a double-branch fault, and so on. The specific values input by the user are not limited here.
[0107] Based on the number of branch faults, a specified number of branches are randomly selected from all branches, and the status (BR_STATUS) of the selected branches is set to disconnected (0). The disconnected branch numbers are recorded for subsequent analysis and result saving.
[0108] By randomly selecting branches multiple times, various different fault scenarios are generated to meet diverse sample generation needs.
[0109] In some cases, if one branch fails, it may cause other branches to operate normally. Therefore, it is necessary to pre-construct the fault impact relationships between branches in the power grid structure, i.e., various fault scenarios. Each fault scenario includes at least two branches with fault associations. That is, for each branch, identify the other branches that its fault would affect, and combine that branch with the identified other branches as a single fault scenario.
[0110] Furthermore, branch faults (such as line breaks) can directly alter the power grid topology (such as the formation of islands). The causal relationship between these two factors can be characterized by joint distribution. For example, when the topological connectivity of a certain area decreases, the probability of branch faults in that area increases accordingly, avoiding logical contradictions that may be caused by independent random numbers (such as a disconnected branch still being marked as "faulty").
[0111] After performing parameter perturbation and fault simulation, in order to ensure that the power grid structure and its operating environment can converge in the power flow calculation and avoid invalid power flow calculation, it is also possible to determine in advance whether the operating conditions in the power grid structure conform to the physical rules.
[0112] S25: Determine whether the index parameters in the operating conditions after the disturbance conform to the physical rules of the power grid structure. If yes, proceed to S26; otherwise, proceed to S27.
[0113] The physical rules here can refer to various physical laws and parameter limitations involved in the power system, such as Kirchhoff's laws, power balance, node voltage safety rules, branch thermal stability limit rules, and so on.
[0114] To improve the efficiency of physical rule judgment, specific physical rules can be used to verify different indicators of disturbance. This reduces the number of physical rules to be verified and improves verification efficiency while ensuring the correct verification of the power grid.
[0115] Step S25 above may include: when the node load is disturbed, determining whether the total change in the load of all nodes is less than the total load of all nodes under the preset percentage before the disturbance; when the node admittance is disturbed, determining whether the admittance matrix is symmetrical; when the resistance or reactance in the branch parameters is disturbed, determining whether the branch power flow does not exceed the line capacity limit.
[0116] Specifically, this can involve: verifying that the total load change ΔP_total after the disturbance is ≤10%·P_base, where P_base is the base total load, to avoid power imbalance. Verifying the symmetry of the admittance matrix (G=GT, B=BT) to avoid abnormal power flow calculations. Verifying that the branch power flow (Pij, Qij) does not exceed the line capacity limit (e.g., |Pij|≤Pij_lim). Where Pij is the branch active power (flowing from node i to node j), Qij is the branch reactive power, G is the conductance component of the admittance matrix, B is the susceptance component of the admittance matrix, GT is the transpose of the conductance matrix, and BT is the transpose of the susceptance matrix.
[0117] S26: The power flow calculation algorithm is used to perform power flow calculation on the disturbance sample to obtain the power flow calculation results.
[0118] Once the disturbance or fault simulation is complete and the physical rules have been verified, it indicates that the power grid structure and operating conditions are normal and that the power flow calculations are likely convergent. At this point, power flow calculations can begin.
[0119] Specifically, pypower.runpf can be used to perform power flow calculations, and ppoption can be used to set algorithms such as the Newton-Raphson method and the fast decoupling method to solve for the node voltages and branch power of the power system.
[0120] Newton-Rafson The nonlinear power balance equation is solved iteratively. Here, J is the Jacobian matrix, ΔP is the active power imbalance, ΔQ is the reactive power imbalance, Δθ is the voltage phase angle correction, and ΔV is the voltage amplitude correction.
[0121] During power flow calculation, pypower.runpf automatically detects whether the power imbalance quantities ΔP and ΔQ meet the convergence conditions and displays the results by returning the convergence flag "success".
[0122] The output power flow calculation results include the calculated node voltage magnitude Vi and node voltage phase angle θi, branch active power Pij and reactive power Qij, and the unchanged information in the sample, for later saving and use.
[0123] In some cases, power flow calculations may not converge. Therefore, the power flow calculation results for each disturbance example may include voltage magnitude, phase angle, etc., or they may be information indicating non-convergence.
[0124] In addition, pypower.runpf can automatically perform parameter checks. Based on the actual needs and operating specifications of the power system, it sets reasonable upper and lower limits for the safe operating node voltage. First, it checks if convergence has occurred; if not, the data is marked as discarded. If convergence has occurred, it iterates through all nodes, checking whether the voltage amplitude is within the set safe range for each. If the voltage amplitude is safe, the data is retained; if it exceeds the range, it is marked as discarded.
[0125] Data that passes the convergence and safety amplitude checks is retained for further processing. Data marked as discarded is regenerated using the data generation process until convergence and voltage limit requirements are met.
[0126] S27: This disturbance has failed.
[0127] If the disturbance or fault simulation is completed, but the physical rule verification fails, it indicates that the current power grid structure and operating conditions are not normal, and there is a high probability that the power flow calculation will not converge. In this case, the disturbance example can be marked as discarded.
[0128] At this point, some disturbance samples are discarded, while others are retained. The retained disturbance samples and their power flow calculation results, such as voltage values and phase angles, need to be saved using a preset format.
[0129] Specifically, the data formats for nodes, generators, and branches can be defined based on model training. The node portion includes the node number (BUS_I), node type (BUS_TYPE), load (PD, QD), admittance (GS, BS), voltage amplitude (VM), and voltage phase angle (VA). The generator portion includes the generator connection node (GEN_BUS), output (generator active output (PG), generator reactive output (QG)), voltage setpoint (VG), and status (GEN_STATUS). The branch portion includes the branch start node (F_BUS), end node (T_BUS), resistance (BR_R), reactance (BR_X), susceptance (BR_B), and status (BR_STATUS). Through unified field definitions and index mapping, consistency in data transmission and processing across different modules is ensured.
[0130] Then, the data is divided into modules, and node data, generator data, branch data and fault information are saved separately in TXT format to ensure data readability and compatibility.
[0131] Finally, a unique filename is generated based on the number of nodes, case number, and fault type information to facilitate subsequent management and use.
[0132] For multiple disturbance examples, some can yield normal power flow calculation results such as voltage and phase angle, while others cannot. If the number of normal power flow calculation results is sufficient to meet the requirements for training samples, then the normal power flow calculation results and their corresponding disturbance examples can provide the final required training samples. However, if the number of normal power flow calculation results is insufficient to meet the requirements for training samples, then the basic examples need to be optimized to obtain more disturbance examples and normal power flow calculation results. Therefore, the sample generation termination condition here is the convergence rate.
[0133] S28: Determine the number of converged results and the number of non-converged results from multiple power flow calculation results; calculate the convergence rate of multiple power flow calculation results based on the number of converged results and the number of non-converged results; when the convergence rate is greater than the preset rate value, determine that multiple power flow calculation results have reached the sample generation termination condition; when the convergence rate is less than or equal to the preset rate value, determine that multiple power flow calculation results have not reached the sample generation termination condition.
[0134] Specifically, pypower.runpf can be used to perform power flow calculations for each disturbance sample, and convergence is determined based on the power imbalance values ΔP and ΔQ. Then, the ratio of convergence counts to the total number of power flow calculations for each disturbance sample is calculated. If the convergence rate is lower than a set threshold (dynamically adjusted; for small-scale power grids with ≤500 nodes, the threshold is set to 70%; for medium / large-scale power grids with >500 nodes, the threshold is set to 60%), the optimization process is triggered.
[0135] Convergence condition:
[0136] in, The threshold is used as the convergence criterion.
[0137] Convergence rate = (Number of convergence attempts / Total number of calculations) × 100% S29: When the power flow calculation results reach the sample generation termination condition, the voltage of all nodes and the power of all nodes in the disturbance sample and the power flow calculation results are determined as training samples for the power flow calculation model.
[0138] The specific implementation of step S29 here is the same as that of step S14 in the aforementioned embodiments. Please refer to the relevant descriptions in the aforementioned embodiments, which will not be repeated here.
[0139] S210: When the power flow calculation result does not meet the sample generation termination condition, the optimal power flow calculation is performed using the basic sample and the power grid optimization objective to obtain the optimal operating conditions of the power grid structure. The power grid structure and the optimal operating conditions are then determined as the new basic sample. Power flow calculation results are generated based on the new basic sample until the generated power flow calculation result meets the sample generation termination condition.
[0140] Specifically, pypower.runopf can be used to minimize generation costs, perform optimal power flow calculations (OPF), optimize the following key parameters, and ensure that they meet the physical constraints of the power grid.
[0141] Key parameters include: generator output (PG, QG), adjusted to meet generator set constraints (P_{g,min}≤PG≤P_{g,max}); node voltage amplitude and phase angle (VM,VA), optimized to the safe operating range (0.95-1.05pu) to avoid voltage overruns; branch power flow (Pij, Qij), optimized active / reactive power flow of the line to avoid overload (P_{ij}≤P_{ij,lim}).
[0142]
[0143] Where Ci(Pg,i) is the power generation cost function of generator i, P_{ij,lim} is the active power limit of the branch, P_{g,min} is the lower limit of the active power output of the generator, and P_{g,max} is the upper limit of the active power output of the generator.
[0144] Then, the PPC data structure of the base sample is updated with parameters optimized by Optimal Power Flow Calculation (OPF). Generator active power output (PG) and reactive power output (QG), voltage amplitude (VM) and phase angle (VA), and line active power output (Pij) and reactive power output (Qij) are extracted from the OPF results. Updates are performed in modules: Generator module: update the PG and QG fields in ppc['gen']; Node module: update the Vm and Va fields in ppc['bus']; Branch module: update the branch active power output (Pij) and branch reactive power output (Qij) fields in ppc['branch']. The number of nodes and branches in the updated PPC data structure is then verified to be consistent with the original topology to avoid data fragmentation. The integrity of the generator-node association (gen.bus) and branch-node connection (branch.fbus, branch.tbus) is verified. The updated PPC data structure is saved as a standardized file as a baseline template for subsequent sample generation.
[0145] To verify whether the optimized base sample meets the convergence rate requirement, the following closed-loop verification process is executed. Perturbation samples are regenerated, and the same number of data generation tasks are executed again according to the original parameter fluctuation range (preset perturbation range, fault simulation scenario), and the convergence rate is calculated. If the convergence rate reaches the set threshold, the verification passes, and the sample generation stage begins. If it does not meet the threshold, a secondary optimization process is triggered, expanding the generator output adjustment range, re-executing the OPF calculation and updating the PPC data structure, and repeating the verification process until the convergence rate meets the requirement.
[0146] As can be seen from the above, the method for generating training samples based on the power flow calculation model provided in this application firstly divides the task into multiple independent subtasks through multi-process parallel generation technology, and further refines each subtask into three task stages, dynamically allocates processes, and makes full use of the computing power of multi-core CPUs, which significantly improves the data generation efficiency and enhances the efficiency of the data stage in the entire model process.
[0147] Secondly, by optimizing the basic samples through optimal power flow calculation (OPF) and updating key parameters, the convergence rate of data generation was significantly improved, ensuring that the data conforms to the actual operating characteristics of the system. The improvement in data quality also led to the improvement in model performance.
[0148] Finally, through a flexible fault simulation mechanism and parameter linkage random generation technology, it supports multiple fault types and random disturbance ranges, generates diverse simulation data, meets the simulation needs of complex systems, and improves the robustness of the model.
[0149] In summary, the innovations in multi-process parallel generation, basic sample optimization, parameter randomization, and fault simulation in this application significantly improve the efficiency, convergence rate, and diversity of data generation, providing a more efficient and reliable solution for generating power flow calculation samples for power systems.
[0150] After generating training samples for the power flow calculation model, these samples can be used to train a deep learning model to achieve efficient and accurate prediction of power flow calculation in the power system.
[0151] First, the training samples are preprocessed and divided.
[0152] Specifically, the generated training samples (including disturbance examples and their corresponding power flow calculation results) are divided into training, validation, and test sets according to a preset ratio. For example, they can be divided in a 70%:15%:15% ratio to ensure that various operating conditions (such as load level, fault type, and network topology changes) are evenly distributed in each dataset, thereby improving the model's generalization ability.
[0153] Each training sample contains: Input characteristics: the power grid structure (such as branch parameters) and operating conditions (such as nodal load, admittance, generator output, and fault status) in the disturbance sample. Output labels: node voltage magnitude, phase angle, and branch power in the power flow calculation results.
[0154] Then, deep learning models are built and trained.
[0155] Specifically, a deep neural network model suitable for power system power flow calculation is constructed, such as a multilayer perceptron (MLP), graph neural network (GNN), or Transformer architecture. The model input consists of grid parameters and operating conditions from disturbance samples, and the output consists of predicted node voltages and branch power.
[0156] The training process includes: The model is trained end-to-end using the training set. The loss function can be the mean squared error (MSE) or a loss function with physical constraints (such as satisfying the power balance equation, voltage safety limits, etc.). During training, the validation set is used for hyperparameter tuning and early stopping strategies to prevent overfitting. After training, the model performance is evaluated using a test set. Evaluation metrics include voltage prediction error, power prediction accuracy, and convergence speed.
[0157] Finally, the model can be applied in practical applications within power systems.
[0158] The trained deep learning model can be deployed in power system dispatch centers or simulation platforms, and can be used in at least the following scenarios: 1. Online power flow calculation: In real-time operation of the power grid, when load, generation or network structure changes rapidly, the model can predict the system state within milliseconds, replacing traditional iterative calculations (such as the Newton-Raphson method) and significantly improving computational efficiency.
[0159] 2. Anticipated Fault Analysis (N-1 / N-2 Verification): Based on the open circuit fault simulation included in the generated samples, the model can quickly assess the safety margin and voltage stability of the system under different fault scenarios, assisting operators in preventive scheduling.
[0160] 3. Data augmentation and synthetic data generation: When there is insufficient historical data of the actual power grid or the coverage of scenarios is limited, this method can be used to generate diverse simulation data, expand the training sample set, and improve the model's predictive ability under extreme conditions.
[0161] 4. Model transfer and adaptive training: For different regions or power grids of different scales (such as distribution networks and transmission networks), the power grid parameters and topology in the generated samples can be adjusted to train a special model that is adapted to the specific system, so as to achieve "one-time training and multiple applications".
[0162] This concludes the description of the power flow calculation method provided in the embodiments of this application.
[0163] Based on the same inventive concept, embodiments of this application also provide a device for generating training samples based on a power flow calculation model.
[0164] Figure 3 This is a schematic diagram of the structure of the device for generating training samples based on the power flow calculation model 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 basic samples, which include the power grid structure and its operating conditions.
[0165] The disturbance module 32 is used to randomly disturb the parameters of the indicators in the operating conditions, and to disturb the parameters of the linked indicators in the operating conditions accordingly, and to determine the power grid structure and the operating conditions after the disturbance as disturbance examples.
[0166] The calculation module 33 is used to perform power flow calculation on the disturbance sample using the power flow calculation algorithm to obtain the power flow calculation results.
[0167] The generation module 34 is used to determine the voltage and power of all nodes in the disturbance sample and the power flow calculation result as training samples for the power flow calculation model when the power flow calculation result reaches the sample generation termination condition.
[0168] The generation module 34 is also used to perform optimal power flow calculation using basic samples and power grid optimization objectives when the power flow calculation results do not meet the sample generation termination conditions, to obtain the optimal operating conditions of the power grid structure, and to determine the power grid structure and optimal operating conditions as new basic samples, so as to generate power flow calculation results based on the new basic samples, until the generated power flow calculation results meet the sample generation termination conditions.
[0169] Furthermore, as Figure 3 In addition to the refinement and expansion of the illustrated device, this application embodiment also provides a device for generating training samples based on a power flow calculation model.
[0170] Figure 4 This is a schematic diagram of the structure of the device for generating training samples based on the power flow calculation model 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 basic samples, which include the power grid structure and its operating conditions.
[0171] The allocation module 42 is used to obtain the total number of nodes in the power grid structure. Based on the total number of nodes, in the generation process of each training sample, a corresponding number of processes are configured for parameter disturbance, power flow calculation and sample storage. Among them, sample storage is used to store training samples. The more total nodes there are, the greater the proportion of parameter disturbance and sample storage compared to power flow calculation.
[0172] The allocation module 42 is also used to determine the generation speed of training samples; if the generation speed is less than the preset speed, the parameter perturbation and the preset number of processes in the sample storage are allocated to the power flow calculation to improve the generation speed of the next training sample.
[0173] In the case that the parameter perturbation process is allocated by the parameter perturbation process pool, the power flow calculation process is allocated by the power flow calculation process pool, the sample storage process is allocated by the sample storage process pool, and the power flow calculation process pool is an independent central processing unit (CPU) core process pool, the allocation module 42 is specifically used to allocate the process with the maximum number of processes obtained from the parameter perturbation process pool to parameter perturbation, the process with the maximum number of processes obtained from the power flow calculation process pool to power flow calculation, and the process with the maximum number of processes obtained from the sample storage process pool to sample storage during the generation of each training sample.
[0174] The allocation module 42 is also used to obtain the current CPU utilization and memory usage; and to adjust the maximum number of processes in the perturbation process pool, the power flow calculation process pool, and the sample storage process pool according to the CPU utilization and memory usage, wherein the CPU utilization and memory usage are negatively correlated with the maximum number of processes.
[0175] The disturbance module 43 is used to randomly disturb the parameters of key indicators in the operating conditions. The key indicators are the indicators used to indicate the boundary conditions for power flow calculation in the operating conditions, and the parameters of the linkage indicators of the indicators in the operating conditions are disturbed accordingly. The power grid structure and the operating conditions after the disturbance are determined as disturbance examples.
[0176] The disturbance module 43 is specifically used to randomly disturb one or more parameters of the node load, node admittance, and branch parameters in the operating conditions; when the node load is disturbed under a first preset condition, the node admittance is disturbed under a second preset condition; when the node admittance is disturbed under a second preset condition, the node load is disturbed under a first preset condition, wherein the first preset condition and the second preset condition are opposites of each other, and the value of the first preset condition is greater than the value of the second preset condition; when the resistance or reactance in the branch parameters is disturbed, the reactance or resistance in the branch parameters is disturbed accordingly, wherein the ratio of the disturbed resistance to the reactance is within a preset range.
[0177] When the parameters of the indicators and their linked indicators are perturbed using the same random number generator, and the parameters of indicators that do not have a linkage relationship are perturbed using different random number generators, and each random number generator has a fixed seed, and the random number generator generates random numbers uniformly within a set perturbation range based on the fixed seed, the perturbation module 43 is specifically used to generate a first random number and a second random number based on the fixed seed of the random number generator corresponding to the indicator; calculate the first perturbation value of the indicator using the first random number, and perturb the parameters of the indicator using the first perturbation value; calculate the second perturbation value of the linked indicator using the second random number, and perturb the parameters of the linked indicator using the second perturbation value.
[0178] The fault module 44 is used to respond to the number of branch faults input in the configuration file, randomly select a target branch from the power grid structure according to the number of branch faults; determine a target fault scenario including the target branch from multiple fault scenarios, wherein each fault scenario includes at least two branches with fault association; and perform fault processing on the target branch in the operating conditions and other branches outside the target branch in the target fault scenario to obtain disturbance samples.
[0179] The verification module 45 is used to determine whether the index parameters in the operating conditions after the disturbance conform to the physical rules of the power grid structure; if yes, it proceeds to the calculation module 46; if no, it determines that the disturbance has failed.
[0180] The verification module 45 is specifically used to determine whether the total change in the load of all nodes is less than the total load of all nodes under the preset percentage before the disturbance when the node load is disturbed; to determine whether the admittance matrix is symmetrical when the node admittance is disturbed; and to determine whether the branch power flow does not exceed the line capacity limit when the resistance or reactance in the branch parameters is disturbed.
[0181] When there are multiple disturbance samples, the calculation module 46 is used to perform power flow calculation on each disturbance sample using a power flow calculation algorithm to obtain multiple power flow calculation results.
[0182] The verification module 47 is used to determine the number of converged results and the number of non-converged results from multiple power flow calculation results; calculate the convergence rate of multiple power flow calculation results based on the number of converged results and the number of non-converged results; when the convergence rate is greater than a preset rate value, determine that multiple power flow calculation results have reached the sample generation termination condition; when the convergence rate is less than or equal to the preset rate value, determine that multiple power flow calculation results have not reached the sample generation termination condition.
[0183] The generation module 48 is used to determine the voltage and power of all nodes in the disturbance sample and the power flow calculation result as training samples for the power flow calculation model when the power flow calculation result reaches the sample generation termination condition.
[0184] The generation module 48 is also used to perform optimal power flow calculation using basic samples and power grid optimization objectives when the power flow calculation results do not meet the sample generation termination conditions, to obtain the optimal operating conditions of the power grid structure, and to determine the power grid structure and optimal operating conditions as new basic samples, so as to generate power flow calculation results based on the new basic samples, until the generated power flow calculation results meet the sample generation termination conditions.
[0185] 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.
[0186] Based on the same inventive concept, this application also provides a computer device.
[0187] 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.
[0188] 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.
[0189] 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.
[0190] 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.
[0191] 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.
[0192] 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.
[0193] 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 method for generating training samples based on a power flow calculation model, characterized in that, The method includes: Obtain a basic sample, which includes the power grid structure and its operating conditions; Randomly disturb the parameters of the indicators in the operating conditions, and correspondingly disturb the parameters of the linked indicators of the indicators in the operating conditions, and determine the power grid structure and the disturbed operating conditions as disturbance examples; The power flow calculation algorithm is used to perform power flow calculation on the disturbance example to obtain the power flow calculation results; When the power flow calculation results reach the sample generation termination condition, the disturbance sample and the voltage and power of all nodes in the power flow calculation results are determined as training samples for the power flow calculation model. When the power flow calculation result does not meet the sample generation termination condition, the optimal power flow calculation is performed using the basic sample and the power grid optimization objective to obtain the optimal operating conditions of the power grid structure. The power grid structure and the optimal operating conditions are then determined as new basic samples to generate power flow calculation results based on the new basic samples, until the generated power flow calculation results meet the sample generation termination condition.
2. The method of claim 1, wherein, The random perturbation of the parameters of the indicators in the operating conditions includes: The parameters of key indicators in the operating conditions are randomly perturbed, wherein the key indicators are indicators used to indicate the boundary conditions for power flow calculation in the operating conditions.
3. The method of claim 2, wherein, The random perturbation of the parameters of key indicators in the operating conditions includes: Randomly perturb one or more parameters in the operating conditions, such as node load, node admittance, and branch parameters; The method of perturbing the parameters of the linked indicators in the operating conditions includes: When the node load is disturbed under a first preset condition, the node admittance is disturbed under a second preset condition. When the node admittance is disturbed under a second preset condition, the node load is disturbed under a first preset condition, wherein the first preset condition and the second preset condition are opposites of each other, and the value of the first preset condition is greater than the value of the second preset condition. When the resistance or reactance in the branch parameters is disturbed, the reactance or resistance in the branch parameters is disturbed accordingly, wherein the ratio of the disturbed resistance to the reactance is within a preset range.
4. The method of claim 1, wherein, After subjecting the parameters of the linked indicators in the aforementioned operating conditions to corresponding perturbations, the method further includes: Determine whether the index parameters in the operating conditions after the disturbance conform to the physical rules of the power grid structure; If so, then perform the step of using the power flow calculation algorithm to calculate the power flow of the disturbance sample; If not, then the disturbance has failed.
5. The method of claim 4, wherein, The determination of whether the index parameters in the post-disturbance operating conditions conform to the physical rules of the power grid structure includes: When the node load is disturbed, it is determined whether the total change in the load of all nodes is less than the total load of all nodes under the preset percentage before the disturbance. When perturbating the nodal admittance, determine whether the admittance matrix is symmetric; When the resistance or reactance in the branch parameters is disturbed, it is determined whether the power flow in the branch does not exceed the line capacity limit.
6. The method of claim 1, wherein, The parameters of the aforementioned indicators and their linked indicators are perturbed using the same random number generator, while the parameters of indicators without a linkage relationship are perturbed using different random number generators. Each random number generator has a fixed seed, and the random number generator generates random numbers uniformly within a set perturbation range based on the fixed seed. The random perturbation of the parameters of the indicators in the aforementioned operating conditions, and the corresponding perturbation of the parameters of the linked indicators in the aforementioned operating conditions, include: The random number generator corresponding to the index generates a first random number and a second random number based on a fixed seed. The first perturbation value of the indicator is calculated using the first random number, and the parameters of the indicator are perturbed using the first perturbation value; The second perturbation value of the linkage index is calculated using the second random number, and the parameters of the linkage index are perturbed using the second perturbation value.
7. The method of claim 1, wherein, The method further includes: In response to the number of branch faults input in the configuration file, a target branch is randomly selected from the power grid structure according to the number of branch faults; From multiple fault scenarios, a target fault scenario including the target branch is determined, wherein each fault scenario includes at least two branches that are fault-associated; Fault handling is performed on the target branch in the operating conditions and other branches outside the target branch in the target fault scenario to obtain disturbance samples.
8. The method of claim 1, wherein, Before randomly perturbing the parameters of the indicators in the operating conditions, the method further includes: Obtain the total number of nodes in the power grid structure; Based on the total number of nodes, a corresponding number of processes are configured for parameter perturbation, power flow calculation, and sample storage during the generation of each training sample. Sample storage is used to store training samples. The more nodes there are, the greater the proportion of parameter perturbation and sample storage compared to power flow calculation.
9. The method according to claim 8, characterized in that, The method further includes: Determine the generation rate of training samples; If the generation speed is less than the preset speed, the parameter perturbation and the preset number of processes in the sample storage are allocated to the power flow calculation to improve the generation speed of the next training sample.
10. The method of claim 8, wherein, The parameter perturbation process is allocated by the parameter perturbation process pool, the power flow calculation process is allocated by the power flow calculation process pool, the sample storage process is allocated by the sample storage process pool, and the power flow calculation process pool is an independent central processing unit (CPU) core process pool. The process of generating each training sample includes configuring a corresponding number of processes for parameter perturbation, power flow calculation, and sample storage, including: During the generation of each training sample, the process with the maximum number of processes obtained from the parameter perturbation process pool is assigned to the parameter perturbation, the process with the maximum number of processes obtained from the power flow calculation process pool is assigned to the power flow calculation, and the process with the maximum number of processes obtained from the sample storage process pool is assigned to the sample storage.
11. The method of claim 10, wherein, The method further includes: Get the current CPU usage and memory usage; The maximum number of processes in the parameter disturbance process pool, the power flow calculation process pool, and the sample storage process pool is adjusted based on the CPU utilization and memory usage, wherein the CPU utilization and memory usage are negatively correlated with the maximum number of processes.
12. The method according to any one of claims 1 to 11, characterized in that, The number of disturbance samples is multiple; the power flow calculation algorithm is used to perform power flow calculation on the disturbance samples to obtain the power flow calculation results, including: A power flow calculation algorithm was used to perform power flow calculations for each disturbance example, resulting in multiple power flow calculation results. The method further includes: The number of convergent results and the number of non-convergent results are determined from the multiple power flow calculation results; The convergence rate of the multiple power flow calculation results is calculated based on the number of converged results and the number of non-converged results; When the convergence rate is greater than the preset rate value, it is determined that the multiple power flow calculation results have reached the sample generation termination condition; When the convergence rate is less than or equal to a preset rate value, it is determined that the multiple power flow calculation results have not met the sample generation termination condition.
13. A device for generating training samples based on a power flow calculation model, characterized in that, The device includes: The acquisition module is used to acquire basic samples, which include the power grid structure and its operating conditions. The disturbance module is used to randomly disturb the parameters of the indicators in the operating conditions, and to disturb the parameters of the linkage indicators of the indicators in the operating conditions accordingly, and to determine the power grid structure and the disturbed operating conditions as disturbance examples. The calculation module is used to perform power flow calculation on the disturbance sample using a power flow calculation algorithm to obtain the power flow calculation results; The generation module is used to determine the voltage and power of all nodes in the disturbance sample and the power of all nodes in the power flow calculation result as training samples for the power flow calculation model when the power flow calculation result reaches the sample generation termination condition. The generation module is also used to perform optimal power flow calculation using the basic sample and the power grid optimization objective when the power flow calculation result does not meet the sample generation termination condition, to obtain the optimal operating conditions of the power grid structure, and to determine the power grid structure and the optimal operating conditions as a new basic sample, so as to generate power flow calculation results based on the new basic sample, until the generated power flow calculation result meets the sample generation termination condition.
14. A computer device comprising a memory, a processor, and a computer program stored on the memory, wherein the computer program comprises instructions that, when executed by the processor, cause the processor to perform the method of any one of claims 1-13. The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 12.
15. A computer readable storage medium having stored thereon 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 12.
16. 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 12.