# Optimum System for Diagnosing Power Quality in Electrical Microgrids
## 1 Introduction  
In the last decades, global primary energy consumption has shown an increasing trend. The combustion of fossil fuels is the main source of energy production and is responsible for % of global greenhouse gas emissions. On the path towards net-zero carbon emissions by 2050, the share of renewable energy sources (RESs) in primary energy consumption will be increased [1, 2]. This new approach is known as distributed generation (DG), and it has promoted the transition from former grids to smart grids (SGs). However, DG notably affects the grid due to its variability, and numerous challenges such as effective forecasting, energy storage management, demand management systems, voltage control, and power system stability arise [3]. Specifically, the integration of DG, particularly with photovoltaic penetration, complicates voltages control in unbalanced distribution systems [4]. Advances in information and communications technologies (ICTs) allow researchers to overcome some of these challenges. In this sense, there are different electrical measurement devices to monitor the data about energy consumption and power quality (PQ), among other functions [5]. According to a European power quality survey [6], PQ issues cause a financial loss of more than EUR 150 billion per year in the 25 countries of the EU. These losses are due to devastating effects in loads and generation, transmission, and distribution systems, such as damage of sensitive loads, loss of efficiency of the power systems, and overheating of cables and equipment, among others [7]. The electronic devices (e.g., electric car chargers, rectifiers, ballasts, switch-mode power supplies, etc.) are one of the main producers of these PQ disturbances (PQDs). PQDs are classified into magnitude variations (voltage sags and swells), sudden transients (impulsive and oscillatory), and steady-state variations (harmonics, notch, and flicker) [8, 9], and their definitions and compatibility levels are contained in the EN 50160:2022 [10] for low, medium, high and, extra-high voltage supply. Among them, harmonic distortion is one of the most common PQDs and has become increasingly important in recent years due to the rise of non-linear and time-varying loads in power systems [11]. The proliferation of RESs facilitated by DG exacerbates the issue ofharmonics, as the power converters connecting these RESs to the power system generate harmonics during operation. In addition, the study of harmonics is crucial due to their inevitable propagation through other electrical microgrids and the broader power system. Identifying nodes that introduce harmonics in a microgrid is complex for two main reasons. First, the indices traditionally used to measure distortion only indicate the presence of distortion at different nodes, without revealing which nodes are responsible for injecting the distortion. Second, certain elements within microgrids, such as capacitors, do not inject harmonics but can amplify existing distortions at the point of common connection (PCC). Recognizing these elements as non-distorting is a significant challenge. In addition, identifying nodes that introduce harmonics is crucial because it allows for mitigating harmonics at their source, preventing their propagation throughout the grid. Therefore, a standard to regulate harmonic distortion measurement is essential. In this sense, the IEC 61000-2-2 [12] establishes total harmonic distortion (THD) as the index for measuring harmonic distortion in both voltage and current, specifying the maximum THD values at any point in the grid. However, this standard is insufficient for understanding the harmonic flow between different nodes in a microgrid. To overcome the above-mentioned drawback, several procedures and algorithms have been published over the last decades to show that flow [11; 13; 14] and even the identification of imbalanced sources [15; 16; 17] are needed to measure the instantaneous voltages and currents at all microgrid nodes. Therefore, the monitoring of all the microgrid nodes is crucial.