A neural network-based secondary frequency control method and device and storage medium

By employing a neural network-based secondary frequency control method, and utilizing privacy-preserving training and differential privacy processing, the risks of privacy leakage and security vulnerabilities in traditional methods are resolved, thereby improving the frequency stability and security of distributed microgrids.

CN122159273APending Publication Date: 2026-06-05DONGHUA UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
DONGHUA UNIV
Filing Date
2026-04-16
Publication Date
2026-06-05

AI Technical Summary

Technical Problem

Traditional secondary frequency control methods for distributed microgrids pose serious risks of privacy breaches and security vulnerabilities. Attackers can intercept plaintext operating data to steal microgrid information and launch fake data injection attacks, leading to frequency fluctuations and power imbalances, which threaten system stability.

Method used

A secondary frequency control method based on neural networks is adopted. By training the active power data of distributed generation units with privacy protection, the neural network is used to establish a mapping relationship of frequency compensation. Combined with differential privacy protection processing, attackers are prevented from inferring the usage of samples, thereby improving the security and stability of the system.

Benefits of technology

It effectively prevents privacy leaks, improves frequency compensation speed and stability, reduces frequency deviation, prevents frequency spikes and power backflow, and enhances the dynamic response performance and security of microgrids.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122159273A_ABST
    Figure CN122159273A_ABST
Patent Text Reader

Abstract

The application discloses a kind of secondary frequency control method, device and storage medium based on neural network, belong to microgrid control technical field, method includes: obtaining the rated angular frequency of distributed microgrid preset, and the active power of each distributed power generation unit;Active power is respectively input into the corresponding pre-trained neural network, and the frequency compensation of each distributed power generation unit is output, the frequency deviation caused by droop control is compensated, so that the angular frequency of distributed microgrid output recovers to the rated angular frequency preset;Corresponding pre-trained neural network refers to the neural network that each distributed power generation unit corresponds one training process and is added privacy protection processing, so that attacker cannot infer whether single sample is used for the training of neural network according to neural network output result.The application can improve the security and stability of microgrid, solve the problem that traditional secondary frequency control method exists privacy leakage risk and security risk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of microgrid control technology, specifically relating to a secondary frequency control method, device, and storage medium based on neural networks. Background Technology

[0002] Secondary frequency control in distributed microgrids is crucial for maintaining the stability and power balance of the distribution network system. Currently, most mainstream distributed cooperative control methods are based on consensus algorithms, relying on the continuous exchange of state information among generation units to restore the frequency. However, this traditional secondary frequency control method suffers from serious privacy risks and security vulnerabilities.

[0003] Distributed generation units typically coordinate their control using plaintext transmission. During operation, these units need to exchange real-time operational data. If this plaintext data is intercepted by an attacker, they can directly probe the actual operating status of each unit and even analyze and map the microgrid's communication topology, providing a data foundation for subsequent targeted attacks.

[0004] Traditional distributed collaborative control methods heavily rely on the accuracy and real-time nature of communication information, making it difficult to maintain the security and stability of distributed microgrids under abnormal operating conditions such as communication interference or data tampering. On the one hand, control commands generated iteratively based on erroneous information are insufficient to effectively suppress large frequency fluctuations; on the other hand, these commands, detached from physical reality, may disrupt local power balance when applied to the microgrid, leading to power backflow and threatening the safe operation of the microgrid. In power systems, power is pre-programmed to flow out from the generation end. Power backflow refers to the actual power flow direction being opposite to the pre-programmed normal direction.

[0005] More seriously, attackers can use long-term collected real-world operational data to train highly accurate proxy models that completely simulate the operating logic and control responses of the target distributed microgrid. Based on these proxy models, attackers can launch fake data injection attacks: the fake data constructed by the proxy model is realistic data that conforms to the operating rules of the distributed microgrid, sufficient to bypass traditional residual-based fake data detection mechanisms. By injecting this realistic fake data, attackers can mislead the controller to make incorrect decisions, such as inducing imbalances in the output of distributed generation units, ultimately causing the entire distributed microgrid system to operate on a fabricated illusion rather than in a true physical state, seriously threatening the security and stability of the microgrid. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of the prior art and provide a secondary frequency control method, device and storage medium based on neural networks, so as to solve the problem of serious privacy leakage risk and security risks in traditional secondary frequency control methods.

[0007] To solve the above-mentioned technical problems, the present invention is implemented using the following technical solution:

[0008] In a first aspect, the present invention provides a secondary frequency control method based on a neural network for a distributed microgrid, comprising: obtaining a preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid; inputting the active power of each distributed generation unit into a corresponding pre-trained neural network, outputting the frequency compensation amount of each distributed generation unit to compensate for the frequency deviation caused by droop control, so that the angular frequency output by the distributed microgrid is restored to the preset rated angular frequency; wherein the corresponding pre-trained neural network refers to a neural network for each distributed generation unit that has privacy protection processing added during the training process, wherein the privacy protection processing includes: performing gradient clipping and noise addition on the gradients of each parameter of each sample in sequence.

[0009] The aforementioned neural network-based quadratic frequency control method, where each neural network consists of an input layer, multiple hidden layers, and an output layer connected sequentially; Training the neural network of the distributed generation unit includes: collecting data from the first distributed generation unit. The active power data of each distributed generation unit and its corresponding ideal frequency compensation data are preprocessed to obtain a training set. The following process is iteratively executed until a preset stopping condition is met to obtain a pre-trained neural network: a batch of samples is randomly selected from the training set, each sample including the first... The active power of each distributed generation unit and its corresponding ideal frequency compensation are calculated. The active power samples of the entire batch are input into the neural network from the input layer, processed by the hidden layer, and then output as predicted frequency compensation values ​​for each sample through the output layer. The loss function for each sample is calculated based on its predicted and ideal frequency compensation values. The parameter gradients for each sample are calculated based on their loss functions. Differential privacy protection processing is applied to the parameter gradients of each sample, including gradient clipping and noise addition. The batch average gradient of each parameter is calculated based on the differential privacy protection processing. The batch average gradient of each layer's parameters is input into the Adam optimizer for parameter updates. The parameters include the weight matrices and bias vectors of each layer in the hidden and output layers.

[0010] The aforementioned neural network-based quadratic frequency control method, wherein the acquisition of the first... The active power data of the first distributed generation unit and its corresponding ideal frequency compensation data, after preprocessing, yield a training set, including: based on a pre-built distributed microgrid, for the first... Each distributed generation unit collects multiple sets of data in the simulation platform. The data includes active power and its corresponding ideal frequency compensation under three operating conditions: load step change, random power fluctuation, and islanding switching. Each power data point and its corresponding ideal frequency compensation constitute a set of data. Load step change is used to simulate load abrupt changes in the distributed microgrid; random power fluctuation is used to simulate the output changes of each distributed generation unit; and islanding switching is used to simulate the transition process between grid-connected and off-grid modes of the distributed microgrid. The collected power data and its corresponding ideal frequency compensation are normalized and scaled to the [-1,1] interval to form the training set for neural network training.

[0011] The aforementioned neural network-based quadratic frequency control method predetermines privacy protection objectives before iteratively executing neural network training, including: defining the maximum allowable privacy leakage throughout the training process and setting a total privacy budget. and failure probability Preset maximum number of iterations , clipping threshold Batch size and noise scale of the current iteration round The batch size of the current training epoch determines the sampling rate of the current training epoch. , Sampling rate, The batch size represents the total number of samples in a batch. This represents the total number of samples in the dataset.

[0012] The aforementioned neural network-based quadratic frequency control method, wherein the gradient clipping includes:

[0013] The weight gradients and bias gradients of each sample in the current training epoch are clipped. The first DG The first sample The formula for calculating the layer weight gradient for clipping is:

[0014] ,

[0015] In the formula, For the cropped first The first DG The first sample Layer weight gradient, For the first The first DG Loss function for each sample For the first The first DG The first sample Layer weight matrix; For the first The first DG The first sample Layer weight gradient; The operation is to output the minimum value; For L2 norm operations;

[0016] For the first The first DG The first sample The formula for calculating the clipping based on the layer bias gradient is:

[0017] ,

[0018] In the formula, For the cropped first The first DG The first sample Layer bias gradient, For the first The first DG The first sample Layer bias vector; For the first The first DG The first sample Layer bias gradient;

[0019] The noise addition includes:

[0020] Calculate the average gradient of the batch after trimming:

[0021] After cutting The first DG The first batch Layer average weight gradient The calculation formula is:

[0022] ,

[0023] After cutting The first DG The first batch Layer average bias gradient The calculation formula is:

[0024] ,

[0025] After cutting The first DG The first batch Add Gaussian noise to the layer average weight gradient:

[0026] ,

[0027] In the formula, To add Gaussian noise to the first The first DG The first batch Layer average weight gradient; It is the identity matrix; With a mean of zero and a variance of , Gaussian noise; For noise scale;

[0028] After cutting The first DG The first batch Add Gaussian noise to the layer average bias gradient:

[0029] ,

[0030] In the formula, To add Gaussian noise to the first The first DG The first batch Layer average bias gradient.

[0031] The aforementioned neural network-based quadratic frequency control method, which performs differential privacy protection processing on the gradients of each parameter for each sample, further includes: using an RDP accountant to calculate the privacy budget accumulated up to the current iteration round. ; Calculate the actual remaining privacy budget , Use the sampling rate of the current iteration round. Noise scale of the current iteration round and the expected number of remaining iterations The formula for calculating the expected remaining privacy consumption is as follows: In the formula, To estimate the remaining privacy consumption; The sampling rate for the current iteration round. , This represents the batch size for the current iteration. The noise scale for the current iteration round; the privacy consumption for the estimated remaining iterations. With remaining privacy budget In comparison, when Greater than In this case, adjust the privacy consumption for the next iteration: increase the noise scale for the next iteration. Alternatively, reduce the sampling rate in the next iteration. ; or, terminate the iteration, including: if there is an actual remaining privacy budget When the privacy cost is less than that of one round, the iteration ends. The privacy cost of one round is calculated by the RDP accountant as the accumulated privacy budget consumed up to the current iteration round. Subtract the privacy budget accumulated up to the previous iteration round get.

[0032] The aforementioned neural network-based secondary frequency control method, when the topology of the distributed microgrid changes, re-collects data on the simulation platform to construct training sets for each distributed generation unit based on the new distributed microgrid topology, and trains the neural networks corresponding to each distributed generation unit to obtain the trained neural networks under the new distributed microgrid topology; the topology change includes communication topology change and / or structural topology change.

[0033] The aforementioned neural network-based secondary frequency control method needs to receive a start signal before obtaining the preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid. The start signal is the upper-level distribution network instability signal.

[0034] The process of determining that the upper-level distribution network is unstable includes: when the angular frequency change rate of the output voltage of the upper-level distribution network exceeds a preset frequency change rate threshold, or when a network attack is detected, the upper-level distribution network is unstable; the angular frequency change rate of the output voltage of the upper-level distribution network refers to the difference in angular frequency of the output voltage of the upper-level distribution network between adjacent sampling intervals.

[0035] Secondly, the present invention provides a secondary frequency control device based on a neural network, which uses the secondary frequency control method based on a neural network described in the first aspect for secondary frequency control, including: an acquisition module and a control module; the acquisition module is used to acquire the preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid; the control module is used to input the active power of each distributed generation unit into the corresponding pre-trained neural network, output the frequency compensation amount of each distributed generation unit, compensate for the frequency deviation caused by droop control, and restore the angular frequency output by each distributed generation unit to the preset rated angular frequency.

[0036] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect.

[0037] Compared with the prior art, the beneficial effects achieved by the present invention are as follows:

[0038] The present invention provides a neural network-based secondary frequency control method that inputs the active power of each distributed generation unit into a corresponding pre-trained neural network and outputs the frequency compensation amount of each distributed generation unit to compensate for the frequency deviation caused by droop control. By adding privacy protection processing during the training process of the neural network, attackers cannot infer whether a single sample was used for neural network training based on the output results of the neural network, thereby improving the security and stability of the microgrid and solving the problem of serious privacy leakage risks and security vulnerabilities in traditional secondary frequency control methods.

[0039] The neural network-based secondary frequency control method of this invention utilizes the powerful nonlinear fitting capability of neural networks to learn the dynamic operation logic of distributed microgrids online, establishes a high-precision mapping relationship between active power and frequency compensation, and outputs the frequency compensation to compensate for the frequency deviation caused by droop control, thereby reducing the deviation between the output angular frequency and the rated angular frequency of the distributed microgrid and improving the dynamic response performance.

[0040] The present invention's neural network-based secondary frequency control method introduces differential privacy protection processing during neural network training. By pruning the parameter gradient, it controls the maximum impact threshold of a single sample data on neural network parameter updates; and adds controllable random noise to the parameter gradient to obscure the specific contribution of a single sample to the neural network parameter updates. Simultaneously, it manages privacy consumption during the iteration process using an RDP accountant to prevent the added noise from being offset by cumulative effects during long-term training, thus avoiding accidental privacy leakage. Ultimately, this prevents attackers from accurately determining whether a specific sample has been used for neural network training, thus preventing the leakage of the original operating state.

[0041] The neural network-based secondary frequency control method of this invention further proposes to determine whether to use the method based on the stability of the upstream distribution network. This allows the distribution network system to switch to the neural network-based secondary frequency control method when subjected to network attacks or large disturbances, discarding malicious or faulty data and instead utilizing a pre-trained neural network to directly output the corresponding frequency compensation amount based on the locally measured active power of each distributed generation unit. This neural network-based secondary frequency control method avoids malicious data interference or potential unreliability in communication links under abnormal operating conditions, thus preventing frequency spikes and power backflow phenomena, and improving the speed and stability of frequency compensation. Attached Figure Description

[0042] Figure 1 This is a schematic diagram of the circuit structure topology of a distributed microgrid according to Embodiment 1 of the present invention;

[0043] Figure 2This is a flowchart illustrating the neural network-based secondary frequency control method of Embodiment 1 of the present invention.

[0044] Figure 3 This is a schematic diagram comparing the frequency changes of the DG1 in Embodiment 1 of the present invention under dynamic load conditions using a neural network-based secondary frequency control method and a traditional distributed cooperative control method.

[0045] Figure 4 This is a schematic diagram comparing the frequency changes of the DG4 in Embodiment 1 of the present invention using a neural network-based secondary frequency control method and a traditional distributed cooperative control method under dynamic load conditions.

[0046] Figure 5 This is a schematic diagram comparing the frequency changes of the DG2 in Embodiment 1 of the present invention under network attack conditions using a neural network-based secondary frequency control method and a traditional distributed cooperative control method.

[0047] Figure 6 This is a schematic diagram comparing the frequency changes of the DG3 in Embodiment 1 of the present invention using a neural network-based secondary frequency control method and a traditional distributed cooperative control method under network attack conditions.

[0048] Figure 7 This is a schematic diagram showing the active power changes of the four DGs in Embodiment 1 of the present invention under network attack conditions using a traditional distributed cooperative control method.

[0049] Figure 8 This is a schematic diagram showing the active power change of the four DGs in Embodiment 1 of the present invention under network attack conditions using a secondary frequency control method based on a neural network. Detailed Implementation

[0050] The technical solution of the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments and specific features in the embodiments are detailed descriptions of the technical solution of the present application, rather than limitations thereof. In the absence of conflict, the embodiments and technical features in the embodiments can be combined with each other.

[0051] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.

[0052] The present invention will be further illustrated below with reference to the accompanying drawings and specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. After reading this invention, any modifications of the invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.

[0053] Example 1:

[0054] The neural network-based secondary frequency control method in this embodiment performs secondary frequency control based on the local primary frequency control. For example... Figure 2 As shown, a secondary frequency control method based on neural networks for distributed microgrids includes:

[0055] Obtain the preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid;

[0056] The active power of each distributed generation unit is input into the corresponding pre-trained neural network, and the frequency compensation amount of each distributed generation unit is output to compensate for the frequency deviation caused by droop control, so that the angular frequency output by the distributed microgrid is restored to the preset rated angular frequency.

[0057] The corresponding pre-trained neural network refers to a neural network for each distributed generation unit that incorporates privacy protection processing during the training process. This privacy protection processing limits the upper limit of each sample's contribution and obscures the specific impact of each sample, making it impossible for attackers to infer whether a single sample was used for training the neural network based on the output of the completed neural network.

[0058] by Figure 1 Based on the microgrid circuit topology shown, this paper illustrates the process of achieving autonomous power allocation and voltage frequency regulation without interconnection communication by adopting a droop control strategy in local primary control:

[0059] Figure 1The diagram shows the circuit topology of a distributed microgrid, including: distributed generation units, inverter circuits, LC filters, line impedance, a common bus, local static loads, and common dynamic loads. Each distributed generation unit is sequentially connected to the inverter circuit, LC filter, local static load connection point, and line impedance, forming a distributed generation branch. Multiple distributed generation branches are connected in parallel to the common bus. The common bus also has common dynamic loads connected in parallel. These common dynamic loads are loads connected to the common bus and are powered collaboratively by all distributed generation units. The dynamic changes of these common dynamic loads are the main disturbance to the microgrid system. The local static load connection point is connected to the local static load of the corresponding distributed generation unit. The output of the LC filter is the voltage and current measurement point for droop control of each distributed branch. The common bus is connected to the upper-level distribution network through a common circuit breaker.

[0060] The process of the droop control strategy includes:

[0061] The voltage and current signals sampled from the voltage and current measurement points of each distributed generation branch are sent to the digital controller. The droop control algorithm module in the digital controller receives the voltage and current signals, performs coordinate transformation and power calculation, and obtains the total active and reactive power output of each distributed generation unit. Based on the active and reactive power, a voltage amplitude and frequency reference signal is generated through the droop characteristic equation. The voltage amplitude and frequency reference signal are processed by a dual closed-loop control algorithm of voltage outer loop and current inner loop to calculate the required PWM duty cycle. The PWM generator generates a logic signal according to the calculated required PWM duty cycle, which is amplified by the gate drive circuit of the inverter circuit and directly drives the gate of the power switching device in the inverter circuit. The operation of the power switching device in the inverter circuit converts the DC input of the distributed generation unit into a high-frequency PWM voltage. After the switching frequency and its harmonic components are filtered out by the LC filter, a sinusoidal AC voltage with the fundamental component consistent with the voltage reference signal is generated at the output of the LC filter. The voltage reference signal refers to the sinusoidal AC signal synthesized by the voltage amplitude and frequency reference signal generated by the droop characteristic equation. The consistency here refers to consistency in voltage amplitude, frequency / phase, and waveform. The voltage phase can be obtained by integrating the angular frequency over time. The digital controller and the PWM generator are built into the same chip; the PWM generator is a hardware peripheral module of the digital controller.

[0062] No. The droop characteristic equation for a distributed generation unit is:

[0063] ,

[0064] In the formula, For the first The angular frequency of the output voltage of each distributed generation unit; The rated angular frequency is the no-load angular frequency at which the microgrid system is expected to operate. The standard value for the power grid is 314.16 rad / s, corresponding to the rated frequency. 50Hz; It is the preset number The active power-frequency droop coefficient of a distributed generation unit is the frequency change caused by a unit power change. Indicates the first The measured active power of a distributed generation unit is the active power measured and calculated from the output of the LC filter of the distributed generation unit. For the first The active power setpoint of the distributed generation unit is the first... The active power reference value for each distributed generation unit, in this embodiment... =0; For the first Reference value for the amplitude of the output voltage of each distributed generation unit; The rated voltage amplitude is the no-load voltage amplitude that the microgrid system is expected to operate at. It is the preset number The reactive power-voltage droop factor of a distributed generation unit is the voltage change caused by a unit change in reactive power. Indicates the first The measured reactive power of a distributed generation unit is the reactive power measured and calculated from the output of the LC filter of the distributed generation unit. For the first In this embodiment, the reactive power setpoint of each distributed generation unit is... =0;

[0065] Ultimately, droop control enables each distributed generation branch to make independent decisions and autonomously achieve the goal of proportionally sharing the total load of the common bus, even without interconnection communication. The total load of the common bus includes the common dynamic load and each branch's local static load. However, this can cause the microgrid system's frequency and voltage to deviate from their rated values, requiring secondary control for restoration. Secondary control includes secondary frequency control and secondary voltage control. This embodiment introduces a secondary frequency control method based on neural networks.

[0066] The goal of independently achieving proportional sharing of the total load on the common busbar refers to:

[0067] When the droop factor of each distributed generation unit (DG) is designed inversely to its rated capacity and the reactive and active power setpoints of each DG are set at the same capacity utilization rate, the load variation and total output power undertaken by each DG are directly proportional to its rated capacity. In a specific embodiment, the active power droop factor ratio of the four DGs is 1:2:1:2, which indicates that their rated capacity ratio is 2:1:2:1, and the load allocation ratio and output power ratio are also 2:1:2:1, thereby achieving capacity-based load sharing.

[0068] This embodiment of neural network-based secondary frequency control employs distributed communication. Each DG only exchanges information with its neighboring DGs. The secondary frequency control method outputs an appropriate frequency compensation amount to eliminate steady-state frequency deviation, restoring the output frequency of all DGs to their rated angular frequency. After secondary frequency control, the... The droop control equations for a distributed generation unit are transformed into:

[0069] ,

[0070] In the formula, For the first Angular frequency compensation of each distributed generation unit;

[0071] This embodiment is based on a secondary control method using neural networks, such as... Figure 1 As shown, the distributed microgrid in this embodiment includes four distributed generation units DG1, DG2, DG3, and DG4. These four distributed generation units employ the following... Figure 1 The dashed lines indicate a chain-like communication topology, where each DG controller transmits status information sequentially and unidirectionally: DG1 communicates with DG2, DG2 communicates with DG3, and DG3 communicates with DG4. Each distributed generation unit is configured with a dedicated neural network. , , and Each neural network employs a unified basic architecture, but the weight parameters of each neural network are independently optimized during training to adapt to the dynamic characteristics of each distributed generation unit. The objective of secondary frequency control is to compensate for the frequency deviation caused by droop control through frequency compensation, thereby improving the safety and stability of the microgrid.

[0072] The structure of each neural network includes an input layer, multiple hidden layers, and an output layer connected in sequence:

[0073] Input layer: Receives a real-time operating state vector with dimension 1. In this embodiment, the real-time operating state vector refers to the active power of the DG.

[0074] Hidden layers: In this embodiment, there are three fully connected hidden layers, each containing 128 neurons. The activation function used is ReLU, which is used to extract non-linear features and enhance the model's expressive power.

[0075] Output layer (layer 5): Single neuron output. In this embodiment, the output of the output layer refers to the frequency compensation amount of the DG.

[0076] A neural network is a non-linear mapping function from input to output;

[0077] No. Layer forward propagation formula:

[0078] For the Neural network of a distributed generation unit (DG):

[0079] Weighted input calculation: ,

[0080] In the formula, For the first The first DG The weighted input vector of the layer; For the first The first DG The weight matrix of the layer, with size ; For the first The first DG The activation output vector of the layer; For the first The first DG Layer bias vector;

[0081] Activate output calculation: ,

[0082] In the formula, For the first Activation function of the layer;

[0083] Specific parameters for each layer:

[0084] Input layer: Input normalized active power: , For the first The active power of each DG, dimension =1;

[0085] First hidden layer ( ): Weight matrix Size is Bias vector Size is The activation function is ReLU. ;

[0086] Second hidden layer ( ): Weight matrix Size is Bias vector Size is The activation function is ReLU. ;

[0087] Third hidden layer ( ): Weight matrix Size is Bias vector Size is The activation function is ReLU. ;

[0088] Output layer ( ): Weight matrix Size is Bias vector Size is The activation function is ReLU. ;

[0089] The first embodiment The overall neural network mapping function for each DG is: ,

[0090] In the formula, For the first Frequency compensation amount of each DG; For the first A neural network for a DG; For the first The set of all parameters of a DG neural network. ;

[0091] ,

[0092] In the formula, For the first Angular frequency compensation of each distributed generation unit;

[0093] The neural network training process in this embodiment is as follows:

[0094] S1: Data Acquisition and Preprocessing: Based on the pre-constructed distributed microgrid in this embodiment, 40,000 sets of data are collected in the simulation platform for each distributed generation unit. The data includes active power and its corresponding ideal frequency compensation under three typical operating conditions: load step change, random power fluctuation, and islanding switching. One set of data consists of a power data and its corresponding ideal frequency compensation. Load step change is used to simulate the load change of the distributed microgrid, random power fluctuation is used to simulate the output change of each distributed generation unit, and islanding switching is used to simulate the conversion process of the distributed microgrid between grid-connected mode and off-grid mode. The collected power data and its corresponding ideal frequency compensation data are normalized and scaled to the [-1,1] interval to form the training set and test set for neural network training.

[0095] From the The training set of the neural network of each distributed generation unit is randomly sampled from a batch of samples for training:

[0096] Each sample includes the first The active power and corresponding ideal frequency compensation of each distributed generation unit; A batch of sample sets Represented as: ,

[0097] In the formula, The batch size represents the total number of samples in a batch. For batch number, ; For the first The first distributed generation unit One sample; For the first The first DG The active power of each sample; For the first The first DG The ideal frequency compensation for each sample is the target output;

[0098] The weight matrix and bias vector of each neural network are initialized separately. The weight matrix is ​​initialized using Xavier, and the bias vector is initialized with zero.

[0099] S2: Input the active power samples of the entire batch into the first... The neural network of each distributed generation unit performs forward propagation, and outputs the predicted frequency compensation amount for each sample:

[0100] For the first The neural network of the first DG Each sample in each batch undergoes steps S21 to S23:

[0101] S21: Input layer processing: Normalized active power input ; For the first The first DG The active power of each sample;

[0102] S22: Hidden layer calculation:

[0103] For the layer:

[0104] No. The first sample Layer weighted input The calculation formula is: ,

[0105] In the formula, For the first The first DG The first sample Layer output;

[0106] After nonlinear activation by the ReLU function, the... The first DG The first sample The formula for calculating the layer's output is: ,

[0107] S23: Output layer calculation:

[0108] No. The formula for calculating the weighted input of each sample output layer is: ,

[0109] After nonlinear activation by the ReLU function, the... The first DG Output of each sample output layer The calculation formula is: ,

[0110] In the formula, It is the first The neural network of the first DG is paired with the first The predicted frequency compensation amount for each sample.

[0111] S3: Calculate the loss function for each sample based on the predicted frequency compensation and the ideal frequency compensation.

[0112] No. The first DG Loss function for each sample The calculation formula is: ,

[0113] In the formula, It is the first The neural network of the first DG is paired with the first The predicted frequency compensation amount for each sample. For the first The first DG The ideal frequency compensation for each sample is the ideal frequency compensation after normalization.

[0114] S4: Based on the loss function for each sample, calculate the gradient of each parameter for each sample:

[0115] S41: Output layer error calculation;

[0116] First, we need to calculate the gradient of the loss function with respect to the output of the output layer. This gradient is the partial derivative of the loss function with respect to the output of the output layer. The product of this gradient and the derivative of the activation function is the error term of the output layer.

[0117] For the output layer ( ):

[0118] No. The first DG The gradient of the loss function for each sample with respect to the output layer:

[0119] ,

[0120] In the formula, For the first The first DG The output of each sample output layer;

[0121] No. The first DG Error per sample output layer:

[0122] ;

[0123] S42: Backpropagation of hidden layer errors;

[0124] The error signal propagates backward along the network, and the error terms of each hidden layer are calculated sequentially from the third hidden layer to the first hidden layer. The error of each hidden layer is obtained by multiplying the error of the next layer by the transpose of the corresponding weight matrix, and then multiplying the result element-wise by the derivative of the activation function of the current layer.

[0125] for , No. The first DG The first sample Hidden layer error The calculation formula is:

[0126] ,

[0127] In the formula, For the first The first DG Layer weight matrix Transpose of; For the first The first DG The first sample Layer error; This is an element-wise multiplication operation; For the first The first DG The first sample Hidden layer activation function in The derivative at point; ;

[0128] S43: Calculation of parameter gradient;

[0129] S431: Weight gradient calculation:

[0130] The weight gradient is calculated from the error of the current layer and the output of the previous layer. The first DG The first sample Layer weight gradient The calculation formula is:

[0131] ,

[0132] In the formula, For the first The first DG The first sample Layer error; For the first The first DG The first sample The layer's output; T represents the transpose operation; Size is ; Size is ; Size is ;

[0133] S432: Bias gradient calculation;

[0134] The bias gradient is obtained by summing the errors of the current layer column-wise, that is, summing over each neuron, the i-th... The first DG The first sample Layer bias gradient The calculation formula is:

[0135] ,

[0136] In the formula, For the first The first DG The first sample The layer errors are summed column by column;

[0137] S433: Calculate the batch average gradient;

[0138] No. The first DG The first batch Layer average weight gradient The calculation formula is:

[0139] ,

[0140] No. The first DG The first batch Layer average bias gradient The calculation formula is:

[0141] .

[0142] S5: Adam optimizer parameter update:

[0143] No. The next iteration calculation steps:

[0144] After calculating the average weight gradient and the average bias gradient, perform the following steps:

[0145] First-order moment estimation:

[0146] , For the first First-moment estimation of the layer-average weighted gradient; The pre-defined first moment is used to estimate the exponential decay rate, which is used to control the decay rate of the momentum term.

[0147] , For the first First-moment estimate of the layer-averaged bias gradient; the first-moment estimate is the momentum term.

[0148] Second-order moment estimation:

[0149] , For the first Second-moment estimation of the layer-average weight gradient; The pre-defined exponential decay rate of the second moment is used to control the decay rate of the adaptive learning rate.

[0150] , For the first Second-moment estimation of layer-average bias gradient;

[0151] The squaring operation in the formula is element-wise squaring; the second-order moment estimation is used to calculate the adaptive learning rate;

[0152] Bias correction:

[0153] , , , ,

[0154] Parameter update:

[0155] ,

[0156] ,

[0157] In the formula, The preset learning rate is used to control the step size of parameter updates; This is a preset numerical stability term used to prevent the denominator from being zero;

[0158] Steps S2 to S5 complete one training iteration of the neural network.

[0159] After calculating the weight gradient and bias gradient of each sample in steps S431 and S432, the process further includes: introducing differential privacy protection processing in each training process, so that privacy protection is no longer an additional security module after training, but a step built into the training process, which directly affects gradient calculation and parameter update. This ensures that while training the neural network using local running data, the maximum impact threshold of a single sample data on the neural network parameter update is controlled, the specific contribution of a single sample to the neural network parameter update is blurred, and privacy consumption is statistically analyzed, so that attackers cannot accurately determine whether a specific sample has been used for neural network training.

[0160] In each training iteration, differential privacy protection is introduced in the gradient calculation of step S4 and the parameter update step S5 of the local neural network of each distributed generation unit. The specific implementation process is as follows:

[0161] Y0: Before iteratively executing steps S2 to S5 for neural network training, the privacy protection objective is determined in advance;

[0162] Y1: After calculating the weight gradient and bias gradient of each sample in steps S431 and S432, each gradient is clipped.

[0163] Y2: Average the clipped gradient and add Gaussian noise;

[0164] Y3: Privacy Accounting Calculations;

[0165] Y4: Use the average gradient from step Y2 with added Gaussian noise to update the Adam optimizer parameters in step S5;

[0166] Step Y0 specifically includes:

[0167] Y01: Defines the maximum privacy leakage allowed throughout the entire training process, including the setting of two parameters:

[0168] Total privacy budget This measures the strength of privacy protection; the smaller the value, the more private the privacy. In this embodiment, the preset total privacy budget is 2.

[0169] failure probability This indicates that privacy protection may fail in very rare cases, but the risk is extremely low. In this embodiment, the preset failure probability is 0.00001.

[0170] Y02: Preset maximum number of iterations , clipping threshold Batch size and noise scale of the current iteration round The batch size of the current training epoch determines the sampling rate of the current training epoch. , Sampling rate, The batch size represents the total number of samples in a batch. The total number of samples in the training set; in this embodiment, For 40,000, The noise scale is 1.0 for the initial training rounds. , It is 256;

[0171] Step Y1 specifically includes:

[0172] The weight gradients and bias gradients of each sample in the current training epoch are clipped. The first DG The first sample The formula for calculating the layer weight gradient for clipping is:

[0173] ,

[0174] In the formula, For the cropped first The first DG The first sample Layer weight gradient; For the first The first DG The first sample Layer weight gradient; For L2 norm operations;

[0175] For the first The first DG The first sample The formula for calculating the clipping based on the layer bias gradient is:

[0176] ,

[0177] In the formula, For the cropped first The first DG The first sample Layer bias gradient; For the first The first DG The first sample Layer bias gradient;

[0178] Gradient clipping in step Y1 ensures the gradient... The norm does not exceed the preset clipping threshold. When the norm of the gradient vector is less than or equal to When the gradient is constant, it remains unchanged; when it is greater than 100°C, the gradient remains constant. When the gradient is scaled proportionally to a length of [length value], the gradient will be scaled proportionally to [length value]. This effectively controls the impact of individual samples on the overall model and limits the maximum contribution of individual samples to parameter updates.

[0179] Step Y2 specifically includes:

[0180] Y21: Calculate the average gradient of the batch after trimming;

[0181] After cutting The first DG The first batch Layer average weight gradient The calculation formula is:

[0182] ,

[0183] After cutting The first DG The first batch Layer average bias gradient The calculation formula is:

[0184] ,

[0185] Y22: Add Gaussian noise;

[0186] After cutting The first DG The first batch Add Gaussian noise to the layer average weight gradient:

[0187] ,

[0188] In the formula, To add Gaussian noise to the first The first DG The first batch Layer average weight gradient; It is the identity matrix; With a mean of zero and a variance of , Gaussian noise; The noise scale is used; the privacy protection strength of a single iteration is determined by the noise scale σ of the Gaussian mechanism and the gradient clipping threshold. A joint decision.

[0189] After cutting The first DG The first batch Add Gaussian noise to the layer average bias gradient:

[0190] ,

[0191] In the formula, To add Gaussian noise to the first The first DG The first batch Layer average bias gradient;

[0192] The Gaussian noise mechanism achieves differential privacy, and the noise scale determines the strength of privacy protection.

[0193] Step Y3 specifically includes:

[0194] Use the RDP accountant (Rényi Differential Privacy Accountant) to calculate the privacy budget accumulated up to the current iteration round. The privacy budget accumulated up to the current iteration round. The calculations are performed automatically by library functions.

[0195] Calculate the actual remaining privacy budget , ;

[0196] Using the sampling rate of the current iteration round Noise scale of the current iteration round and the expected number of remaining iterations Calculate the estimated remaining privacy consumption: In the formula, To estimate the remaining privacy consumption; The sampling rate for the current iteration round. , This represents the batch size for the current iteration. This represents the noise scale for the current iteration round.

[0197] Privacy consumption for the estimated remaining iterations. With remaining privacy budget In comparison, when Greater than This means that the remaining iterations are about to exceed the total privacy budget, and the privacy consumption of the next iteration needs to be adjusted:

[0198] Increase the noise scale in the next iteration round. In one specific embodiment, the noise scale of the next iteration round The noise level can be increased proportionally. ;

[0199] Alternatively, reduce the sampling rate in the next iteration. ;

[0200] Alternatively, terminate the iteration: if the remaining privacy budget is insufficient to complete one round of updates, i.e. When the privacy cost is less than that of a single iteration, the iteration ends. The privacy cost of a single iteration can be calculated by the RDP accountant as the accumulated privacy budget consumed up to the current iteration. Subtract the privacy budget accumulated up to the previous iteration round get.

[0201] Step Y4 specifically includes:

[0202] The Adam optimizer parameters in step S6 are updated using the average weight gradient and average bias gradient with Gaussian noise added in step Y2. The specific process includes:

[0203] The Gaussian noise of the first The first DG The first batch Layer average weight gradient and average bias gradient Replace the average weight gradient calculated in step S53. and average bias gradient Perform step S6 to update the Adam optimizer parameters.

[0204] The parameters are updated using the average weight gradient with added noise, allowing the neural network to learn gradually.

[0205] S6: Check the stopping condition. In this embodiment, the iteration terminates if one of the following conditions is met:

[0206] Accumulated up to the current iteration round Privacy consumption Approaching or reaching the total privacy budget ;

[0207] Alternatively, reaching the preset maximum number of iterations. ;

[0208] Alternatively, the neural network may converge.

[0209] If the stopping condition is not met, the steps S1 to S5 of adding steps Y0 to Y4 are executed repeatedly until the stopping condition is met, at which point the iteration terminates and the trained neural network is obtained.

[0210] When the topology of a distributed microgrid changes, based on the new distributed microgrid topology, data is re-collected on the simulation platform for each distributed generation unit to construct a training set for each distributed generation unit. The neural networks corresponding to each distributed generation unit are then trained to obtain the trained neural networks under the new distributed microgrid topology. The topology change includes changes in communication topology and / or structural topology.

[0211] The communication topology here refers to the communication method among the distributed generation units within a distributed microgrid. In another embodiment, such as... Figure 1 The chain communication topology shown is modified so that DG1 communicates with DG2, DG2 communicates with DG1 and DG3, and DG3 communicates with DG2 and DG4. This constitutes a change in communication topology. Here, structural topology change refers to a change in the connection of distributed generation units within the distributed microgrid. In specific embodiments, changes in the number of distributed generation units or changes in location such as DG1 becoming DG2 are all considered structural topology changes.

[0212] Traditional secondary frequency control methods are based on consensus protocols and traditional distributed cooperative control methods. Each distributed generation unit (DG) constructs a secondary frequency control law according to a preset communication topology, utilizing local information and information from its communicating neighbors. During the iteration process, each DG gradually adjusts its output frequency compensation amount through interaction with neighbor information and updates to its local information. As the number of iterations increases, the frequency compensation amounts of each DG within the distributed microgrid will converge to a common value according to the consensus protocol, thereby restoring and stabilizing the angular frequency output by the distributed microgrid to its rated angular frequency.

[0213] The neural network-based secondary frequency control method of this embodiment further includes a process of detecting the stability of the upstream distribution network and determining that the upstream distribution network is unstable, including:

[0214] When the angular frequency change rate of the output voltage of the upstream distribution network exceeds the preset frequency change rate threshold If a network attack is detected, the upstream distribution network becomes unstable; the rate of change of the angular frequency of the upstream distribution network output voltage refers to the difference in the angular frequency of the upstream distribution network output voltage between adjacent sampling intervals; in a specific embodiment, the attack detector of the distribution network alarms, i.e. This indicates that the upstream distribution network has detected a network attack.

[0215] When the upstream distribution network is stable, traditional distributed collaborative control methods are used to eliminate frequency deviations;

[0216] When the upper-level distribution network is unstable, the secondary frequency control method based on neural networks in this application is adopted. This means that before obtaining the preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid, a start signal is also required. The start signal is the upper-level distribution network instability signal.

[0217] This application presents a neural network-based secondary frequency control method aimed at improving the security and stability of microgrids. It can suppress frequency fluctuations under abnormal operating conditions and effectively prevent power backflow. When subjected to cyberattacks, traditional distributed cooperative control methods, while still relying on consensus protocols for iterative calculations, converge to an incorrect common solution based on falsified data due to attackers tampering with the actual data. Although this common solution mathematically satisfies consistency, it violates the actual physical power flow constraints of the distribution network, potentially leading to severe imbalances in local power distribution and ultimately power backflow on some lines.

[0218] In contrast, the secondary control method based on neural networks in this embodiment does not rely on real-time communication information. It only uses the local active power of each distributed generation unit to obtain the corresponding frequency compensation amount, which can prevent power backflow while achieving stable frequency recovery.

[0219] When the upper-level distribution network is stable, the distributed microgrid adopts the traditional distributed cooperative control method based on the consensus protocol. It utilizes the information interaction and iterative convergence mechanism between distributed units to achieve frequency regulation and ensure the accuracy of power compensation during the operation of the distribution network.

[0220] When the upstream distribution network becomes unstable, the system immediately switches to the neural network-based secondary frequency control method described in this application. Utilizing pre-trained neural networks, it directly outputs the corresponding frequency compensation amount based on the locally measured active power of each distributed generation unit. This neural network-based secondary frequency control method avoids malicious data interference or potential unreliability in communication links under abnormal operating conditions, thus preventing frequency spikes and power backflow, and improving the speed and stability of frequency compensation.

[0221] This strategy of switching the secondary frequency control method based on the stability of the upper-level distribution network not only ensures high performance in daily operation but also improves the security of distributed microgrids under extreme conditions.

[0222] To verify the effectiveness of the neural network-based quadratic frequency control method in this embodiment, a system was constructed as follows: Figure 1 The simulation model shown is a distributed microgrid system containing four distributed generation units (DGs). For ease of analysis, all parameters of each DG are set to be identical except for the droop coefficient. Under normal operating conditions, the output power ratio of each distributed power source is: Two simulation scenarios are set up: dynamic load and network attack.

[0223] The dynamic load condition is set as follows: the system carries a stable load for 0 to 6 seconds; from the 6th second onwards, the load begins to fluctuate until the 11th second. The dynamic load condition is used to simulate situations where the angular frequency change rate of the output voltage of the upstream distribution network caused by load fluctuations exceeds a preset frequency change rate threshold.

[0224] Simulation results are as follows Figure 3 and 4 As shown. Figure 3 and Figure 4 The figures show a comparison of frequency variations for DG1 and DG4 under dynamic load conditions using a neural network-based secondary frequency control method and a traditional distributed cooperative control method. As can be clearly seen from the figures, the frequency fluctuation amplitude under dynamic load conditions is significantly lower when using the neural network-based secondary frequency control method proposed in this application.

[0225] The network attack scenario is set as follows: no external attack occurs within the first 3 seconds; then, at t=3s, an attack is introduced into the distributed power source DG2.

[0226] Simulation results are as follows Figures 5 to 8 As shown. Among them, Figure 5 and Figure 6 The diagrams show a comparison of frequency changes in DG2 and DG3 under network attack conditions using a neural network-based secondary frequency control method and a traditional distributed cooperative control method. Figure 7 and Figure 8 The active power output of each distributed generation unit under the two control methods is then presented.

[0227] from Figure 5 As can be seen, when the network attack occurred, the frequency of DG2 using the traditional distributed cooperative control method rose sharply to 51.5Hz in a very short time, significantly exceeding the power grid's safe operating limit of 50.5Hz. Furthermore, during the frequency recovery process, as... Figure 7As shown, a negative active power output from DG1 indicates that the actual power flow is opposite to the set direction, meaning that DG1 is actually absorbing active power, and power recirculation has occurred. In contrast, as... Figure 6 As shown, DG2 employs the neural network-based secondary frequency control method of this application, and does not exhibit drastic frequency fluctuations when attacked. Furthermore, during the frequency recovery process, as... Figure 8 As shown, each distributed generation unit can still maintain stable power distribution performance, effectively improving the overall safety and stability of the distributed microgrid operation.

[0228] Example 2:

[0229] Based on the same inventive concept as Embodiment 1, this embodiment introduces a secondary frequency control device based on a neural network, which uses the secondary frequency control method based on a neural network described in Embodiment 1 to perform secondary frequency control, including: an acquisition module and a control module;

[0230] The acquisition module is used to acquire the preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid.

[0231] The control module is used to input the active power of each distributed generation unit into the corresponding pre-trained neural network, output the frequency compensation amount of each distributed generation unit, compensate for the frequency deviation caused by droop control, and restore the angular frequency output by each distributed generation unit to the preset rated angular frequency.

[0232] Example 3:

[0233] This invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in Embodiment 1.

[0234] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0235] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0236] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0237] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0238] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A secondary frequency control method based on neural networks for distributed microgrids, characterized in that, include: Obtain the preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid; The active power of each distributed generation unit is input into the corresponding pre-trained neural network, and the frequency compensation amount of each distributed generation unit is output to compensate for the frequency deviation caused by droop control, so that the angular frequency output by the distributed microgrid is restored to the preset rated angular frequency. The corresponding pre-trained neural network refers to a neural network for each distributed generation unit that incorporates privacy protection processing during the training process. The privacy protection processing includes: performing gradient clipping and noise addition on the gradients of each parameter of each sample in sequence.

2. The neural network-based secondary frequency control method according to claim 1, characterized in that, The structure of each neural network includes an input layer, multiple hidden layers, and an output layer connected in sequence. No. Training the neural network for a distributed generation unit includes: Collection of the first The active power data of each distributed generation unit and its corresponding ideal frequency compensation data are preprocessed to obtain the training set. Iteratively execute the following process until a preset stopping condition is met to obtain a pre-trained neural network: A batch of samples is randomly drawn from the training set, and each sample includes the first... The active power and corresponding ideal frequency compensation of each distributed generation unit. The active power samples of the entire batch are input into the neural network from the input layer. After being processed by the hidden layer, the predicted frequency compensation amount of each sample is output through the output layer. The loss function for each sample is calculated based on the predicted frequency compensation amount and the ideal frequency compensation amount. Calculate the parameter gradient for each sample based on the loss function of each sample. Differential privacy protection processing is performed on the gradients of each parameter for each sample, which includes gradient clipping and noise addition; The batch average gradient of each parameter is calculated based on the gradient of each parameter in each sample after differential privacy protection processing. The batch average gradient of each layer's parameters is input into the Adam optimizer for parameter updates; the parameters include the weight matrix and bias vector of each layer in the hidden and output layers.

3. The neural network-based secondary frequency control method according to claim 2, characterized in that, The collection of the first The active power data and corresponding ideal frequency compensation data of each distributed generation unit are preprocessed to obtain a training set, including: Based on pre-built distributed microgrids, for the first Each distributed generation unit collects multiple sets of data in the simulation platform. The data includes active power and its corresponding ideal frequency compensation under three operating conditions: load step change, random power fluctuation, and islanding switching. Each power data point and its corresponding ideal frequency compensation constitute a set of data. Among them, load step change is used to simulate load abrupt changes in the distributed microgrid; random power fluctuation is used to simulate the output changes of each distributed generation unit; and islanding switching is used to simulate the transition process of the distributed microgrid between grid-connected and off-grid modes. The collected power data and their corresponding ideal frequency compensation values ​​are normalized and scaled to the [-1,1] interval to form the training set for neural network training.

4. The neural network-based secondary frequency control method according to claim 2, characterized in that, Before iteratively performing neural network training, privacy protection objectives are pre-determined, including: Define the maximum privacy disclosure allowed throughout the entire training process and set the total privacy budget. and failure probability ; Preset maximum number of iterations , clipping threshold Batch size and noise scale of the current iteration round The batch size of the current training epoch determines the sampling rate of the current training epoch. , Sampling rate, The batch size represents the total number of samples in a batch. This represents the total number of samples in the dataset.

5. The neural network-based secondary frequency control method according to claim 2, characterized in that, The gradient clipping includes: The weight gradients and bias gradients of each sample in the current training epoch are clipped. The first DG The first sample The formula for calculating the layer weight gradient for clipping is: , In the formula, For the cropped first The first DG The first sample Layer weight gradient, For the first The first DG Loss function for each sample For the first The first DG The first sample Layer weight matrix; For the first The first DG The first sample Layer weight gradient; The operation is to output the minimum value; For L2 norm operations; For the first The first DG The first sample The formula for calculating the clipping based on the layer bias gradient is as follows: , In the formula, For the cropped first The first DG The first sample Layer bias gradient, For the first The first DG The first sample Layer bias vector; For the first The first DG The first sample Layer bias gradient; The noise addition includes: Calculate the average gradient of the batch after trimming: After cutting The first DG The first batch Layer average weight gradient The calculation formula is: , After cutting The first DG The first batch Layer average bias gradient The calculation formula is: , After cutting The first DG The first batch Add Gaussian noise to the layer average weight gradient: , In the formula, To add Gaussian noise to the first The first DG The first batch Layer average weight gradient; It is the identity matrix; With a mean of zero and a variance of , Gaussian noise; For noise scale; After cutting The first DG The first batch Add Gaussian noise to the layer average bias gradient: , In the formula, To add Gaussian noise to the first The first DG The first batch Layer average bias gradient.

6. The neural network-based secondary frequency control method according to claim 4, characterized in that, The differential privacy protection processing of the gradients of each parameter for each sample also includes: Use the RDP accountant to calculate the privacy budget that has been consumed up to the current iteration round. ; Calculate the actual remaining privacy budget , ; Using the sampling rate of the current iteration round Noise scale of the current iteration round and the expected number of remaining iterations The formula for calculating the expected remaining privacy consumption is as follows: In the formula, To estimate the remaining privacy consumption; The sampling rate for the current iteration round. , This represents the batch size for the current iteration. The noise scale for the current iteration round; Privacy consumption for the estimated remaining iterations. With remaining privacy budget In comparison, when Greater than Adjust the privacy consumption for the next iteration round: Increase the noise scale in the next iteration round. ; Alternatively, reduce the sampling rate in the next iteration. ; Alternatively, terminate the iteration, including: if there is an actual remaining privacy budget. When the privacy cost is less than that of one round, the iteration ends. The privacy cost of one round is calculated by the RDP accountant as the accumulated privacy budget consumed up to the current iteration round. Subtract the privacy budget accumulated up to the previous iteration round get.

7. The neural network-based quadratic frequency control method according to claim 1, characterized in that, When the topology of a distributed microgrid changes, based on the new distributed microgrid topology, data is re-collected on the simulation platform for each distributed generation unit to construct a training set for each distributed generation unit. The neural networks corresponding to each distributed generation unit are then trained to obtain the trained neural networks under the new distributed microgrid topology. The topology change includes changes in communication topology and / or structural topology.

8. The neural network-based quadratic frequency control method according to claim 1, characterized in that, Before obtaining the preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid, it is also necessary to receive a start signal, which is an unstable signal of the upper-level distribution network. The process of determining that the upper-level distribution network is unstable includes: when the angular frequency change rate of the output voltage of the upper-level distribution network exceeds a preset frequency change rate threshold, or when a network attack is detected, the upper-level distribution network is unstable. The rate of change of the angular frequency of the output voltage of the upper-level distribution network refers to the difference in the angular frequency of the output voltage of the upper-level distribution network between adjacent sampling intervals.

9. A secondary frequency control device based on a neural network, characterized in that, The method for secondary frequency control based on neural networks as described in claim 1 includes: an acquisition module and a control module; The acquisition module is used to acquire the preset rated angular frequency of the distributed microgrid and the active power of each distributed generation unit in the distributed microgrid. The control module is used to input the active power of each distributed generation unit into the corresponding pre-trained neural network, output the frequency compensation amount of each distributed generation unit, compensate for the frequency deviation caused by droop control, and restore the angular frequency output by each distributed generation unit to the preset rated angular frequency.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method of claim 1.