Reduction of Total Harmonic Distortion of Wind Turbine Active Power Using Blade Angle Adaptive PI Controller

: Power quality can have a large detrimental effect on industrial processes and the commer-cial sector. Thus, this paper proposes a new technique to improve the power quality of electric power systems. This technique relies on auto-adjusting of the blade angle to mitigate the harmonics in wind generator active power. A new adaptive PI blade-angle controller is applied in this technique to reduce the total harmonic distortion ( THD ) of the output power. The parameters of the adaptive PI controller are initialized by using the Harmony Search algorithm (HSA), hybrid Harmony Search optimization and Equilibrium optimization (EO), and hybrid Harmony Search optimization and Teaching learning-based optimization (TLBO). The execution of the optimization algorithms relies mainly on the optimization objective function. Two optimization objective functions are mathemat-ically modeled and compared to enhance the power quality. The ﬁrst one is to minimize the sum square of error, while the second objective is to minimize the THD . Many case studies are applied with various wind-speed proﬁles under normal and faulty conditions. Results show the superiority of HSA hybrid EO algorithm with the second objective functions through reducing the harmonics and enhancing the power quality. Moreover, laboratory studies are applied to investigate the effect of the blade-angle variations on the extracted active power. M.A.S.; M.A.A. and A.E.-M.; project administration, M.A.A. and A.E.-M.; funding acquisition, M.A.S. authors read the of manuscript.


Introduction
Due to the rising demand for wind energy, power quality has become a significant issue. Wind power plants should ensure the stability and reliability of the power system by achieving the required power-quality standards. The main problems of the wind-system power quality are voltage deviation, voltage flicker, voltage fluctuation, and harmonic distribution [1,2].
In the presented research work, only the power quality harmonics issue is considered. Harmonics in electric power systems can cause several complications; as in doubly fed induction generators (DFIG), the unwanted harmonic current can cause torque pulsations, more copper-winding losses, and thermal effects on transformers and rotating machines. Harmonics may also excite mechanical resonance modes of the wind-turbine components [3].
The harmonics are mainly composed due to nonlinear loads. Moreover, in DFIG wind turbines, power converters that control the real and reactive power can generate harmonics due to their nonlinear devices. Furthermore, harmonics can be generated by the rotor non-sinusoidal conditions and the unbalance stator voltages. Unbalanced stator voltages can be resolved into three sequences: positive, negative, and zero-sequence voltages. These

Total Harmonic Distortion (THD)
The harmonics frequency can be defined as follows: where n is a positive integer that represents the harmonic order. When n < 1, it is called sub-harmonics [19]. Figure 1 shows a waveform that contains first and third harmonics. In the description of the harmonic order, there are three types of harmonics: even harmonics, odd harmonics, and define triplet harmonics. The harmonic sequence has three harmonic sequences: positive sequence, negative sequence, and zero sequence harmonics [20].

Total Harmonic Distortion (THD)
The harmonics frequency can be defined as follows: = n f (1) where n is a positive integer that represents the harmonic order. When n < 1, it is called sub-harmonics [19]. Figure 1 shows a waveform that contains first and third harmonics.
In the description of the harmonic order, there are three types of harmonics: even harmonics, odd harmonics, and define triplet harmonics. The harmonic sequence has three harmonic sequences: positive sequence, negative sequence, and zero sequence harmonics [20]. There are two main definitions for total harmonic distortion. Originally, it was defined as the harmonic components of a waveform compared to the fundamental component [21,22]. Moreover, it can be defined as the harmonic components compared to the waveform's root mean square (RMS) components [23]. At low values of THD, the two definitions nearly give the same values. Thus, THD is defined as follows [24]: where is the current of the nth harmonic; n is the harmonic value, and all possible harmonics are included; and I1 is the nominal system current at the fundamental frequency. The first definition is used in this paper. Moreover, and are the total harmonic distortion of voltage, V, and power, P, respectively, as shown in following equations: The standard limits of the total harmonic distortion (THD) in any power system are listed in (ANSI/IEEE 519-1992) standard lists [25,26]. Thus, the analysis of the harmonics of the system and the system installation should meet standard (IEEE 519-1992) to limit the THD [27].
The distortion power or the distortion volt-amperes is given by the quantity D. It represents all cross products of voltage and current at different frequencies. The quantity D cannot be defined as power, because it does not flow through the system. The quantity Q represents the sum of the traditional reactive power values at each frequency. P, Q, D, and S are correlated as follows: There are two main definitions for total harmonic distortion. Originally, it was defined as the harmonic components of a waveform compared to the fundamental component [21,22]. Moreover, it can be defined as the harmonic components compared to the waveform's root mean square (RMS) components [23]. At low values of THD, the two definitions nearly give the same values. Thus, THD is defined as follows [24]: THD = ∑ ∞ n=2 I n 2 I 1 (2) where I n is the current of the nth harmonic; n is the harmonic value, and all possible harmonics are included; and I 1 is the nominal system current at the fundamental frequency. The first definition is used in this paper. Moreover, THD 1 and THD 2 are the total harmonic distortion of voltage, V, and power, P, respectively, as shown in following equations: The standard limits of the total harmonic distortion (THD) in any power system are listed in (ANSI/IEEE 519-1992) standard lists [25,26]. Thus, the analysis of the harmonics of the system and the system installation should meet standard (IEEE 519-1992) to limit the THD [27].
The distortion power or the distortion volt-amperes is given by the quantity D. It represents all cross products of voltage and current at different frequencies. The quantity D cannot be defined as power, because it does not flow through the system. The quantity Q represents the sum of the traditional reactive power values at each frequency. P, Q, D, and S are correlated as follows: This power factor is called the distorted power factor, and it is caused by the harmonics [28].

Laboratory Studies
The operation of the blade-angle controller is divided into four main regions, as shown in Figure 2. Before the cut in speed (nearly 4.9 m/s), no electric power is generated. Between the cut in speed and the rated speed (nearly 12 m/s), the controller aims to maximize the generated power (maximum power point tracking MPPT). Above the rated speed, the controller function is to regulate the generated power at rated value. Regions two and three are known as the utilized power range. At high gust-wind speeds (above 25 m/s), the turbine should be locked to protect the turbine (shutdown power range) [29].
This power factor is called the distorted power factor, and it is caused by the harmonics [28].

Laboratory Studies
The operation of the blade-angle controller is divided into four main regions, as shown in Figure 2. Before the cut in speed (nearly 4.9 m/s), no electric power is generated. Between the cut in speed and the rated speed (nearly 12 m/s), the controller aims to maximize the generated power (maximum power point tracking MPPT). Above the rated speed, the controller function is to regulate the generated power at rated value. Regions two and three are known as the utilized power range. At high gust-wind speeds (above 25 m/s), the turbine should be locked to protect the turbine (shutdown power range) [29]. The impact of changing the blade angle on the turbine output power can be illustrated inside the Laboratory. The LUCAS-NÜLLE GmbH model wind power plant connection diagram is shown in Figure 3a. All the scenarios of practical relevance are emulated under different wind-speed profiles, with the aid of the wind turbine controller. The LUCAS-NÜLLE GmbH Model wind lab is composed of the following [30,31]: 1. Wind-turbine control unit that comprises two three-phase inverters; 2. A 400/230 V rated voltage three-phase DFIG generator of 0.8 kW rated power; 3. A 1 KVA rated power three-phase transformer; 4. A variable output voltage (0-240 V) power supply with (3-10 A) adjustable limit output current; 5. Three-phase meters. Figure 3b shows the wind power plant laboratory setup. Initially, the DFIG is set at the synchronization speed (4.9 m/s) with zero pitch angle. At this speed, the generator stator side is connected to the grid. The impact of changing the blade angle on the turbine output power can be illustrated inside the Laboratory. The LUCAS-NÜLLE GmbH model wind power plant connection diagram is shown in Figure 3a. All the scenarios of practical relevance are emulated under different wind-speed profiles, with the aid of the wind turbine controller. The LUCAS-NÜLLE GmbH Model wind lab is composed of the following [30,31]: Wind-turbine control unit that comprises two three-phase inverters; 2.
Three-phase meters. Figure 3b shows the wind power plant laboratory setup. Initially, the DFIG is set at the synchronization speed (4.9 m/s) with zero pitch angle. At this speed, the generator stator side is connected to the grid.
The wind turbine control unit allows three modes of operation: fixed speed fixed pitch (FSFP), variable speed fixed pitch (VSFP), and variable speed variable pitch (VSVP).  The wind turbine control unit allows three modes of operation: fixed speed fixed pitch (FSFP), variable speed fixed pitch (VSFP), and variable speed variable pitch (VSVP).
The first mode of operation is applied at different wind speeds: 5, 6, and 7 m/s. The blade angle is varied from zero degree to 15 degrees with step size 5 degrees. The active power is directly proportional to the cubic of the velocity. The maximum active power is achieved at zero blade angle and is inversely proportional with the blade angle, as shown in Figure 4a-c. The first mode of operation is applied at different wind speeds: 5, 6, and 7 m/s. The blade angle is varied from zero degree to 15 degrees with step size 5 degrees. The active power is directly proportional to the cubic of the velocity. The maximum active power is achieved at zero blade angle and is inversely proportional with the blade angle, as shown in Figure 4a  In Reference [31], the second mode is applied, and the results show that the maximum power is achieved at zero blade angle, and that there is an inverse relation between the blade angle and the output active power. In this paper, the third mode is applied to discuss the blade-angle variations through the four regions of blade-angle control.
The third mode of operation (VSVP) is applied through four different case studies at four different wind-speed profiles, as shown in Figures 5-8. Below the cut in speed (4.9 m/s) the WT is not able to generate power at all. Between 4.9 and 9 m/s (rated speed), the In Ref. [31], the second mode is applied, and the results show that the maximum power is achieved at zero blade angle, and that there is an inverse relation between the blade angle and the output active power. In this paper, the third mode is applied to discuss the blade-angle variations through the four regions of blade-angle control.
The third mode of operation (VSVP) is applied through four different case studies at four different wind-speed profiles, as shown in  (4.9 m/s) the WT is not able to generate power at all. Between 4.9 and 9 m/s (rated speed), the blade angle is automatically tuned to reach the maximum allowable power by keeping the blade angle at zero degree (MPPT). Above the 9 m/s, the rated power (150 watt) is reached, and the blade angle's function is to regulate this rated power. Power regulation occurs by increasing the blade angle to keep up with the increase of wind speed. blade angle is automatically tuned to reach the maximum allowable power by keeping the blade angle at zero degree (MPPT). Above the 9 m/s, the rated power (150 watt) is reached, and the blade angle's function is to regulate this rated power. Power regulation occurs by increasing the blade angle to keep up with the increase of wind speed.    blade angle is automatically tuned to reach the maximum allowable power by keeping the blade angle at zero degree (MPPT). Above the 9 m/s, the rated power (150 watt) is reached, and the blade angle's function is to regulate this rated power. Power regulation occurs by increasing the blade angle to keep up with the increase of wind speed.

Wind Turbine Model
The wind-power system is simulated on SIMULINK/MATLAB, as shown in Figure  9. It is connected to an infinity source (120 KV) through 25 km transmission line. The wind power plant consists of six wind turbines, each of 1.5 MW rated power. Each wind turbine consists of a doubly fed induction generator (DFIG) and a protection system, which is used to continuously monitor the voltage, current, and the machine speed. The API controller is inside the wind-turbine doubly fed block.

Wind Turbine Model
The wind-power system is simulated on SIMULINK/MATLAB, as shown in Figure  9. It is connected to an infinity source (120 KV) through 25 km transmission line. The wind power plant consists of six wind turbines, each of 1.5 MW rated power. Each wind turbine consists of a doubly fed induction generator (DFIG) and a protection system, which is used to continuously monitor the voltage, current, and the machine speed. The API controller is inside the wind-turbine doubly fed block.

Wind Turbine Model
The wind-power system is simulated on SIMULINK/MATLAB, as shown in Figure 9. It is connected to an infinity source (120 KV) through 25 km transmission line. The wind power plant consists of six wind turbines, each of 1.5 MW rated power. Each wind turbine consists of a doubly fed induction generator (DFIG) and a protection system, which is used to continuously monitor the voltage, current, and the machine speed. The API controller is inside the wind-turbine doubly fed block.

Adaptive PI Blade-Angle-Controller Model
The adaptive PI is expressed as follows [32][33][34]: where e(t) is the error signal, K c is a constant value, K p is the proportional gain, and K i is the integral gain. The integral and proportional gains are expressed as follows [32][33][34]: Energies 2021, 14, x FOR PEER REVIEW 9 of 26

Adaptive PI Blade-Angle-Controller Model
The adaptive PI is expressed as follows [32][33][34]: where e(t) is the error signal, is a constant value, is the proportional gain, and is the integral gain. The integral and proportional gains are expressed as follows [32][33][34]: The parameters of the controller are , , and [32,33]. The previous equations show that the controller gains ( , ) are time-varying quantities, and this is an advantage over the conventional PID controller. The and are adjusted by the square of error signal and controller parameters to withstand any variation in the wind-speed profile or the system parameters. The adaptive PI controller block diagram is shown in Figure 10.

Blade-Angle Mechanical Delay
There are limitations to the rate of change of the blade angle ( ), due to the mechan- The parameters of the controller are K 1 , K 2 , and K c [32,33]. The previous equations show that the controller gains (K p , K i ) are time-varying quantities, and this is an advantage over the conventional PID controller. The K p and K i are adjusted by the square of error signal and controller parameters to withstand any variation in the wind-speed profile or the system parameters. The adaptive PI controller block diagram is shown in Figure 10.

Adaptive PI Blade-Angle-Controller Model
The adaptive PI is expressed as follows [32][33][34]: where e(t) is the error signal, is a constant value, is the proportional gain, and is the integral gain. The integral and proportional gains are expressed as follows [32][33][34]: The parameters of the controller are , , and [32,33]. The previous equations show that the controller gains ( , ) are time-varying quantities, and this is an advantage over the conventional PID controller. The and are adjusted by the square of error signal and controller parameters to withstand any variation in the wind-speed profile or the system parameters. The adaptive PI controller block diagram is shown in Figure 10.

Blade-Angle Mechanical Delay
There are limitations to the rate of change of the blade angle ( ), due to the mechanical delay of the servo motors that are responsible for blades rotation. These limitations are expressed as follows:

Blade-Angle Mechanical Delay
There are limitations to the rate of change of the blade angle (β), due to the mechanical delay of the servo motors that are responsible for blades rotation. These limitations are expressed as follows: Moreover, the operating range of the blade angle is limited between zero to 45 • .

Optimization Algorithm
Recently, different classical and heuristics optimization algorithms are applied to enhance the performance of the system and increase its reliability. Three heuristic optimization algorithms are proposed to initialize the adaptive PI controller parameters.

Harmony Search Algorithm (HSA)
The Harmony Search algorithm is a meta-heuristic algorithm which relies on the improvisation process of musicians [35].
The implementation of the HS algorithm follows these steps: Step1: Initialization of harmony memory (HM).
Step2: Improvisation of new harmony.
Step3: The new harmony is included in the HM or excluded.
Step4: repeating Steps 2 and 3 until stopping criteria are met.

Teaching Learning-Based Optimization (TLBO)
Similar to other nature-based algorithms, TLBO is considered as a population method that uses population of solutions. It relies mainly on group of learners and two phases: learning phase and teaching phase [36].

Equilibrium Optimization (EO)
The EO algorithm relies on the volume balance models. These models are used to estimate both equilibrium and dynamic states. The algorithm consists mainly of particles; each particle has its own concentration. This group of particles acts as search agents [37].

Hybrid Optimization Algorithm (HSATLBO, HSAEO)
Hybrid optimization combines two optimization algorithms and applies it to reach the optimal solution. In this algorithm, initially, HSA is applied, and its optimum solution is obtained. The obtained optimum solution is tolerated by ±10% and used as an input range for both TLBO and EO optimization algorithms.

Objective Function
Two different objective functions are identified for the proposed problem. One is the voltage and power error objective function, and the second one is the total harmonic distortion objective function.

Error Objective Function
The error objective function is defined by the summation of the square of error in both signals: voltage signal and power signal. The two signals (voltage and power) are compared with reference signal and the square of error of both signals are finally summed. The main purpose of the optimization algorithm is to minimize this sum square of errors. The error in the voltage signal (E v ) is given in Equation (11): The error in the power signal (E p ) is given in Equation (12): The equation of objective is given in Equation (13):

Total Harmonic Distortion (THD) Objective Function
The total harmonic distortion is determined from the power signal. The mathematical model of the THD calculates the first five harmonics, using only Fast Fourier transform analysis (FFT) [38]. Reducing the THD is the objective of the algorithms. The objective two equation is given as Equation (14):

Normal and Faulty Case Studies
The simulated case studies include a comparison between the proposed adaptive PI controller with the conventional PID controller to prove that the adaptive PI is as good as or better than the PID controller. Moreover, the case studies include a comparison between the two objective functions: error objective (Section 5.2.1) and THD objective (Section 5.2.2). The comparison is carried out at normal and LG (line-ground) faulty conditions. In Ref. [33], we proved the superiority of the adaptive PI over the PID controller. Moreover, it was shown that the hybrid (HSA-TLBO) shows better response than HSA and other optimization algorithms.

Normal Cases
The blade angles of the turbine are tuned by the PID controller with the error objective function, while they are tuned by the adaptive PI controller with both the error objective and THD objective functions. The algorithms are applied to initialize the controller's parameters, which are listed in Table 1. These parameters are used in all normal cases. The first case is the validation case study of the proposed controller with the new objective function (THD objective). Figure 11 shows the wind-speed profile applied to wind turbine. The active power responses for the adaptive PI controller show better performance with lower oscillations than the conventional PID, as shown in Figure 12a. The active powers of the three API controllers are superimposed under the green curve. The power responses for the adaptive PI (HSA-EO) controller with the two objective functions are  The active power responses for the adaptive PI controller show better performance with lower oscillations than the conventional PID, as shown in Figure 12a. The active powers of the three API controllers are superimposed under the green curve. The power responses for the adaptive PI (HSA-EO) controller with the two objective functions are nearly the same. The API HAS-EO with objective two has the lowest steady state error, as shown in Figure 12b. The active power responses for the adaptive PI controller show better performance with lower oscillations than the conventional PID, as shown in Figure 12a. The active powers of the three API controllers are superimposed under the green curve. The power responses for the adaptive PI (HSA-EO) controller with the two objective functions are nearly the same. The API HAS-EO with objective two has the lowest steady state error, as shown in Figure 12b.
The blade angles of the controllers are shown in Figure 12b. The blade angle of the PID starts from zero value to acquire less rising time, but it failed to keep up with the wind-speed fluctuations. Meanwhile, the adaptive PI blade angles overcame the windspeed fluctuations and regulated the power. The numerical comparisons of the controllers are listed in Table 2. The adaptive PI controllers outperform the classical PID. The differences between the three adaptive PI The blade angles of the controllers are shown in Figure 12b. The blade angle of the PID starts from zero value to acquire less rising time, but it failed to keep up with the windspeed fluctuations. Meanwhile, the adaptive PI blade angles overcame the wind-speed fluctuations and regulated the power.
The numerical comparisons of the controllers are listed in Table 2. The adaptive PI controllers outperform the classical PID. The differences between the three adaptive PI controllers are very small. The active power statistical analysis of each controller is given in Table 3. The K p and K i parameters of the adaptive PI are shown in Figure 13a,b, respectively. The results show the advantage of the adaptive PI with time-varying parameters that continuously vary with wind-speed fluctuations to the PID with constant parameters. The and parameters of the adaptive PI are shown in Figure 13a,b, respectively. The results show the advantage of the adaptive PI with time-varying parameters that continuously vary with wind-speed fluctuations to the PID with constant parameters. The total harmonic distortion of the active power with different control strategies are shown in Figure 14. The adaptive PI shows lower THD compared to the PID controller. Moreover, for the adaptive PI, the THD objective function (Obj. 2) shows lower THD than the error objective function (Obj. 1). The power THD of API with objective two is 7.1189% at bus voltage equal to 575 volts, as shown in Figure 14. The IEEE standard 519-2014 did not define the power THD limits, while it defined the accepted limit of voltage THD at bus voltage (≤1 kv) to be less than or equal to 8% [41]. The total harmonic distortion of the active power with different control strategies are shown in Figure 14. The adaptive PI shows lower THD compared to the PID controller. Moreover, for the adaptive PI, the THD objective function (Obj. 2) shows lower THD than the error objective function (Obj. 1). The power THD of API with objective two is 7.1189% at bus voltage equal to 575 volts, as shown in Figure 14. The IEEE standard 519-2014 did not define the power THD limits, while it defined the accepted limit of voltage THD at bus voltage (≤1 kv) to be less than or equal to 8% [41].

Normal Second Case
Another wind-speed profile is applied to the wind turbine, as shown in Figure 15. Figure 16a,b shows the active power and blade-angle responses of the adaptive PI with different objective functions. The performance of the new objective function is better with no oscillations and less settling time. Figure 17a,b shows the adaptive PI and gains, respectively.

Normal Second Case
Another wind-speed profile is applied to the wind turbine, as shown in Figure 15. Figure 16a,b shows the active power and blade-angle responses of the adaptive PI with different objective functions. The performance of the new objective function is better with no oscillations and less settling time. Figure 17a,b shows the adaptive PI K p and K i gains, respectively.

Normal Second Case
Another wind-speed profile is applied to the wind turbine, as shown in Figure 15. Figure 16a,b shows the active power and blade-angle responses of the adaptive PI with different objective functions. The performance of the new objective function is better with no oscillations and less settling time. Figure 17a,b shows the adaptive PI and gains, respectively.

Normal Second Case
Another wind-speed profile is applied to the wind turbine, as shown in Figure 15. Figure 16a,b shows the active power and blade-angle responses of the adaptive PI with different objective functions. The performance of the new objective function is better with no oscillations and less settling time. Figure 17a,b shows the adaptive PI and gains, respectively.  The numerical comparisons of the controllers are listed in Table 4. The three adaptive PI controllers have nearly the same rising time. The API HSA-TLBO and API HSA-EO with objective two have no oscillations unlike the API HAS-EO with objective one. Table  5 shows the active power statistical analysis of each controller. The robustness of the new objective function is more clearly proved by this third case. Another different wind-speed profile is applied to the wind turbine, as shown in Figure   Figure 17. (a) K p adaptive PI gain of normal second case. (b) K i adaptive PI gain of normal second case.
The numerical comparisons of the controllers are listed in Table 4. The three adaptive PI controllers have nearly the same rising time. The API HSA-TLBO and API HSA-EO with objective two have no oscillations unlike the API HAS-EO with objective one. Table 5 shows the active power statistical analysis of each controller. The robustness of the new objective function is more clearly proved by this third case. Another different wind-speed profile is applied to the wind turbine, as shown in Figure 18. Figure 19a,b shows the active power and the focusing active power of different control strategies respectively. The adaptive PI with the new objective function superb the other controllers due to its lowest oscillations. The blade angles and the controller's gains are shown in Figure 20a-c, respectively. The robustness of the new objective function is more clearly proved by this third case. Another different wind-speed profile is applied to the wind turbine, as shown in Figure  18. Figure 19a,b shows the active power and the focusing active power of different control strategies respectively. The adaptive PI with the new objective function superb the other controllers due to its lowest oscillations. The blade angles and the controller's gains are shown in Figure 20a-c, respectively.  The numerical comparisons of the controllers are listed in Table 6. The three adaptive PI controllers have nearly the same rising time. The API HSA-EO with objective two outperforms the other two controllers due to its lowest peak-to-peak oscillations. Table 7 shows the active power statistical analysis of each controller.
(a) The numerical comparisons of the controllers are listed in Table 6. The three adaptive PI controllers have nearly the same rising time. The API HSA-EO with objective two outperforms the other two controllers due to its lowest peak-to-peak oscillations. Table 7 shows the active power statistical analysis of each controller. The numerical comparisons of the controllers are listed in Table 6. The three adaptive PI controllers have nearly the same rising time. The API HSA-EO with objective two outperforms the other two controllers due to its lowest peak-to-peak oscillations. Table 7 shows the active power statistical analysis of each controller.

. Normal Fourth Case
Another gust-wind-speed profile is applied to the wind turbine, as shown in Figure 21. Figure 22a,b shows the active power and focusing active power responses of the adaptive PI with different objective functions. Figure 23 shows the blade angles of the two controllers. The performance of the new objective function is more robust with no oscillations than the old objective function. Figure 24a,b shows the adaptive PI K p and K i gains, respectively.
Another gust-wind-speed profile is applied to the wind turbine, as shown in Figure  21. Figure 22a,b shows the active power and focusing active power responses of the adaptive PI with different objective functions. Figure 23 shows the blade angles of the two controllers. The performance of the new objective function is more robust with no oscillations than the old objective function. Figure 24a,b shows the adaptive PI and gains, respectively. The numerical comparisons of the controllers are listed in Table 8. The three adaptive PI controllers have nearly the same rising time. The API HSA-EO with objective two outperforms the other two controllers, due to its lowest peak-to-peak oscillations. Table 9 shows the active power statistical analysis of each controller.  Another gust-wind-speed profile is applied to the wind turbine, as shown in Figure  21. Figure 22a,b shows the active power and focusing active power responses of the adaptive PI with different objective functions. Figure 23 shows the blade angles of the two controllers. The performance of the new objective function is more robust with no oscillations than the old objective function. Figure 24a,b shows the adaptive PI and gains, respectively. The numerical comparisons of the controllers are listed in Table 8. The three adaptive PI controllers have nearly the same rising time. The API HSA-EO with objective two outperforms the other two controllers, due to its lowest peak-to-peak oscillations. Table 9 shows the active power statistical analysis of each controller.    From Tables 3, 5, 7 and 9, the best standard deviation (SD) and root mean square error (RMSE) are for API HSA-EO Obj. 2.

Faulty Cases
In power systems, when faults occur, voltage unbalance is observed and, consequently, harmonics are produced [42]. Thus, the adaptive PI with the THD objective function is tested under different wind-speed profiles with faulty conditions. A line-to-ground (LG) short-circuit fault is applied in the middle of the transmission line with grounding   From Tables 3, 5, 7 and 9, the best standard deviation (SD) and root mean square error (RMSE) are for API HSA-EO Obj. 2.

Faulty Cases
In power systems, when faults occur, voltage unbalance is observed and, consequently, harmonics are produced [42]. Thus, the adaptive PI with the THD objective function is tested under different wind-speed profiles with faulty conditions. A line-to-ground (LG) short-circuit fault is applied in the middle of the transmission line with grounding The numerical comparisons of the controllers are listed in Table 8. The three adaptive PI controllers have nearly the same rising time. The API HSA-EO with objective two outperforms the other two controllers, due to its lowest peak-to-peak oscillations. Table 9 shows the active power statistical analysis of each controller. From Tables 3, 5, 7 and 9, the best standard deviation (SD) and root mean square error (RMSE) are for API HSA-EO Obj. 2.

Faulty Cases
In power systems, when faults occur, voltage unbalance is observed and, consequently, harmonics are produced [42]. Thus, the adaptive PI with the THD objective function is tested under different wind-speed profiles with faulty conditions. A line-to-ground (LG) short-circuit fault is applied in the middle of the transmission line with grounding resistance 0.1 ohm and 0.5 s fault duration. The case studies are applied to the adaptive PI controller with the two different objective functions. The parameters of the controller are initialized by HSA-EO algorithm (which is the most successful algorithm in normal cases) and listed in Table 10. The wind speed of Figure 11 is again applied to the wind turbine. The active power of adaptive PI with THD objective has lower steady state error, as shown in Figure 25a. The blade angle and the controller gains are shown in Figures 25b and 26a,b,  The wind speed of Figure 11 is again applied to the wind turbine. The active power of adaptive PI with THD objective has lower steady state error, as shown in Figure 25a. The blade angle and the controller gains are shown in Figures 25b and 26a,b, respectively. The numerical comparisons of the controllers are listed in Table 11. The two adaptive PI controllers have nearly same rising time, settling time, positive peak, and negative peak. Table 12 shows the active power statistical analysis of each controller.  The numerical comparisons of the controllers are listed in Table 11. The two adaptive PI controllers have nearly same rising time, settling time, positive peak, and negative peak. Table 12 shows the active power statistical analysis of each controller.  The adaptive PI with THD objective succeeded to reduce the total harmonic distortion to a very low acceptable value (9.93%), while the adaptive PI with error objective failed to reduce the THD (72.8%). The percentage of the active power THD for both controllers are shown in Figure 27. The authors of References [43][44][45] claimed that, at faulty conditions, the voltage and current THD can exceed the 8% limit of IEEE standard 519-2014 and reach 20%. The numerical comparisons of the controllers are listed in Table 11. The two adaptive PI controllers have nearly same rising time, settling time, positive peak, and negative peak. Table 12 shows the active power statistical analysis of each controller. ' Table 11. Numerical comparison between the controllers at faulty first case. The adaptive PI with THD objective succeeded to reduce the total harmonic distortion to a very low acceptable value (9.93%), while the adaptive PI with error objective failed to reduce the THD (72.8%). The percentage of the active power THD for both controllers are shown in Figure 27. The authors of References [43][44][45] claimed that, at faulty conditions, the voltage and current THD can exceed the 8% limit of IEEE standard 519-2014 and reach 20%.

Faulty Second CASE
The second case includes another applied wind-speed profile, as shown in Figure 28. Figure 29a shows the active power of the controllers. The adaptive PI HSA-EO has no oscillations and better response. Figures 29b and 30a,b show the blade-angle responses and the controller parameters, respectively.

Faulty Second CASE
The second case includes another applied wind-speed profile, as shown in Figure 28. Figure 29a shows the active power of the controllers. The adaptive PI HSA-EO has no

Faulty Second CASE
The second case includes another applied wind-speed profile, as shown in Figure 28. Figure 29a shows the active power of the controllers. The adaptive PI HSA-EO has no oscillations and better response. Figures 29b and 30a,b show the blade-angle responses and the controller parameters, respectively. The numerical comparisons of the controllers are listed in Table 13. The settling time of the API with objective two is lower than the API with objective one. Table 14 shows the active power statistical analysis of each controller.

Faulty Second CASE
The second case includes another applied wind-speed profile, as shown in Figure 28. Figure 29a shows the active power of the controllers. The adaptive PI HSA-EO has no oscillations and better response. Figures 29b and 30a,b show the blade-angle responses and the controller parameters, respectively. The numerical comparisons of the controllers are listed in Table 13. The settling time of the API with objective two is lower than the API with objective one. Table 14 shows the active power statistical analysis of each controller.  The third case includes another applied wind-speed profile, as shown in Figure 31. Figure 32a,b proved again the superiority of the adaptive PI HSA-EO, with THD objective over the error objective function. Figure 33a,b show the gains of the adaptive PI controllers. The numerical comparisons of the controllers are listed in Table 13. The settling time of the API with objective two is lower than the API with objective one. Table 14 shows the active power statistical analysis of each controller. The third case includes another applied wind-speed profile, as shown in Figure 31. Figure 32a,b proved again the superiority of the adaptive PI HSA-EO, with THD objective over the error objective function. Figure 33a,b show the gains of the adaptive PI controllers. The third case includes another applied wind-speed profile, as shown in Figure 31. Figure 32a,b proved again the superiority of the adaptive PI HSA-EO, with THD objective over the error objective function. Figure 33a,b show the gains of the adaptive PI controllers.  The numerical comparisons of the controllers are listed in Table 15. The settling time and the negative peak of the API with objective two are lower than that of the API with objective one. Table 16 shows the active power statistical analysis of each controller.   The numerical comparisons of the controllers are listed in Table 15. The settling time and the negative peak of the API with objective two are lower than that of the API with objective one. Table 16 shows the active power statistical analysis of each controller.   The numerical comparisons of the controllers are listed in Table 15. The settling time and the negative peak of the API with objective two are lower than that of the API with objective one. Table 16 shows the active power statistical analysis of each controller. Another gust-wind-speed profile is applied to the wind turbine, as shown in Figure 34. Figure 35a,b shows the active power and focusing active power responses of the adaptive PI with different objective functions. Figure 35b shows the blade angles of the two controllers. The performance of the new objective function is more robust with no oscillations than the old objective function. Figure 36a,b shows the adaptive PI K p and K i gains, respectively. The numerical comparisons of the controllers are listed in Table 17. The settling time, positive peak, and negative peak of the API with objective two are lower than those of the API with objective one. Table 18 shows the active power statistical analysis of each controller.  The numerical comparisons of the controllers are listed in Table 17. The settling time, positive peak, and negative peak of the API with objective two are lower than those of the API with objective one. Table 18 shows the active power statistical analysis of each controller.

Results
This paper proposes a new approach to enhance the system power quality obtained from wind turbines with DFIG by reducing the total harmonics distortion of the active power. The new approach relies mainly on adjusting the blade angle of the wind turbine. The blade angles are auto-adjusted by the proposed adaptive PI controller. The initialization of the proposed controller is carried out through using optimization algorithms. Two optimization objective functions are compared: error objective and THD objective.
The adaptive PI HSA-EO with THD objective performs better than the adaptive PI HSA-EO with error objective and the conventional PID in reducing THD. For normal cases, the THD decreases to 7.11% with the THD objective function, while in the error objective function, it decreases to 8.84%, and in the conventional PID, it decreases to 31.15%. In the faulty case, the THD decreases to 9.93% with the THD objective function, while in the error objective function, it decreases to 72.8%. Laboratory studies are also carried out to study the changes of the extracted active power with the blade-angle variations.  The numerical comparisons of the controllers are listed in Table 17. The settling time, positive peak, and negative peak of the API with objective two are lower than those of the API with objective one. Table 18 shows the active power statistical analysis of each controller.  From Tables 12, 14, 16, and 18, again, the best standard deviation (SD) and root mean square error (RMSE) is for API HSA-EO Obj. 2, except for case two, where the API HSA-EO Obj. 1 has a slightly better SD and RMSE but with higher oscillations in active power waveform.

Results
This paper proposes a new approach to enhance the system power quality obtained from wind turbines with DFIG by reducing the total harmonics distortion of the active power. The new approach relies mainly on adjusting the blade angle of the wind turbine. The blade angles are auto-adjusted by the proposed adaptive PI controller. The initialization of the proposed controller is carried out through using optimization algorithms. Two optimization objective functions are compared: error objective and THD objective.
The adaptive PI HSA-EO with THD objective performs better than the adaptive PI HSA-EO with error objective and the conventional PID in reducing THD. For normal cases, the THD decreases to 7.11% with the THD objective function, while in the error objective function, it decreases to 8.84%, and in the conventional PID, it decreases to 31.15%. In the faulty case, the THD decreases to 9.93% with the THD objective function, while in the error objective function, it decreases to 72.8%. Laboratory studies are also carried out to study the changes of the extracted active power with the blade-angle variations.

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