{'fraction_non_alphanumeric': 0.028196937988765283, 'fraction_numerical': 0.008921687410507766, 'mean_word_length': 4.603373791400946, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Enhanced Two-Stage Hierarchical Control for a Dual Mode WECS-Based Microgrid

: Along with the great beneﬁts of utilizing renewable energy (e.g., wind energy) in the power system, there are also some issues, such as increasing the uncertainty and reducing the system inertia. Communication-based centralized control has started to play a signiﬁcant role in reacting to the aforementioned issues, especially for relatively small systems, such as microgrids. In this context, in this paper, an enhanced communication-based hierarchical control for a dual mode wind energy conversion system-based microgrid is modeled and investigated. The primary stage utilized the P-V/Q-f droop method, which is the preferred droop method to be used in microgrids when the line impedance is mainly resistive. The secondary stage relied on an enhanced methodology for compensating the deviations of voltage and frequency and improving the performance of the microgrid during small and large signal disturbances. Moreover, as this microgrid operates in a dual mode, the mode transition cases from grid-tied mode to autonomous mode and vice versa have been addressed. Thereafter, an improved control scheme for the unplanned outage transition and a modiﬁed control scheme for the pre-synchronization and reconnection transition were proposed. Finally, the proposed work was evaluated by the simulation results in MATLAB environment.


Introduction
Because of the urgent need for a clean environment, the electricity sector is rapidly moving toward renewable energy utilization. A wind energy conversion system (WECS) is one of the highly promising renewable energy systems. WECSs have been utilized under different capacities (a few kilowatts to several megawatts), and different types of generators (double-fed induction generator (DFIG), permanent magnet synchronous generator (PMSG), and others) [1]. In a WECS, as in many other distributed generators (DGs), the generator is linked to the grid via a power electronics-based converter. The high penetration of these converters in the grid and the diminution of system inertia have introduced new problems regarding the voltage and the frequency controls. The microgrid (MG), which is comprised of a number of DGs, has emerged as a solution to these problems caused by the high penetration of power converter-based DGs and enable the large-scale utilization of such DGs [2]. An MG can work either connected to the main grid or in an autonomous manner, with the latter used under unplanned action (i.e., fault condition or severe deviation in voltage or frequency) or planned action (i.e., maintenance issues) [3].
In autonomous mode, the MG loads must be supplied by DGs; therefore, at least one of the DGs must behave as a controlled voltage source [4]. In such a manner, the MG requires a type of control to allow it to meet several requirements, such as regulating voltage and frequency and avoiding the circulating currents between DGs [5]. When the MG operates connected to the main grid, both voltage and frequency postures can be regulated by the main grid because of the relative disparity The rest of this paper is arranged as follows: Section 2 describes the detailed structure of WECS-based MG. In Section 3, the hierarchical control is presented; this control includes the primary stage based on P-V/Q-f droop technique, and the improved secondary stage to mitigate the deviations of voltage and frequency. Moreover, this section also covers the small signal analysis for both primary and secondary stages. Section 4 contains the analysis and the proposed methods for smooth transitions between grid-tied and autonomous modes. Section 5 presents the case study scenarios and the related results. Finally, this work is concluded in Section 6. Figure 1 shows the typical structure for the WECS-based MG that contains two types of WECS connected to the same bus system with MG load. The main grid can be connected and disconnected to the MG bus system through the static switch. One unit from each type of WECS is used in this model, and a number of units can be added to each type in parallel. Both types of WECS are equipped with PMSGs because of the high efficiency and the compactness of PMSG, along with the recent popularity of using the PMSG, especially for offshore wind farms [28].

WECS 1: Battery-Backed WECS
The configuration of WECS 1 is shown in Figure 2. Because the pitch plate control is not our primary interest, it is not presented in this paper. The extracted electrical power from PMSG is injected to the DC-link via an uncontrolled rectifier and a boost converter. The benefits of this structure are its simplicity and cost reduction [29]. The control of the boost converter attempts to achieve the maximum power point by utilizing the lookup table of wind turbine characteristics, whereas the control of buck/boost converter attempts to keep the DC-link voltage constant and regulates the battery current on two sides. As long as this WECS is responsible for regulating voltage and frequency during islanded mode, the need for the battery is inevitable. With the battery rated capacity of 400 kWh and nominal voltage 800 V, the reference current for the battery I bref is set to be: where Kp b and Ki b are the proportional and integral gains for battery current PI controller, respectively, and V b is the voltage at the battery terminals. For the grid-side converter (GSC), there is particular objective regarding each MG mode. The objective is attaining constant voltage and frequency for the MG load during autonomous mode. For grid-tied mode, the objective is providing the available active power or observing the required active power to charge the battery. Hence, to generate the current references, two different current control loops are used. The first loop is adjusting the current references based on two-stage hierarchical control. The second loop is mainly relying on the state of charge (SOC) during the grid-tied mode. Both loops will be illustrated in detail in Section 4. After achieving the current references in dq form, the next loop is the voltage regulating loop. Neglecting the effect of the filter capacitor, the output voltages from this loop can be clarified as: where ωL is the compensation part of the filter inductor, Kp d , Ki d , Kp q , and Ki q are the proportional and integral gains for direct and quadrature currents regulators, respectively.

WECS 2: WECS Supported by Adaptive Operation
In this WECS, controlled converters are used in both machine and grid sides (see Figure 3). The machine-side converter (MSC) is utilized to elicit the maximum power generated by the wind turbine. The maximum power point tracking (MPPT) algorithm is used to evaluate the maximum active current I q by utilizing the rotor speed ω r as shown in Figure 4. The reference currents of this converter in the dq rotating frame can be written as: where P is the number of pole pairs, φ B is the magnetic flux of the generator, and T e * is the reference electrical torque and can be evaluated as: (6) where ω r * is the reference value of the rotor speed, Kp T and Ki T are the proportional and the integral gains for the torque regulator, respectively.  For GSC, as in WECS 1, it also has particular objectives regarding each MG mode. During grid-tied mode, the objective is to inject the maximum obtainable active power to the MG bus system and to regulate the DC-link voltage. Thus, the current references in dq form will be set as: I G q re f = 0 where V * DC and V DC are the set value and the actual value for DC-link voltage, respectively, Kp DC and Ki DC are the proportional and the integral gains for the DC-link voltage regulator, respectively.
During autonomous mode, the maximum active power is not always required by the MG load. Sometimes, the generated active power is even higher than the required active power by the load and the available capacity in the battery of WECS 1. To avoid a power imbalance during autonomous mode, the adaptive operation is proposed in this paper. This approach selects the proper references for active and reactive currents. The active current reference can be set to choose the minimum of two values, namely, the maximum current and the required active current, as: where P req is the active power required by MG load, and V d is the direct axis voltage. In the case of setting the required active current as the reference, the surplus power in DC-link can be utilized in terms of the reactive power with consideration of the size of DC-link capacitor. The available reactive current can be clarified as: where Equation (10) can be achieved only when the maximum current is greater than the required active current. To ensure that the available reactive current is not greater than the required reactive current, the reactive current reference can be adjusted through PI regulator as: where Kp r and Ki r are the proportional and integral gains for the PI regulator, Q req is the reactive power required by MG load, and Q avl is the available reactive power and can be evaluated as: Note that Q req must be limited by Q avl as a maximum limit. In the adaptive operation, when the required active current is selected, the DC-link voltage regulator will be inoperative. Thus, to adjust the DC voltage in this particular case, a chopper converter is utilized on the DC-link. The modulation signal for chopper S ch can be formed as: where Kp ch and Ki ch are the proportional and integral gains for chopper regulator, respectively, P ch is the maximum chopper power, and R ch is the chopper resistance.

Two-Stage Hierarchical Control System
Based on the time response, the hierarchy gradient considers the droop control as the primary stage that handles sharing the active and reactive powers. The secondary stage is utilized to modify the primary stage output by compensating the perversions caused by the unknown line impedance.

Primary Stage
To emulate the behavior of the synchronous generator, the droop control for inverter-based DGs was investigated earlier in [30]. In this control method, the frequency is proportional to the active power alteration, while the voltage profile is linked to the alteration of reactive power. This method is modified to consider small systems, such as low-voltage MGs [27]. In such systems, the R/X L rate of line impedance is generally high (e.g., R/X L = 7.7 [31]). Therefore, the line impedance characteristics can be considered as mainly resistive. In a resistive line impedance system, the active and reactive powers can be clarified as follows: where E and V are the inverter output voltage and the grid voltage, respectively, Z is the line impedance, ϕ is the power angle. Note from Equations (15) and (16) that the active power is proportional to the voltage variation, while the reactive power is proportional to the power angle. Accordingly, the droop expressions can be written as Equations (17) and (18). Figure 5 illustrates the droop control for resistive line impedance system.
where E * and ω * are the preset voltage and frequency, respectively, n EP and m fQ are active and reactive droop slopes, respectively, and can be defined in Equations (19) and (20). P meas and Q meas are the measured active and reactive powers, respectively, after passing through the low pass filter (LPF), and they can be obtained in Equations (21) and (22).
where V max , V min , ω max , and ω min are the maximum and minimum allowed limits of voltage and frequency, respectively, P max and Q max are the maximum attainable active and reactive powers, respectively, and ω c is the cutoff frequency of LPF.

Secondary Stage
The critical loads in MG necessitate the deviation of voltage and frequency within the permissible limits during both load and generation changes. With the uncertainty of the line impedance, the droop control method does not meet this requirement without the support of a communication link [32]. The secondary stage is applied to compensate the deviations in voltage amplitude and frequency during the change of load or generation. The main idea is to compare the voltage and the frequency of the load to the reference values and inject the differences back to the primary stage through the PI controllers [21,26,33]. To reduce the intricacy of the communication link and to speed up the compensation, the load voltage and frequency in this study are converted to the dq rotating frame and compared with the outputs of primary stage as demonstrated in Figure 6. The resulting direct and quadrature voltages can be formed as: where V d ** and V q ** are the new voltage references in dq form, Kp dsec , Ki dsec , Kp qsec , and Ki qsec are the proportional and integral gains for direct and quadrature secondary controllers, respectively, and, Vd L and Vq L are load voltages in dq form. This method can reduce the steady-state error caused by primary stage faster than the traditional secondary method. However, the internal control loops will be more influenced during the large change in load. To overcome this trade-off, two damping terms of active and reactive loads (δ P and δ Q ) are added to each of the direct and quadrature voltage references. The new voltage references are illustrated in Equations (25)-(28) with α and β as the adaptive gains for active and reactive loads damping and have been set to 0.6 and 0.2, respectively.
where P 1 and Q 1 are the output active and reactive powers of WECS1, respectively; P 2 and Q 2 are the output active and reactive powers of WECS2, respectively; and P L and Q L are the load active and reactive powers, respectively. It is worth mentioning that the power losses in Equations (27) and (28) are neglected, thereby ensuring δ P and δ Q will both always be zero during the normal steady state condition.

Small Signal Analysis
Comprehensive small signal analysis for primary and secondary stages is presented in this part of the section. The small signal model for the primary stage can be achieved by linearizing Equations (17) and (18) as: where ∆ refers to the small perturbation around the equilibrium point [26,34]. Equations (29) and (30) can be rearranged as: By considering Equations (31) and (32) in the time domain, thus, where the dotted variables refer to the derivate with respect to time. Considering the measuring filter, the output active and reactive powers of the inverter can be written in dq form as: As the rotating axis is aligned with the output filter voltage (V q = 0), the small model of active and reactive powers can be obtained as: Because the compensation of secondary stage will be in the dq rotating frame, the droop control output can be obtained after the park transformation as Equations (39) and (40), (see Figure 5).
By substituting Equation (33) in Equations (41) and (42), the state equation for primary control can be written as: For secondary control, with considering the transient terms (δ P and δ Q ) are equal to zero, Equations (25) and (26) can be linearized and expressed in Equations (45) and (46) after performing some mathematical operations.
By substituting Equations (43) and (44) in Equations (45) and (46), thus, By considering the state vector for the state-space model as [∆E ∆ω ∆V d * ∆V q * ∆V d ** ∆V q ** ∆P ∆Q] T , and [∆V d ∆I d ∆I q ] T as the input vector and using the parameters of Table 1, the eigenvalues of the system can be defined In Equation (49), where they lie on the left side of the S-plane.

Formulation of Mode Transition
In this section, the formulation of the mode transition is described basically for WECS1. Two major cases are considered: unplanned grid-tied to autonomous transition and the transition of planned reconnection to the main grid. In each case, the transition strategy must be designed to satisfy the requirement for a smooth transition while avoiding any out of limits operating conditions.

From Grid-Tied to Autonomous
In this transition, two aspects require serious attention: the fast problem announcement to avoid system deterioration and the appropriate adaptation to the new mode. When the MG operates in a grid-tied mode, the objective of WECS1 is injecting the available active power or observing the required active power to charge the battery. Meanwhile, the phase locked loop (PLL) can equip the synchronization with the main grid. Hence, the current references can be obtained as follows: where I ch and I PMSG are nominal charging current of the battery and rectified PMSG output current, respectively. Note that the reactive current is set to zero during grid-tied mode; thus, the reactive load will be supplied by the main grid side. When an abnormal condition occurs (i.e., fault condition or severe deviation in voltage or frequency), the MG must separate from the main grid and operate in autonomous mode. To acclimate with the new mode, the MG control strategy needs to be changed to the forming voltage-frequency strategy aiming to keep voltage and frequency controlled by the two-stage hierarchical control. The fault detection relay is responsible for judging the transfer instant where this relay is providing two signals. The first signal is supposed to be delivered to WECS1 to change the control strategy, and the second signal is responsible for switching off the static switch. Further, the adaptation to the new mode necessitates a suitable methodology to ensure the synchronizing components (voltage, frequency, and phase angle) remain within the operating limits. The main reason behind the deviation of the synchronizing components is the sudden unbalance between the load of MG and the output of DGs. Consequently, the key idea of achieving a smooth transition in this paper relies on satisfying rapid compensation for the required active and reactive currents. First, the currents of the main grid in dq form are evaluated and compared with the output currents of the inverter. Second, the differences in currents are injected into the main current regulator after passing through PI controller, as shown in Figure 7. The measured values of main grid active and reactive currents must be saved in temporary memory at the outage moment. Once the inputs of PI controller equal to zero, the compensator must be switched off, leaving the current regulator working in the forming voltage-frequency strategy. Hence, the current references can be obtained as: where I d VF and I qVF are the direct and quadrature current references in the forming voltage-frequency strategy, Kp d , Ki d , Kp q , and Ki q are the proportional and integral gains for direct and quadrature current regulators, respectively.

From Autonomous to Grid-Tied
Once the main grid returns to its normal condition, the MG has enough time to become synchronized with the main grid before closing the static switch. The pre-synchronization method is a well-qualified method to get the synchronizing components of MG to be within the limits of their counterparts in the main grid [35,36]. As the control strategy in autonomous mode is ruled by the droop control, the preset values of voltage and frequency in droop control must be modified to coincide with the voltage and frequency of the main grid. To synchronize the MG with the main grid, three error components are added to the active and reactive power loops in droop control, as shown in Figure 8. Where E * new and ω * new in Figure 8 are the new preset voltage and angular frequency of droop control, respectively. V Grid , θ Grid , f Grid , V MG , θ MG , and f MG are voltages, phase angles, and frequencies of grid side and MG side, respectively. By tuning accurate gains for PI controllers, the time spent for synchronization will be minimized. The PI gains of voltage component can be tuned separately, whereas the PI gains of frequency and phase angle components must be tuned together because they may influence each other. Once the inputs of PI controllers equal to zero, the MG will reconnect to the main grid through the static switch and the control strategy will be changed at the same time. The main grid voltage during synchronization often includes some harmonics; therefore, an LPF is utilized to extract the main grid voltage with the fundamental frequency. A related point to be mentioned in this transition is that, as the references of the secondary stage are the outputs of droop control in dq form, there is no need to disable the secondary stage throughout the synchronization process.

Simulation Results
To evaluate the effectiveness of the proposed work, WECS-based MG shown in Figure 1 is modeled in the MATLAB/Simulink environment. The design parameters of the system are shown in Table 2 based on typical values for low-voltage systems with an R/X L rate of line impedance is nearly equal to 6 [27,32]. Table 3 shows the control parameters for the entire system, and they have been defined by the trial and error (TAE) method after an extensive number of iterations to ensure the best convergence of the controlled components to the desired values.

Mitigate the Deviations during Large Changes in Load
Assuming that the MG is operating in autonomous mode, for this scenario, the output of WECS2 is considered to be constant. The performance of the proposed secondary control is evaluated under balanced and unbalanced load changes. Figure 9 shows the output active and reactive powers of both WECS1 and WECS2 as they are responding to the balanced load change. An additional load of 0.162 + j0.1 PU is added at t = 3 s, and another load of 0.323 + j0.133 PU is suddenly removed at t = 5.5 s. The responses of voltage and frequency caused by the restoration by classical secondary control [21] due to balanced load changes are shown in Figure 10 with a red line. It can be seen that both postures of voltage and frequency are deviating in the permitted limits. However, the low damping has led to an overshoot during large load change, even with the best-tuned gains of current regulators. The responses of voltage and frequency caused by the restoration via the proposed control due to a balanced load change are shown in Figure 10 with a blue line. Similarly, to evaluate the performance of the proposed control under unbalanced load changes, an unbalanced load (phase A: 0.162 + j0.1 PU, phase B: 0.12 + j0.075 PU, phase C: 0 + j0 PU) is added and removed at t = 3 s and t = 5.5 s, respectively. Figure 11 shows the output active and reactive powers of both WECS1 and WECS2 as they are responding to the unbalanced load change. Figure 12 clarifies the voltage and frequency responses during the unbalanced load changes with the restoration by the classical and proposed control methods. Comparing the responses of the proposed control to that of classical control, for both balanced and unbalanced load changes, it can be seen that the deviations have been clearly mitigated via the direct compensation. Moreover, it significantly verifies the effectiveness of the damping terms during load change (t = 3 s and t = 5.5 s). Thus, the additional terms have evidently damped the overshoot for the same gains of current regulators.

Smooth Mode Transition between Grid-Tied and Autonomous
For the outage scenario, the MG is supposed to be operated in grid-tied mode. The SOC is set within the range of charging the battery only from PMSG (Case 2 in Equation (50)). Accordingly, the active and reactive loads of MG that could not be supplied by WECS2 are supplied from the main grid side. An outage of the main grid is assumed to occur at t = 1 s. At the outage moment, the control strategy of WECS1 is changed to the forming voltage-frequency strategy. When the outage occurred, the available output power in MG is sufficient to feed the local load; thus, no load shedding is required. Figure 13a,b shows the active and reactive currents of the main grid at the point of common coupling (PCC), with and without the proposed method. The proposed method is found to reduce the large transient in current, as is significantly reflected in the response of MG voltage. Figure 13c,d shows the response of MG voltage during the transition with and without the proposed method.  For reconnection scenario, WECS1 is set to operate in the forming voltage-frequency strategy under autonomous mode. It is assumed that the main grid returned to its normal condition at t = 0.5 s. For verification purpose, all the synchronizing components of the MG are supposed to have variances with their counterparts in the main grid. To confirm the tying of main grid and to override the low-quality interval, a delay of 0.5 s is specified before starting the pre-synchronization procedure. Accordingly, the switches of all compensators have closed at t = 1 s. The responses of RMS voltage and frequency through the synchronization are shown in Figure 14b,c. The variance in phase angle before and after the synchronization is shown in Figure 14d. The timing sequence for synchronization is defined as follow. The variation in frequency of 0.1 Hz has been eliminated after 0.5 s. The variation in voltage of 8 V is reduced to zero after 1.3 s. Then, the difference in phase angle which is 6 • has been adjusted to zero after 3.5 s. Therefore, at t = 4.5 s, the control strategy is changed back, and the static switch of MG is closed. The main grid started supplying the MG load after t = 4.5 s, as shown in Figure 14a. The results demonstrate that the pre-synchronization method allows the perfect tracking for the main grid synchronizing components and ensures the smooth reconnection to the main grid.

Conclusions
This paper presented an investigation into the modeling of an enhanced control stand on the two-stage hierarchical structure for WECS-based MG. The MG configuration was comprised of two types of WECSs with particular features for each type. WECS1 is utilized to extract the maximum power during both modes and support the system frequency during autonomous mode; thus, it is supposed to be backed with a battery. For WECS2, as it is assumed to be free of a battery, it was supported by a proposed adaptive operation to avoid power unbalance and provide system flexibility. In terms of hierarchical structure, the primary stage utilized the P-V/Q-f droop method, which is the preferred method to be used in MGs with mainly resistive line impedance, whereas the secondary stage relied on an enhanced methodology for compensating the deviations of voltage and frequency in the dq rotating frame. Moreover, two damping terms were added to each loop in the secondary stage to assist in the overshoot damping during a large change in load. Furthermore, a small signal analysis was performed to evaluate the eigenvalues and validate the stability of the proposed control. In the aspect of mode transition, the robust controls for both the unplanned outage transition and the pre-synchronization and reconnection transition were proposed and investigated to clarify their features. The proposed approach was proven to be effective by the simulation results: firstly, for a small signal and large signal disturbances with a comparison to the conventional control method and secondly, for both formulations of mode transition presented.