A FDIA detection method and device based on diffusion model

Through the FDIA detection method based on the diffusion model, combined with the U-net++ network model and discrete wavelet transform, the spatial and temporal characteristics of the smart grid are extracted, which solves the problem of poor robustness in the existing technology and achieves efficient abnormal data detection and power grid Improved security.

CN118518982BActive Publication Date: 2024-10-01JIANGXI NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410969260.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-19
Publication Date
2024-10-01
Estimated Expiration
2044-07-19

AI Technical Summary

Technical Problem

The existing FDIA anomaly data detection technology has poor robustness when dealing with abnormal data of different types and intensities, and insufficient extraction of spatial and temporal features of nodes, resulting in low detection accuracy and reliability.

Method used

The FDIA detection method based on the diffusion model is used to obtain the smart grid topology data and bus power status data, calculate the bus status matrix and tensor, and use the diffusion model and U-net++ network model to perform forward and reverse process calculations, combined with discrete wavelet The transformation extracts the energy fluctuation ratio matrix and identifies abnormal positions in the topological structure.

Benefits of technology

It improves the robustness and accuracy of FDIA detection, can effectively reduce abnormal data interference, realize real-time monitoring and positioning of smart grids, and improve the safety and stability of power grid operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118518982B_ABST
    Figure CN118518982B_ABST
Patent Text Reader

Abstract

The invention discloses an FDIA detection method and device based on a diffusion model, comprising: calculating the power of a bus according to smart grid topology data and bus power state data to obtain a bus state matrix; obtaining a bus state tensor by dividing time periods; inputting the bus state tensors of all historical time periods into a diffusion model and a U‑net++ network model for training; inputting the bus state tensor of a current time period into the diffusion model and the trained U‑net++ network model to obtain a predicted bus state tensor; performing discrete wavelet transform on the predicted bus state tensor of the current time period and the bus state tensor to obtain a loss matrix, and finding all abnormal positions in the smart grid topology according to the loss matrix; the invention effectively reduces the abnormal data interference in the smart grid through forward diffusion and reverse denoising of the diffusion model, and can realize real-time monitoring and positioning of abnormal situations in the smart grid.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of smart grid anomaly detection, and in particular to a FDIA detection method and device based on a diffusion model. Background Art

[0002] As an important part of the modern power system, the safe and stable operation of smart grid is of vital importance to social and economic development. With the continuous development of smart grid technology, the network data security threats it faces are also increasing, including false data injection attacks (FDIA). These attacks may cause abnormal operation of smart grid systems, even cause equipment damage and service interruption, seriously affecting the safety and reliability of power systems. Research on abnormal data detection of smart grid FDIA is of great significance to improving the safety of power systems. By analyzing abnormal data in smart grid systems, timely discovering and identifying attack behaviors, it is helpful to take corresponding defense measures in time to prevent the impact of attacks on power systems from further expanding, thereby ensuring the stable operation of power systems.

[0003] At present, the main FDIA abnormal data detection technologies include statistical methods, topological structure analysis methods, time series analysis methods, and machine learning methods. Among them, machine learning-based methods have been widely used. The main process is to collect data first, analyze the characteristics of abnormal data, and finally set the corresponding anomaly detection rules according to the characteristics of abnormal data. For example, the existing method uses generative adversarial networks (GANs) and gated recurrent units (GRUs) for abnormal data detection and classification. First, the original data is mapped to the latent space, then the abnormal confidence score is defined, and then the loss between the original data and the model prediction data is calculated to determine whether there is an anomaly. This method needs to be re-adjusted every time a new anomaly type appears, which is time-consuming. In addition, the effect of inverse mapping is not considered during the training process, and the interpretability of the anomaly detection confidence score is poor.

[0004] The publication number is CN114978586A, and the name is a power grid attack detection method, system and electronic device based on attack genes. It proposes to use discrete wavelet transform to obtain the corresponding target time domain attack gene, and then train the graph neural network model to obtain the probability of each first preset node being attacked, and determine whether the power grid node to be detected is attacked by judging the attack probability. This scheme improves the flexibility in frequency response by extracting the target time domain attack gene through wavelet transform, but the scheme relies on wavelet transform to extract data time domain features to train the graph neural network model. This method does not consider the spatial characteristics of the node, and the detection effect of FDIA regional attacks is insufficient.

[0005] The publication number is CN113794742A, and the name is a high-precision detection method for FDIA in power systems. It proposes to train the GRU prediction model through the network layer features in the historical data packets and the historical power detection data, and then perform FDIA detection. This scheme trains the GRU model based on a large amount of historical data, and the training and prediction process of the model requires high computing resources. At the same time, the disguised network layer features can easily cause the disguised data to be misjudged as real data by the GRU prediction model, which greatly restricts the detection accuracy of the trained GRU prediction model for FDIA. Summary of the invention

[0006] In order to solve the above technical problems, a technical solution adopted by the present invention is: to provide an FDIA detection method based on a diffusion model, the method comprising:

[0007] S10. Obtain smart grid topology data and bus power status data, and calculate the active power of the bus at all sampling moments in sequence according to the smart grid topology data and bus power status data or reactive power , get the bus state matrix at all sampling moments;

[0008] S20.According to Divide the time period, combine the bus state matrices at all sampling moments in each time period, and obtain the bus state tensors of all time periods;

[0009] S30. sequentially input the bus state tensor of all historical time periods into the diffusion model for forward process calculation to obtain a Gaussian noise tensor, an iteration tensor and an iteration number, and input the Gaussian noise tensor, the iteration tensor and the iteration number into the U-net++ network model for training;

[0010] S40. Input the bus state tensor of the current time period into the diffusion model for forward process calculation to obtain an iteration tensor, input the iteration tensor and the total number of iterations into the trained U-net++ network model to obtain a predicted Gaussian noise tensor;

[0011] S50. Input the predicted Gaussian noise tensor and the iterative tensor into the diffusion model for reverse process calculation to obtain the predicted bus state tensor for the current time period;

[0012] S60. Perform discrete wavelet transform on the predicted bus state tensor and the bus state tensor of the current time period to obtain a predicted energy fluctuation ratio matrix and an energy fluctuation ratio matrix, subtract the energy fluctuation ratio matrix from the predicted energy fluctuation ratio matrix and take the absolute value to obtain a loss matrix, and find all abnormal locations in the smart grid topology structure of the current time period based on the loss matrix.

[0013] Furthermore, the S10 includes:

[0014] S11. At the sampling time Create one OK The bus state matrix of the column , represents the number of the busbars, and the sampling time is calculated by the state estimation model The power of all buses, the state estimation model is ,in Indicates the active power of the bus or reactive power , represents the bus power status data, express and The nonlinear function between is calculated as follows:

[0015] ,

[0016] ,

[0017] ,

[0018] ;

[0019] in, Any bus The active power at Indicates the bus The reactive power at Indicates that the bus The total number of directly connected buses, and Respectively represent busbar and busbar The voltage amplitude on the bus Indicates busbar Directly connected busbar; Indicates the bus and the busbar The voltage phase angle difference between Indicates the bus and the busbar The conductance between Indicates the bus and the busbar The susceptance between Indicates the bus To the bus The active power, Indicates the bus To the bus Reactive power; Indicates the bus Conductivity to ground, Indicates the bus Susceptance to ground;

[0020] S12. The busbar Active power at or reactive power Stored in the bus state matrix The Line Column, the bus To the bus Active power or reactive power Stored in the bus state matrix The Line List.

[0021] Furthermore, the S20 includes:

[0022] The busbar state tensor is expressed as , ,in, Indicated in The bus state tensor for a time period, Indicated in The first The bus state matrix corresponding to the sampling time is: Represents the bus state tensor For one A three-dimensional tensor of Represents the number of sampling moments in a single time period, and its calculation formula is: , Indicates the sampling frequency of the bus data.

[0023] Further, the S30 includes:

[0024] S31. Get bus state tensor , the bus state tensor As the initial tensor , The initial value is 1;

[0025] S32. Create a Gaussian noise tensor , get random Gaussian noise from the standard normal distribution and store it in the Gaussian noise tensor , use linear scheduling to obtain the Gaussian weight parameter for the iteration , The initial value is 1; the linear scheduling method represents the Gaussian weight parameter As the number of iterations increases linearly, the calculation formula is: , , is the total number of iterations, represents the hyperparameters in the diffusion model, The value range of is a positive integer;

[0026] S33. Determine the number of iterations Is it equal to 1? If so, the initial tensor Input the diffusion model to perform forward process calculation to obtain the iterative tensor , if not, iterate the tensor Input the diffusion model to perform forward process calculation to obtain the iterative tensor , the forward process calculation formula is:

[0027] ;

[0028] in, Represents an iterated tensor Input the diffusion model to perform forward process calculation to obtain an iterative tensor;

[0029] S34. The number of iterations and the iterable tensor The U-net++ network model is input for training, and the loss function of the U-net++ network model is:

[0030] ;

[0031] in, Represents the loss value of the U-net++ network model, Indicates that and the iterable tensor Input the predicted Gaussian noise tensor obtained by the U-net++ network model, Represents the Gaussian noise tensor Subtract the square of the L2 norm of the predicted Gaussian noise tensor, Represents a variable , , Expected value;

[0032] S35. Judgment Is it greater than the total number of iterations? If so, go to S36. If not, , go to S32;

[0033] S36. , determine the busbar state tensor Is it the bus state tensor of the current time period? If so, go to S40; if not, go to S31.

[0034] Furthermore, the S40 includes:

[0035] S41. Create a Gaussian noise tensor , get random Gaussian noise from the standard normal distribution and store it in the Gaussian noise tensor , obtain the Gaussian weight parameter of each iteration in step S32, and obtain the Gaussian weight parameter , Indicates The Gaussian weight parameter of the iteration is calculated using the inverse formula Perform calculations, Represents the total number of iterations, and obtains the inverse weight parameter , Indicates The inverse weight parameter of the iteration, the inverse formula is:

[0036] ;

[0037] in, represents the total number of iterations;

[0038] S42. The bus state tensor of the current time period As the initial tensor , the initial tensor Input the diffusion model to perform fast forward process calculation to obtain the iterative tensor , the formula for calculating the fast forward process is:

[0039] ;

[0040] S43. The total number of iterations and the iteration tensor Input the trained U-net++ network model to get the predicted Gaussian noise tensor .

[0041] Furthermore, the S50 includes:

[0042] The formula for the reverse process calculation is:

[0043] ;

[0044] in, represents the predicted bus state tensor for the current time period, Represents the bus state tensor of the current time period The iterative tensor calculated by the forward process, Represents the total number of iterations and the iteration tensor Input the predicted Gaussian noise tensor obtained by the trained U-net++ network model, represents the cumulative inverse weight parameter, which is calculated as follows: ,in, represents the total number of iterations, Represents the bus state tensor for the current time period The first Gaussian weight parameters.

[0045] Furthermore, the S60 includes:

[0046] S61. Obtain the bus state tensor of the current time period , initialize the scaling coefficients of the Daubechies 4 wavelet and wavelet coefficients , the scaling factor and wavelet coefficients Satisfies the following relationship:

[0047] ;

[0048] S62. Use scaling factor Build a OK Scaling matrix for columns , using the wavelet coefficients Build a OK The wavelet matrix of columns , Represents the number of sampling moments in a single time period, the scaling matrix It is expressed as:

[0049] ;

[0050] The wavelet matrix It is expressed as:

[0051] ;

[0052] S63. Create a Trend signal tensor and a The fluctuation signal tensor , Indicates the number of buses, and calculates the bus state tensor for the current time period The trend signal and fluctuation signal are stored in the trend signal tensor and the fluctuation signal tensor , the calculation formula of the trend signal and the fluctuation signal is:

[0053] , , , , ;

[0054] in, A tensor representing the trend signal middle The elements at the position, Represents the bus state tensor of the current time period middle The elements at the position, Represents the scaling matrix middle OK Elements of a column; Represents the fluctuation signal tensor middle The elements at the position, Represents the wavelet matrix middle OK Elements of a column;

[0055] S64. Create a The approximate signal tensor of and a The detail signal tensor , calculate the bus state tensor for the current time period The approximate signal and the detail signal are stored in the approximate signal tensor respectively. and the detail signal tensor , the calculation formula of the approximate signal and the detail signal is:

[0056] , , , , ;

[0057] in, Represents the approximate signal tensor middle The elements of the position, A tensor representing the trend signal middle The elements at the position, Represents the scaling matrix middle OK Elements of a column; Represents the detail signal tensor middle The elements of the position, Represents the wavelet matrix middle OK Elements of a column;

[0058] S65. Create a OK The bus state tensor of the current time period The energy fluctuation ratio matrix , according to the approximate signal tensor and the detail signal tensor Calculate the bus state tensor for the current time period The energy fluctuation ratio is stored in the energy fluctuation ratio matrix , the calculation formula of the energy fluctuation ratio is:

[0059] , , ;

[0060] in, Represents the energy fluctuation ratio matrix middle OK The elements of the column, Represents the approximate signal tensor middle The elements of the position, Represents the detail signal tensor middle Elements of position;

[0061] S66. Obtain the predicted bus state tensor for the current time period According to steps S61 to S65, the predicted bus state tensor Calculate and obtain the predicted bus state tensor The predicted energy fluctuation ratio matrix ;

[0062] S67. The energy fluctuation ratio matrix The predicted energy fluctuation ratio matrix After subtraction, take the absolute value to get the loss matrix of the current time period , if the loss matrix Middle Line The element value of the column is greater than the threshold , then the bus An exception occurs at Middle Line The element value of the column is greater than the threshold , then the bus and busbar An exception occurred.

[0063] Furthermore, a FDIA detection device based on a diffusion model comprises:

[0064] Data acquisition module: used to collect data according to the sampling frequency Collect bus power status data in the smart grid at each sampling moment;

[0065] Data preprocessing module: used to calculate the active power of the bus at all sampling moments based on the smart grid topology data and the bus power status data or reactive power , get the bus state matrix at all sampling moments; according to Divide the time period, combine the bus state matrices at all sampling moments in each time period, and obtain the bus state tensors of all time periods;

[0066] Model training module: used for inputting the bus state tensor of all historical time periods into the diffusion model for forward process calculation, obtaining Gaussian noise tensor, iteration tensor and iteration number, and inputting the Gaussian noise tensor, iteration tensor and iteration number into the U-net++ network model for training;

[0067] Model prediction module: used for inputting the bus state tensor of the current time period into the diffusion model for forward process calculation to obtain the iteration tensor, inputting the iteration tensor and the total number of iterations into the trained U-net++ network model to obtain the predicted Gaussian noise tensor; inputting the predicted Gaussian noise tensor and the iteration tensor into the diffusion model for reverse process calculation to obtain the predicted bus state tensor of the current time period;

[0068] Anomaly detection module: used to perform discrete wavelet transform on the predicted bus state tensor and the bus state tensor of the current time period to obtain a predicted energy fluctuation ratio matrix and an energy fluctuation ratio matrix, subtract the energy fluctuation ratio matrix from the predicted energy fluctuation ratio matrix and take the absolute value to obtain a loss matrix, and find all abnormal locations in the smart grid topology structure of the current time period according to the loss matrix.

[0069] The beneficial effects of the present invention are:

[0070] 1. The spatial and temporal characteristics of the measurement nodes are extracted according to the smart grid topology and power status data, and the forward diffusion and reverse denoising processes of the diffusion model are used to effectively reduce the interference of abnormal data in the smart grid. The U-net++ network model is used to train Gaussian noise, so that the diffusion model has a strong generalization ability and can handle abnormal data of different types and intensities, thereby improving the robustness of FDIA detection.

[0071] 2. Using discrete wavelet transform to calculate the energy fluctuation ratio matrix of the bus state tensor can deeply mine all measurement nodes with abnormal fluctuations, further improving the accuracy and reliability of FDIA detection; the present invention can process the power status data in the smart grid in real time, realize the real-time monitoring and positioning of abnormal conditions in the grid, and improve the safety and stability of grid operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] Figure 1 It is a flow chart of a FDIA detection method based on a diffusion model provided by the present invention.

[0073] Figure 2 It is a structural flow chart of a FDIA detection method based on a diffusion model provided by the present invention.

[0074] Figure 3 It is a structural diagram of an FDIA detection device based on a diffusion model provided by the present invention. DETAILED DESCRIPTION

[0075] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present invention can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present invention.

[0076] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present invention, rather than all of the embodiments.

[0077] Figure 1: is a flow chart of a FDIA detection method based on a diffusion model provided by an embodiment of the present invention, the method comprising:

[0078] S10. Obtain smart grid topology data and bus power status data, and calculate the active power of the bus at all sampling moments in sequence according to the smart grid topology data and bus power status data or reactive power , get the bus state matrix at all sampling moments;

[0079] S20.According to Divide the time period, combine the bus state matrices at all sampling moments in each time period, and obtain the bus state tensors of all time periods;

[0080] S30. sequentially input the bus state tensor of all historical time periods into the diffusion model for forward process calculation to obtain a Gaussian noise tensor, an iteration tensor and an iteration number, and input the Gaussian noise tensor, the iteration tensor and the iteration number into the U-net++ network model for training;

[0081] S40. Input the bus state tensor of the current time period into the diffusion model for forward process calculation to obtain an iteration tensor, input the iteration tensor and the total number of iterations into the trained U-net++ network model to obtain a predicted Gaussian noise tensor;

[0082] S50. Input the predicted Gaussian noise tensor and the iterative tensor into the diffusion model for reverse process calculation to obtain the predicted bus state tensor for the current time period;

[0083] S60. Perform discrete wavelet transform on the predicted bus state tensor and the bus state tensor of the current time period to obtain a predicted energy fluctuation ratio matrix and an energy fluctuation ratio matrix, subtract the energy fluctuation ratio matrix from the predicted energy fluctuation ratio matrix and take the absolute value to obtain a loss matrix, and find all abnormal locations in the smart grid topology structure of the current time period based on the loss matrix.

[0084] In this embodiment, the smart grid topology data and bus power status data are first obtained, and the active power of the bus at all sampling moments is calculated in sequence according to the smart grid topology data and bus power status data. or reactive power , get the bus state matrix at all sampling moments; then, according to The time period is divided, and the bus state matrices of all sampling moments in each time period are combined to obtain the bus state tensor of all time periods; then the bus state tensors of all historical time periods are input into the diffusion model for forward process calculation to obtain the Gaussian noise tensor, iteration tensor and number of iterations, which are then input into the U-net++ network model for training; then the bus state tensor of the current time period is input into the diffusion model for forward process calculation to obtain the iteration tensor, and the iteration tensor and the total number of iterations are input into the trained U-net++ network model to obtain the predicted Gaussian noise tensor; the predicted Gaussian noise tensor and iteration tensor are input into the diffusion model for reverse process calculation to obtain the predicted bus state tensor of the current time period; finally, the predicted bus state tensor of the current time period and the bus state tensor are subjected to discrete wavelet transform to obtain the predicted energy fluctuation ratio matrix and the energy fluctuation ratio matrix, and the energy fluctuation ratio matrix is ​​subtracted from the predicted energy fluctuation ratio matrix and the absolute value is taken to obtain the loss matrix, and all abnormal locations in the smart grid topology structure of the current time period are found according to the loss matrix.

[0085] Optionally, The value is one minute.

[0086] Furthermore, the S10 includes:

[0087] S11. At the sampling time Create one OK The bus state matrix of the column , represents the number of the busbars, and the sampling time is calculated by the state estimation model The power of all buses, the state estimation model is ,in Indicates the active power of the bus or reactive power , represents the bus power status data, express and The nonlinear function between is calculated as follows:

[0088] ,

[0089] ,

[0090] ,

[0091] ;

[0092] in, Any bus The active power at Indicates the bus The reactive power at Indicates that the bus The total number of directly connected buses, and Respectively represent busbar and busbar The voltage amplitude on the bus Indicates busbar Directly connected busbar; Indicates the bus and the busbar The voltage phase angle difference between Indicates the bus and the busbar The conductance between Indicates the bus and the busbar The susceptance between Indicates the bus To the bus The active power, Indicates the bus To the bus Reactive power; Indicates the bus Conductivity to ground, Indicates the bus Susceptance to ground;

[0093] S12. The busbar Active power at or reactive power Stored in the bus state matrix The Line Column, the bus To the bus Active power or reactive power Stored in the bus state matrix The Line List.

[0094] Specifically, the S20 includes:

[0095] The busbar state tensor is expressed as , ,in, Indicated in The bus state tensor for a time period, Indicated in The first The bus state matrix corresponding to the sampling time is: Represents the bus state tensor For one A three-dimensional tensor of Represents the number of sampling moments in a single time period, and its calculation formula is: , Indicates the sampling frequency of the bus data.

[0096] Optionally, the sampling frequency One second each time.

[0097] Further, refer to Figure 2 , the S30 comprises:

[0098] S31. Get bus state tensor , the bus state tensor As the initial tensor , The initial value is 1;

[0099] S32. Create a Gaussian noise tensor , get random Gaussian noise from the standard normal distribution and store it in the Gaussian noise tensor , use linear scheduling to obtain the Gaussian weight parameter for the iteration , The initial value is 1; the linear scheduling method represents the Gaussian weight parameter As the number of iterations increases linearly, the calculation formula is: , , is the total number of iterations, represents the hyperparameters in the diffusion model, The value range of is a positive integer;

[0100] S33. Determine the number of iterations Is it equal to 1? If so, the initial tensor Input the diffusion model to perform forward process calculation to obtain the iterative tensor , if not, iterate the tensor Input the diffusion model to perform forward process calculation to obtain the iterative tensor , the forward process calculation formula is:

[0101] ;

[0102] in, Represents an iterated tensor Input the diffusion model to perform forward process calculation to obtain an iterative tensor;

[0103] S34. The number of iterations and the iterable tensor The U-net++ network model is input for training, and the loss function of the U-net++ network model is:

[0104] ;

[0105] in, Represents the loss value of the U-net++ network model, Indicates that and the iterable tensor Input the predicted Gaussian noise tensor obtained by the U-net++ network model, Represents the Gaussian noise tensor Subtract the square of the L2 norm of the predicted Gaussian noise tensor, Represents a variable , , Expected value;

[0106] S35. Judgment Is it greater than the total number of iterations? If so, go to S36. If not, , go to S32;

[0107] S36. , determine the busbar state tensor Is it the bus state tensor of the current time period? If so, go to S40; if not, go to S31.

[0108] In this embodiment, first obtain the bus state tensor , the bus state tensor As the initial tensor , The initial value is 1; create a Gaussian noise tensor , get random Gaussian noise from the standard normal distribution and store it in the Gaussian noise tensor , use linear scheduling to obtain the Gaussian weight parameter for the iteration , The initial value is 1; then determine the number of iterations Is it equal to 1? If so, the initial tensor Input the diffusion model to perform forward process calculation and obtain the iterative tensor , if not, iterate the tensor Input the diffusion model to perform forward process calculation and obtain the iterative tensor ; Next, the number of iterations and the iterable tensor Input U-net++ network model for training and judge Is it greater than the total number of iterations? If so, , determine the busbar state tensor Is it the bus state tensor of the current time period? If so, the U-net++ network model training is finished. If not, continue to use the bus state tensor of the next time period. Input diffusion model for training.

[0109] Specifically, the linear scheduling method represents the Gaussian weight parameter As the number of iterations increases linearly, the calculation formula is: , , is the total number of iterations, represents the hyperparameters in the diffusion model, The value range of is a positive integer.

[0110] Specifically, the formula for the forward process calculation is:

[0111] ;

[0112] in, Represents an iterated tensor The iterative tensor obtained by inputting the diffusion model to perform forward process calculation.

[0113] Specifically, the loss function of the U-net++ network model is:

[0114] ;

[0115] in, Represents the loss value of the U-net++ network model, Indicates that and the iterable tensor Input the predicted Gaussian noise tensor obtained by the U-net++ network model, Represents the Gaussian noise tensor Subtract the square of the L2 norm of the predicted Gaussian noise tensor, Represents a variable , , expected value.

[0116] In another embodiment of the present invention, the bus state tensor is first obtained , the bus state tensor As the initial tensor , The initial value is 1; create a Gaussian noise tensor , get random Gaussian noise from the standard normal distribution and store it in the Gaussian noise tensor , use linear scheduling to obtain the Gaussian weight parameter for the iteration , The initial value is 1; then determine the number of iterations Is it equal to 1? If so, the initial tensor Input the diffusion model to perform forward process calculation and obtain the iterative tensor , if not, iterate the tensor Input the diffusion model to perform forward process calculation and obtain the iterative tensor Next, the number of iterations and the iterable tensor Input U-net++ network model for training and judge Is it greater than the total number of iterations? If not, , create the next Gaussian noise tensor , continue to the next iteration of the forward process calculation of the diffusion model.

[0117] Furthermore, the S40 includes:

[0118] S41. Create a Gaussian noise tensor , get random Gaussian noise from the standard normal distribution and store it in the Gaussian noise tensor , obtain the Gaussian weight parameter of each iteration in step S32, and obtain the Gaussian weight parameter , Indicates The Gaussian weight parameter of the iteration is calculated using the inverse formula Perform calculations, Represents the total number of iterations, and obtains the inverse weight parameter , Indicates The inverse weight parameter of the iteration, the inverse formula is:

[0119] ;

[0120] in, represents the total number of iterations;

[0121] S42. The bus state tensor of the current time period As the initial tensor , the initial tensor Input the diffusion model to perform fast forward process calculation to obtain the iterative tensor , the formula for calculating the fast forward process is:

[0122] ;

[0123] S43. The total number of iterations and the iteration tensor Input the trained U-net++ network model to get the predicted Gaussian noise tensor .

[0124] Furthermore, the S50 includes:

[0125] The formula for the reverse process calculation is:

[0126] ;

[0127] in, represents the predicted bus state tensor for the current time period, Represents the bus state tensor of the current time period The iterative tensor calculated by the forward process, Represents the total number of iterations and the iteration tensor Input the predicted Gaussian noise tensor obtained by the trained U-net++ network model, represents the cumulative inverse weight parameter, which is calculated as follows: ,in, represents the total number of iterations, Represents the bus state tensor for the current time period The first Gaussian weight parameters.

[0128] Furthermore, the S60 includes:

[0129] S61. Obtain the bus state tensor of the current time period , initialize the scaling coefficients of the Daubechies 4 wavelet and wavelet coefficients , the scaling factor and wavelet coefficients Satisfies the following relationship:

[0130] ;

[0131] S62. Use scaling factor Build a OK Scaling matrix for columns , using the wavelet coefficients Build a OK The wavelet matrix of columns , Represents the number of sampling moments in a single time period, the scaling matrix It is expressed as:

[0132] ;

[0133] The wavelet matrix It is expressed as:

[0134] ;

[0135] S63. Create a Trend signal tensor and a The fluctuation signal tensor , Indicates the number of buses, and calculates the bus state tensor for the current time period The trend signal and fluctuation signal are stored in the trend signal tensor and the fluctuation signal tensor , the calculation formula of the trend signal and the fluctuation signal is:

[0136] , , , , ;

[0137] in, A tensor representing the trend signal middle The elements at the position, Represents the bus state tensor of the current time period middle The elements at the position, Represents the scaling matrix middle OK Elements of a column; Represents the fluctuation signal tensor middle The elements at the position, Represents the wavelet matrix middle OK Elements of a column;

[0138] S64. Create a The approximate signal tensor of and a The detail signal tensor , calculate the bus state tensor for the current time period The approximate signal and the detail signal are stored in the approximate signal tensor respectively. and the detail signal tensor , the calculation formula of the approximate signal and the detail signal is:

[0139] , , , , ;

[0140] in, Represents the approximate signal tensor middle The elements of the position, A tensor representing the trend signal middle The elements at the position, Represents the scaling matrix middle OK Elements of a column; Represents the detail signal tensor middle The elements of the position, Represents the wavelet matrix middle OK Elements of a column;

[0141] S65. Create a OK The bus state tensor of the current time period The energy fluctuation ratio matrix , according to the approximate signal tensor and the detail signal tensor Calculate the bus state tensor for the current time period The energy fluctuation ratio is stored in the energy fluctuation ratio matrix , the calculation formula of the energy fluctuation ratio is:

[0142] , , ;

[0143] in, Represents the energy fluctuation ratio matrix middle OK The elements of the column, Represents the approximate signal tensor middle The elements of the position, Represents the detail signal tensor middle Elements of position;

[0144] S66. Obtain the predicted bus state tensor for the current time period According to steps S61 to S65, the predicted bus state tensor Calculate and obtain the predicted bus state tensor The predicted energy fluctuation ratio matrix ;

[0145] S67. The energy fluctuation ratio matrix The predicted energy fluctuation ratio matrix After subtraction, take the absolute value to get the loss matrix of the current time period , if the loss matrix Middle Line The element value of the column is greater than the threshold , then the bus An exception occurs at Middle Line The element value of the column is greater than the threshold , then the bus and busbar An exception occurred.

[0146] Specifically, the scaling factor of Daubechies 4 wavelet is S={0.4829629131445341,0.8365163037378079, 0.2241438680420134, 0.1294095225512604}, wavelet coefficient J={ 0.1294095225512604, 0.2241438680420134, 0.8365163037378079, 0.4829629131445341}.

[0147] An FDIA detection device based on a diffusion model provided in an embodiment of the present invention is introduced below. The FDIA detection device based on a diffusion model described below and the FDIA detection method based on a diffusion model described above can refer to each other.

[0148] refer to Figure 3 , a FDIA detection device based on a diffusion model, comprising:

[0149] Data acquisition module: used to collect data according to the sampling frequency Collect bus power status data in the smart grid at each sampling moment;

[0150] Data preprocessing module: used to calculate the active power of the bus at all sampling moments based on the smart grid topology data and the bus power status data or reactive power , get the bus state matrix at all sampling moments; according to Divide the time period, combine the bus state matrices at all sampling moments in each time period, and obtain the bus state tensors of all time periods;

[0151] Model training module: used for inputting the bus state tensor of all historical time periods into the diffusion model for forward process calculation, obtaining Gaussian noise tensor, iteration tensor and iteration number, and inputting the Gaussian noise tensor, iteration tensor and iteration number into the U-net++ network model for training;

[0152] Model prediction module: used for inputting the bus state tensor of the current time period into the diffusion model for forward process calculation to obtain the iteration tensor, inputting the iteration tensor and the total number of iterations into the trained U-net++ network model to obtain the predicted Gaussian noise tensor; inputting the predicted Gaussian noise tensor and the iteration tensor into the diffusion model for reverse process calculation to obtain the predicted bus state tensor of the current time period;

[0153] Anomaly detection module: used to perform discrete wavelet transform on the predicted bus state tensor and the bus state tensor of the current time period to obtain a predicted energy fluctuation ratio matrix and an energy fluctuation ratio matrix, subtract the energy fluctuation ratio matrix from the predicted energy fluctuation ratio matrix and take the absolute value to obtain a loss matrix, and find all abnormal locations in the smart grid topology structure of the current time period according to the loss matrix.

[0154] In this embodiment, according to the sampling frequency Collect the bus power status data in the smart grid at each sampling moment; calculate the active power of the bus at all sampling moments based on the smart grid topology data and the bus power status data or reactive power , get the bus state matrix at all sampling moments; according to The time period is divided, and the bus state matrices of all sampling moments in each time period are combined to obtain the bus state tensor of all time periods; the bus state tensors of all historical time periods are input into the diffusion model for forward process calculation to obtain the Gaussian noise tensor, iteration tensor and number of iterations, and the Gaussian noise tensor, iteration tensor and number of iterations are input into the U-net++ network model for training; the bus state tensor of the current time period is input into the diffusion model for forward process calculation to obtain the iteration tensor, and the iteration tensor and the total number of iterations are input into the trained U-net++ network model to obtain the predicted Gaussian noise tensor; the predicted Gaussian noise tensor and iteration tensor are input into the diffusion model for reverse process calculation to obtain the predicted bus state tensor of the current time period; the predicted bus state tensor of the current time period and the bus state tensor are subjected to discrete wavelet transform to obtain the predicted energy fluctuation ratio matrix and the energy fluctuation ratio matrix, and the energy fluctuation ratio matrix is ​​subtracted from the predicted energy fluctuation ratio matrix and the absolute value is taken to obtain the loss matrix, and all abnormal locations in the smart grid topology structure of the current time period are found according to the loss matrix.

[0155] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0156] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A FDIA detection method based on a diffusion model, characterized in that: include: S10. Obtain smart grid topology data and bus power status data, and calculate the active power of the bus at all sampling moments in sequence according to the smart grid topology data and bus power status data or reactive power , get the bus state matrix at all sampling moments; S20.According to Divide the time period, combine the bus state matrices at all sampling moments in each time period, and obtain the bus state tensors of all time periods; S30. sequentially input the bus state tensor of all historical time periods into the diffusion model for forward process calculation to obtain a Gaussian noise tensor, an iteration tensor and an iteration number, and input the Gaussian noise tensor, the iteration tensor and the iteration number into the U-net++ network model for training; S40. Input the bus state tensor of the current time period into the diffusion model for forward process calculation to obtain an iteration tensor, input the iteration tensor and the total number of iterations into the trained U-net++ network model to obtain a predicted Gaussian noise tensor; S50. Input the predicted Gaussian noise tensor and the iterative tensor into the diffusion model for reverse process calculation to obtain the predicted bus state tensor for the current time period; S60. Perform discrete wavelet transform on the predicted bus state tensor and the bus state tensor of the current time period to obtain a predicted energy fluctuation ratio matrix and an energy fluctuation ratio matrix, subtract the energy fluctuation ratio matrix from the predicted energy fluctuation ratio matrix and take the absolute value to obtain a loss matrix, and find all abnormal locations in the smart grid topology structure of the current time period based on the loss matrix.

2. The FDIA detection method based on the diffusion model as claimed in claim 1, characterized in that: The S10 comprises: S11. At the sampling time Create one OK The bus state matrix of the column , represents the number of the busbars, and the sampling time is calculated by the state estimation model The power of all buses, the state estimation model is ,in Indicates the active power of the bus or reactive power , represents the bus power status data, express and The nonlinear function between is calculated as follows: , , , ; in, Any bus The active power at Indicates the bus The reactive power at Indicates that the bus The total number of directly connected buses, and Respectively represent busbar and busbar The voltage amplitude on the bus Indicates busbar Directly connected busbar; Indicates the bus and the busbar The voltage phase angle difference between Indicates the bus and the busbar The conductance between Indicates the bus and the busbar The susceptance between Indicates the bus To the bus The active power, Indicates the bus To the bus Reactive power; Indicates the bus Conductivity to ground, Indicates the bus Susceptance to ground; S12. The busbar Active power at or reactive power Stored in the bus state matrix The Line Column, the bus To the bus Active power or reactive power Stored in the bus state matrix The Line List.

3. The FDIA detection method based on the diffusion model as claimed in claim 1, characterized in that: The S20 includes: The busbar state tensor is expressed as , ,in, Indicated in The bus state tensor for a time period, Indicated in The first The bus state matrix corresponding to the sampling time is: Represents the bus state tensor For one A three-dimensional tensor of Represents the number of sampling moments in a single time period, and its calculation formula is: , Indicates the sampling frequency of the bus data.

4. The FDIA detection method based on the diffusion model as claimed in claim 1, characterized in that: The S30 includes: S31. Get bus state tensor , the bus state tensor As the initial tensor , The initial value is 1; S32. Create a Gaussian noise tensor , get random Gaussian noise from the standard normal distribution and store it in the Gaussian noise tensor , use linear scheduling to obtain the Gaussian weight parameter for the iteration , The initial value is 1; the linear scheduling method represents the Gaussian weight parameter As the number of iterations increases linearly, the calculation formula is: , , is the total number of iterations, represents the hyperparameters in the diffusion model, The value range of is a positive integer; S33. Determine the number of iterations Is it equal to 1? If so, the initial tensor Input the diffusion model to perform forward process calculation to obtain the iterative tensor , if not, iterate the tensor Input the diffusion model to perform forward process calculation to obtain the iterative tensor , the forward process calculation formula is: ; in, Represents an iterated tensor Input the diffusion model to perform forward process calculation to obtain an iterative tensor; S34. The number of iterations and the iterable tensor The U-net++ network model is input for training, and the loss function of the U-net++ network model is: ; in, Represents the loss value of the U-net++ network model, Indicates that and the iterable tensor Input the predicted Gaussian noise tensor obtained by the U-net++ network model, Represents the Gaussian noise tensor Subtract the square of the L2 norm of the predicted Gaussian noise tensor, Represents a variable , , Expected value; S35. Judgment Is it greater than the total number of iterations? If so, go to S36. If not, , go to S32; S36. , determine the busbar state tensor Is it the bus state tensor of the current time period? If so, go to S40; if not, go to S31.

5. The FDIA detection method based on the diffusion model as claimed in claim 4, characterized in that: The S40 comprises: S41. Create a Gaussian noise tensor , get random Gaussian noise from the standard normal distribution and store it in the Gaussian noise tensor , obtain the Gaussian weight parameter of each iteration in step S32, and obtain the Gaussian weight parameter , Indicates The Gaussian weight parameter of the iteration is calculated using the inverse formula Perform calculations, Represents the total number of iterations, and obtains the inverse weight parameter , Indicates The inverse weight parameter of the iteration, the inverse formula is: ; in, represents the total number of iterations; S42. The bus state tensor of the current time period As the initial tensor , the initial tensor Input the diffusion model to perform fast forward process calculation to obtain the iterative tensor , the formula for calculating the fast forward process is: ; S43. The total number of iterations and the iteration tensor Input the trained U-net++ network model to get the predicted Gaussian noise tensor .

6. The FDIA detection method based on diffusion model as claimed in claim 1, characterized in that: The S50 comprises: The formula for the reverse process calculation is: ; in, represents the predicted bus state tensor for the current time period, Represents the bus state tensor of the current time period The iterative tensor calculated by the forward process, Represents the total number of iterations and the iteration tensor Input the predicted Gaussian noise tensor obtained by the trained U-net++ network model, represents the cumulative inverse weight parameter, which is calculated as follows: ,in, represents the total number of iterations, Represents the bus state tensor for the current time period The first Gaussian weight parameters.

7. The FDIA detection method based on diffusion model as claimed in claim 1, characterized in that: The S60 includes: S61. Obtain the bus state tensor of the current time period , initialize the scaling coefficients of the Daubechies 4 wavelet and wavelet coefficients , the scaling factor and wavelet coefficients Satisfies the following relationship: ; S62. Use scaling factor Build a OK Scaling matrix for columns , using the wavelet coefficients Build a OK The wavelet matrix of columns , Represents the number of sampling moments in a single time period, the scaling matrix It is expressed as: ; The wavelet matrix It is expressed as: ; S63. Create a Trend signal tensor and a The fluctuation signal tensor , Indicates the number of buses, and calculates the bus state tensor for the current time period The trend signal and fluctuation signal are stored in the trend signal tensor and the fluctuation signal tensor , the calculation formula of the trend signal and the fluctuation signal is: , , , , ; in, A tensor representing the trend signal middle The elements at the position, Represents the bus state tensor of the current time period middle The elements at the position, Represents the scaling matrix middle OK Elements of a column; Represents the fluctuation signal tensor middle The elements at the position, Represents the wavelet matrix middle OK Elements of a column; S64. Create a The approximate signal tensor of and a The detail signal tensor , calculate the bus state tensor for the current time period The approximate signal and the detail signal are stored in the approximate signal tensor respectively. and the detail signal tensor , the calculation formula of the approximate signal and the detail signal is: , , , , ; in, Represents the approximate signal tensor middle The elements of the position, A tensor representing the trend signal middle The elements at the position, Represents the scaling matrix middle OK Elements of a column; Represents the detail signal tensor middle The elements of the position, Represents the wavelet matrix middle OK Elements of a column; S65. Create a OK The bus state tensor of the current time period The energy fluctuation ratio matrix , according to the approximate signal tensor and the detail signal tensor Calculate the bus state tensor for the current time period The energy fluctuation ratio is stored in the energy fluctuation ratio matrix , the calculation formula of the energy fluctuation ratio is: , , ; in, Represents the energy fluctuation ratio matrix middle OK The elements of the column, Represents the approximate signal tensor middle The elements of the position, Represents the detail signal tensor middle Elements of position; S66. Obtain the predicted bus state tensor for the current time period According to steps S61 to S65, the predicted bus state tensor Calculate and obtain the predicted bus state tensor The predicted energy fluctuation ratio matrix ; S67. The energy fluctuation ratio matrix The predicted energy fluctuation ratio matrix After subtraction, take the absolute value to get the loss matrix of the current time period , if the loss matrix Middle Line The element value of the column is greater than the threshold , then the bus An exception occurs at Middle Line The element value of the column is greater than the threshold , then the bus and busbar An exception occurred.

8. An FDIA detection device based on a diffusion model, characterized in that: Implementing a FDIA detection method based on a diffusion model as described in any one of claims 1 to 7, comprising: Data acquisition module: used to collect data according to the sampling frequency Collect bus power status data in the smart grid at each sampling moment; Data preprocessing module: used to calculate the active power of the bus at all sampling moments based on the smart grid topology data and the bus power status data or reactive power , get the bus state matrix at all sampling moments; according to Divide the time period, combine the bus state matrices at all sampling moments in each time period, and obtain the bus state tensors of all time periods; Model training module: used for inputting the bus state tensor of all historical time periods into the diffusion model for forward process calculation, obtaining Gaussian noise tensor, iteration tensor and iteration number, and inputting the Gaussian noise tensor, iteration tensor and iteration number into the U-net++ network model for training; Model prediction module: used for inputting the bus state tensor of the current time period into the diffusion model for forward process calculation to obtain the iteration tensor, inputting the iteration tensor and the total number of iterations into the trained U-net++ network model to obtain the predicted Gaussian noise tensor; inputting the predicted Gaussian noise tensor and the iteration tensor into the diffusion model for reverse process calculation to obtain the predicted bus state tensor of the current time period; Anomaly detection module: used to perform discrete wavelet transform on the predicted bus state tensor and the bus state tensor of the current time period to obtain a predicted energy fluctuation ratio matrix and an energy fluctuation ratio matrix, subtract the energy fluctuation ratio matrix from the predicted energy fluctuation ratio matrix and take the absolute value to obtain a loss matrix, and find all abnormal locations in the smart grid topology structure of the current time period according to the loss matrix.