Modeling and Simulation of a PI Controlled Shunt Active Power Filter for Power Quality Enhancement Based on P-Q Theory

: The design of reliable power ﬁlters that mitigate current and voltage harmonics to meet the power quality requirements of the utility grid is a major requirement of present-day power systems. In this paper, a detailed systematic approach to design a shunt active power ﬁlter (SAPF) for power quality enhancement is discussed. A proportional–integral (PI) controller is adopted to regulate the DC-link voltage. The instantaneous reactive power theory is employed for the reference current’s extraction. Hysteresis current control is used to obtain the gate pulses that control the voltage source inverter (VSI) switches. The detailed SAPF is developed and simulated for balanced nonlinear loads and unbalanced nonlinear loads using MATLAB / Simulink. The simulation results indicate that the proposed ﬁlter can minimize the harmonic distortion to a level below that deployed by the Institute of Electrical and Electronics Engineers (IEEE) standards.


Introduction
Nonlinear electric appliances, which rely on power electronic switches, are widely used in the domestic and industrial utilization of every utility throughout the world [1,2]. The presence of nonlinear loads, such as personal computers, variable frequency drives (VFDs) and arc furnaces, gives rise to power quality problems, e.g., harmonic distortion, voltage fluctuation and noise [3][4][5]. Harmonic distortion in low-voltage distribution systems is responsible for power losses, electric devices heating, insulation failures, interference issues in communication systems and in the worst cases, electric power system failure [6,7]. Therefore, the need for the elimination of power quality problems has become an important issue for both the utility and the customer [8]. In order to curb the uncensored injection of harmonic currents in power networks, the Institute of Electrical and Electronics Engineers-Standards Association ("IEEE-SA") addressed the harmonics limitations standard in (IEEE Std 519-1992 [9]), which was revised in 2014 (IEEE Std 519-2014 [10]). The limits of the total harmonic distortion (THD) are specified in this standard to not exceed 5%. Hence, to comply with the 5% limit, power filters are used [11].
The literature review reveals that power filters are efficient available technologies that are widely used to eliminate harmonic distortion propagation. Conventionally, series and shunt passive power filters are tied to the distribution network for power quality improvement [12][13][14][15][16][17][18]. However, it is challenging to design a passive power filter that can effectively eliminate harmonic current distortion in industrial nonlinear loads connected to a stiff power supply. Moreover, the passive filter is associated with inherent drawbacks such as its enormous size, resonance with load impedance or utility impedance, Electronics 2020, 9,637 2 of 17 instability and inflexibility [19]. Conversely, active power filters (APFs) that employ voltage source inverters (VSIs) have been alternatively recommended as a replacement for passive filters to overcome the classic filter's limitations. APFs possess several features, including ascendant filtering accuracy, a fast dynamic response and flexibility, making it an ideal solution for power quality problems [20,21].
The harmonic mitigation capability of the shunt active power filter is mainly determined by the current harmonics and reactive power sensing method, as well as the compensation control algorithm [22]. Between the different reference compensation current control methods, the instantaneous reactive power theory (P-Q theory) is widely applied. The generalized version of the P-Q theory was first proposed by Akagi et al. in 1983 [23]. Many researchers have presented several techniques for fundamental and harmonic components extraction, such as reference compensation current determination and voltage regulation of the DC-link capacitor. In [24], the authors presented a modified instantaneous reactive power theory (P-Q theory) to estimate the reference compensation currents needed to compensate for the harmonic current drawn by the nonlinear loads connected at the point of common coupling (PCC). Gary W. et al. [25] proposed an approach that can perform harmonic current minimization under unbalanced voltage conditions. In [26], a strategy was presented to eliminate the harmonic distortion of the source side and minimize the inherent impact of the harmonics on the rectifier transformer. Wada [27] introduced a control strategy to avoid the "whack-a-mole" phenomenon which occurs with the presence of power factor correction capacitors in long-distance distribution feeders. The result showed that an active power filter connected to the end bus of the feeder can inhibit the harmonic proliferation throughout the feeder. In [28], the extraction of positive-sequence components using a sliding discrete Fourier transform is carried out to extract the reference compensation current. Mehrasa [29] introduced a multilevel converter control approach based on the Direct Lyapunov control algorithm to eliminate the harmonic current and compensate for the reactive power. Kanjiya [30] conducted real-time experiments to assess the proposed shunt active power filter that were controlled by a single-step noniterative optimized algorithm. The results proved that the proposed control technique can compensate for the harmonic currents under steady-state and dynamic load conditions. The literature review presents a solid framework for this study by affording various research on the shunt active power filter's design and control. Most of the previous research endeavors have attempted to enhance the power quality in balanced power systems. Additionally, there is a lack of published research that discusses the design of the shunt active power filter's (SAPF) proportional-integral (PI) controller. However, this paper describes, in detail, the procedures in which a Simulink model of the PI-based shunt active power filter employs the instantaneous reactive power theory for reference current extraction. The harmonic current compensation strategy is applied to a three-phase three-wire power system considering balanced and unbalanced nonlinear loads.
The next section presents the principle of the operation of the SAPF and discusses the methodology and details of the harmonics extraction algorithm used in this proposed system. The simulation results are presented and discussed in Section 3. Finally, Section 4 concludes the findings of the study.

Shunt Active Power Filter Topology and Operation: An Overview
A shunt active power filter, as shown in Figure 1 [31,32], is composed of two circuits: the power circuit and the control circuit. The power circuit is accountable for synthesizing the required compensation current. It consists of a PWM-based voltage source inverter (VSI) and a DC-link capacitor to maintain and regulate the DC voltage, as well as storing energy. Further, the control circuit continuously tracks the variation of the harmonic current to determine the instantaneous reference compensation current and consequently controls the power circuit to precisely synthesize the required harmonic current. The efficiency of the harmonic current compensation process broadly depends on the harmonic extraction and current control techniques [33], which will be discussed in the following subsections.
The concept of the shunt active power filter is rather modest. Before connecting the filter at the point of common coupling (PPC), the current flow in the power system is expressed as follows [34]: where i S is the source current, i L is the load current, i 1L represents the fundamental component of the load current and i H refers to the harmonic component of the load current. Subsequently, when the SAPF is installed at the PCC, two additional currents are presented: the harmonic compensation current generated by the SAPF which is equal in magnitude with the harmonic current, but the phase is shifted by 180 • ; and the DC-link current (i dc ) that is exploited by the SAPF to keep the DC-link voltage (V dc ) at the desired level. The current flow in the power system is then expressed as [34] i where i C denotes the injected compensation current and i dc refers to the DC-link current. Hypothetically, the harmonic compensation current is determined by the voltage level across the DC-link capacitor. When the voltage across the DC-link capacitor is maintained at the predetermined level, the generated harmonic compensation current will be precisely identical to the harmonic current drawn by the nonlinear load, where they will cancel out each other. In regard to this, the system's current becomes sinusoidal with the fundamental frequency, and the expression in (2) becomes as follows [34]: Electronics 2020, 9, x FOR PEER REVIEW 3 of 18 depends on the harmonic extraction and current control techniques [33], which will be discussed in the following subsections. The concept of the shunt active power filter is rather modest. Before connecting the filter at the point of common coupling (PPC), the current flow in the power system is expressed as follows [34]: where iS is the source current, iL is the load current, i1L represents the fundamental component of the load current and iH refers to the harmonic component of the load current. Subsequently, when the SAPF is installed at the PCC, two additional currents are presented: the harmonic compensation current generated by the SAPF which is equal in magnitude with the harmonic current, but the phase is shifted by 180°; and the DC-link current (idc) that is exploited by the SAPF to keep the DC-link voltage (Vdc) at the desired level. The current flow in the power system is then expressed as [34] where iC denotes the injected compensation current and idc refers to the DC-link current. Hypothetically, the harmonic compensation current is determined by the voltage level across the DC-link capacitor. When the voltage across the DC-link capacitor is maintained at the predetermined level, the generated harmonic compensation current will be precisely identical to the harmonic current drawn by the nonlinear load, where they will cancel out each other. In regard to this, the system's current becomes sinusoidal with the fundamental frequency, and the expression in (2) becomes as follows [34]: Figure 1. Three-phase three-wire shunt active power filter configuration.

Harmonic Extraction
The harmonic extraction estimation is a major process which has a direct influence on the effective performance and accuracy of the shunt active power filter. There are several techniques to

Harmonic Extraction
The harmonic extraction estimation is a major process which has a direct influence on the effective performance and accuracy of the shunt active power filter. There are several techniques to Electronics 2020, 9, 637 4 of 17 calculate the reference current, which are categorized under two approaches: time domain analysis and frequency domain analysis. The time domain analysis is a simple approach which relies on algebraic transformations and circuit analysis. It requires less calculation, and therefore shortens the control process. On the other hand, the frequency domain approach is more complex, requiring a large processing memory.
In this paper, the instantaneous reactive power theory (P-Q theory) in the time domain is presented and the simulation model is built using MATLAB/Simulink. Figure 2 shows the block diagram representation of the instantaneous reactive power theory. Basically, the instantaneous reactive power theory is based on the transformation of the a-b-c stationary reference coordinate to the 0-α-β rotating coordinate, which is known as a Clarke transformation. The source voltages and currents are transformed into 0-α-β components, as shown in the following expressions [35] where v a , v b , and v c refer to the three-phase voltages at the a-b-c coordinate, i a , i b , and i c represent the three-phase currents at the a-b-c coordinate, v 0 , v α , and v β are the three-phase voltages at the 0-α-β coordinate, and i 0 , i α , and i β refer to the three-phase currents at the 0-α-β coordinate.
The system considered in this paper is a three-phase three-wire system, therefore, a zero-sequence component is absent. In the α-β coordinate, the complex sum of the active and reactive powers (P and Q) can be represented by where S is the complex power, P refers to the active power, Q represents the reactive power, and * is the complex conjugate. Hence, the instantaneous active and reactive power components (P and Q) can be formed as follows [35]: Electronics 2020, 9, x FOR PEER REVIEW 4 of 17 calculate the reference current, which are categorized under two approaches: time domain analysis and frequency domain analysis. The time domain analysis is a simple approach which relies on algebraic transformations and circuit analysis. It requires less calculation, and therefore shortens the control process. On the other hand, the frequency domain approach is more complex, requiring a large processing memory. In this paper, the instantaneous reactive power theory (P-Q theory) in the time domain is presented and the simulation model is built using MATLAB/Simulink. Figure 2 shows the block diagram representation of the instantaneous reactive power theory. Basically, the instantaneous reactive power theory is based on the transformation of the a-b-c stationary reference coordinate to the 0-α-β rotating coordinate, which is known as a Clarke transformation. The source voltages and currents are transformed into 0-α-β components, as shown in the following expressions [35] where va, vb, and vc refer to the three-phase voltages at the a-b-c coordinate, ia, ib, and ic represent the three-phase currents at the a-b-c coordinate, v0, vα, and vβ are the three-phase voltages at the 0-α-β coordinate, and i0, iα, and iβ refer to the three-phase currents at the 0-α-β coordinate.
The system considered in this paper is a three-phase three-wire system, therefore, a zerosequence component is absent. In the α-β coordinate, the complex sum of the active and reactive powers (P and Q) can be represented by where S is the complex power, P refers to the active power, Q represents the reactive power, and * is the complex conjugate. Hence, the instantaneous active and reactive power components (P and Q) can be formed as follows [35]: With the presence of nonlinear loads, the instantaneous active and reactive power components are decomposed of their AC and DC parts, as illustrated in Expressions (8) and (9), respectively. As shown in Figure 3, the DC part (p) of the instantaneous real power (P) represents the fundamental voltage and current components and corresponds to the power transferred from the source to the load, while the AC part ( p) corresponds to the energy exchanged between the source and the load. The average or DC component of the instantaneous real power, which is the only power that should be provided by the three-phase AC source, is extracted by means of a high-order low-pass filter, as shown in Figure 2. With regard to the instantaneous reactive power component (Q), q and q, respectively, represent the fundamental component and harmonic component which are accountable for the energy circulation between the load phases [32]. With the presence of nonlinear loads, the instantaneous active and reactive power components are decomposed of their AC and DC parts, as illustrated in Expressions (8) and (9), respectively. As shown in Figure 3, the DC part ( ̅ ) of the instantaneous real power (P) represents the fundamental voltage and current components and corresponds to the power transferred from the source to the load, while the AC part ( ) corresponds to the energy exchanged between the source and the load. The average or DC component of the instantaneous real power, which is the only power that should be provided by the three-phase AC source, is extracted by means of a high-order low-pass filter, as shown in Figure 2. With regard to the instantaneous reactive power component (Q), and , respectively, represent the fundamental component and harmonic component which are accountable for the energy circulation between the load phases [32]. To generate the harmonic reference currents, the AC component ( ) of the active power and the total reactive power (Q) are required. To recompose the voltage source inverter switching losses, and to preserve the DC-link voltage at the required level, the shunt active power filter consumes a small amount of real power ( ̅ ) from the three-phase AC source or an external power supply. Therefore, the AC component ( ) of the active power is measured as in Equation (10). Hence, the compensation reference currents in the α-β coordinates are calculated using Expression (11) and transformed to the a-b-c coordinates through an inverse transformation, as shown in Expression (12). To generate the harmonic reference currents, the AC component ( p) of the active power and the total reactive power (Q) are required. To recompose the voltage source inverter switching losses, and to preserve the DC-link voltage at the required level, the shunt active power filter consumes a small amount of real power (p loss ) from the three-phase AC source or an external power supply. Therefore, the AC component ( p) of the active power is measured as in Equation (10). Hence, the compensation reference currents in the α-β coordinates are calculated using Expression (11) and transformed to the a-b-c coordinates through an inverse transformation, as shown in Expression (12).

Current Control Technique
Throughout the phase of the SAPF's current control design, several control methods have been applied in order to obtain the control pulses which are responsible for defining the operation of the filter switching states. Among these methods, the hysteresis band current is adopted in this study in order to generate the switching signals of the voltage source inverter. Through the different current control techniques, hysteresis current control is widely used due to its simple topology, fast response, accuracy and unconditioned stability.
In hysteresis current control, the current is kept in a predefined band of width, or the hysteresis band (HB), around the reference current, as shown in Figure 4. The actual current (i Sa ,i Sb , i Sc ) is compared to the reference current (i * a, , i * b , i * c ) and the VSI switches are turned on and off in accordance with the error to maintain the actual current within the hysteresis band. When the current error exceeds the upper limit of the hysteresis band, the VSI output is switched off or vice versa. Typically, the DC voltage goes to the maximum value when the output current needs to increase, and to the minimum voltage when the current needs to decrease [36].
filter switching states. Among these methods, the hysteresis band current is adopted in this study in order to generate the switching signals of the voltage source inverter. Through the different current control techniques, hysteresis current control is widely used due to its simple topology, fast response, accuracy and unconditioned stability. In hysteresis current control, the current is kept in a predefined band of width, or the hysteresis band (HB), around the reference current, as shown in Figure 4. The actual current ( , , ) is compared to the reference current ( , * , * , * ) and the VSI switches are turned on and off in accordance with the error to maintain the actual current within the hysteresis band. When the current error exceeds the upper limit of the hysteresis band, the VSI output is switched off or vice versa. Typically, the DC voltage goes to the maximum value when the output current needs to increase, and to the minimum voltage when the current needs to decrease [36].

PI controller
One of the crucial control phases of the shunt active power filter is to maintain a steady DC voltage level at the DC side of the voltage source inverter by means of DC-link voltage regulation. In general, power filters that employ voltage source inverters to generate the harmonic reference currents comprise of DC-link capacitors for energy storage. Hypothetically, the capacitor voltage should remain constant with no real power interchange between the filter and the AC grid. Practically, as aforementioned, the

PI Controller
One of the crucial control phases of the shunt active power filter is to maintain a steady DC voltage level at the DC side of the voltage source inverter by means of DC-link voltage regulation. In general, power filters that employ voltage source inverters to generate the harmonic reference currents comprise of DC-link capacitors for energy storage. Hypothetically, the capacitor voltage should remain constant with no real power interchange between the filter and the AC grid. Practically, as aforementioned, the voltage source inverter consumes a small portion of real power for its switching operation [11]. Hence, to maintain a constant DC-link voltage and effectively compensate the harmonic current, a proportional-integral controller is used in the DC-link voltage control loop. The DC-link capacitor voltage (v dc ) is compared with a reference DC voltage (v dc_ref ) and the error (v dc − v dc_ref ) is served as the input to the PI controller, in which the steady-state error in the reference current signal tracking is eliminated. Figure 5 illustrates the inner current control loop and the outer voltage control loop of the DC voltage PI controller. The gains G PI (s) and G VSI represent the transfer functions of the PI controller and VSI, respectively. When the VSI switches are operated at a high frequency, the magnitudes of (i Sa , i Sb , i Sc ) are almost equal to the magnitudes of (i * a, , i * b , i * c ). Therefore, it can be assumed that the closed-loop current controller transfer function is unity.
where i Sabc represent the three-phase source currents; i * abc refer to the three-phase reference current.
Electronics 2020, 9, 637 7 of 17 , ) are almost equal to the magnitudes of ( , , , ). Therefore, it can be assumed that the closed-loop current controller transfer function is unity.
where represent the three-phase source currents; * refer to the three-phase reference current. The values of the proportional gain (Kp) and integral gain (Ki) of the PI controller can be determined based on the step response of the closed-loop block diagram presented in Figure 6. Therefore, the transfer function of the controlled closed-loop of the DC voltage is derived as in Equation (14 where represents the DC voltage, _ is the DC reference voltage, refers to the proportional gain, is the integral gain, and C is the capacitor.  The values of the proportional gain (Kp) and integral gain (Ki) of the PI controller can be determined based on the step response of the closed-loop block diagram presented in Figure 6. Therefore, the transfer function of the controlled closed-loop of the DC voltage is derived as in Equation (14) v dc v dc_re f = where v dc represents the DC voltage, v dc_re f is the DC reference voltage, K p refers to the proportional gain, K i is the integral gain, and C is the capacitor.
( ) = * 1 (13) where represent the three-phase source currents; * refer to the three-phase reference current. The values of the proportional gain (Kp) and integral gain (Ki) of the PI controller can be determined based on the step response of the closed-loop block diagram presented in Figure 6. Therefore, the transfer function of the controlled closed-loop of the DC voltage is derived as in Equation (14 where represents the DC voltage, _ is the DC reference voltage, refers to the proportional gain, is the integral gain, and C is the capacitor.  Since the transfer function of the DC voltage closed-loop control is a second-order transfer function, the proportional gain (Kp) and the integral gain (Ki) can be determined by equating the obtained open-loop transfer function in Equation (14) with the general form transfer function of a second-order system in Expression (15) where ω n is the damping natural frequency, and ζ refers to the damping factor. By equating Equation (14) and Expression (15): Hence, K p = 2ζω n C and K i = ω n 2ζ

Results and Discussion
The effectiveness of the proposed shunt active power filter control algorithm in the mitigation of current harmonics due to nonlinear loads is performed through a system simulation using the MATLAB/Simulink power tool. Figure 7 shows the complete Simulink model that consists of (i) a three-phase AC voltage source, (ii) a nonlinear load (a resistor connected to a three-phase universal Electronics 2020, 9, 637 8 of 17 diode bridge), and (iii) a shunt active power filter. For the simulation, the system parameters are listed in Table 1. The analysis of the SAPF's effectiveness towards harmonic current elimination is examined under both balanced and unbalanced nonlinear load conditions.

Results and Discussion
The effectiveness of the proposed shunt active power filter control algorithm in the mitigation of current harmonics due to nonlinear loads is performed through a system simulation using the MATLAB/Simulink power tool. Figure 7 shows the complete Simulink model that consists of (i) a three-phase AC voltage source, (ii) a nonlinear load (a resistor connected to a three-phase universal diode bridge), and (iii) a shunt active power filter. For the simulation, the system parameters are listed in Table 1. The analysis of the SAPF's effectiveness towards harmonic current elimination is examined under both balanced and unbalanced nonlinear load conditions.    Figure 8 shows the distorted three-phase source current (i S ) and nonlinear load current (i L ) waveforms under a balanced system and with a nonlinear load connected. The source current is distorted due to the nonlinearity behavior of the load. The fast Fourier Transform (FFT) analysis in Figure 9 shows the total harmonic distortion (THD) of the source current as 30.88%, which exceeds the IEEE harmonic standard limit [10].  In order to generate the compensation reference current ( * , * , * ), the three-phase source voltage and current ( , , , and , , ) are sensed and transformed from the a-b-c coordinates to the α-β coordinates ( , and , ) by means of a Clarke transformation. Figures 10-12 show the Clarke transformation using Simulink and the transformed voltages and currents, respectively.   In order to generate the compensation reference current ( * , * , * ), the three-phase source voltage and current ( , , , and , , ) are sensed and transformed from the a-b-c coordinates to the α-β coordinates ( , and , ) by means of a Clarke transformation. Figures 10-12 show the Clarke transformation using Simulink and the transformed voltages and currents, respectively.  In order to generate the compensation reference current (i * a , i * b , i * c ), the three-phase source voltage and current (v a , v b , v c , and i a , i b , i c ) are sensed and transformed from the a-b-c coordinates to the α-β coordinates (v α , v β and i α , i β ) by means of a Clarke transformation. Figures 10-12 show the Clarke transformation using Simulink and the transformed voltages and currents, respectively.        These voltages and currents ( , and , ) are used to calculate the instantaneous active and reactive power. The instantaneous active power is passed through a high-order low-pass filter to extract the average component of the active power that is needed, along with the total reactive power to generate the reference current in the α-β coordinates. Furthermore, the generated compensation reference currents ( * , * ) are transformed from the α-β frame to the a-b-c frame ( * , * , * ). Figures 13-15 show the Simulink model of the reference compensation currents' generation, and their waveforms in the α-β and a-b-c frames, respectively. These voltages and currents (v α , v β and i α , i β ) are used to calculate the instantaneous active and reactive power. The instantaneous active power is passed through a high-order low-pass filter to extract the average component of the active power that is needed, along with the total reactive power to generate the reference current in the α-β coordinates. Furthermore, the generated compensation reference currents (i * α , i * β ) are transformed from the α-β frame to the a-b-c frame (i * a , i * b , i * c ). Figures 13-15 show the Simulink model of the reference compensation currents' generation, and their waveforms in the α-β and a-b-c frames, respectively.     Figure 16 shows the filtered source current and the load current waveforms after the shunt active power filter is connected to the point of common coupling and in parallel with the nonlinear load. The FFT analysis in Figure 17 shows that the Total Harmonic Distortion (THD) is reduced from 30.88% to only 1.18% which is a permissible value when compared with the 5% IEEE standard limit. . Figure 13. Simulink reference current generation in (a) the α-β frame; (b) the a-b-c frame.   Figure 16 shows the filtered source current and the load current waveforms after the shunt active power filter is connected to the point of common coupling and in parallel with the nonlinear load. The FFT analysis in Figure 17 shows that the Total Harmonic Distortion (THD) is reduced from 30.88% to only 1.18% which is a permissible value when compared with the 5% IEEE standard limit.  Figure 16 shows the filtered source current and the load current waveforms after the shunt active power filter is connected to the point of common coupling and in parallel with the nonlinear load. The FFT analysis in Figure 17 shows that the Total Harmonic Distortion (THD) is reduced from 30.88% to only 1.18% which is a permissible value when compared with the 5% IEEE standard limit.

Unbalanced System Nonlinear Load
In this section, the performance of the proposed shunt active filter is examined under an unbalanced nonlinear load condition. A three-phase unbalanced R-L-C load which is connected to an uncontrolled universal diode bridge is considered. Figures 18 and 19 show the source and load current waveforms, and the harmonic spectrum analysis for phase three before compensation, respectively. The total harmonic distortion of the system is 90.30%, which overrides the IEEE standards to a significant extent.

Unbalanced System Nonlinear Load
In this section, the performance of the proposed shunt active filter is examined under an unbalanced nonlinear load condition. A three-phase unbalanced R-L-C load which is connected to an uncontrolled universal diode bridge is considered. Figures 18 and 19 show the source and load current waveforms, and the harmonic spectrum analysis for phase three before compensation, respectively. The total harmonic distortion of the system is 90.30%, which overrides the IEEE standards to a significant extent.

Unbalanced System Nonlinear Load
In this section, the performance of the proposed shunt active filter is examined under an unbalanced nonlinear load condition. A three-phase unbalanced R-L-C load which is connected to an uncontrolled universal diode bridge is considered. Figures 18 and 19 show the source and load current waveforms, and the harmonic spectrum analysis for phase three before compensation, respectively. The total harmonic distortion of the system is 90.30%, which overrides the IEEE standards to a significant extent.  . Before compensation unbalanced system source current FFT analysis. Figure 19. Before compensation unbalanced system source current FFT analysis.
As shown in Figure 20, the distorted source current shown in Figure 18 is restored back to the sinusoidal waveform by means of the shunt active power filter. The source current's FFT analysis in Figure 21 reveals that the shunt active power filter reduced the THD of the source current from 12.97% to 1.13%. Table 2 summarizes the source current's total harmonic distortion results of the different conditions that have been considered in this study. The THD spectrum analysis of the proposed system has been compared with those of a few existing design methods available in the literature. The THD results, before compensation and after compensation, of the different methodologies are presented in Table 3. The tabular comparison reveals that the proposed system outperforms the other systems in the literature in harmonic current compensation for an unbalanced system and also occupies the third position for the balanced system.    As shown in Figure 20, the distorted source current shown in Figure 18 is restored back to the sinusoidal waveform by means of the shunt active power filter. The source current's FFT analysis in Figure 21 reveals that the shunt active power filter reduced the THD of the source current from 12.97% to 1.13%. Table 2 summarizes the source current's total harmonic distortion results of the different conditions that have been considered in this study. The THD spectrum analysis of the proposed system has been compared with those of a few existing design methods available in the literature. The THD results, before compensation and after compensation, of the different methodologies are presented in Table 3. The tabular comparison reveals that the proposed system outperforms the other systems in the literature in harmonic current compensation for an unbalanced system and also occupies the third position for the balanced system.

Conclusions
Power quality studies are aimed at maintaining the power systems' current and voltage as pure sinusoidal with a 1 p.u magnitude at a 1 p.u frequency and the phase shift of 120 degrees between the adjacent phases in a three-phase power system. Harmonic distortion is one of the power quality problems that are associated with nonlinear loads which draw non-sinusoidal currents and cause power quality deterioration. In this paper, the design aspects of a three-phase three-wire shunt active power filter, based on the instantaneous reactive power theory and hysteresis-PI control algorithm, have been simulated using the MATLAB/Simulink platform. The effectiveness of the filter in minimizing the current harmonics has been evaluated under balanced and unbalanced nonlinear load conditions. A comparative analysis with other algorithms has been performed to measure the proposed system performance compared with the other techniques in question.
The following conclusions have been made from the simulation analysis: • The proposed shunt active power filter was able to restore the distorted source current to its original sinusoidal waveform; • The investigations indicate that the proposed filter was able to minimize the current harmonics significantly less than the IEEE standard limits in both conditions; • The FFT spectrum analyses reveal that by employing the proposed SAPF, the THDs were reduced from 30.88% to 1.18 and from 12.97% to 1.13% for balanced and unbalanced systems, respectively; • The proposed shunt active power filter can effectively mitigate the harmonic current in both balanced and unbalanced power systems. However, the comparative study emphasized that the system performance surpassed the other states of art in the literature which are applied to balanced and unbalanced conditions.
This system can be experimentally established and verified through the development of a prototype model and the control algorithm can be extended in optimizing the PI controller parameters.