# An Improved Power Quality Disturbance Detection Using Deep Learning Approach

Authors: Kavaskar Sekar; Karthick Kanagarathinam; Sendilkumar Subramanian; Ellappan Venugopal; C. Udayakumar
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

Recently, the distribution network has been integrated with an increasing number of renewable energy sources (RESs) to create hybrid power systems. Due to the interconnection of RESs, there is an increase in power quality disturbances (PQDs). The aim of this article was to present an innovative method for detecting and classifying PQDs that combines convolutional neural networks (CNNs) and long short-term memory (LSTM). The disturbance signals are fed into a combined CNN and LSTM model, which automatically recognizes and classifies the features associated with power quality disturbances. In comparison with other methods, the proposed method overcomes the limitations associated with conventional signal analysis and feature selection. Additionally, to validate the proposed method's robustness, data samples from a modified IEEE 13-node hybrid system are collected and tested using MATLAB/Simulink. The results are good and encouraging.


---

## Body

## 1. Introduction

Renewable energy sources (RESs) can provide an efficient solution to increase in demand for electricity and also reduce the risk of pollution or global warming. However, the integration of RESs increases the use of solid-state devices, which overstress power quality disturbances (PQDs) such as harmonics, sag or swell in voltage, flicker, and voltage unbalance. Moreover, RESs have major characteristics of fluctuation and intermittent. The instability of renewable energy (RE) generation is an important cause of power quality disturbance, which guides voltage unbalance or fluctuation [1, 2]. The PQDs lead to a failure of electrical equipment [3]. It is understandable that these disturbances are a threat to grid when connected with multiple energy sources. Hence, there is an essential requirement to detect these PQDs to get better quality of power and keep the equipment away from failures. The identification and classification of PQDs depend mainly on feature extraction [4]. For feature extraction, several methods have been developed to detect and classify PQDs. The Fourier transform (FT) is a frequency-domain analysis and is suitable for stationary signal analysis. However, it is incapable to choose feature information when the signal is nonstationary. The discrete Fourier transform (DFT) and short-time Fourier transform (STFT) overcome the drawback of FT using a time-frequency window to localize transient in a signal proposed in [5]. The transient signals are not effectively designated in the STFT due to a fixed window. The S transform (ST) [6–9] uses a moving window, but the precision becomes lower while examining nonstationary transients.The authors proposed a Hilbert–Huang transform (HHT)-based method for detecting the single and multiple PQD signals [10–12], but the HHT is unsuccessful to build a frequency spectrum that leads to a loss of frequency components having small energy contents. The DWT [13–19] methods are more suitable in the signal processing for PQDs to overcome the fixed resolution issue of STFT for analyzing the PQDs. The selection of suitable mother wavelets and sampling rate is the main challenge in DWT. Its accuracy relies on proper feature selection and classifier. Besides, all of these approaches are likely to be pretentious by the noise level of the signal and substantial computational work. Consequently, there is a requirement for a novel PQD detection with wide applicability.Deep learning (DL) is very effective in automatic feature extraction of image and speech analysis. The DL can extract spatial and temporal features from the input without signal transformation [20]. The application of DL in the PQD problem not only improves the accuracy but also simplifies the process by eliminating handcrafted feature extraction. The application of convolutional neural networks (CNNs) in PQD classification is provided in [21], and the CNN combined with a long-short term memory (LSTM) is used for PQD classification in [22], but the training time, the number of parameters, and the performance against noise were not discussed. Besides, both [21, 22] have not considered the overfitting problem, which may extremely decline the accuracy of DNN. The PQDs are assessed based on a deep belief network in [23]. Although these methods are producing acceptable results in PQD detection in single PQDs, they scuffle with multiple PQDs.The PQD signal is converted to a 2D image, which is input to DCNN for the detection and classification in [24]. The 2D image of the signal is entirely different from the 1D signal data. Moreover, multiple PQDs are not considered in this work. An effective technique is proposed in [25, 26] using DCNN for single and multiple PQD detection and classification. However, these methods need an enhancement. In this study, a PQD detection method based on combined CNN and LSTM is proposed. The contributions of work are enumerated as follows: (1) by analyzing single and multiple PQDs, the combination of CNN and LSTM layers eliminates manual feature extraction and enables automatic feature extraction and classification. (2) Since the computational complication of the CNN is high, the batch normalization (BN) layer is used to speed up the training process, and the reduced number of parameters is fed to LSTM. (3) To investigate the strength of the method, a complete evaluation of training parameters and accuracy with another model is conducted, including DCNN and CNN with the gated recurrent unit (GRU). 4). Further, to analyze the method, the data are collected by simulating a hybrid system with the PQDs and tested. The rest of this article is arranged as follows: Section 2 explains mathematical models of PQD. In Section 3, the construction proposed model is discussed. Section 4 presents the detailed results and comparison. Section 5 infers construction and verification of the proposed method on hybrid system. Section 6 concludes the work.


## 2. Power Quality Disturbance Data

A total of 16 PQDs are considered in this work, which include 10 single PQDs (normal, sag, swell, harmonics, flicker, interruption, spike, notch, impulsive, and oscillatory transient) and 6 multiple PQDs (sag with harmonics, sag with flicker, flicker with harmonics, interruption with harmonics, swell with harmonics, and swell with flicker). The proposed PQD detection method uses the data set, which is obtained from mathematical models given in Table1.Table 1
Mathematical model for PQDs.
LabelEventMathematical modelsModel parametersC1Normalxt=A1±∝ut−t1−ut−t2sinwt∝≤0.1, T ≤t2−t1≤9TC2Sagxt=A1−∝ut−t1−ut−t2sinwt0.1≤∝≤0.9, T ≤t2−t1≤9TC3Swellxt=A1+∝ut−t1−ut−t2sinwt0.1≤∝≤0.8, T ≤t2−t1≤9TC4Interruptionxt=A1−∝ut−t1−ut−t2sinwt0.9≤∝≤1, T ≤t2−t1≤9TC5Harmonicsxt=A∝1sinwt+∝3sin3wt+∝5sin5wt+∝7sin7wt0.05≤∝3,∝5,∝7≤0.15, ∑∝i2=1C6Flickerxt=A1+∝fsinβwtsinwt0.1≤∝f≤0.2,5≤β≤20HzC7Oscillatory transientxt=Asinwt+∝−ct−t1/τsinwnt−t1ut2−ut10.1≤∝≤0.8,0.5T≤t2−t1≤3T,8≤τ≤40ms,300≤fn≤900HzC8Impulsive transientxt=A1−∝iut−t1−ut−t2sinwt0≤∝i≤0.414,T/20≤t2−t1≤T/10C9Notchxt=sinwt−signsinwt×∑n=09kut−t1−0.02n−ut−t1−0.02n0.1≤k≤0.4, 0≤t2,t1≤0.5T,0.01T≤t2−t1≤0.05TC10Spikext=sinwt+signsinwt×∑n=09kut−t1−0.02n−ut−t1−0.02n0.1≤k≤0.4, 0≤t2,t1≤0.5T,0.01T≤t2−t1≤0.05TC11Sag with harmonicsxt=A1−∝ut−t1−ut−t2∝1sinwt+∝3sin3wt+∝5sin5wt0.1≤∝≤0.9, T ≤t2−t1≤9T, 0.05≤∝3,∝5,∝7≤0.15, ∑∝i2=1C12Swell with harmonicsxt=A1+∝ut−t1−ut−t2∝1sinwt+∝3sin3wt+∝5sin5wt0.1≤∝≤0.8, T ≤t2−t1≤9T, 0.05≤∝3,∝5,∝7≤0.15, ∑∝i2=1C13Flicker with harmonicsxt=A1+∝fsinβwtsinwt∝1sinwt+∝3sin3wt+∝5sin5wt0.1≤∝f≤0.2,5≤β≤20Hz, 0.05≤∝3,∝5,∝7≤0.15, ∑∝i2=1C14Interruption with harmonicsxt=A1−∝ut−t1−ut−t2∝1sinwt+∝3sin3wt+∝5sin5wt0.1≤∝≤0.9, T ≤t2−t1≤9T, 0.05≤∝3,∝5,∝7≤0.15, ∑∝i2=1C15Flicker with sagxt=A1+∝fsinβwtsinwt1−∝ut−t1−ut−t20.1≤∝≤0.9, T ≤t2−t1≤9T, 0.1≤∝f≤0.2,5≤β≤20Hz,C16Flicker with swellxt=A1+∝fsinβwtsinwt1+∝ut−t1−ut−t20.1≤∝≤0.8, T ≤t2−t1≤9T, 0.1≤∝f≤0.2,5≤β≤20Hz,The parameters of the mathematical model are varied as per the direction of IEEE 1159 standard [27]. In all the mathematical models of PQDs, the parameter “A” indicates the amplitude of the waveform and is set to 1 per unit. The factor “α” shows the intensity of the disturbances. The step function u(t) of model presents the time span of PQD in a signal. Harmonic disturbance data use the 3rd, 5th, and 7th orders. The flicker frequency (∝f) varied from 5 to 20 Hz, and the corresponding flicker magnitude varied from 0.1 to 0.2 p.u. During oscillatory transient signal generation, fn varies from 300 to 900 Hz, time constant (τ) varies from 0.008 to 0.04 s, and impulse magnitude (∝i) varies from 0 to 0.414 p.u. The notch or spike magnitude (k) varies from 0.1 to 0.4 p.u, and the width varies from 0.01 to 0.05 cycles. The sampling frequency of 3200 Hz is set because electric power signal recording equipment mostly uses the chosen sampling frequency. The generated signal contains 640 sampling points (10 cycles, 0.2 s) with the fundamental frequency of 50 Hz. In each PQD case, 8000 data have been generated by varying parameters, and hence, a total of 1,28,000 (8000 × 16 PQDs) data instances have been generated, but there is always some noise superimposed in the signal when it is actually collected from the real system through sensors. So, noise is added to the PQD data set with different signal-to-noise ratios (SNRs) of 20 dB to 40 dB, which increases the total data samples to 5,12,000 (4 × 1,28,000). The details of data set used in this study are presented in Table 2. The characteristic PQ signals simulated by mathematical model equations are shown in Figure 1.Table 2
Data set.
Samples numberNoise levelTraining set32000 × 16 = 51200020 dB to 40 dBValidation set512000 × 0.01 = 512020 dB to 40 dBTest set512000 × 0.01 = 512020 dB to 40 dBFigure 1
PQ disturbances: (a) sag, (b) swell, (c) harmonics, (d) impulse, (e) interruption, (f) notch, (g) oscillatory, (h) spike, (i) flicker, (j) flicker with harmonics, (k) interruption with harmonics, (l) sag with harmonics, (m) sag with flicker, (n) swell with harmonics, and (o) swell with flicker.
(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)(o)


## 3. The Proposed Method

The disadvantages of conventional signal investigation and feature selection can be overwhelmed by DL. A CNN can be used to take widespread feature extraction by convolutional layer and feature dimension reduction by pooling. Hence, the CNN reveals better generalization capability than old-fashioned feature extraction methods. In PQD detection, a 1D convolutional operation is ensuring spatial feature extraction while holding temporal features. The LSTM network shows outstanding temporal feature extraction capability. The PQD detection is a kind of time-series signal data. This needs that the PQD detection model would hold exceptional temporal and spatial feature extraction capabilities. Consequently, 1D CNN and LSTM network are utilized in the PQD detection model. It extracts the spatial features by 1D CNN, and then, it extracts the temporal features by LSTM network. As a result, this model extracts the features of PQD more completely. The proposed structure of combined CNN and LSTM model is presented in Figure2, which comprises pair of CNN (two convolutional layers + pooling layers) stacked with three LSTM layers and two fully connected layers at the end.Figure 2
Proposed CNN + LSTM architecture.


### 3.1. Convolutional Layers

The convolutional layer (CL) is the primary layer in CNN. It transfers low-level features into high-level features. The convolutional operator is accomplished on the input with a kernel to create features. The output of CL is given as follows:(1)y=fwr∗xi+br,where y is the output of CL. wr and br are the weight and bias of the rth layer, respectively, and f(x) is the activation function. It comprehends the activation of a neuron to output. The rectified linear unit (ReLU) activation function is preferred in deep learning rather than the tanh function.(2)fReLU=max0,y.


### 3.2. Pooling Layer

A pooling layer is commonly added next to the CL. It is primarily used for downsampling. The pooling layer is used to reduce the dimension of the data after the convolution layer and extract vital information. It may decrease the influence of data fluctuations. For the PQD waveform, max pooling is better than average pooling and is hence used in this work. The mathematical expression for max pooling is given as follows:(3)fy=maxiyi.


### 3.3. BN Layer

BN is a method to increase the speed of neural networks. It is used to normalize the input by means of adjusting and scaling the activations. It allows each network to learn by itself more independently than other layers. Besides, it reduces overfitting efficiently compared with dropout. The input data batchx_i may be normalized using the following formula:(4)yi=γ×xi−μxε+σx2+β,where μ_x is the batch mean and σx2 is the batch variance. The learned scale and shift parameters are given by ϒ and β, respectively, ensuring that the input data have the same distribution.


### 3.4. Fully Connected Layer

It is also called the dense layer, and this layer has learning parameterD. The output of the dense layer is calculated by the following formula:(5)y=fx∗Dr+br.


### 3.5. Softmax Layer

The softmax layer computes the probability distribution of “n” output classes. Hence, the softmax layer is used to foresee the class to which the input data belong. The probability distribution is computed by the following equation:(6)Pi=exi∑exj,j=0,1,2,……n,where xi is the input. The output of p lies between 0 and 1, and the sum of all the probabilities will be equal to 1. The softmax layer is used for PQD classification in this work.


### 3.6. LSTM

LSTM is capable of learning long-term dependencies. A LSTM unit is composed of a cell, input gate, output gate, and forget gate. The cell evokes value over arbitrary time intervals, and the three gates control the flow of information into and out of the cell [28]. The LSTM is well suited for classification problems based on time-series data. Figure 3 demonstrates the construction of LSTM, which comprises input gate, output gate, and forget gate. These gates pick and discard the information passing over the network. Input gate i(t) has an activation function tanh ranging from −1 to 1.Figure 3
LSTM network.It takes the current inputx(t), C(t−1), and h(t−1) parameters for processing. Forget gate f(t) has two activation functions namely sigmoid and tanh. The forget gate chooses exactly how much information is retained from the previous output. The data are to be passed through the network when the value is 1. On the other hand, the data are not to be transformed into the network when the value is 0. The output gate o(t) has an activation function of sigmoid ranging from −1 to 1. The following equations are used to compute i(t), o(t), and f(t) at each and every time step:(7)it=σWiCt−1ht−1×xt+bi,ot=σWoCt−1ht−1×xt+bi,ft=σWfCt−1ht−1×xt+bi.


### 3.7. GRU

The GRU is also a kind of RNN similar to LSTM with forget gate but has less parameters than LSTM [29]. It is also reducing time consumption in the training process due to lack of output gate. Hence, GRU is used for the PQD classification problem for comparison. A CNN stacked with GRU is used in this study for comparison.


## 3.1. Convolutional Layers

The convolutional layer (CL) is the primary layer in CNN. It transfers low-level features into high-level features. The convolutional operator is accomplished on the input with a kernel to create features. The output of CL is given as follows:(1)y=fwr∗xi+br,where y is the output of CL. wr and br are the weight and bias of the rth layer, respectively, and f(x) is the activation function. It comprehends the activation of a neuron to output. The rectified linear unit (ReLU) activation function is preferred in deep learning rather than the tanh function.(2)fReLU=max0,y.


## 3.2. Pooling Layer

A pooling layer is commonly added next to the CL. It is primarily used for downsampling. The pooling layer is used to reduce the dimension of the data after the convolution layer and extract vital information. It may decrease the influence of data fluctuations. For the PQD waveform, max pooling is better than average pooling and is hence used in this work. The mathematical expression for max pooling is given as follows:(3)fy=maxiyi.


## 3.3. BN Layer

BN is a method to increase the speed of neural networks. It is used to normalize the input by means of adjusting and scaling the activations. It allows each network to learn by itself more independently than other layers. Besides, it reduces overfitting efficiently compared with dropout. The input data batchx_i may be normalized using the following formula:(4)yi=γ×xi−μxε+σx2+β,where μ_x is the batch mean and σx2 is the batch variance. The learned scale and shift parameters are given by ϒ and β, respectively, ensuring that the input data have the same distribution.


## 3.4. Fully Connected Layer

It is also called the dense layer, and this layer has learning parameterD. The output of the dense layer is calculated by the following formula:(5)y=fx∗Dr+br.


## 3.5. Softmax Layer

The softmax layer computes the probability distribution of “n” output classes. Hence, the softmax layer is used to foresee the class to which the input data belong. The probability distribution is computed by the following equation:(6)Pi=exi∑exj,j=0,1,2,……n,where xi is the input. The output of p lies between 0 and 1, and the sum of all the probabilities will be equal to 1. The softmax layer is used for PQD classification in this work.


## 3.6. LSTM

LSTM is capable of learning long-term dependencies. A LSTM unit is composed of a cell, input gate, output gate, and forget gate. The cell evokes value over arbitrary time intervals, and the three gates control the flow of information into and out of the cell [28]. The LSTM is well suited for classification problems based on time-series data. Figure 3 demonstrates the construction of LSTM, which comprises input gate, output gate, and forget gate. These gates pick and discard the information passing over the network. Input gate i(t) has an activation function tanh ranging from −1 to 1.Figure 3
LSTM network.It takes the current inputx(t), C(t−1), and h(t−1) parameters for processing. Forget gate f(t) has two activation functions namely sigmoid and tanh. The forget gate chooses exactly how much information is retained from the previous output. The data are to be passed through the network when the value is 1. On the other hand, the data are not to be transformed into the network when the value is 0. The output gate o(t) has an activation function of sigmoid ranging from −1 to 1. The following equations are used to compute i(t), o(t), and f(t) at each and every time step:(7)it=σWiCt−1ht−1×xt+bi,ot=σWoCt−1ht−1×xt+bi,ft=σWfCt−1ht−1×xt+bi.


## 3.7. GRU

The GRU is also a kind of RNN similar to LSTM with forget gate but has less parameters than LSTM [29]. It is also reducing time consumption in the training process due to lack of output gate. Hence, GRU is used for the PQD classification problem for comparison. A CNN stacked with GRU is used in this study for comparison.


## 4. Simulation Results

### 4.1. Metrics for Evaluation

The evaluation parameters of the proposed method are given as follows:Confusion Matrix: it is used to assess the classification performance of a model.Accuracy = (true positive + true negative)/total test casesPrecision = true positive/(true positive + true negative)Recall = true positive/(true positive + false negative)F1 Score = 2∗ precision ∗ recall/(precision + recall)


### 4.2. Results and Discussions

Initially, 512000 samples have been produced as described in Section2. From the total data set, 98% are used for training, 1% for validation, and 1% for testing. Usually, the training procedure is done with a mini-batch in deep learning. The mini-batch size is chosen as 64 for all three models, such that the training time of different methods is computed accurately. A total of 100 epochs are chosen in this work. However, in each epoch, loss during validation was monitored. The validation loss does not drop for incessant 20 epochs, and the training algorithm would be finished in advance of the scheduled epoch to evade overfitting. Then, the model with the top show in the validation set is chosen as the ultimate model. Moreover, the Python coding for the complete architecture of the proposed CNN + LSTM was carried out in Tesla K80 GPU in this work. During the training, the accuracy and loss values of all models are shown in Figure 4. It is noted that the CNN + LSTM model has better accuracy and less loss during training compared with the other two models.Figure 4
Comparison of training accuracy and loss of different DL models.For all three models, the details of final models and their properties such as parameters, training time, elapsed epochs, accuracy, and loss during validation are presented in Table3. The combined CNN and LSTM model has less training parameters and produces better classification accuracy during validation. A total of 5120 cases were considered during testing, and the confusion matrices of all three models are shown in Tables 4-6. It was noted that the DCNN model accurately classified 5105 cases and 15 cases are misclassified that produces an accuracy of 99.70%. The combined CNN and GRU has classified 5109 cases correctly and produces the classification accuracy of 99.78%. The proposed method (CNN + LSTM) produces better calcification accuracy of 99.90% with only 5 cases that were misclassified.Table 3
DNN training model performance.
Type of modelTime consumed during each epoch (s)Total parametersBest validation lossBest validation accuracyTraining time (s)Elapsed epochCNN + LSTM77956320.00320.9990361947CNN + GRU781009440.00370.9978265234DCNN971748200.00400.9970446246Table 4
Confusion matrix of combined CNN and LSTM.
ActualPredictedC1C2C3C4C5C6C7C8C9C10C11C12C13C14C15C16C1304---------------C21319-----1--------C33-303-------------C4---299------------C5----287-----------C6-----327----------C7------309---------C8-------345--------C9--------342-------C10---------304------C11----------307-----C12-----------360----C13------------308---C14-------------311--C15--------------361-C16---------------329Table 5
Confusion matrix of combined CNN and GRU.
ActualPredictedC1C2C3C4C5C6C7C8C9C10C11C12C13C14C15C16C1300-3-----1-------C21319-----1--------C32-304-------------C4---2990-----------C5----287-----------C6-----327----------C7------309---------C8-------345--------C9--------3411------C10---------304------C11----------307-----C12-----------360----C13------------308---C14-------------311--C15-------------2359-C16---------------329Table 6
Confusion matrix of DCNN.
ActualPredictedC1C2C3C4C5C6C7C8C9C10C11C12C13C14C15C16C1300-3-----1-------C21319-----10-------C32-304-------------C4---299------------C5----287-----------C6----------------C7------309---------C8-------345--------C9--------3411------C10---------304------C11---------0307-----C12---------00360----C13------------307-1-C14-------------310-1C15-------------2359-C16---------------327Table7 shows the effectiveness of the combined CNN and LSTM method in terms of precision, recall, andF1 score. The proposed CNN + LSTM model produced 99.90% precision (macro-average), while other deep learning models such as CNN + GRU and DCNN attained 99.79% and 99.71%, respectively. Similarly, F1 score for CNN + LSTM is 99.92%, while CNN + GRU has 99.78% and DCNN has 99.71%. The proposed CNN + LSTM model has the highest precision and F1 score compared with the other DL models. Hence, the proposed CNN + LSTM model outclassed the other models in terms of evaluation parameters.Table 7
Evaluation parameters of the three models.
ActualCNN + LSTMCNN + GRUDCNNPrecisionRecallF1 scorePrecisionRecallF1 scorePrecisionRecallF1 scoreC11.00000.99020.99510.98680.99010.98850.98680.99010.9885C20.99381.00000.99690.99381.00000.99690.99381.00000.9969C30.99021.00000.99510.99350.99020.99180.99350.99020.9918C41.00001.00001.00001.00001.00001.00001.00001.00001.0000C51.00001.00001.00001.00001.00001.00001.00001.00001.0000C61.00001.00001.00001.00001.00001.00001.00001.00001.0000C71.00001.00001.00001.00001.00001.00001.00001.00001.0000C81.00000.99710.99861.00000.99710.99861.00000.99710.9986C91.00001.00001.00000.99710.99710.99710.99710.99710.9971C101.00001.00001.00001.00000.99670.99841.00000.99670.9984C111.00001.00001.00001.00001.00001.00001.00001.00001.0000C121.00001.00001.00001.00001.00001.00001.00001.00001.0000C131.00001.00001.00001.00001.00001.00000.99681.00000.9984C141.00001.00001.00001.00000.99360.99680.99680.99360.9952C151.00001.00001.00000.99451.00000.99720.99450.99170.9931C161.00001.00001.00001.00001.00001.00000.99390.99700.9954Average0.99900.99920.99910.99790.99780.99780.99710.99710.9971To test the proposed model under noise grade, 1% of data from each category (both no noise and noise grade) has been randomly selected and the test results are presented in Table8. The DCNN has provided good accuracy with pure signal (no noise signal). On the other hand, when the noise grade increases the performance is very poor. It uses 174410 trainable parameters and 410 non-trainable parameters. The LSTM + GRU model has a slight improvement in accuracy in all the categories of noise grade. However, the CNN + LSTM proposed in this work produces 100% classification rate for less noise grade and 99.31% under the worst noise grade of 20 dB as well. It uses 95632 parameters with training time of 95 s per epoch on GPU. This shows that the CNN + LSTM is an effective method to identify comprehensive features of each PQD. The performance of CNN + LSTM is better than CNN + GRU and DCNN under different noise levels.Table 8
Performance of DCNN and hybrid CNN.
PQD labelThe performance of DL model under noise gradeDCNNCNN + GRUCNN + LSTMPure40 dB30 dB20 dBPure40 dB30 dB20 dBPure40 dB30 dB20 dBC1100.00100.0098.8197.62100.00100.00100.00100.00100.00100.00100.00100.00C2100.0098.6398.6397.26100.0098.6398.6397.26100.00100.0098.6398.63C3100.0098.6798.6798.67100.00100.0098.6798.67100.00100.0098.6797.33C4100.00100.00100.0098.63100.00100.00100.0098.63100.00100.00100.00100.00C5100.00100.00100.0098.73100.00100.00100.0098.73100.00100.00100.00100.00C6100.00100.00100.0098.65100.00100.00100.0098.65100.00100.00100.00100.00C7100.00100.00100.0098.73100.00100.00100.00100.00100.00100.00100.00100.00C8100.00100.0098.8198.81100.00100.0098.8198.81100.00100.00100.00100.00C9100.00100.00100.0098.78100.00100.0097.5698.78100.00100.00100.00100.00C10100.00100.00100.0098.90100.00100.00100.0098.90100.00100.00100.00100.00C11100.00100.0098.8198.81100.00100.00100.00100.00100.00100.00100.00100.00C12100.00100.0098.2598.28100.00100.0098.2598.28100.00100.0098.2596.55C13100.00100.00100.0097.78100.00100.0098.8998.89100.00100.00100.00100.00C14100.00100.0098.8298.82100.00100.00100.0098.82100.00100.00100.00100.00C15100.00100.0097.5998.80100.00100.00100.0098.80100.00100.00100.0097.59C16100.0098.8498.8498.84100.0098.8498.8498.84100.00100.0098.8498.84Average100.0099.7699.2098.51100.0099.8499.3598.88100.00100.0099.6699.31


### 4.3. Comparison of Computational Time

The DNNs may be performed on GPU to accomplish greater speed. The total number of units in GPU is greater than the CPU processor. Hence, the computational speed for DCNN on GPU is very fast. The computational time of DCNN is considerably lesser due to its parallel computation of GPU. The computation time in GPU and CPU is compared for 512000 samples in the DCNN model in Table9.Table 9
Impact of processor on training time.
ProcessorTraining time (s)For 128000 samplesFor 512000 samplesGPU (Tesla K80)2495CPU (Intel i7 Processor)90360


### 4.4. Comparison with Existing Work

To validate the proposed method, the comparison has been done with existing DCNN and the conventional methods. The performance of different methods under complex PQ disturbances is listed in Table10. This shows that the conventional methods require features from signal transformation before classification. Basically, the variance in the number and type of features produces a difference in the classification rate. For example, the FDST and DT designed with twenty features produced an accuracy of 99.28% [33]. Conversely, the ST and RF attained 99.7% of accuracy with only four features [30]. Hence, the multiple information is captured by CNN + LSTM, which makes it promising for automatic feature extraction. The proposed CNN + LSTM shows the superiority of the model compared with the traditional models. The proposed CNN + LSTM considered sixteen PQDs and produced 100% accuracy for low noise grade and 99.31% under the worst noise grade compared with the other DL models and other traditional methods.Table 10
Comparison with the existing methods.
MethodsNumber of features selectedNumber of PQDsAccuracy in %Pure40 dB30 dB20 dBWPT and GA [18]15898.33---WT and PSO [19]1199896.8793.625–ST and RF [30]41599.799.999.795.9FFT and ANNs [31]–8–93.9595.65–ST and PNN [32]41197.4---FDST and DT [33]201399.2898.897.49–Deep CNN [24]AUTO999.67---Deep CNN [25]AUTO1699.9699.9599.6698.13Deep CNN [26]AUTO24---99.26The proposed CNN + LSTMAUTO1610010099.6999.31


## 4.1. Metrics for Evaluation

The evaluation parameters of the proposed method are given as follows:Confusion Matrix: it is used to assess the classification performance of a model.Accuracy = (true positive + true negative)/total test casesPrecision = true positive/(true positive + true negative)Recall = true positive/(true positive + false negative)F1 Score = 2∗ precision ∗ recall/(precision + recall)


## 4.2. Results and Discussions

Initially, 512000 samples have been produced as described in Section2. From the total data set, 98% are used for training, 1% for validation, and 1% for testing. Usually, the training procedure is done with a mini-batch in deep learning. The mini-batch size is chosen as 64 for all three models, such that the training time of different methods is computed accurately. A total of 100 epochs are chosen in this work. However, in each epoch, loss during validation was monitored. The validation loss does not drop for incessant 20 epochs, and the training algorithm would be finished in advance of the scheduled epoch to evade overfitting. Then, the model with the top show in the validation set is chosen as the ultimate model. Moreover, the Python coding for the complete architecture of the proposed CNN + LSTM was carried out in Tesla K80 GPU in this work. During the training, the accuracy and loss values of all models are shown in Figure 4. It is noted that the CNN + LSTM model has better accuracy and less loss during training compared with the other two models.Figure 4
Comparison of training accuracy and loss of different DL models.For all three models, the details of final models and their properties such as parameters, training time, elapsed epochs, accuracy, and loss during validation are presented in Table3. The combined CNN and LSTM model has less training parameters and produces better classification accuracy during validation. A total of 5120 cases were considered during testing, and the confusion matrices of all three models are shown in Tables 4-6. It was noted that the DCNN model accurately classified 5105 cases and 15 cases are misclassified that produces an accuracy of 99.70%. The combined CNN and GRU has classified 5109 cases correctly and produces the classification accuracy of 99.78%. The proposed method (CNN + LSTM) produces better calcification accuracy of 99.90% with only 5 cases that were misclassified.Table 3
DNN training model performance.
Type of modelTime consumed during each epoch (s)Total parametersBest validation lossBest validation accuracyTraining time (s)Elapsed epochCNN + LSTM77956320.00320.9990361947CNN + GRU781009440.00370.9978265234DCNN971748200.00400.9970446246Table 4
Confusion matrix of combined CNN and LSTM.
ActualPredictedC1C2C3C4C5C6C7C8C9C10C11C12C13C14C15C16C1304---------------C21319-----1--------C33-303-------------C4---299------------C5----287-----------C6-----327----------C7------309---------C8-------345--------C9--------342-------C10---------304------C11----------307-----C12-----------360----C13------------308---C14-------------311--C15--------------361-C16---------------329Table 5
Confusion matrix of combined CNN and GRU.
ActualPredictedC1C2C3C4C5C6C7C8C9C10C11C12C13C14C15C16C1300-3-----1-------C21319-----1--------C32-304-------------C4---2990-----------C5----287-----------C6-----327----------C7------309---------C8-------345--------C9--------3411------C10---------304------C11----------307-----C12-----------360----C13------------308---C14-------------311--C15-------------2359-C16---------------329Table 6
Confusion matrix of DCNN.
ActualPredictedC1C2C3C4C5C6C7C8C9C10C11C12C13C14C15C16C1300-3-----1-------C21319-----10-------C32-304-------------C4---299------------C5----287-----------C6----------------C7------309---------C8-------345--------C9--------3411------C10---------304------C11---------0307-----C12---------00360----C13------------307-1-C14-------------310-1C15-------------2359-C16---------------327Table7 shows the effectiveness of the combined CNN and LSTM method in terms of precision, recall, andF1 score. The proposed CNN + LSTM model produced 99.90% precision (macro-average), while other deep learning models such as CNN + GRU and DCNN attained 99.79% and 99.71%, respectively. Similarly, F1 score for CNN + LSTM is 99.92%, while CNN + GRU has 99.78% and DCNN has 99.71%. The proposed CNN + LSTM model has the highest precision and F1 score compared with the other DL models. Hence, the proposed CNN + LSTM model outclassed the other models in terms of evaluation parameters.Table 7
Evaluation parameters of the three models.
ActualCNN + LSTMCNN + GRUDCNNPrecisionRecallF1 scorePrecisionRecallF1 scorePrecisionRecallF1 scoreC11.00000.99020.99510.98680.99010.98850.98680.99010.9885C20.99381.00000.99690.99381.00000.99690.99381.00000.9969C30.99021.00000.99510.99350.99020.99180.99350.99020.9918C41.00001.00001.00001.00001.00001.00001.00001.00001.0000C51.00001.00001.00001.00001.00001.00001.00001.00001.0000C61.00001.00001.00001.00001.00001.00001.00001.00001.0000C71.00001.00001.00001.00001.00001.00001.00001.00001.0000C81.00000.99710.99861.00000.99710.99861.00000.99710.9986C91.00001.00001.00000.99710.99710.99710.99710.99710.9971C101.00001.00001.00001.00000.99670.99841.00000.99670.9984C111.00001.00001.00001.00001.00001.00001.00001.00001.0000C121.00001.00001.00001.00001.00001.00001.00001.00001.0000C131.00001.00001.00001.00001.00001.00000.99681.00000.9984C141.00001.00001.00001.00000.99360.99680.99680.99360.9952C151.00001.00001.00000.99451.00000.99720.99450.99170.9931C161.00001.00001.00001.00001.00001.00000.99390.99700.9954Average0.99900.99920.99910.99790.99780.99780.99710.99710.9971To test the proposed model under noise grade, 1% of data from each category (both no noise and noise grade) has been randomly selected and the test results are presented in Table8. The DCNN has provided good accuracy with pure signal (no noise signal). On the other hand, when the noise grade increases the performance is very poor. It uses 174410 trainable parameters and 410 non-trainable parameters. The LSTM + GRU model has a slight improvement in accuracy in all the categories of noise grade. However, the CNN + LSTM proposed in this work produces 100% classification rate for less noise grade and 99.31% under the worst noise grade of 20 dB as well. It uses 95632 parameters with training time of 95 s per epoch on GPU. This shows that the CNN + LSTM is an effective method to identify comprehensive features of each PQD. The performance of CNN + LSTM is better than CNN + GRU and DCNN under different noise levels.Table 8
Performance of DCNN and hybrid CNN.
PQD labelThe performance of DL model under noise gradeDCNNCNN + GRUCNN + LSTMPure40 dB30 dB20 dBPure40 dB30 dB20 dBPure40 dB30 dB20 dBC1100.00100.0098.8197.62100.00100.00100.00100.00100.00100.00100.00100.00C2100.0098.6398.6397.26100.0098.6398.6397.26100.00100.0098.6398.63C3100.0098.6798.6798.67100.00100.0098.6798.67100.00100.0098.6797.33C4100.00100.00100.0098.63100.00100.00100.0098.63100.00100.00100.00100.00C5100.00100.00100.0098.73100.00100.00100.0098.73100.00100.00100.00100.00C6100.00100.00100.0098.65100.00100.00100.0098.65100.00100.00100.00100.00C7100.00100.00100.0098.73100.00100.00100.00100.00100.00100.00100.00100.00C8100.00100.0098.8198.81100.00100.0098.8198.81100.00100.00100.00100.00C9100.00100.00100.0098.78100.00100.0097.5698.78100.00100.00100.00100.00C10100.00100.00100.0098.90100.00100.00100.0098.90100.00100.00100.00100.00C11100.00100.0098.8198.81100.00100.00100.00100.00100.00100.00100.00100.00C12100.00100.0098.2598.28100.00100.0098.2598.28100.00100.0098.2596.55C13100.00100.00100.0097.78100.00100.0098.8998.89100.00100.00100.00100.00C14100.00100.0098.8298.82100.00100.00100.0098.82100.00100.00100.00100.00C15100.00100.0097.5998.80100.00100.00100.0098.80100.00100.00100.0097.59C16100.0098.8498.8498.84100.0098.8498.8498.84100.00100.0098.8498.84Average100.0099.7699.2098.51100.0099.8499.3598.88100.00100.0099.6699.31


## 4.3. Comparison of Computational Time

The DNNs may be performed on GPU to accomplish greater speed. The total number of units in GPU is greater than the CPU processor. Hence, the computational speed for DCNN on GPU is very fast. The computational time of DCNN is considerably lesser due to its parallel computation of GPU. The computation time in GPU and CPU is compared for 512000 samples in the DCNN model in Table9.Table 9
Impact of processor on training time.
ProcessorTraining time (s)For 128000 samplesFor 512000 samplesGPU (Tesla K80)2495CPU (Intel i7 Processor)90360


## 4.4. Comparison with Existing Work

To validate the proposed method, the comparison has been done with existing DCNN and the conventional methods. The performance of different methods under complex PQ disturbances is listed in Table10. This shows that the conventional methods require features from signal transformation before classification. Basically, the variance in the number and type of features produces a difference in the classification rate. For example, the FDST and DT designed with twenty features produced an accuracy of 99.28% [33]. Conversely, the ST and RF attained 99.7% of accuracy with only four features [30]. Hence, the multiple information is captured by CNN + LSTM, which makes it promising for automatic feature extraction. The proposed CNN + LSTM shows the superiority of the model compared with the traditional models. The proposed CNN + LSTM considered sixteen PQDs and produced 100% accuracy for low noise grade and 99.31% under the worst noise grade compared with the other DL models and other traditional methods.Table 10
Comparison with the existing methods.
MethodsNumber of features selectedNumber of PQDsAccuracy in %Pure40 dB30 dB20 dBWPT and GA [18]15898.33---WT and PSO [19]1199896.8793.625–ST and RF [30]41599.799.999.795.9FFT and ANNs [31]–8–93.9595.65–ST and PNN [32]41197.4---FDST and DT [33]201399.2898.897.49–Deep CNN [24]AUTO999.67---Deep CNN [25]AUTO1699.9699.9599.6698.13Deep CNN [26]AUTO24---99.26The proposed CNN + LSTMAUTO1610010099.6999.31


## 5. Simulation of PQDs in Hybrid System

### 5.1. Hybrid System Studied

To further analyze the proposed method, a standard IEEE 13-node system [34] is modified to form a hybrid system as shown in Figure 5.Figure 5
Modified hybrid system.The hybrid system model is generated by incorporating the wind and solar photovoltaic (PV) cells into a standard IEEE 13-node test system. In the modified system, a wind energy conversion system (WECS) with doubly fed induction motor (DFIG) rated 1.5 MW, 575 V integrated at bus 680 through the transformer XWG, and an 8 km overhead transmission line. The model parameters of wind energy system have been reported in [35]. Similarly, a PV plant with the capacity of 1 MW is connected to the grid through the transformer XSPV at node 680, and the model parameters of complete PV system have been reported in [36]. Consequently, node 680 is considered as a point of common coupling (PCC). The complete experimental parameters such as load details, transformer data, and feeder details of the proposed system are provided in [37]. A capacitor bank is associated with nodes 611 and 675. The nonlinear load is connected to node 680 in the modified IEEE 13-node test system, and voltage regulator between nodes 632 and 650 is not used.


### 5.2. Generation of PQDs in Hybrid System

The modified IEEE 13-node system is simulated in MATLAB/Simulink. A normal waveform is produced at standard voltage and frequency. The voltage sag signal may be produced by adding line to ground faults at the generation side, switching huge load at a time, and sudden start-up of wind turbine. Voltage swell signals are generated by removing huge load in the system or by adding line to line faults at the generator end. For the generation of voltage interruption signal, the system is operated in islanding mode with the huge load in DGs that are tripped. Harmonics and notch are generated by connecting nonlinear loads. An oscillatory transient and spike are generated by switching a capacitor bank to the system due to the islanding process. The arc furnace model is connected at the load side to create flickering waveforms [38]. An impulsive transient is generated by connecting the lightning model in the system.The multiple PQDs may be produced by simultaneous presentations of faults, switching, and mode changing of the grid. Nevertheless, there is less opportunity for multiple PQDs at a time in any system. Therefore, on a hybrid system only single PQDs with 200 cases are generated by changing different combinations of grid operations. These samples are added with noise (40 dB, 30 dB, and 20 dB) such that the total samples are 800 (200 × 4). All these samples are validated through the proposed CNN + LSTM method, and the test results are presented in Table11. It is noted that 797 among 800 cases are classified correctly with the classification rate of 99.63%. The evaluation metrics such as precision, recall, and F1 score is the same as accuracy with 99.63%, which infers that the proposed DL model works better even though the test data set is different. These results show that the proposed DL model is a more generalized model for the detection and classification of PQDs.Table 11
Confusion matrix of hybrid system.
ActualPredictedC1C2C3C4C5C6C7C8C9C10PrecisionRecallF1 scoreC180000000000100.0098.7799.38C20790000010098.75100.0099.37C31079000000098.75100.0099.37C400080000000100.00100.00100.00C500008000000100.00100.00100.00C600000800000100.00100.00100.00C700000080000100.00100.00100.00C800000008000100.0097.5698.77C90000000179098.75100.0099.37C1000000000080100.00100.00100.00Average99.6399.6399.63


## 5.1. Hybrid System Studied

To further analyze the proposed method, a standard IEEE 13-node system [34] is modified to form a hybrid system as shown in Figure 5.Figure 5
Modified hybrid system.The hybrid system model is generated by incorporating the wind and solar photovoltaic (PV) cells into a standard IEEE 13-node test system. In the modified system, a wind energy conversion system (WECS) with doubly fed induction motor (DFIG) rated 1.5 MW, 575 V integrated at bus 680 through the transformer XWG, and an 8 km overhead transmission line. The model parameters of wind energy system have been reported in [35]. Similarly, a PV plant with the capacity of 1 MW is connected to the grid through the transformer XSPV at node 680, and the model parameters of complete PV system have been reported in [36]. Consequently, node 680 is considered as a point of common coupling (PCC). The complete experimental parameters such as load details, transformer data, and feeder details of the proposed system are provided in [37]. A capacitor bank is associated with nodes 611 and 675. The nonlinear load is connected to node 680 in the modified IEEE 13-node test system, and voltage regulator between nodes 632 and 650 is not used.


## 5.2. Generation of PQDs in Hybrid System

The modified IEEE 13-node system is simulated in MATLAB/Simulink. A normal waveform is produced at standard voltage and frequency. The voltage sag signal may be produced by adding line to ground faults at the generation side, switching huge load at a time, and sudden start-up of wind turbine. Voltage swell signals are generated by removing huge load in the system or by adding line to line faults at the generator end. For the generation of voltage interruption signal, the system is operated in islanding mode with the huge load in DGs that are tripped. Harmonics and notch are generated by connecting nonlinear loads. An oscillatory transient and spike are generated by switching a capacitor bank to the system due to the islanding process. The arc furnace model is connected at the load side to create flickering waveforms [38]. An impulsive transient is generated by connecting the lightning model in the system.The multiple PQDs may be produced by simultaneous presentations of faults, switching, and mode changing of the grid. Nevertheless, there is less opportunity for multiple PQDs at a time in any system. Therefore, on a hybrid system only single PQDs with 200 cases are generated by changing different combinations of grid operations. These samples are added with noise (40 dB, 30 dB, and 20 dB) such that the total samples are 800 (200 × 4). All these samples are validated through the proposed CNN + LSTM method, and the test results are presented in Table11. It is noted that 797 among 800 cases are classified correctly with the classification rate of 99.63%. The evaluation metrics such as precision, recall, and F1 score is the same as accuracy with 99.63%, which infers that the proposed DL model works better even though the test data set is different. These results show that the proposed DL model is a more generalized model for the detection and classification of PQDs.Table 11
Confusion matrix of hybrid system.
ActualPredictedC1C2C3C4C5C6C7C8C9C10PrecisionRecallF1 scoreC180000000000100.0098.7799.38C20790000010098.75100.0099.37C31079000000098.75100.0099.37C400080000000100.00100.00100.00C500008000000100.00100.00100.00C600000800000100.00100.00100.00C700000080000100.00100.00100.00C800000008000100.0097.5698.77C90000000179098.75100.0099.37C1000000000080100.00100.00100.00Average99.6399.6399.63


## 6. Conclusion

This study proposes an application of combined CNN and LSTM to the PQD classification. The proposed CNN + LSTM comprehends an automatic feature extraction and selection and eliminates conventional ladders to enhance PQD detection. The proposed CNN + LSTM is compared with the other models such as DCNNs and CNN + GRU. The result indicates that the proposed CNN + LSTM method has higher accuracy, while taking less training than the other DL models. Compared with the existing methods, the CNN + LSTM algorithm performs well in noisy environments. The number of the parameters and complexity of the CNN + LSTM model are reduced, and hence, the computation speed is less. The proposed method is validated with a hybrid system and evidenced to achieve PQD classification with high accuracy. The proposed method is comprehended under offline environments. However, the online implementation is considered in future work.



---

*Source: 7020979-2022-05-21.xml*