A Layering Linear Discriminant Analysis-Based Fault Diagnosis Method for Grid-Connected Inverter

: Grid-connected inverters are the core equipment for connecting marine energy power generation systems to the public electric utility. The variation of current sensor fault severity will make fault samples multimodal. However, linear discriminant analysis assumes that the same fault is independent and identically distributed. To solve this problem, this paper proposes a layering linear discriminant analysis method based on traditional linear discriminant analysis. The proposed method divides the historical fault data based on the sensor fault severity layer-by-layer until the distribution of the same fault category in each subset is very close. Linear discriminant analysis is used to analyze historical fault data in each subgroup, and the kappa coefﬁcient is applied as the basis for ending the training process. A BP neural network is employed to estimate the fault severity during the testing process, and the fault diagnosis sub-model is selected. The proposed method enables the accurate diagnosis of faults with different distributions in the same category and provides an accurate estimate of the sensor’s fault severity degree. The estimated value of the sensor’s fault degree can provide critical information for the maintenance of the equipment and can be used to correct the sensor’s output.


Introduction
In recent years, ocean energy has attracted more attention due to its reproducibility, cleanness, and vast reserves [1,2]. Ocean energy includes wave energy, tidal energy, and ocean current energy [3,4]. Unfortunately, ocean energy conversion systems, as either immersed or floating systems, are affected by severe constraints due to their geographical location and weather conditions. These constraints lead to ocean energy systems potentially suffering from a high failure rate, mainly related to the mechanical parts, the electric generator, and even the power converters. In this context, the cascaded H-bridge inverter is favored for the electrical energy transmission of ocean energy fields due to its characteristics of easy modularization and convenient expansion of level numbers [5]. Due to the unstable output of ocean power generation, the power transmitted by the inverter fluctuates, aggravating the material's temperature cycle in the power semiconductor switches. Temperature cycle, mechanical vibration, and electromagnetic interference can damage the power semiconductor switch and current sensor [6,7]. The failure of power switches causes distortions in the inverter's output voltage and deteriorates the safety of other healthy components in the system [8]. The measurement errors caused by the current sensor fault propagate in the control loop through feedback [9]. These errors continue to accumulate and act on the driving module of the switch through the controller's signals, disrupting the normal operation of the power switch and then causing compound failure or even leading to secondary accidents. Therefore, it is of great significance to study the open-circuit and current sensor faults in the grid-connected inverter to improve the reliability and stability of the whole system [10,11].
The analytical model-based method uses state variables to infer other variables that characterize the system's operation status [12]. This method compares the estimated and actual values to locate the fault [13]. The signal-based fault diagnosis method depends on the signal distortion caused by the fault [14]. The distinguishing fault features are extracted by signal processing methods such as Fourier transform [15][16][17], wavelet decomposition [18,19], and variational modal decomposition [20,21]. The extracted features are often used as input for an intelligent algorithm, and the intelligent algorithm finally identifies the fault types. Compared with model-based and signal processing-based fault diagnosis methods, datadriven fault diagnosis methods are more suitable for applications with complex system structures. Data-driven fault diagnosis methods can be divided into fault feature extraction and identification based on intelligent algorithms [22]. The feature extraction method extracts the features that represent the system's operating state from the monitoring signals. An intelligent algorithm locates the fault by analyzing the fault characteristics, such as BP network, extreme learning machine, support vector machine, etc. A BP neural network is a multilayer network with back-propagation errors that adjust weights and thresholds to learn input-to-output mappings. BP networks are theoretically capable of learning arbitrary nonlinear mapping relationships. Many different optimization algorithms have been proposed to improve the effectiveness of BP networks by optimizing the initial weights and thresholds [23,24].
Because of their effectiveness and easy implementation, scholars frequently make use of multivariate statistical analysis methods in feature extraction, such as principal component analysis, independent component analysis, and linear discriminant analysis [25]. These methods reduce the data dimension as much as possible on the premise of retaining sufficient fault information, thereby reducing the complexity of the model. Cai et al. [26] used principal component analysis (PCA) to extract the main feature components. The extracted data only reflect the projections that maximize the variance in the traditional PCA method. Wang et al. [27] used robust principal component analysis (RPCA) to extract fault features, adding weight factors to change the original PCA projection matrix so that the projected variables can better distinguish similar faults. The literature [28] shows that variable selection based on linear discriminant analysis can improve diagnostic accuracy while reducing the complexity of the model. With the continuous development of equipment, the complexity of sample data is also increasing, and the performance of traditional linear discriminant analysis methods has declined. The system's nonlinear, non-Gaussian, and multimodal properties are indexed as the main reasons for the performance degradation of these methods. The nonlinear characteristics of the system make the linear method unable to complete high-precision fault diagnosis. Reference [29] first performs a nonlinear transformation on the sample, then performs principal component analysis, and finally realizes the nonlinear principal component analysis of the original sample. This method is based on the assumption that the principal components are Gaussian distributed. In another study, a new monitoring statistic was constructed by introducing a local anomaly factor, which can find anomalous outliers in the given sample under any data distribution [30]. Regarding the non-Gaussian nature of samples, Reference [31] divides the non-Gaussian sample data into several Gaussian distribution subsets, and then each subset is analyzed. Tests on synthetic and natural datasets show that the method can significantly reduce the influence of non-Gaussian data distribution.
Affected by equipment operating states or different fault degrees, fault data belonging to the same fault category may exhibit multimodal characteristics [32]. One study from the literature [33] considers the global information represented by the between-class and within-class matrices. It uses the reverse nearest neighbor to mine the local details in the sample data, enabling the method to better describe faults containing multimodal sample data. Reference [34] takes the neighborhood of the sample as the smallest subset through the reverse nearest neighbor, which can explain multimodal data in more detail.
In the event of a current sensor fault, multimodal data also appear. Under the influence of closed-loop control, the change in the sensor fault degree significantly impacts the fault signal. Moreover, the information on the fault degree of the sensor has important guiding significance for the overhaul and maintenance of the equipment.
Few methods can simultaneously diagnose open-circuit and current sensor faults. Gou et al. [35] consider these two types of fault in the three-phase inverter of an asynchronous motor, ignoring the fault severity degree variation. Variations in the fault severity degree can lead to significant differences in the dispersion of data for different faults, which reduces the diagnostic accuracy. This paper proposes a fault diagnosis method for grid-connected inverters based on layering linear discriminant analysis (LLDA) to solve these problems. The basic idea of this paper is to divide the historical fault data into several subsets according to the current sensor's fault degree in a layering manner in the offline modeling process and to use linear discriminant analysis to extract the features of these subsets. As the number of layers increases, the number of subsets will also increase, and the difference in the fault degree in each subset will be smaller. We use the kappa coefficient as the evaluation index to build multiple fault diagnosis sub-models gradually. A BP neural network estimates the fault severity degree of the sample, and the fault diagnosis sub-model to which it belongs is identified based on the estimation result.
The rest of this paper is organized as follows. Section 2 describes the effect of the multimodality of the sample data. Section 3 details the composition of the proposed method. Section 4 presents the experimental platform and results, and Section 5 gives the conclusions. Figure 1 shows a typical three-phase, three-wire, voltage source grid-connected inverter. Each phase consists of two H-bridges, and each H-bridge is supplied by a DC source. Three current sensors are placed on the AC side to measure the currents for the closed-loop control. The controller adjusts the IGBT drive signal according to the feedback information of the current sensor and controls the output voltage of the inverter. Sensor failure is manifested as a difference between the measured value and the actual operating state of the system. In a closed-loop system, measurement errors can cause the control signal to deviate from its expected value through a feedback loop. Under the effect of the abnormal control signal, abnormal signs can also appear in other healthy sensors, and this poses a challenge for fault diagnosis and isolation of sensor faults. There are two common fault types in the current sensor: gain-variation fault and zero-offset fault, which are defined in Equations (1) and (2), respectively.

Problem Description
where I x_gain is the output of the current sensor in gain-variation fault, I x_offset is the output of the current sensor in zero-offset fault, i x is the actual current in the circuit, ε x is the variation of the gain, D x is the sensor's offset, and x represents the phase. Under the normal case, ε x and D x are both zero, and the measured value of the sensor is a true reflection of the current in the circuit. While a zero-offset fault causes significant DC components in the three-phase currents, a gain-variation fault changes the amplitudes of the three-phase currents.
In the d-q coordinate system, two PI controllers are used to perform feedback current control with decoupling terms for producing voltage references, as shown in Figure 2. i * d and i * q are the reference currents on the d-q coordinates, respectively, ω is the angular frequency of the grid, and E d and E q are the grid voltages in the d-q coordinate system, respectively. In the sensor fault, the current fed back to the controller changes from i d , i q to I d , I q . A current sensor failure makes the three-phase current measurements no longer symmetrical, so I d and I q can have AC components. Under the adjustment of the PI controller, u d and u q also become AC components. u d and u q cause fluctuations in i d and i q , and the grid-connected inverter will simultaneously transmit fluctuating active and reactive power into the public electric utility, threatening the public electric utility. The severity degree of the sensor fault can be considered constant over a short period. However, the severity degree can change due to nonlinear effects such as the sensor usage time, device temperature drift in the power supply, and signal conditioning circuits. The variation of the fault degree will make the fault samples more dispersed. The average and standard deviation reflect the distribution of the samples [36]. The current power frequency and DC components are strongly influenced by gain-variation fault and zero-offset fault, respectively, so these are chosen to calculate the range and standard deviation separately. The samples were normalized based on z-score before calculating the average and standard deviation of the samples. Table 1 shows the range and standard deviation under different fault severity degrees. The range and standard deviation of the samples are more significant when the fault severity varies over a broader range, implying a higher dispersion degree of the samples.    Figure 3 shows the performance of LDA under multimodal data. In this figure, the variance of the first type of faults is considerable in the second-dimensional feature. Due to the high dispersion of fault type 1, there is a significant error in using the mean value of each variable to inscribe the center of the category. In the traditional LDA method, the projection is in the direction perpendicular to the second-dimensional part to obtain a minor withinclass distance. However, there is a partial overlap region between the second and third types of faults after projection. When the samples of the same fault are not independent and identically distributed, it is difficult to obtain the minimum within-class distance while guaranteeing the maximum between-class distance. Traditional LDA ignores the difference in dispersion caused by the variation of fault severity degrees. Because the main influences on fault data distribution are gain-variation and offset, this paper proposes dividing the current sensor fault data into layers according to the values of ε x and D x . Finally, the dispersion of feature data for different categories is relatively close within each subset.

The LLDA-Based Fault Diagnosis Method for Grid-Connected Inverter
The proposed fault diagnosis method includes the establishment and evaluation of layering linear discriminant analysis, followed by fault severity degree estimation based on a BP neural network.

Basic Principles of LDA
LDA is a classical dimension reduction method [36], which expects data in the same category to be as close as possible and can better reflect the differences between data. The combination of LDA and probability mode can realize fault classification. Multi-class LDA can be achieved by optimizing the following objectives: where ∏ diag A is the product of the diagonal elements of A, W is a matrix of n × d, S b is the between-class scatter matrix, and S W is the within-class scatter matrix. m i is the number of samples for the i-th class fault, µ i is the average vector of the i-th class, and µ is the mean vector of the total samples.
After obtaining the projection data for each fault type, the maximum likelihood estimation can be used to calculate the mean and variance of each fault.
where X i is the i-th sample in each fault, and K represents the number of each fault. When a new fault sample appears, each fault's distribution probability density function calculates the probability that the current fault sample belongs to that fault type. The class corresponding to the maximum probability is the prediction class. The probability density function is shown below.
where d represents the dimensions of fault features, and ∑ is the covariance matrix of training samples for each class.

Establishment and Evaluation of Layering Diagnostic Model Based on Linear Discriminant Analysis
The fault diagnosis model is trained in layers based on LDA in this part. The proposed method builds a fault diagnosis model hierarchically and progressively. The fault data are firstly divided based on the current sensor's fault severity degree, and then the diagnostic model's kappa statistic is used as the layering termination criterion. When building a layering fault diagnosis model based on linear discriminant analysis, historical fault data need to be divided. Figure 4 depicts the division process of historical fault data in a 4-layer structure. This uses ε x and D x as the division basis to build a layering fault diagnosis model. The sensor fault data are first separated from other faults in the dividing process. After each layer finishes dividing the data, a part of the data in each subset is extracted to train the LDA. Another part of the data is used as test data to verify the performance of the diagnostic model. In the proposed method, the division process of historical fault data is repeated until the diagnostic model meets the conditions. There will be lower dispersion of fault data in each fault subset with more layers, resulting in higher diagnostic accuracy. In the division of sensor fault data, ε x and D x are used to separate gain and offset historical fault data. The farther the values of ε x and D x deviate from zero, the more severe the failure. In decomposing from 2-layer to 3-layer, III.2 contains relatively severe gain-variation and zero-offset faults, and III.1 includes samples of relatively minor severity.

Evaluation of Diagnostic Models Based on Kappa Statistic
In dividing the fault data and building a layering diagnosis model, the evaluation of the diagnosis model is crucial. For this purpose, we apply the kappa statistic to evaluate the model. The kappa coefficient was proposed by Cohen et al. and is a statistic that reflects the agreement between the measured and actual variables [37]. In fault classification, it can be used to determine whether the output results of the diagnostic model are consistent with the actual results. The higher k is, the higher the agreement between the two results is, with values in the range of 0-0.2 indicating low agreement and values in the range of 0.8-1 indicating almost complete agreement. The calculation of the kappa coefficient is where p o is the overall diagnostic accuracy, and p e can be calculated through Equation (9). N is the number of samples, m is the number of fault types, x i denotes the total number of samples whose predicted outcome is the i-th fault, and X i is the total number of the i-th fault in the actual results.

Fault Severity Degree Estimation Based on BP Neural Network
Since the division of fault data and the creation of the diagnostic model are based on the fault severity degree, the values of ε x and D x need to be estimated when a new fault signal appears. There is a nonlinear relationship between the magnitudes and average values of the three-phase currents with ε x and D x . Since the BP neural network method has a powerful nonlinear fitting ability, it is applied in this work to estimate the fault severity degree.
As shown in Figure 5, the neural network has three input neurons and one output neuron. When the command current of the system is stable, When the command current of the system is stable, under the action of closed-loop control, the average values of the three-phase currents are zero. In the zero-offset fault, DC components in the three-phase currents are unavoidable. So, in estimating the offset, the input to the neural network is the average values of the three-phase currents, and the output is the estimated value of the offset. I x is calculated through Equation (10), and I x is the output of the current sensor. N is the number of sampling points in a grid cycle. During the system's real-time operation, to obtain a faster diagnosis speed, the calculation of I x is also continuously performed. To calculate I x in a sliding window manner, the length of the window is the fundamental period of the grid, and the sliding step of the window is one control period. The gain-variation fault and the variation of command current can both change the amplitudes of the three-phase currents, and it is difficult to extract the amplitudes due to measurement noise. The integral of the absolute current value in (11) can also reflect the current's amplitude. Unlike load-variation, the gain-variation fault causes the amplitudes to be different. The three-phase currents will remain symmetrical under the closed-loop control when the load changes, so k x is close to 1. However, under the gain fault, k x is no longer close to 1 and has a close relationship with the degree of gain-variation. The variable k x shown in Equation (11) is finally chosen to estimate the gain-variation to eliminate the effect of command current variation. Figure 6 shows the flowchart of the proposed fault diagnosis method based on LLDA. The starting point of the proposed method is to divide the fault data into layers, so that the dispersion of the fault data in each layer is relatively low. When the degree of dispersion of different faults is relatively low, the error caused by using the mean value of each variable to represent the cluster center is also relatively reduced. The proposed method consists of a training process and a testing process. In the training process, the Fourier transform is used to obtain the fault characteristics implied in the three-phase currents. After the historical fault data have been divided into layers, a part of the data is used as training data to train the LDA. The building of the layering diagnosis model continues until the stopping condition is met. In the testing process, the BP neural network is used to estimate the fault severity degree of the sensor. Based on the estimation results, a diagnostic sub-model is selected, and the trained model can output the final diagnostic result.

Flow Chart of the LLDA-Based Fault Diagnosis Method
After locating the fault and estimating the fault severity, the estimated value can be used to correct the output of the faulty sensor. Gain-variation and zero-offset faults are processed using (12) and (13) to eliminate the effects of ε x and D x , respectively. Faulttolerant control can be realized by replacing the output signal of the faulty sensor witĥ I x_gain andÎ x_offset .Î whereÎ x_gain andÎ x_offset are the estimation values of the actual current under gain-variation and zero-offset faults, respectively.

Data Acquisition
A three-phase grid-connected experimental platform was built to validate the proposed method. The experimental platform is composed of several main parts, as shown in Figure 7. Table 2 lists the parameters of the experimental system. The open-circuit fault is simulated by lowering the driving signal. This experimental platform can be explained as follows: The open-circuit fault setting unit connects the controller and the drive circuit of the switch, which utilizes the cooperation of the NOR gate logic circuit and the self-locking button. When the self-locking button is pressed, 5 V voltage is input to the NOR gate logic circuit with the drive signal output by the controller, and the control signal transmitted to the switch is set to a low level. The switch remains open under the continuous action of the low-level control signal, and this state is consistent with the open-circuit fault. In the measurement of voltage and current signals, the signal conditioning circuit adjusts the sensor output signal to a range suitable for sampling by the controller. Since it is impossible to make the current sensor fail at a specific moment, the sensor fault is simulated by changing the measured value in the controller. The results sampled by the ADC need to be scaled up to reflect the actual status precisely. In this paper, the gain-variation fault of the current sensor is simulated by changing this scaling, and the zero-offset fault is simulated by superimposing a constant term onto the normal scaling result. For example, the zero-offset fault is simulated by superimposing a constant onto the measured signal. Figure 7 illustrated the experimental test bench. The controller used in the experiment is dSPACE's DS1102.  The types of faults studied in this paper belong to three categories: open-circuit fault of IGBT, gain-variation fault, and zero-offset fault of the current sensor. Among them, the open-circuit fault of the IGBT consists of eight types according to the fault location. There are six common fault types in the current sensor: gain-variation and zero-offset fault in A, B, and C-phase, respectively. The specific fault classification is shown in Table 3. Table 3. Labeling of the faults.

Fault Type Fault Location Label
Healthy state -1 Gain-variation fault of current sensor A-phase current sensor 2 B-phase current sensor 3 C-phase current sensor 4 Zero-offset fault of current sensor A-phase current sensor 5 B-phase current sensor 6 C-phase current sensor 7 Open-circuit fault Fault data are collected under various operating conditions to examine the performance and robustness of the proposed method. The reference current on the d-axis is 4 A, the switching frequency is 5 kHz, and the sampling frequency is 20 kHz. The gain-variation varies from −0.3 to 0.3 in an interval of 0.05, and the zero-offset varies from −3 A to 3A in an interval of 0.5 A.  The t-distributed stochastic neighbor embedding (t-SNE) method is a nonlinear dimensionality reduction technique suitable for visualization by embedding high-dimensional data into a two-dimensional format. Figure 9 shows the two-dimensional feature distribution produced using t-SNE, which does not have any real physical significance. The numbers in the legend represent the fault labels in Table 3. In the 1-layer structure, LDA is used for feature extraction of all types and severity degrees. The visualization result in Figure 9a shows overlapping between faults 2-7, which are six types of current sensor faults. Meanwhile, there are clear boundaries between open-circuit faults. Figure 9b shows that the characteristics of various faults have a high degree of aggregation, and the distance between different fault categories is noticeable. Figure 9c,d shows the visualization results of the current sensor fault features in 2-layer and 3-layer, respectively. The overlap between the sensor fault samples decreases as the number of layers increases. This phenomenon shows that layering effectively improves the separability of current sensor faults. The reduction in overlap area is mainly due to the decreasing dispersion of the sensor fault samples within each subset as the number of layers increases. The lower the dispersion is, the lower the error is in using the mean of each variable as the category center, and the LDA can find a projection matrix that distinguishes all faults. In the layering establishment of the fault diagnosis model, the kappa coefficient is used as an indication for iteration termination. Table 4 shows the variation of the kappa coefficient with the increase in layers, based on the experimental data. In 1-layer, the kappa coefficient is only 0.8393, indicating that the model has a poor diagnostic performance on the test set. When the layer number becomes 2, the kappa coefficient rapidly increases to 0.9815. When the number of layers is increased to 3, the kappa coefficient grows further, but the increase is not significant. For application scenarios that require incredibly high diagnostic accuracy, further increasing the number of layers could make sense. In this application scenario, when the number of layers is two, there is a favorable diagnostic performance.

Fault Severity Degree Estimation Based on BP Neural Network
The estimation of ε x and D x is performed using a BP neural network, with the number of neurons in the input, hidden, and output layers being 3, 10, and 1, respectively. The activation function in the hidden layer is the sigmoid function. Figure 10 shows the estimated results of the gain-variation and offset of the A-phase current sensor. The results demonstrate that when the fault severity degree changes, the network can control the estimation error of the gain-variation in the range [−0.005-0.005], and the estimation error of the offset does not exceed 5 × 10 −4 , indicating that the neural network has an excellent estimating performance.  Figure 10 shows the estimated error distributions for the sensor gain-variation and zero-offset faults. The blue bar represents the number of samples that fall within the current estimation error. The red line represents the cumulative sample size as a proportion of the total sample, with higher slopes indicating a relatively high concentration of estimation error. The cumulative probabilities in Figure 11 suggest that the estimation error of gain-variation concentrates on −5 × 10 −3 , 5 × 10 −3 , and the estimation error of zero-offset concentrates on −5 × 10 −4 , 5 × 10 −4 . The estimation errors for offset are mainly concentrated around zero compared with the estimation errors for gain-variation. The proposed method is compared with the diagnostic methods in [26,35], and Table 5 shows their diagnostic accuracies. The first method in the table uses PCA for feature extraction, replacing more original variables with fewer new variables while retaining as much information about the original variables as possible. To obtain more information, PCA needs the variance of the projected data to be as large as possible in the projection direction. Compared with the open-circuit fault, the fault characteristics of the current sensor fault are not significant. Therefore, the features of sensor failures are submerged in the feature extraction process, leading to this method's low diagnostic accuracy. ReliefF is a feature selection algorithm that assigns different weights to features based on their ability to distinguish close-range samples. The variation of the current sensor's fault severity degree increases the distance between the same fault category. Therefore, the ReliefF algorithm reduces the weight of the feature, failing to select the optimal feature subset.

Conclusions
Variations in the current sensor's fault degree cause the fault sample data to exhibit significant multimodal characteristics. Therefore, this paper uses the current sensor's fault degree to divide the historical fault data layer-by-layer. In this way, the multimodal data are divided into multiple equally distributed subsets, enabling the linear discriminant analysis to perform well in these subsets. The final experimental results also show that LLDA can effectively reduce the influence of multimodality on fault diagnosis. The estimated value of failure degree is important information for equipment operation and maintenance.
In this work, a BP neural network is applied to select the average value and the ratio of three-phase currents' integral value to estimate the fault severity degree. The network achieves good estimation results under different fault degrees, with the maximum estimation error being less than 0.005. The estimated value of the sensor fault severity degree can also be used to correct the faulty sensor's output signal and to achieve faulttolerant control. This information will also be useful for guiding subsequent equipment maintenance.
It should be noted that in the proposed method, the number of layers is a critical variable. Theoretically, as the number of layers increases, the effectiveness of fault diagnosis will improve, and the kappa coefficient in the experimental results also verifies this. The selection of the number of layers in this paper is based on the kappa coefficient. The selection of layers needs to be further improved in future research.