A harmonic source modeling method based on bi-lstm and transfer learning

CN119046702BActive Publication Date: 2026-09-18ELECTRIC POWER RES INST STATE GRID SHANXI ELECTRIC POWER
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411007077.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-25
Publication Date
2026-09-18
Estimated Expiration
2044-07-25

AI Technical Summary

Technical Problem

[0005]本发明的目的是为了解决现有的谐波源建模方法训练耗费时间长、拟合精度不够高以及谐波源建模问题复杂度较高的问题,提出了一种基于Bi-LSTM与迁移学习的谐波源建模方法

Benefits of technology

[0014] 1. This invention effectively classifies operating conditions and removes abnormal data by introducing waveform energy and DBSCAN clustering analysis; it uses Bi-LSTM neural network for benchmark model training and utilizes transfer learning method to establish transfer model, thereby improving the model's adaptability and generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046702B_ABST
    Figure CN119046702B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of power grid harmonic source modeling, and specifically discloses a harmonic source modeling method based on Bi-LSTM and transfer learning, which comprises the following steps: collecting monitoring data and calculating total energy of three-phase voltage waveform; performing cluster analysis on the total energy of three-phase voltage waveform, and dividing the monitoring data into voltage-current data sets under multiple different operating conditions; constructing a Bi-LSTM model, selecting a training data set to perform training and optimization, and obtaining a voltage-current Bi-LSTM benchmark model; using a transfer learning method, transferring part of parameters in the voltage-current Bi-LSTM benchmark model to voltage-current data sets that do not participate in model training, establishing a voltage-current mapping transfer model, and completing harmonic source modeling. The application reduces the complexity of the harmonic source modeling problem, and solves the problems of long training time and insufficient fitting accuracy of the existing harmonic source modeling method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of power grid harmonic source modeling technology, specifically involving the design of a harmonic source modeling method based on Bi-LSTM and transfer learning. Background Technology

[0002] The extensive integration of renewable energy and the gradual adoption of hybrid AC / DC networks have become two major characteristics of modern power systems, leading to increasingly prominent grid harmonic problems. Against this backdrop, the challenging issue of harmonic source modeling has garnered significant attention from both academia and industry. Harmonic source modeling plays a crucial role in harmonic component analysis, interaction analysis, and responsibility allocation. A well-chosen and accurate harmonic source model can simplify the complexity of the analysis and reduce errors. However, to date, a universal harmonic source modeling method has not yet emerged, and different types of modeling methods exhibit varying performance in different application scenarios. Currently, based on modeling approaches, harmonic source modeling methods can be divided into two main categories: mechanistic modeling methods and data-driven modeling methods. Each category can be further subdivided into time-domain modeling methods and frequency-domain modeling methods.

[0003] Mechanistic modeling methods start from specific circuit topologies, apply basic circuit principles, and comprehensively utilize wavelet analysis, time series analysis, and other methods to obtain analytical expressions between inputs and outputs (usually UI relationships). Harmonic source modeling based on cross-frequency admittance matrices is unsuitable for situations where harmonic source operating conditions change frequently or where the harmonic source exhibits strong randomness. Harmonic source modeling based on circuit mechanisms has clearly defined physical meanings for each parameter in its analytical expression, offering better interpretability. However, mechanistic modeling methods require complete knowledge of the circuit topology, which is sometimes difficult to achieve in practical engineering. Furthermore, when the circuit topology changes, the modeling work must be completed entirely, limiting its versatility.

[0004] Data-driven harmonic source models are a modeling approach that has gradually gained attention with the development of smart grids. These models do not require knowledge of the specific topology and are applicable to complex systems. As a general-purpose modeling method, data-driven frequency domain modeling implicitly reflects the coupling relationships between harmonics of different frequencies, adapts to dynamic changes, and is fast and easy to use. Currently, neural network modeling of harmonic sources mainly uses Radial-Basis Function Neural Networks (RBFNNs). However, neural network-based harmonic source modeling requires large-scale datasets and time-consuming training, making it unsuitable for real-time modeling. Summary of the Invention

[0005] The purpose of this invention is to solve the problems of long training time, insufficient fitting accuracy, and high complexity of existing harmonic source modeling methods. A harmonic source modeling method based on Bi-LSTM and transfer learning is proposed.

[0006] The technical solution of this invention is: a harmonic source modeling method based on Bi-LSTM and transfer learning, comprising the following steps:

[0007] S1. Collect voltage waveform data and current waveform data through monitoring devices, calculate the energy of each phase voltage waveform, and calculate the total energy of the three-phase voltage waveform based on the energy of each phase voltage waveform;

[0008] S2. The DBSCAN clustering algorithm is used to perform cluster analysis on the total energy of the three-phase voltage waveform, and the voltage waveform data and current waveform data are divided into multiple voltage-current datasets under different operating conditions.

[0009] S3. Preprocess and standardize the voltage-current dataset to obtain a standardized voltage-current dataset;

[0010] S4. Construct a Bi-LSTM model, and based on the Bi-LSTM model, select a standardized voltage-current dataset under a specific operating condition to establish a training dataset;

[0011] S5. Train the Bi-LSTM model using the training dataset, and optimize the network structure and hyperparameters of the Bi-LSTM model to obtain the voltage-current Bi-LSTM baseline model.

[0012] S6. Using the transfer learning method, some parameters in the voltage-current Bi-LSTM baseline model are transferred to the voltage-current dataset that was not involved in the model training, and a voltage-current mapping transfer model is established to complete the harmonic source modeling.

[0013] The beneficial effects of this invention are:

[0014] 1. This invention effectively classifies operating conditions and removes abnormal data by introducing waveform energy and DBSCAN clustering analysis; it uses Bi-LSTM neural network for benchmark model training and utilizes transfer learning method to establish transfer model, thereby improving the model's adaptability and generalization ability.

[0015] 2. This invention reduces the complexity of harmonic source modeling by establishing a harmonic source model using only raw voltage and current waveform monitoring data, i.e., the voltage-current waveform mapping relationship. The established voltage-current waveform Bi-LSTM neural network model can fit the current waveform of the monitoring point under various operating conditions very well.

[0016] 3. The transferred model established using the transfer learning method has a short training time, high fitting accuracy, and small prediction error. Further optimization of the non-transfer layer structure and parameters of the transferred model can yield a transferred model with even higher fitting accuracy.

[0017] Preferably, the voltage waveform energy mentioned in step S1 represents the sum of the squares of the amplitudes of all sampling points of the periodic discrete voltage waveform within one period, and the specific calculation method is as follows:

[0018] S11. For continuous voltage signals, a fixed sampling frequency f s Sampling is performed to obtain the discrete signal v(n);

[0019] S12. Extract a data segment of one period from the discrete signal v(n);

[0020] S13. Squaring the amplitude of each sampling point within a data segment of one period yields the squared amplitude value v(n) for each sampling point. 2 ;

[0021] S14. The sum of the squared amplitude values ​​of all sampling points within one period is used to obtain the voltage waveform energy E. The formula for calculating the voltage waveform energy E is as follows:

[0022]

[0023] Where n represents the nth sampling point, and N represents the total number of sampling points in one period.

[0024] Preferably, the formula for calculating the total energy of the three-phase voltage waveform in step S1 is:

[0025] E ABC =E A +E B +E C

[0026] Among them, E ABC E represents the total energy of the three-phase voltage waveform. A E represents the energy of the phase A voltage waveform. B E represents the energy of the B-phase voltage waveform. C This represents the energy of the C-phase voltage waveform.

[0027] The beneficial effects of the above preferred solution are:

[0028] Waveform energy is an important indicator for describing the overall characteristics of power waveforms. It helps to accurately analyze and process waveform data, ensuring the stability and reliability of the system.

[0029] Preferably, step S2 specifically includes the following steps:

[0030] S21. The total energy E of the three-phase voltage waveform ABC All data is marked as pending processing.

[0031] S22. The total energy E of the three-phase voltage waveform ABC Each data point P in the diagram is positioned at the center of a circle, and E is set to... ps Draw a circle with a radius to obtain a circular region containing different numbers of objects;

[0032] S23. Determine whether the number of objects contained in the circular region of data P is less than the preset minimum number min P. ts If yes, mark the data P as a boundary point or noise point and proceed to step S25; otherwise, proceed to step S24.

[0033] S24. Mark data point P as the core data point and establish cluster C. i Unclassified data points within the circular domain of data P are grouped into cluster C. i ;

[0034] S25. Determine the total energy E of the three-phase voltage waveform. ABC If all data points have been classified, output the operating condition classification result and end the process; otherwise, return to step S22.

[0035] The beneficial effects of the above preferred solution are:

[0036] The DBSCAN clustering algorithm is used to perform cluster analysis on the total energy of three-phase voltage waveforms, which achieves effective classification of voltage and current waveform data. It can accurately detect changes in system operating status. At the same time, DBSCAN's anomaly detection capability can effectively remove abnormal data, ensuring the accuracy and reliability of the analysis results.

[0037] Preferably, the calculation formula for the standardization process in step S3 is:

[0038]

[0039] Where x represents the original data, x′ represents the standardized data, and x max x represents the maximum value in the original data sequence. min This represents the minimum value in the original data sequence.

[0040] The beneficial effects of the above preferred solution are:

[0041] Standardization can accelerate the convergence speed of gradient descent during Bi-LSTM model training.

[0042] Preferably, the Bi-LSTM model in step S4 includes an input layer, a forward LSTM layer, a backward LSTM layer, and an output layer; the input layer is connected to both the forward LSTM layer and the backward LSTM layer; the output layer is connected to both the forward LSTM layer and the backward LSTM layer.

[0043] The forward LSTM layer and the backward LSTM layer each include multiple LSTM units connected in series. Each LSTM unit includes a forget gate, an update gate, and an output gate connected in sequence.

[0044] The calculation formula for the LSTM unit is as follows:

[0045]

[0046] Among them, Γ f Indicates the output parameters of the forget gate; Γ u Indicates updating the output parameters of the gate; Γ o The output parameters of the output gate are represented by σ(·); the nonlinear activation function is represented by x. (t) This represents the input of the LSTM unit at the current time; c (t-1) c represents the memory unit from the previous moment. (t) The memory unit representing the current moment; This represents the memory representation corresponding to the input information at the current moment; a (t-1) This represents the output of the LSTM unit at the previous time step; a (t) Represents the output of the LSTM unit at the current time; tanh(·) represents the hyperbolic tangent function; W fa This represents the output 'a' of the LSTM unit at the previous time step after the forget gate. (t-1) The weight matrix W fx This represents the input x of the LSTM unit at the current time step of the forget gate. (t) The weight matrix W ua This indicates that the output 'a' of the LSTM unit at the previous time step of the update gate is being updated. (t-1) The weight matrix W ux This represents the input x of the LSTM unit at the current time of the update gate. (t) The weight matrix W oa This represents the output 'a' of the LSTM unit at the previous time step of the output gate. (t-1) The weight matrix W ox This represents the input x of the LSTM unit at the current time of the output gate. (t) The weight matrix W ca c (t-1) The output a of the LSTM unit at the previous time step (t-1) The weight matrix W cx c (t-1) The current input x of the LSTM unit(t) The weight matrix; b f The bias matrix representing the forget gate; b u b represents the bias matrix of the update gate; o b represents the bias matrix of the output gate; c c (t-1) The bias matrix.

[0047] The beneficial effects of the above preferred solution are:

[0048] The Bi-LSTM model can effectively learn the long-term dependencies of different time series data, better handle the gradient problem that may exist during neural network training, and add a backpropagation LSTM layer. The output is jointly determined by the forward LSTM layer and the backward LSTM layer, realizing the consideration of the correlation between future time data and current time output.

[0049] Preferably, the optimization of the network structure of the Bi-LSTM model in step S5 includes the optimization of the number of network layers and the number of neurons in each layer;

[0050] The optimization of the hyperparameters of the Bi-LSTM model includes optimization of the activation function, loss function, optimization algorithm, and learning rate.

[0051] Preferably, the loss function is the mean squared error, and its calculation formula is as follows:

[0052]

[0053] in, The mean squared error is represented by m; the number of training samples is represented by y; and the true value is represented by y. Indicates the predicted value; y i This represents the true value of the i-th training sample; This represents the predicted value of the i-th training sample.

[0054] Preferably, the optimization algorithm chosen is the adaptive moment estimation optimization algorithm, whose calculation formula is as follows:

[0055]

[0056] Where θ is the parameter to be optimized; t represents the number of times θ is updated; α t V represents the learning rate when the number of updates is t; α represents the initial learning rate; β1, β2, and ε are all adjustable hyperparameters. t S represents the first moment estimate of the gradient; t This represents the second-order moment estimate of the gradient.

[0057] The beneficial effects of the above preferred solution are:

[0058] By optimizing the number of network layers, the number of neurons per layer, the activation function, the loss function, the optimization algorithm, and the learning rate, the adaptability and generalization ability of the Bi-LSTM model are improved.

[0059] Preferably, when establishing the voltage-current mapping transfer model in step S6, the maximum mean deviation distance between the source and target domains, calculated based on the maximum mean deviation, is used as the initiation index for transfer learning.

[0060] The formula for calculating the maximum mean deviation is:

[0061]

[0062] in, The expression represents the squared form of the maximum mean deviation; k(·,·) represents the kernel function in the RKHS space; X T Represents the feature space of the target domain; X S(k) N represents the feature space of the candidate source domain; T Indicates the number of samples in the target domain; x i x represents the i-th sample in the target domain; j N represents the j-th sample in the target domain; S(k) Indicates the number of samples in the candidate source domain; Represents the j-th sample in the candidate source domain; Let i represent the i-th sample in the candidate source domain.

[0063] The beneficial effects of the above preferred solution are:

[0064] The essence of maximum mean deviation calculation is to map the features of sample data in the source and target domains from the original feature space to the RKHS space, and then calculate the distance between the data means of the target and source domains in the new space after mapping, which reduces the computational complexity. Attached Figure Description

[0065] Figure 1 The diagram shows a flowchart of a harmonic source modeling method based on Bi-LSTM and transfer learning. Detailed Implementation

[0066] Exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be understood that the embodiments shown and described in the drawings are merely exemplary and are intended to illustrate the principles and spirit of the invention, and are not intended to limit the scope of the invention.

[0067] Example 1, as Figure 1 As shown, a harmonic source modeling method using a bidirectional long short-term memory neural network (Bi-LSTM) and transfer learning includes the following steps:

[0068] S1. Collect voltage waveform data and current waveform data through monitoring devices, calculate the energy of each phase voltage waveform, and calculate the total energy of the three-phase voltage waveform based on the energy of each phase voltage waveform;

[0069] S2. Density-Based Spatial Clustering of Applications with Noise (DBSCAN) is used to perform cluster analysis on the total energy of the three-phase voltage waveform, dividing the voltage waveform data and current waveform data into multiple voltage-current datasets under different operating conditions;

[0070] S3. Preprocess and standardize the voltage-current dataset to obtain a standardized voltage-current dataset;

[0071] S4. Construct a Bi-LSTM model, and based on the Bi-LSTM model, select a standardized voltage-current dataset under a specific operating condition to establish a training dataset;

[0072] S5. Train the Bi-LSTM model using the training dataset, and optimize the network structure and hyperparameters of the Bi-LSTM model to obtain the voltage-current Bi-LSTM baseline model.

[0073] S6. Using the transfer learning method, some parameters in the voltage-current Bi-LSTM baseline model are transferred to the voltage-current dataset that was not involved in the model training, and a voltage-current mapping transfer model is established to complete the harmonic source modeling.

[0074] In this embodiment, the voltage waveform energy mentioned in step S1 represents the sum of the squares of the amplitudes of all sampling points of the periodic discrete voltage waveform within one period, reflecting the total energy of the voltage waveform within one period. The period of the signal is T, and the sampling frequency is f. s At that time, the number of sampling points in one period is N = T * f s The specific calculation method for voltage waveform energy is as follows:

[0075] S11. For continuous voltage signals, a fixed sampling frequency f s Sampling is performed to obtain the discrete signal v(n);

[0076] S12. Extract a data segment of one period from the discrete signal v(n);

[0077] S13. Squaring the amplitude of each sampling point within a data segment of one period yields the squared amplitude value v(n) for each sampling point. 2 ;

[0078] S14. The sum of the squared amplitude values ​​of all sampling points within one period is used to obtain the voltage waveform energy E. The formula for calculating the voltage waveform energy E is as follows:

[0079]

[0080] Where n represents the nth sampling point, and N represents the total number of sampling points in one period.

[0081] In this embodiment, the formula for calculating the total energy of the three-phase voltage waveform in step S1 is:

[0082] E ABC =E A +E B +E C

[0083] Among them, E ABC E represents the total energy of the three-phase voltage waveform. A E represents the energy of the phase A voltage waveform. B E represents the energy of the B-phase voltage waveform. C This represents the energy of the C-phase voltage waveform.

[0084] In this embodiment, the DBSCAN algorithm is used when the object radius E is given. ps and the minimum number of min P ts Under the condition of judging dataset E ABC Whether the data points meet the conditions, and effectively separate the data clusters of voltage waveform energy under different operating conditions, step S2 specifically includes the following steps:

[0085] S21. The total energy E of the three-phase voltage waveform ABC All data is marked as pending processing.

[0086] S22. The total energy E of the three-phase voltage waveform ABC Each data point P in the diagram is positioned at the center of a circle, and E is set to... ps Draw a circle with a radius to obtain a circular region containing different numbers of objects;

[0087] S23. Determine whether the number of objects contained in the circular region of data P is less than the preset minimum number min P. ts If yes, mark the data P as a boundary point or noise point and proceed to step S25; otherwise, proceed to step S24.

[0088] S24. Mark data point P as the core data point and establish cluster C. i Unclassified data points within the circular domain of data P are grouped into cluster C. i ;

[0089] S25. Determine the total energy E of the three-phase voltage waveform.ABC If all data points have been classified, output the operating condition classification result and end the process; otherwise, return to step S22.

[0090] In this embodiment, the sum of squared errors (SSE) is used as the evaluation index for clustering performance. The sum of squared errors is calculated by measuring the Euclidean distance d from all subclasses to the corresponding cluster center. SSE To evaluate the clustering effect, the d SSE The calculation formula is:

[0091]

[0092] Where L represents the number of cluster partitions, c i d(c) represents the cluster center of cluster χ. i ,χ) represents the Euclidean distance between vectors. The clustering effect is closely related to L. As L dynamically increases from 1 to the number of real-world time periods k, d SSE It will decrease accordingly; when the value of L exceeds the value of k and then increases, d SSE The trend will tend to level off and may increase slightly; the inflection point will be considered the optimal clustering point.

[0093] In this embodiment, the calculation formula for the standardization process in step S3 is:

[0094]

[0095] Where x represents the original data, x′ represents the standardized data, and x max x represents the maximum value in the original data sequence. min This represents the minimum value in the original data sequence.

[0096] In this embodiment, the Bi-LSTM model in step S4 includes an input layer, a forward LSTM layer, a backward LSTM layer, and an output layer; the input layer is connected to both the forward LSTM layer and the backward LSTM layer; the output layer is connected to both the forward LSTM layer and the backward LSTM layer.

[0097] The forward LSTM layer and the backward LSTM layer each include multiple LSTM units connected in series. Each LSTM unit includes a forget gate, an update gate, and an output gate connected in sequence. The three-gate structure uses the current input x... (t) and the output a from the previous time step (t-1) As input, the output value of the gate structure is controlled between 0 and 1 using the Sigmoid function. The output value of the forget gate will be compared with the neuron state c from the previous time step. (t-1) Multiplication is used to achieve the effect of forgetting part of the memory from the previous moment; the updated gate output value is then compared with the output value of the tanh(·) function. The components are multiplied and then added to the neuron state function that has passed through the forget gate, adding the information of the current input to the neuron state; the output gate is used to control the output at the current time.

[0098] The calculation formula for the LSTM unit is as follows:

[0099]

[0100] Among them, Γ f Indicates the output parameters of the forget gate; Γ u Indicates updating the output parameters of the gate; Γ o The output parameters of the output gate are represented by σ(·); the nonlinear activation function is represented by x. (t) This represents the input of the LSTM unit at the current time; c (t-1) c represents the memory unit from the previous moment. (t) The memory unit representing the current moment; This represents the memory representation corresponding to the input information at the current moment; a (t-1) This represents the output of the LSTM unit at the previous time step; a (t) Represents the output of the LSTM unit at the current time; tanh(·) represents the hyperbolic tangent function; W fa This represents the output 'a' of the LSTM unit at the previous time step after the forget gate. (t-1) The weight matrix W fx This represents the input x of the LSTM unit at the current time step of the forget gate. (t) The weight matrix W ua This indicates that the output 'a' of the LSTM unit at the previous time step of the update gate is being updated. (t-1) The weight matrix W ux This represents the input x of the LSTM unit at the current time of the update gate. (t) The weight matrix W oa This represents the output 'a' of the LSTM unit at the previous time step of the output gate. (t-1) The weight matrix W ox This represents the input x of the LSTM unit at the current time of the output gate. (t) The weight matrix W ca c (t-1) The output a of the LSTM unit at the previous time step (t-1) The weight matrix W cx c (t-1) The current input x of the LSTM unit (t) The weight matrix; b f The bias matrix representing the forget gate; b u b represents the bias matrix of the update gate; o b represents the bias matrix of the output gate; c c (t-1) The bias matrix.

[0101] In this embodiment, the optimization of the network structure of the Bi-LSTM model in step S5 includes the optimization of the number of network layers and the number of neurons per layer;

[0102] The optimization of the hyperparameters of the Bi-LSTM model includes the optimization of the activation function, loss function, optimization algorithm, and learning rate; the activation functions include the Sigmoid function, Tanh function, and ReLU function, etc.

[0103] In this embodiment, the loss function is chosen as mean squared error, and its calculation formula is as follows:

[0104]

[0105] in, The mean squared error is represented by m; the number of training samples is represented by y; and the true value is represented by y. Indicates the predicted value; y i This represents the true value of the i-th training sample; This represents the predicted value of the i-th training sample.

[0106] In this embodiment, the optimization algorithm selected is the adaptive moment estimation optimization algorithm, and its calculation formula is as follows:

[0107]

[0108] Where θ is the parameter to be optimized; t represents the number of times θ is updated; α t Let represent the learning rate when the number of updates is t; α represents the initial learning rate; β1, β2, and ε are all adjustable hyperparameters, typically taken as β1 = 0.9, β2 = 0.999, and ε = 1 × 10⁻⁶. -8 V t S represents the first moment estimate of the gradient; t This represents the second-order moment estimate of the gradient.

[0109] In this embodiment, transfer learning is defined as: given a source domain D s ={X s ,P(X s The learning task T corresponding to the source domain s ={Y s f s (·)}、Target Domain D t ={X t Q(X) t )} and the learning task T corresponding to the target domain t ={Y t f t (·)}, the purpose of transfer learning is to acquire the source domain D s and learning task Ts The implicit knowledge is used to improve the target domain D t The prediction function f t The learning efficiency of (·), where D s ≠D t Or T s ≠T t .

[0110] In step S6, when establishing the voltage-current mapping transfer model, the maximum mean deviation distance between the source and target neighborhoods, calculated based on the maximum mean deviation (MMD), is used as the priming metric for transfer learning. The distance metric based on the maximum mean deviation can measure the distribution P(X) in the Reproducing Kernel Hilbert Space (RKHS). T ) and P(X S(k) The magnitude of the difference between them;

[0111] The formula for calculating the maximum mean deviation is:

[0112]

[0113] in, The feature mapping function from the original feature space to the RKHS space; Let represent the RKHS norm. In RKHS space, the kernel function... Therefore, the formula for calculating the maximum mean deviation can be written as:

[0114]

[0115] in, The expression represents the squared form of the maximum mean deviation; k(·,·) represents the kernel function in the RKHS space; X T Represents the feature space of the target domain; X S(k) N represents the feature space of the candidate source domain; T Indicates the number of samples in the target domain; x i x represents the i-th sample in the target domain; j N represents the j-th sample in the target domain; S(k) Indicates the number of samples in the candidate source domain; Represents the j-th sample in the candidate source domain; Let i represent the i-th sample in the candidate source domain.

[0116] The smaller the difference between the two distributions, the higher the MMD value. The closer to 0, the greater the value; conversely, the further away from 0, the greater the value, if and only if the two distributions are identical. It is 0.

[0117] Example 2: A simulation model of VSC connected to an AC power grid was built using MATLAB / Simulink software. The simulation time was set to 24 seconds. Perturbations were injected at 6, 12, and 18 seconds to simulate and obtain multi-condition voltage and current waveform data at point PCC1. The simulation generated four stages of data divided into three operating conditions, each lasting 6 seconds, and obtained operating condition clustering results based on waveform energy. To accelerate the convergence speed of gradient descent during network training, the voltage and current waveform data were standardized, linearly transforming their values ​​to 0–1.

[0118] Based on the requirements for input and output data size during Bi-LSTM model training, this embodiment uses a sequence of three-phase voltage waveform amplitude data at a certain moment with a sequence length of 128 as input and a sequence of three-phase current waveform amplitude data at the corresponding moment with a sequence length of 128 as output. Taking a sampling interval of one data point, a sliding window sampling is performed on the standardized voltage-current time series, ultimately obtaining 184,320 pairs of input and output data.

[0119] The dataset was divided into a training set (50%, 92,160 pairs), a validation set (20%, 36,864 pairs), and a test set (30%, 55,296 pairs). The training set was used to train the network model; the validation set was used to evaluate whether the network model had overfitting or underfitting issues; and the test set was used to verify the generalization ability of the network model.

[0120] The computer hardware configuration used was as follows: CPU 12th Gen Intel(R) Core(TM) i5-12400F, memory 16GB. The PyTorch deep learning framework, version PyTorch-2.2.1, and the programming language was Python 3.11.8 were used for neural network training and validation.

[0121] Using three-phase voltage waveform data as input and corresponding three-phase current waveform data as output, a voltage-current dataset is constructed. The neural network is trained multiple times using different network structures and hyperparameter settings to obtain the neural network model with the best fitting effect, which is the benchmark model for operating condition I1. Its model structure and hyperparameter values ​​are shown in Table 1 and Table 2, respectively.

[0122] Table 1. Benchmark Model Structure

[0123]

[0124] Table 2. Hyperparameter values ​​of the baseline model

[0125]

[0126] The three Bi-LSTM layers in the model under specified operating condition I1 were designated as transfer layers. The parameters of these transfer layers were transferred to the corresponding layers of the network to be trained. Multiple training iterations were performed on a dataset consisting of voltage and current waveform data under other operating conditions, considering both non-transfer layer network structure and hyperparameter optimization. The mapping model with the best fit was selected to construct the transferred model, as shown in Table 3 as Transfer Model 1 and Transfer Model 2. Compared to Transfer Model 1, Transfer Model 2 further optimized the network structure and hyperparameters of its non-transfer layers.

[0127] Furthermore, without employing transfer learning, multiple neural network training sessions were conducted directly on a dataset composed of voltage and current waveform data from other operating conditions. The mapping model with the best fitting effect was selected, and two control models were established, as shown in Table 3: Control Model 1 and Control Model 2. Control Model 1 and Control Model 2 adopted the network structures and hyperparameter settings of the corresponding transferred models 1 and 2, respectively, to compare the impact of transfer learning on the training time and results of the neural network models. It is worth noting that, to explore the impact of data size on the method proposed in this invention, the data size of the transferred models and control models for other operating conditions, except for the baseline model, was set to be 1 / 4 of the baseline model's data size, i.e., training set (50%, 23040 pairs), validation set (20%, 9216 pairs), and test set (30%, 13824 pairs).

[0128] In this embodiment, the results of the benchmark model are analyzed. One of the prerequisites for applying transfer learning is that the established benchmark model should be able to reflect the mapping relationship between data well. The quality of the benchmark model's fit to the data mapping relationship will directly affect the fit of the transferred model to similar data mapping relationships.

[0129] Simulations of the training process of the I1 benchmark model under operating conditions show that the loss function of the I1 benchmark model has converged to a small value, and there are no overfitting or underfitting problems. The predicted current waveform based on the I1 benchmark model under operating conditions matches the measured current waveform well. The prediction error range of the benchmark model is -0.15 to 0.14. In the I1 model, 78.74% and 92.58% of the prediction data errors are in the range of -0.3 to 0.3 and -0.5 to 0.5, respectively.

[0130] The results of the transferred models were analyzed, and the neural network models and their training results are shown in Table 3. Table 3 shows that when the neural network structure and hyperparameter settings are the same, the training time of the transferred model trained using the transfer learning method is significantly shorter than that of the directly trained control model. This is because the transferred model directly transfers the pre-trained parameters of the transfer layers in the baseline model, greatly reducing the number of parameters to be trained. Taking condition I3 in Table 3 as an example, the directly trained I3-3 control model has 466,755 parameters to be trained and requires 25.4 seconds of training time. However, the I3-1 transferred model, because it transfers the pre-trained parameters of the three Bi-LSTM layers in the I1 baseline model, only needs to train 10,563 parameters (Dense 1, Dense 2, and the output layer), with a training time of 3.7 seconds, reducing the training time to approximately 1 / 7 of the original.

[0131] Table 3 Neural Network Models and Their Training Results

[0132]

[0133] For the transferred model 1 and the control model 1, as shown in Table 3, the final loss function value of the transferred model trained using the transfer learning method is smaller than that of the control model trained without the transfer learning method, indicating that the transferred model has a better fitting effect than the control model. This phenomenon can be attributed to the fact that during the parameter transfer process, when the structure of the transferred network is completely consistent with the network structure of the baseline model, all parameters of the baseline model can be transferred to the transferred network (including non-transfer layers), while only the parameters of the transfer layers are frozen, and the remaining layers are trained using the transferred parameters as the initial parameters of the model. Compared with the control model, the network parameters of the transferred model have undergone a similar model pre-training process. At this time, the values ​​of the parameters to be trained in the transferred model are closer to the optimal solution than the randomly initialized parameter values. Therefore, the transferred model has a better fitting effect than the control model.

[0134] For the transferred model 2 and the transferred model 1, Table 3 shows that the fitting effect of the transferred model 2 is better than that of the transferred model 1. This is because, compared with the transferred model 1, the non-transfer layer network structure and hyperparameters of the transferred model 2 have been further optimized, making it more suitable for fitting the voltage-current waveform mapping relationship under this operating condition. Taking operating condition I3 as an example, compared with the constructed transferred model 1 (i.e., model I3-1), the number of neurons in the non-transfer layers (i.e., Dense 1, Dense 2, and output layer) of the transferred model 2 (i.e., model I3-2) has been optimized from 64, 64, 1 to 96, 96, 1, respectively, and the number of training steps has been optimized from 20 to 100. Therefore, the fitting effect of the transferred model 2 is better.

[0135] Further comparison in Table 3 between the transferred model 2 and the control model 2 reveals that the transferred model 2 has a wider parameter optimization space compared to the control model 2. Taking scenario I3 as an example, the model fit is better when the training steps for I3-2 reach 100 steps, with a training time of 31.7 seconds, while the control model 2 takes 20.1 seconds to train with only 20 steps. It is known that when the network structure and other hyperparameter settings are consistent, the training time is directly proportional to the number of training steps. With the same number of training steps, the control model 2 incurs a higher time cost for network structure and hyperparameter optimization. Therefore, compared to the control model 2, the transferred model 2 has a wider parameter optimization space.

[0136] Those skilled in the art will recognize that the embodiments described herein are intended to help the reader understand the principles of the invention, and should be understood that the scope of protection of the invention is not limited to such specific statements and embodiments. Those skilled in the art can make various other specific modifications and combinations based on the technical teachings disclosed in this invention without departing from the spirit of the invention, and these modifications and combinations are still within the scope of protection of this invention.

Claims

1. A harmonic source modeling method based on Bi-LSTM and transfer learning, characterized in that, Includes the following steps: S1. Collect voltage waveform data and current waveform data through monitoring devices, calculate the energy of each phase voltage waveform, and calculate the total energy of the three-phase voltage waveform based on the energy of each phase voltage waveform; S2. The DBSCAN clustering algorithm is used to perform cluster analysis on the total energy of the three-phase voltage waveform, and the voltage waveform data and current waveform data are divided into multiple voltage-current datasets under different operating conditions. S3. Preprocess and standardize the voltage-current dataset to obtain a standardized voltage-current dataset; S4. Construct a Bi-LSTM model, and based on the Bi-LSTM model, select a standardized voltage-current dataset under a specific operating condition to establish a training dataset; S5. Train the Bi-LSTM model using the training dataset, and optimize the network structure and hyperparameters of the Bi-LSTM model to obtain the voltage-current Bi-LSTM baseline model. S6. Using the transfer learning method, some parameters in the voltage-current Bi-LSTM baseline model are transferred to the voltage-current dataset that was not involved in the model training, and a voltage-current mapping transfer model is established to complete the harmonic source modeling.

2. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that, The voltage waveform energy mentioned in step S1 represents the sum of the squares of the amplitudes of all sampling points of a periodic discrete voltage waveform within one period. The specific calculation method is as follows: S11. For continuous voltage signals, a fixed sampling frequency f s Sampling is performed to obtain the discrete signal v(n); S12. Extract a data segment of one period from the discrete signal v(n); S13. Squaring the amplitude of each sampling point within a data segment of one period yields the squared amplitude value v(n) for each sampling point. 2 ; S14. The sum of the squared amplitude values ​​of all sampling points within one period is used to obtain the voltage waveform energy E. The formula for calculating the voltage waveform energy E is as follows: Where n represents the nth sampling point, and N represents the total number of sampling points in one period.

3. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that, The formula for calculating the total energy of the three-phase voltage waveform in step S1 is as follows: AND ABC =And A +E B +E C Among them, E ABC E represents the total energy of the three-phase voltage waveform. A E represents the energy of the phase A voltage waveform. B E represents the energy of the B-phase voltage waveform. C This represents the energy of the C-phase voltage waveform.

4. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that, Step S2 specifically includes the following steps: S21. The total energy E of the three-phase voltage waveform ABC All data is marked as pending processing. S22. The total energy E of the three-phase voltage waveform ABC Each data point P in the diagram is positioned at the center of a circle, and E is set to... ps Draw a circle with a radius to obtain a circular region containing different numbers of objects; S23. Determine whether the number of objects contained in the circular region of data P is less than the preset minimum number min P. ts If yes, mark the data P as a boundary point or noise point and proceed to step S25; otherwise, proceed to step S24. S24. Mark data point P as the core data point and establish cluster C. i Unclassified data points within the circular domain of data P are grouped into cluster C. i ; S25. Determine the total energy E of the three-phase voltage waveform. ABC If all data points have been classified, output the operating condition classification result and end the process; otherwise, return to step S22.

5. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that, The calculation formula for the standardization process in step S3 is as follows: Where x represents the original data, x′ represents the standardized data, and x max x represents the maximum value in the original data sequence. min This represents the minimum value in the original data sequence.

6. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that, The Bi-LSTM model described in step S4 includes an input layer, a forward LSTM layer, a backward LSTM layer, and an output layer; the input layer is connected to both the forward LSTM layer and the backward LSTM layer; the output layer is connected to both the forward LSTM layer and the backward LSTM layer. The forward LSTM layer and the backward LSTM layer each include multiple LSTM units connected in series. Each LSTM unit includes a forget gate, an update gate, and an output gate connected in sequence. The calculation formula for the LSTM unit is as follows: Among them, Γ f Indicates the output parameters of the forget gate; Γ u Indicates updating the output parameters of the gate; Γ o The output parameters of the output gate are represented by σ(·); the nonlinear activation function is represented by x. (t) This represents the input of the LSTM unit at the current time; c (t-1) c represents the memory unit from the previous moment. (t) The memory unit representing the current moment; This represents the memory representation corresponding to the input information at the current moment; a (t-1) This represents the output of the LSTM unit at the previous time step; a (t) Represents the output of the LSTM unit at the current time; tanh(·) represents the hyperbolic tangent function; W fa This represents the output 'a' of the LSTM unit at the previous time step after the forget gate. (t-1) The weight matrix W fx This represents the input x of the LSTM unit at the current time step of the forget gate. (t) The weight matrix W ua This indicates that the output 'a' of the LSTM unit at the previous time step of the update gate is being updated. (t-1) The weight matrix W ux This represents the input x of the LSTM unit at the current time of the update gate. (t) The weight matrix W oa This represents the output 'a' of the LSTM unit at the previous time step of the output gate. (t-1) The weight matrix W ox This represents the input x of the LSTM unit at the current time of the output gate. (t) The weight matrix W ca c (t -1) The output a of the LSTM unit at the previous time step (t-1) The weight matrix W cx c (t-1) The current input x of the LSTM unit (t) The weight matrix; b f The bias matrix representing the forget gate; b u b represents the bias matrix of the update gate; o b represents the bias matrix of the output gate; c c (t-1) The bias matrix.

7. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that, The optimization of the network structure of the Bi-LSTM model described in step S5 includes optimizing the number of network layers and the number of neurons per layer; The optimization of the hyperparameters of the Bi-LSTM model includes optimization of the activation function, loss function, optimization algorithm, and learning rate.

8. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 7, characterized in that, The loss function chosen is the mean squared error, and its calculation formula is as follows: in, The mean squared error is represented by m; the number of training samples is represented by y; and the true value is represented by y. Indicates the predicted value; y i This represents the true value of the i-th training sample; This represents the predicted value of the i-th training sample.

9. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 7, characterized in that, The optimization algorithm selected is the adaptive moment estimation optimization algorithm, and its calculation formula is as follows: Where θ is the parameter to be optimized; t represents the number of times θ is updated; α t V represents the learning rate when the number of updates is t; α represents the initial learning rate; β1, β2, and ε are all adjustable hyperparameters. t S represents the first moment estimate of the gradient; t This represents the second-order moment estimate of the gradient.

10. The harmonic source modeling method based on Bi-LSTM and transfer learning according to claim 1, characterized in that, In step S6, when establishing the voltage-current mapping transfer model, the maximum mean deviation distance between the source and target domains, calculated based on the maximum mean deviation, is used as the activating metric for transfer learning. The formula for calculating the maximum mean deviation is: in, The expression represents the squared form of the maximum mean deviation; k(·,·) represents the kernel function in the RKHS space; X T Represents the feature space of the target domain; X S(k) N represents the feature space of the candidate source domain; T Indicates the number of samples in the target domain; x i x represents the i-th sample in the target domain; j N represents the j-th sample in the target domain; S(k) Indicates the number of samples in the candidate source domain; Represents the j-th sample in the candidate source domain; Let i represent the i-th sample in the candidate source domain.

Citation Information

Patent Citations

  • Method for diagnosing faults of three-level inverters on basis of empirical mode decomposition and decision-making tree RVM (relevant vector machines)

    CN106682303A

  • Power amplifier harmonic prediction method based on transfer learning

    CN116596061A