*Proceeding Paper* **Detection and Classification of Power Quality Disturbances Using LSTM †**

**Fatma Zohra Dekhandji \*, Abdelmadjid Recioui, Athmane Ladada and Taha Slimane Moulay Brahim**

Laboratory of Signals and systems, Institute of Electrical and Electronic Engineering, University M'hamed Bougara of Boumerdes, Boumerdes 35000, Algeria

**\*** Correspondence: fzdekhandji@univ-boumerdes.dz

† Presented at the 2nd International Conference on Computational Engineering and Intelligent Systems, Online, 18–20 November 2022.

**Abstract:** The detection and diagnosis of power quality (PQ) issues are critical topics in the electrical power system's generation, transmission, and distribution. Nonlinear loads, power electronic converters, system malfunctions, and switching events are the most common causes of PQ issues. The main purpose of this work is to use an artificial intelligence (AI) technique based on automatic feature extraction to discover and identify PQ difficulties. The AI technique consists of a dedicated architecture of the Long Short-Term Memory (LSTM) network, which is a special type of Recurrent Neural Network (RNN).

**Keywords:** smart grids; power quality; monitoring; LSTM

#### **1. Introduction**

In today's world, power quality (PQ) is important for modern electric power utilities and their consumers, especially when it comes to power quality disturbances, because of the huge increase in nonlinear load, the increased use of sensitive electronic devices, and the need to apply green power globally as well as increase renewable energy applications. Power quality issues have become more crucial than ever [1]. Interruptions and other disturbances are caused by greater usage of semiconductor devices, lighting controls, solidstate switching devices, inverters, and protection and relaying equipment. Such issues have become some of the most pressing concerns for engineers and decision-makers, as frequent occurrences result in significant financial losses for power companies [2].

Detecting power quality issues is critical for improving power quality in electric power systems and for making effective decisions about how to handle network disturbances. Engineers reading waveforms in the field is one method of identifying and classifying power disruptions. Unfortunately, due to the amount of data sampled in current power systems, manual recording is nearly impossible. Furthermore, more equipment failures in power systems occurred because of PQ problems, as well as damage to its sensitive controllers. As a result, the expense of addressing these issues is high in terms of finances, and it results in time losses. Therefore, studying the waveforms of power quality disturbances is important in order to detect and classify them successfully [3]. The power system must overcome various power quality challenges; some of them make it operational, resulting in a blackout of the network. The most significant challenges that the power system must overcome include:voltage spikes, voltage fluctuations, voltage unbalance, voltage sag, voltages swell, harmonic distortion, noise, very short interruptions, and long interruptions [4].

In order to evaluate the power quality and the disturbances that are experienced, it is necessary to detect and classify these disturbances in time, precisely and correctly. To do that, several signal processing methods, such as FT, ST, and WT, have offered sophisticated mathematical algorithms that may detect power quality problems, and these algorithms have shown substantial success in this field [3–5]. Classification techniques like ANN, SVM,

**Citation:** Dekhandji, F.Z.; Recioui, A.; Ladada, A.; Moulay Brahim, T.S. Detection and Classification of Power Quality Disturbances Using LSTM. *Eng. Proc.* **2023**, *29*, 2. https:// doi.org/10.3390/engproc2023029002

Academic Editor: Hamid Bentarzi

Published: 10 January 2023

**Copyright:** © 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

and Fuzzy logic provide assistance to the detecting algorithm by testing, validating, and training large amounts of signals. This helps to ensure that the selected algorithm is both successful and efficient [6]. Long Short-Term Memory (LSTM) hasprovided a powerful mathematical algorithm for the detection and classification of PQ problems in a power system. LSTM isa developed version of Recurrent Neural Network (RNN). LSTM contains neurons to perform computation (memory cells). These cells have weights and gates; the gates are the defining characteristic of LSTM models. There are three gates within each cell: theinput, forget, and output gates [7].

In this work, the PQ detection and classification system is presented in order to solve part of the power system problems. The paper is divided into the following sections: a description of power quality problems with their causes and effects. Next, a presentation of the existing detection and classification methods is given, with a brief explanation oftheiradvantages and drawbacks. Finally, the simulation results and their discussion are given, with conclusions drawn.

#### **2. Long Short-Term Memory (LSTM)**

#### *2.1. Recurrent Neural Networks (RNN)*

Recurrent neural networks (RNNs) are networks with an internal network loop that ensures information persistence. RNNs have been particularly developed to process sequential data [8]. RNNs have complete connections between adjacent layers and nodes within the same layer as illustrated in Figure 1. Furthermore, RNNs' hidden units receive feedback from prior states to current status. These properties are appropriate for dealing with temporal–spatial data [9].


**Figure 1.** Architecture of a recurrent neural network.

RNNs are referred to as recurrent because they do the same task for each element of a sequence, with the outcome relying on previous estimates. Another way to conceive of RNNs is that they have a "memory" that stores information about previous calculations [10]. As a result, RNNs can link earlier data to the current task. RNN is already being used to solve a number of problems using an internal state (memory) to process a sequence of inputs, including language modeling and translation, speech recognition, text recognition, time series data, and autonomous driving systems to predict vehicle trajectories and assist in avoiding accidents.

#### *2.2. RNN Architecture*

In Figure 2, (xt) denotes the current input of time step t, (ht) is the output of that time step, and A denotes the network's recurrently connected unit. The previous time step's output is passed on to the following time step as an extra input. If a dense layer is following, the last concealed state (ht) is passed and processed to form (yt ), or if a dense layer follows, (ht) is passed and processed to form (yt ).

**Figure 2.** A simple rolled RNN layer and its corresponding unrolled architecture.

#### *2.3. Long Short-Term Memory (LSTM)*

Long Short-Term Memory networks are a developed version of the previously mentioned simple RNNs. Hochreiter and Schmidthuber first proposed them in 1997 [11], and they have demonstrated accurate performance in modeling both long- and short-term dependencies of sequential data [8]. In theory, they were created expressly for long-term dependencies in order to overcome the vanishing/exploding gradient problem. Figure 3 shows the structure of a simple LSTM network for prediction, which includes a sequence input layer, an LSTM layer, and a prediction (classification) output layer.

**Figure 3.** LSTM network system.

#### *2.4. LSTM Network Architecture*

The LSTM architecture is based on the existence of a memory cell that is capable of maintaining its state over time and has a nonlinear gating mechanism that controls the flow of information into and out of the cell. The LSTM network is being utilized to create a more complicated and deeper nonlinear neural network capable of demonstrating the effect of long-term memory [12].

LSTM networks have an input layer, an output layer, and a multitude of hidden layers in between. The memory cell is built into the hidden layer. Each cell has three gates (input, forget, and output) and a recurrent connection unit [13].

The LSTM architecture is depicted in Figure 4 as it unfolds over time. The LSTM cell (denoted as A in Figure 4) on the left represents the previous time step, while the cell on the right represents the next time step. The current time step is halfway through. The cell contains three lines. It obtains the input (Xt) and the output from the previous time step in the bottom left corner (the output from the previous layer is called the hidden state in RNNs and is abbreviated as (ht−1). Before running into the four gates denoted as yellow boxes in the drawing, the input (Xt) and the hidden state (ht−1) are concatenated. The cell's third input, which comes from the preceding cell, is represented by a straight arrow that passes through the upper section of the cells. This is the cell state, which allows the LSTM to remember long-term dependencies with a far lower risk of the vanishing and exploding gradient problems that plague typical RNNs [14–17].

**Figure 4.** LSTM module containing four interacting layers.

#### **3. Results and Discussions**

#### *3.1. Description of the Simulation Environment*

MATLAB is used to generate several PQ signals, including interruptions, sag, harmonic distortion, flicker, swell, surge, sag with harmonics, and swell with harmonics, in this section. A comparative study to evaluate the LSTM performance in terms of the detection and classification of these signals is performed. Each simulated waveform is made up of voltage waves recorded at a rate of 64 samples per cycle. A total of 200 case studies are created for each power quality problem by varying the voltage magnitude and the beginning and finish time instants of each PQ problem. Simulated signals are blended with random white noise with signal-to-noise ratios of 40 dB and 20 dB, respectively.

The signal-to-noise ratio (SNR) is a metric that compares the strength of a desired signal to the strength of an additive white Gaussian noise as:

$$\text{SNR} = \frac{\text{Psignal}}{\text{Proise}} \tag{1}$$

where P designates the power. Higher values of SNR generally mean a better specification since this means more useful information (the signal) than unwanted data (the noise).

#### *3.2. Proposed Methodology*

As shown in Figure 5, the LSTM system is designed and built to perform detection and classification using five parameters: amplitude, start time, end time, duration, and THD percent, as well as two outputs: waveform class and harmonics indicator.

**Figure 5.** Block diagram of proposed method.

#### *3.3. Model Implementation and Training*

In this section, the proposed model is trained by altering the voltage magnitude and the start and finish time instants of each power quality problem; 200 case studies are constructed for each PQ problem. Figure 6 shows the trained system.

**Figure 6.** Training process of LSTM model.

To detect and classify the problem waveforms, the LSTM has two outputs as follows:



**Table 1.** LSTM Network Outputs.

#### *3.4. Results and Discussions*

Table 2 summarizes the performance of the LSTM technique following extensive simulations. The percentage values indicated show how good LSTM is in terms of power quality disturbance detection and classification.


**Table 2.** Summary of the Obtained results.

The following remarks may be drawn from Table 2:


#### **4. Conclusions**

The main objective of this work is to develop a Power Quality Detection and Classification using Long Short-Term Memory (LSTM). The method is able to identify and classify several PQ problems (normal, sag, swell, surge, distortion, and interruption) in both simple and complex power quality disturbances in the presence of random noise at different values of the signal-to-noise ratio (SNR). The detection and classification using the LSTM model aredesigned and implemented to perform with five input data parameters (amplitude, start time, end time, duration, THD %) and two outcomes: the waveform class and a harmonics content indicator.The detection and classification of PQ problems using LSTM show the high accuracy of this model, even in the worst cases of adding harmonics with 30-dB SNR simultaneously with PQ problemsignals. This proves the robustness of the LSTM method, as the obtained classification rate was 96.3674%. Hence, the findings of the present work prove that the LSTM network is a leading method in the world of PQ detection and classification.

**Author Contributions:** Conceptualization, F.Z.D. and A.R.; methodology, A.R.; software, F.Z.D.; validation, A.R., T.S.M.B. and A.L.; formal analysis, F.Z.D.; investigation, A.R.; resources, F.Z.D.; data curation, T.S.M.B.; writing—original draft preparation, F.Z.D.; writing—review and editing, A.R.; visualization, F.Z.D.; supervision, A.R.; project administration, F.Z.D. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research received no external funding.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable.

**Data Availability Statement:** The data presented in this study are available on request from the corresponding author. The data have been synthesized for the purpose of this study and are not publicly available.

**Conflicts of Interest:** The authors declare no conflict of interest.

#### **References**


**Disclaimer/Publisher's Note:** The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
