Adaptive Power Factor Regulation Under Asymmetrical and Non-sinusoidal Grid Condition with Distributed Energy Resource

Active and reactive power regulation, unbalanced current compensation, and harmonic current mitigation are the most significant functionalities typically embedded to a three-phase multifunctional grid-connected inverter. However, a vital control feature minimally addressed in the literature is the capability to adjust the grid power factor to the minimum value required by standards or grid codes. Hence, this paper presents an adaptive compensation approach to perform dynamic power factor regulation under varying power demand and unpredictable energy generation, also withstanding non-ideal voltage conditions. To demonstrate such an approach, a global power factor definition is first introduced, being validated upon bidirectional power flow conditions and under unbalanced and distorted voltages. Secondly, a simple algorithm is devised to attain scaling coefficients used on compensation purposes, allowing to instantaneously weigh up reference control signals to track a desired grid-side power factor value. As a result, the strategy can be used to retrofit the controllers of grid-connected inverters with little effort, limiting distribution losses and improving power quality. Simulations and analyses of a representative real study case are conducted to illustrate how the proposed approach copes with unpredictable distributed energy resources and variable load demands. Moreover, experimental results considering a grid-connected inverter prototype are shown to validate the feasibility of the control approach to real-life implementations.


I. INTRODUCTION
As the integration of distributed energy resources (DER) into power grids incessantly grows, it is highly important to understand the potential benefits of such perspective to both electricity suppliers and end-users [1]- [4]. The beneficial trend behind DERs is mainly motivated by the multifaceted application of power electronic converters, which are interfacing equipment capable of flexibly regulating power generation and consumption. In fact, grid-connected inverters allow DERs to be flexibly interfaced with the electric grid, since they support active power dispatch to feed loads and strive for financial goals, while concomitantly complying with standards and grid codes [5], [6]. Moreover, inverters can offer multiple ancillary functionalities, such as compensation of power quality (PQ) disturbances and reactive power support [7]- [12].
In this context, considering the generation of sustainable energy with low environmental impact, as well as the reduced maintenance costs and reduction on energy bills, gridconnected photovoltaic (PV) systems have spread rapidly in recent years mainly in industrial and commercial buildings. Nonetheless, since PV-based systems generate energy mostly during daylight hours, besides being highly influenced by weather conditions and grid condition (voltage level, harmonics and imbalance), their grid integration is still tied to many technical challenges. For example, from an industrial and commercial load perspective, a PV system reduces the net active power provided by the grid, typically making the power factor to be below standardized limits and increasing the electricity billing charges (i.e., due to utility penalties). Hence, DER deployments into electric grids bring such a challenging contrast in terms of power factor regulation. Moreover, the power factor correction in these plants is often achieved by installing capacitor banks, passive filter or static VAR compensators [13]- [18].
However, facility operators have reported detrimental effects and recurrent failures of power factor correction passive solutions [18]- [21]. These problems are caused by local or general resonance conditions excited by harmonics currents generated by time-varying nonlinear loads (modern facility loads) such as AC/DC static converters, adjustablespeed drives, frequency inverters, soft starters, arc and induction furnaces, welding machines, electric traction systems, static and rotary compensation and others. Moreover, these systems may experience an increase of the voltage distortion and imbalances due to the propagation of unbalanced and nonlinear loads, especially when the upstream grid is weak [16], [22]- [25]. The identification of an effective solution in the outlined scenario depends on both grid and load characteristics and should include resonance analysis at the design stage [18]- [21]. Otherwise, the performance of distribution grids is worsened because power factor compensation cannot be fully achieved and power quality is compromised. Due to that, the consumption of self-generated electricity under unbalanced and harmonic conditions has become one of the greatest issues for performing power factor correction in power systems of commercial and industrial buildings dotted with DERs.
To overcome these limitations, a versatile and reliable use of grid-connected inverters combined with advanced ancillary functions can be adopted. Although the basic operating principle of active power filters (APF) was established in the 1970s [26], these devices continue to be a relevant research area because it is easy to embed their filtering characteristics onto the control of DER-interfacing inverters. Consequently, forming the grounds to the so-called multifunctional gridconnected inverters [7]- [9], [27]- [34]. Therefore, wherever there is the possibility to offer ancillary services, the APF function of the grid-connected inverters should be activated to improve the PQ. However, to fully exploit the potential of grid-connected inverters, an important question must be answered at this point, how to generate their control references signals if their remaining power capabilities vary during the day and depend on weather conditions. At the same time, another challenge is to cope with the variability in energy consumption by loads throughout the day, making it difficult to select ancillary services offer by inverters. Consequently, a flexible compensation strategy becomes an interesting solution to dynamically adjust the control of inverters according to specific power supply profiles and load conditions. A common constraint found in most of the control approaches discussed in the literature is that each grid-connected inverter is designed and steered to improve the network operation by compensating all unwanted current components, neglecting the possibility to implement a partial compensation strategy to satisfy a preset goal. Moreover, the accomplishment of compensation goals under variable generation conditions and varying electricity consumption profiles is often disregarded [27]- [31]. Nevertheless, considering the advanced features of DERs described in the IEEE Standard 1547-2018 [5], potential functionalities can be explored in grid-connected inverters and cooperate in the active control of power quality indices according to demand profiles.
Thus, in this paper a multifunctional grid-connected inverter is used to provide the ancillary service of power factor regulation at the grid-side, simultaneously to the injection of the energy generated by a renewable source. The proposed approach offers a background to adaptive compensation of the grid-side power factor taking into account the unpredictable behavior of load demand and energy generation. Moreover, such an approach is able to keep the power factor constant at the grid-side based on power factor values recommended by standards or utility codes. The principle behind the adaptive approach is to weigh the compensation currents according to the desired grid-side power factor value and the actual power factor, which is estimated considering instantaneous measurements of load demand and power generation. According to the value chosen for the desired grid-side power factor, the compensation of PQ disturbances may be total (i.e., the desired power factor is unitary) or partial (i.e., the desired power factor less than unity).
In comparison to conventional methods, the proposed approach performs the compensation of PQ disturbances adopting the grid-side power factor as an important parameter to drive the compensation action of the multifunctional inverter. As a result, the method ensures that the level of compensation is directly dictated by the desired PQ level at the grid side, which is indicated by the power factor. Furthermore, the compensation is adaptable according to changes in the level of PQ disturbances or according to the level of active power injection. Consequently, such an approach allows concurrent analysis and design of partial compensation strategies to improve the grid-side power factor, also allowing to meet whichever standard or utility criteria is established.

II. THEORETICAL BACKGROUND TO POWER FACTOR COMPENSATION
In three-phase systems, the active power flowing through a given load can be calculated by (1).
Another relevant power term to characterize the electrical system operation is the apparent power, which is given by (2): where and are the collective RMS value of voltages and currents, according to definition (3).
The definition in (2) was introduced by Buchholz in 1922 [35]. A justification for such a definition was provided in [36], [37] and recently was incorporated in the IEEE Std. 1459, namely, the effective apparent power [38].
Finally, to characterize the electrical system utilization, the corresponding power factor is defined as: Notice that the definition from (4) does not use the "reactive power" quantity, which lacks a consensual and technically consisted definition under unbalanced and distorted conditions. Therefore, to avoid any physical misinterpretation, (4) refers to the non-active power term ( ) instead of the reactive power. It is consensually known that the active power defined in (1), which corresponds to the average power consumption, is not enough to characterize the operation of electrical systems. This occurs because current flowing through energy storage elements, just as voltages and currents nonlinearities, and unbalanced load behaviors must be also taken into account while analyzing electrical circuits. All these phenomena are accounted together by such a non-active power .
Considering non-ideal operation conditions of electrical circuits, (4) is a more appropriate definition of power factor, since it is seen as an efficiency index being even adopted by control approaches and standards/grid codes. Hence, such a power factor calculation can be determined for any power system, independently of waveform distortions and imbalances, leading that it is affected not only by load unbalance and nonlinearity but also by supply unbalance and distortion. By adopting the definition in (4), any ambiguity in the apparent power definition is eliminated, allowing the use of the power factor as a global PQ index.
Note that, in (3a), only phase voltages are considered. In practice, the phase voltages can be obtained by measuring only two line voltages [36], [39], [40], as given by (5). Hence, the line voltages and are measured at the point of common coupling (PCC) and is obtained by applying Kirchhoff's law, i.e., = −( + ). The subscripts a, b, and c stand for the phases of the three-phase electric system.

A. INSTANTANEOUS POWER FACTOR COMPENSATION
Let and be the instantaneous voltage and current arrays for a generic three-phase circuit [40]. By using (6) and (7), one can obtain the instantaneous balanced active currents , as well as the non-active currents , respectively. One can refer to [40] for more details about the current decomposition.
In (6), the parameter = / 2 is the equivalent balanced conductance accounting for all phases. The active power (P) and the collective RMS value of voltages ( ) are calculated according to (1) and (3a) respectively. Note that the balanced active currents track phase voltages irrespective of their waveform. The term "balanced" therefore refers to load symmetry, not to current symmetry [40]. The definitions in (6) and (7) are extensions of the Fryze's approach [41], which was also incorporated by Buchholz [42], Depenbrock [43] and others [36], [37].
Similarly to (3), the collective RMS value of the balanced active currents is given by = √ 2 + 2 + 2 , in which , and stand for the RMS value of the active balanced currents of phase a, b and c, respectively. Then, (6) can be rewritten in terms of the collective RMS values (bold capital variables) and lead to (8).
Since the non-active current is orthogonal to the balanced active current, (7) can be written in terms of collective RMS value and expressed as follows: Equation (8) shows that, is the current responsible for total active power absorption and result exactly equal to (1). In conclusion, the power factor defined in (4) relates balanced active current to non-active current (i.e., = ) and is equal to unity only if the load is purely resistive and balanced, independently of supply voltage waveforms. Moreover, a balanced pure resistive load may have a unitary power factor even under non-sinusoidal and asymmetrical voltage source conditions. In this way, as includes all unwanted currents, i.e., harmonics, unbalances and reactive currents, for development of the compensation strategy, the compensating currents can be expressed as = = − (10) so that grid currents after compensation becomes = − = (11) Notice that this technique consists on attaining a compensation behavior by the inverter by means of , resulting that the grid needs to only provide . Therefore, the grid currents will resemble the waveform of the voltages [i.e., leading to a unity power factor ( = ⇔ = )]. Based on the above consideration, the instantaneous power factor compensation can be easily implemented, developed and marketed by the active power filter (APF) designers and operators.
In the subsequent sections, the operating principle of the proposed control strategy for a grid-connected inverter is explained in detail.

III. PROPOSED CONTROL FOR ADAPTABLE POWER FACTOR COMPENSATION
A different approach of that used on conventional APFs is needed for adaptive compensation, where the compensation task is performed based on ancillary actions of the multifunctional grid-connected inverter. From this perspective, this section introduces a simple and efficient reference signal generator to partial compensation of the power factor concerning the scenario discussed in Section II, in which a grid-connected inverter operates under intermittent generation and variable active and non-active power demand. Furthermore, the consideration that voltages can be unbalanced and distorted is taken into account. In fact, it can be demonstrated that a partial compensation is achieved if the compensation system absorbs, as a minimum, a non-active current portion opposite to that absorbed by the noncompensated system ( ), resulting in a power factor in the grid-side with a minimum value ( ), which is generally imposed by grid codes and standards. This is a consequence of the basic theorem of compensation, which states that: Thus, a necessary and sufficient condition to ensure a preset value of power factor at a given PCC is that the corresponding non-active currents absorptions are minimum. In this case, the compensation can be performed by estimating a compensation coefficient to track a power factor reference, which adapts the reference signals and provides the desired absorption at PCC. According to this principle, a partial compensation of the power factor should produce the same effect on the unwanted currents (reactive, unbalanced and distortion), since the compensation system improves also the currents waveform through the grid.

A. REFERENCE SIGNAL GENERATOR WITHOUT ACTIVE POWER INJECTION
To illustrate the partial compensation principle, the absorbed non-active currents at the PCC are compensated partially by the reference signal , which can be derived from (10): where, is a compensation coefficient that ranges between 0 and 1. Note that = 0 correspond to full compensation because the reference currents turn equal to the non-active currents . The unity compensation coefficient means no compensation. On the other hand, 0 < < 1 corresponds to partial compensation, then the remaining currents (uncompensated) becomes the minimum non-active currents which are still circulating on the grid-side: where is the collective RMS value of . Since (14) is the minimum value of the grid current, the minimum grid power factor after the compensation is therefore given by: It is important to note that, can be preset (i.e. as a reference value to attend a specific PQ standard, = ) to find the value of the compensation coefficient in order to improve the power factor instantaneously. From (4), (14) and (15), the compensation coefficient can be calculated as: Assuming that the control system is capable to read load power factor and once has been established by consumers based on the local standards or set by the utilities (normally, is around 0.92), the compensation current references are easy to obtain trough (13). This strategy corresponds to partial power factor regulation. Note that when is unitary, the compensation coefficient becomes zero, making the current references equal to the non-active currents (10), leading to grid currents free of undesired load disturbing effects.

B. REFERENCE SIGNAL GENERATOR WITH ACTIVE POWER INJECTION
The above definitions offer a clear description and are the basis of the partial power factor compensation. In practice, however, they do not allow to achieve the compensation objective when the system includes a DER. In fact, the active power injected into the grid changes the value of the grid-side active power, and consequently, the power factor is also modified. Accordingly, in order to guarantee the compensation objective, the compensation coefficient must be adjusted to include the active power variation caused by the DER.
Since the DER reduces the energy drawn from the utility grid, the net active power in grid-side can be evaluated by including the injected active power , thus: From (4) we now define the grid-side global power factor, by: where stands for the active power of the local load (1), for the non-active power due to the local load (9.b) and for the active power injected by the DER. The above definition gives a proper evaluation of the partial power factor compensation in the assumption that the load is a prosumer. In this way, the compensation coefficient ( ) is redefined accounting for the desired power factor reference at the grid-side ( ) and the actual grid power factor ( ): Clearly, (18) is equal to (4) only if the active power injected is zero. In such cases (16) and (19) are equivalent. In conclusion, from (13) the current references accounted to achieve the partial power factor compensation, considering active power injection are: It is important to highlight that the proposed approach is different from other multifunctional strategies since it allows the control of the grid power factor in a straightforward way. Conventional approaches use only load quantities to define the compensation currents, which does not ensure the desired power factor in the grid-side when the DER power is integrated in the multifunctional grid-connected inverter. Fig. 1. presents the flowchart of the proposed approach to achieve a specific power factor value ( ) at the grid-side, as well as harmonic and unbalanced minimizations. The stepby-step procedure to carry out the proposed algorithm is summarized below:

C. PROPOSED ADAPTIVE CONTROL ALGORITHM
1. Initially, define the value of the reference for power factor, (target grid-side power factor). ) and the DC current injected in the DC-link ( ). 3. Calculates active power of local load using (1), DER power using (21), grid-side power using (17), non-active power of local load (9.b) and the actual grid-side power factor according to (18). 4. The result of the calculated power factor is compared to the fixed power factor set in step 1.

If
is lower that utility limits ( ) go to step 6, otherwise go back to step 2. 6. Using (19) regulate the scaling compensation coefficient ( ) that leads to a minimum power factor required by the utility or standard. 7. Using measured grid-connected inverter information and target power factor, the control system turns ON the APF function according to (20). To bring the actual power to the reference value (targeted power factor), the algorithm is updated once per fundamental cycle in an online open-loop strategy. As can be observed in Fig. 1, the proposed approach is quite simple and practical and has the advantage to takes into account the time-varying system conditions (i.e. both energy generation and consumption) to adapt the power factor and preserves the objective of compensation, which is to achieve and maintain the highest facility power factor to attend the utility requirement.

D. PROPOSED CONTROL STRATEGY
A basic block diagram of the reference signals generation approach is shown in Fig. 2. It refers to a situation, where the control system aims at regulating the grid-side power factor by properly driving the grid-connected inverter control system. The controller performs as follows: 1. Initially, the balanced active currents are determined according (6). Currents are then compared with load currents absorbed at the PCC to generate internal references . In fact, unwanted current terms should be minimized by the compensation system. 2. The currents * to transfer the power from converter's DC side to the grid are determined using the equivalent conductance definition: So, the current references to be injected by the gridconnected inverter is determined by * = . Under generic voltage condition, the active power injection considers the implementation of a three-phase PLL method which tracks the fundamental positive sequence voltages of each phase, regardless of the existence of asymmetries and/or distortions, i.e. = −1 + . 3. The target power factor at the grid-side , together with active powers and and non-active power are then fed to proposed control algorithm (Fig. 1) to extract the scaling compensation coefficient kG, which is subtracted from the unity and multiplied by the internal references to generate the reference * .
4. Reference * is compared with actual DC bus voltage to generate error signal, which is processed by a voltage regulator based on a proportional-integral (PI) controller. The output signal of the voltage regulator is multiplied by PCC voltages to generate current references * used to maintain the DC voltage regulated. 5. The references for the grid-connected inverter control system are determined by: * = * + * − * . 6. Finally, references * are compared with converter currents and the error signal goes through the current controller which consists on a proportional plus resonant harmonic controller (PR+HC).

IV. CASE STUDIES AND SIMULATION RESULTS
As an example of application, consider the electrical system of Fig. 3. It includes a nonlinear and linear unbalanced loads and power electronics converter (PEC) with LCL output filter. The parameters and the active power produced by the DER are shown in Table I. Moreover, in order to deal with intermittent renewable generation under variable load demands a real case of PV system is also considered. The case studies consist of varying the power factor correction by the ancillary function of the grid-connected inverter to analyze the control dynamics behavior and the applicability of the proposed approach while the PEC has available power margin. Fig. 3 shows the typical electrical diagram of a grid-connected inverter as a three-phase three-wire system. The main parameters for converter, electrical grid, and loads are listed in Table I. Such electric and control schemes from Fig. 3 are  adopted for simulation results brought on the study cases from Sections IV-B to IV-E.

A. MODELING OF THE CONTROL SYSTEM USED IN SIMULATIONS
The modeling and control design for the three-phase inverter is widely discussed in the literature [44], [45]. In this work the grid-connected inverter and its respective control system are modeled based on the [10]. Since this paper considers a three-wire system, the inverter control can be achieved considering only two phases of the voltages and currents as shown in Fig. 3.
The control system comprises two main loops. The first one is a fast current loop to control the inverter currents and the other is a slower voltage loop, responsible for maintaining constant DC bus voltage.
As mentioned before, a PI regulator [47] is used to regulate the DC bus voltage and its transfer function is given by: where is the controller proportional gain, while is the integral gain. The converter was designed with a switching frequency of 20 kHz. The converter DC bus voltage is adjusted to 400 V and the DC bus capacitance is 4.5 mF ( ). The gains of the PI controller are adjusted to = 2.2 and = 49 allowing a passing band of 6 Hz and a margin phase of 75°.
The current controller is of PR+HC type [48], [49] and its transfer function is given by: where ℎ is the harmonics order, [= 377 rad/s] is the grid line frequency and , , are the proportional gain, integral gain and the bandwidth of the resonant controller, respectively. The bandwidth of the current lop was set at 1.2 kHz aiming the compensation of current harmonics. In addition, the loop gain at harmonic frequencies is increased using the resonant controller through the adjustment of the resonant peaks by . The parameters of the current control loop are = 0.95, = 100 and = 5 rad/s. It should be highlighted that the control scheme is implemented in natural reference frame ( ). In addition, the current and voltage controllers are intended to be implemented in a digital platform with a sampling frequency of 18 kHz. The effect of processing delay and PWM modulator were considered during the control design. For the sake of simplicity, this exhaustive analysis is not shown in this paper. However, it can be found in [50].
Owing to the high gain at the resonance frequency, the grid-connected inverter associated with the LCL filter may become an unstable system. This inconvenience can be overcome using the well-known active damping techniques, which do not affect the converter efficiency by emulating the behavior of a resistor in series with the filter capacitor [44], [45]. The active damping is obtained considering that the current through the capacitor ( ) is summed to the reference voltage of the PWM modulator block as shown in Fig. 2.
The current through the capacitor is weighted by the damping gain KD, which corresponds to a resistance for damping the resonance of the LCL filter. In this work, the damping factor was selected as = 1.0 performing the resonance damping with small effect in the stability margins near the cutoff frequency of the current control loop. A more detailed analysis regarding the virtual resistor used in this paper, as well as modeling and control design may be found in [44], [50].

B. PROPOSED CONTROL SYSTEM PERFORMANCE CONSIDERING A NONLINEAR LOAD
To demonstrate the feasibility of the proposed control system, four different intervals with precise compensation objectives have been considered: • Interval #1 (t < 0.8 s): The multifunctional inverter is first analyzed without any ancillary function. • Interval #2 ( 0.8 s < t < 0.9 s): The APF function is turned ON and the reference power factor is set to 0.8.
• Interval #3 (0.9 s < t < 1.0 s): The is increased from 0.8 to 0.92. • Interval #4 (t > 1.0 s): The APF function must perform full power factor compensation, i.e., = 1. Such intervals are set at different instants to verify that the system adjusts its reference to achieve a specific power factor value. The system operation is described with reference to the power factor, and the condition of voltages and currents at the different network points (i.e., from the grid, load and converter perspectives).
The simulation results are split in three main cases being the first one dealing with symmetrical (balanced) sinusoidal grid voltage, the second one deals with asymmetrical sinusoidal grid voltage while in the third case the grid voltage is considered distorted and asymmetrical. In all cases the DER injects 1.6 kW of active power into the DC side of the PEC.

C. CASE I -SYMMETRICAL SINUSOIDAL GRID VOLTAGE CONDITION
The results for the system's operation under symmetrical sinusoidal grid voltage conditions are depicted in Figs. 4 and 5. To compare the dynamic from the initial stage going through partial compensation, as well as to full compensation, results are presented in Fig. 4. It is shown the behavior of the PCC voltages , the grid-side currents , the inverter currents and the DC bus voltage , while Fig. 5 shows the detailed waveforms of the PCC voltages and the grid currents for each simulated interval. The waveforms in the initial stage (Interval #1) when the APF function is turned OFF (no compensation) and the PEC is just injecting active power into the main grid such as conventional interface converter present high current distortion due to nonlinear load. The high current unbalance and considerable phase-shifted in relation to the voltages are due to linear loads (Ry, Ly and Rx). Consequently, the grid power factor is very low (λG ≅ 0.42), the current unbalance factor is high (UFIG ≅ 41 %) and the total harmonics distortion of the phase currents are also high (THDIa ≅ 41 %; THDIb ≅ 28 % e THDIc ≅ 45 %). Table II shows complete set measures taken at PCC. It is worth highlighting that, the unbalance factors ( ) are calculated as a ratio between the RMS values of the negative sequence and positive components of the voltages and currents.
At Interval #2, after turning ON the APF function of the inverter, although being distorted and unbalanced, the gridside currents are now smaller than before (i.e., during Interval #1), due to the partial power factor compensation, which reduces part of the distortion and imbalance. Furthermore, by doing so, the grid-side currents are slightly phase-shifted in relation to voltages. Table II shows the control system effectiveness to track the power factor reference. In fact, the grid-side power factor is practically the same as the minimum stipulated value, i. e., λG ≅ λRef = 0.8.
The Interval # 3, as depicted in Fig. 4 and Fig. 5, shows the voltages and currents when the reference value of the power factor is increased from 0.8 to 0.92. It can be seen a significant reduction of the imbalance and distortion contents in the gridside currents. In fact, the currents are now slightly unbalanced with reduced harmonic distortion. Again, within the compensation objective, the grid-side power factor results closer to the target power factor, i.e. λG ≅ λRef = 0.92. In addition, unbalance and distortion current factors are also proportionally reduced (see Table II).
The last stage (Interval #4) corresponds to full compensation, where the grid-side currents now are practically sinusoidal, balanced, and in phase with the voltages. In addition, it is observed that the voltage disturbances were also compensated since the voltage distortion and unbalanced were imposed by the load. Besides,  oo Table II shows the grid-side power factor (λG ≅ 1) is maximized, the current unbalanced factor (UFIG ≅ 0.5 %) and current distortion (THDIa,b,c ≅ 3 %) are minimized. Finally, data reported in Table II demonstrate that for the four considered intervals, grid-side power factor measurement is complying with the pre-set desired reference value, i.e., λG ≅ λRef.
Another mater to highlight in Fig. 4 is the behavior of the DC link voltage control, which provides an adequate response, regardless of the current processing by the grid-connected inverter. It is also noted that the transition between the different stages (compensation objectives) are smooth and very quickly causing minimum voltage ripple around of the reference value adjusted in 400 V.

D. CASE II -ASYMMETRICAL SINUSOIDAL GRID VOLTAGE CONDITION
In this section, we validate the ability of the proposed strategy to regulate the grid-side power factor according to the target power factor in scenarios that grid voltages are unbalanced. For this purpose, the same intervals of Case I and its operation conditions are considered. However, the grid voltage is adjusted to present an unbalanced level of 5 % at the negative sequence component. It is important to highlight international recommendations such as the IEEE Std. 1547-2018 [5], which defines a maximum allowable voltage imbalance of 5 %. Fig. 6 and Fig. 7 shows that the effect of the asymmetry in the grid voltage is present in the PCC voltage waveforms when no compensation is applied (Interval #1), resulting in an unbalance factor of UFVPCC = 5.39 % (see Table III). It is worth to note that the voltage asymmetry resulted in a current waveform through the grid ( ) quite different from the current seen in Case I at interval #1.
At interval #2 the adaptable compensation algorithm is activated to track a target power factor equal to 0.8 at the grid side, reducing the unbalance factor of the current from 88 % to 48 %. The PCC unbalance factor is kept at around 5 % since the asymmetry is imposed by the grid voltage source. In  addition, the current distortion is reduced as seen in Table III. At interval #3 the reference power factor was adjusted to 0.92 reducing even more the current distortion. At interval #4 the grid power factor is fully compensated resulting in approximately unity, and the voltage unbalance factor is slightly reduced but kept at around 5% as expected.

E. CASE III -ASYMMETRICAL DISTORTED GRID VOLTAGE CONDITION
Since the electrical systems are prone to the existence of asymmetrical and distorted voltages, it is important to verify that the proposed strategy is robust to operate under such conditions. Therefore, the following case considers the same intervals of Case I and its operation conditions, along with an additional distortion and asymmetry in grid voltages. The amplitude of the harmonic distortion is 5 % at the 5 th harmonic order and the unbalanced level is 5 % at the negative sequence component. Fig. 8 shows PCC voltages , grid-side currents , inverter currents and DC bus voltage obtained according to the proposed adaptable power factor compensation approach. Notice that the PCC voltages exhibit considerable asymmetry (UFVPCC = 5.1 %) and distortion (THDVPCC = [7.9 %, 10.5 % and 7.8 %] for phase a, b and c, respectively) as seen in Table IV.
It can be noted in the initial situation (Interval #1), grid currents are as well significantly unbalanced and distorted, presenting more visible mismatch in amplitude and waveform distortion in contrast to the Case I. Therefore, the significant current imbalance and distortion is due not only to the nonlinear unbalanced load but also to the supply voltage, which is now asymmetric and distorted. Yet, note that the inverter   injects only sinusoidal balanced currents in phase with the voltages. In addition, it can still be noted that the DC voltage remain with minimum voltage ripple around its reference value. As seen in Fig. 8 and Fig. 9, after 0.8 s, the APF function is enabled and the inverter starts compensating the power factor, minimizing the presence of harmonics distortion and unbalance current at the grid-side. Then, the objectives in the intervals #2 and #3 demonstrate the partial compensation of currents. Although unbalance and distortion in the grid voltage, the currents are now reasonably balanced with reduced harmonics content and minimum phase shift with respect to the voltages.
Finally, after the full compensation (Interval #4), it can be noted that the grid currents are now in phase and track voltage waveforms with good accuracy resulting in currents with the same waveform of the voltages, i.e. unity power factor. The power factor values presented in Table IV demonstrates that, in general for the three considered objectives, i.e. intervals #2, #3 and #4, grid power factor measurements are complying with the preset desired reference values even considering asymmetries and distortion in the main grid voltages. Table IV summarize the PQ indexes obtained from the proposed approach and the corresponding power factor.

F. OPERATION OF THE PROSED CONTROL SYSTEM CONSIDERING A GRID-CONNECTED PV SYSTEM WITH TIME VARYING LOAD DEMAND
To demonstrate the effectiveness and practice feasibility of the proposed approach, this subsection aims to expand the previous results, considering a typical application of a threephase DER based on a multifunctional grid-connected PV system supplying a real load demand extracted from [18]. The aggregate consumption and generation profiles are shown in the top of Fig. 10. The recurring pulses in consumption ( ) profile are attributed to the dynamic nature of the commercial load. Moreover, the DER power from the PV system ( ) is only available during daylight hours and is susceptible to variations due to clouds. Consumption peak is 24 kW, while generation is near 7.2 kW.
For the sake of easy visualization and data analysis, three different days are considered during simulations: 1) during the first day, the grid-connected PV system injects only active power (no compensation); 2) during the second day the control system turns ON the APF function to perform partial compensation, aiming at maintaining the grid-side power factor in 0.95; 3) during the third day, the reference λRef is increased from 0.95 to 1.0 (i.e., striving for full compensation).
The bottom of Fig. 10 demonstrates the grid-side power factor λG (red line) and the reference power factor λRef (discontinued blue line) during such days considered on the analysis, also showing the performance and dynamics of the compensation coefficient kG (blue line). Note on the first day that the grid-side power factor reaches a value as low as 0.73. Equally notable, the power factor remains below 0.9 between 8:30h and 18:30h due to the commercial consumer load profile. On the other hand, the PV generation contributes to reducing the grid power consumption during the daylight hours, resulting in a strong reduction of the power. In fact, decreases the λG, because, from the grid point of view, only the active power ( ) is reduced, whereas the non-active power remains the same [51].
Of course, this fact highlights the importance of the dynamic power factor compensation performed by the ancillary functions of the grid-connected inverters. As expected, during the second day the activation of the APF function reduce part of the nonactive power, thus the grid-side power factor steps up to 0.95, whereas during the third day the grid-side power factor improves further, approaching unity. In fact, after updating the power factor refence λRef from 0.95 to 1.0, the APF function removes every residual nonactive power. The power factor tracking after the second day demonstrate the effectiveness of the dynamic compensation of the power factor. In particular, the results present an excellent correspondence between the reference and grid-side power factor (λG ≅ λRef). Furthermore, due to the proposed approach, the effect of the intermittent PV system generation and the variable load demand on tracking the λRef is minimal, showing that the system reacts properly to suddenly active power (both, consumed and generated) variation. Therefore, the power factor can be kept within the limits specified by utilities or standards.
Finally, grid-side currents and inverter currents are reported in Fig. 11, showing that the compensation system is capable to ensure a grid current proportional to the compensation objectives, minimizing the current unbalance and distortion regardless of the varying load demand (i.e., harmonics, unbalance and reactive power consumption), as well as under intermitted energy generation.

V. EXPERIMENTAL RESULTS
Experimental results are herein presented to validate de applicability of the proposed control approach to real-life implementations. A three-phase three-wire circuit was adopted for experiments, similarly to the circuit presented in Fig. 3. considering a 22.5 kVA grid-connected inverter, line impedances, and a four-quadrant AC voltage source that emulates the grid. The grid emulator was from REGATRON (model TC-ACS-30-528-4WR), line impedances connecting the grid to the PCC of the prototype were devised by cables, and the inverter adopted a three-leg topology using SEMIKRON SEMiX 403GB128Ds IGBT modules with Skyper 32PRO gate drivers.
The inverter presented an LCL filter with passive damping, and PR current controllers modeled according to [47], being tuned to the fundamental, 3 rd , 5 th and 7 th orders. The DC bus of the grid-connected inverter was fed by a bidirectional DC voltage source from ITECH (model IT6012C-800-50). Two DPO3000 from Tektronix were used to acquire voltage and current waveforms, knowing that the PCC phase voltages were measured in relation to a virtual resistor. Moreover, a TMS320F28379D digital signal processor (DSP) was used to operate the prototype and embed the required control algorithms. The physical and control parameters of the grid and inverter are presented in Table V. For the experimental results it was used the unbalanced non-linear load shown in Fig. 12(a). A picture of the prototype is presented in Fig. 12(b) and experimental results are shown in Fig. 13, Fig, 14 and Fig.  15.
In Fig. 13(a), a first experimental result is presented, demonstrating how the load currents were unbalanced and distorted, even though the PCC voltages were purely sinusoidal. In addition, note that the PCC currents were significantly phase-shifted in relation to the PCC voltages. For this case, the apparent, active and non-active powers seen at the grid-side (only due to load powers) were 6.10 kVA, 2.86 kW and 5.38 kVA, respectively. Consequently, a low global power factor at the grid-side was obtained, being λG = 0.472. Then, in Fig. 13(b), the PEC was started to operate as a DER injecting 800 W of three-phase active power into the grid, which was approximately 30% of the balanced active currents drawn by the loads. As a consequence, the inverter currents were balanced and the PCC currents slightly changed their amplitudes. A final value of λG = 0.353 was obtained for this result, being lower than the global power factor observed at PCC when the inverter was off. It shows that the injection of active power decreased the grid-side power factor. However, this value low value of power factor is expected according to (18). Later, in Fig. 14(a) the dynamic power factor correction approach was implemented, concomitantly to the active power injection, aiming at improving the power quality at the PCC.
A reference of power factor of λref = 0.92 was considered for this experiment, and the same amount of 800 W of three-phase balanced active power was still injected by the grid-connected inverter. One can note in Fig. 14(a) that the amplitudes of the grid currents ( , and ) were significantly reduced due to the operation of the inverter (see that the inverter processed unbalanced and nonlinear currents) when compared with Fig.  13(b). Nevertheless, unbalanced and distortion features were still present in the PCC currents due to the partial compensation. By taking λref = 0.92 as reference for the proposed control approach, the non-active power measured at the grid-side was 1.037 VA, which represents a reduction of approximately 80% in relation to the scenario of Fig. 13(a). Thus, the strategy allowed a global factor of λG = 0.921 to be obtained at the grid-side, reaching the desired operational point. This result indicates that the multifunctional gridconnected inverter was able to precisely adapt to the given operational point, ensuring the feasibility of the control approach.
For the experiment in Fig. 14(b), the reference factor λref was increased to 1.0, intending to compensate all the nonactive power seen at the grid-side. As a result, the grid current became practically in-phase with the voltages, additionally to being practically balanced. Even though the current harmonics at the grid were not completely eliminated due to the limited resonant bands of the current controllers, it is seen in Fig. 14(b) that a significant reduction in distortion occurred for this case (see the grid-side currents at phase a and b for example). Moreover, a non-active power of 459 VA was obtained at the grid-side, which resulted in a high global power factor of λG = 0.992. Thus, this result demonstrates that the PEC was able to dynamically adjust its operation to practically reach the desired goal.
A final experimental is brought in Fig. 15 to depict the dynamic behavior of the grid-connected inverter when a transition occurs in λref. This result integrates the results from   Fig. 13(b) and Fig. 14(b), showing how the system behaves when λref is abruptly set to 1.0. It is seen in Fig. 15 that, as soon as the inverter's reference was changed, it quickly adjusted its current injection and reached steady-state operation after less than one cycle fundamental. Most importantly, such operation occurred without causing any overcurrents or overvoltages, which demonstrates that the approach could be adequately applied to grid-connected inverters without impairing stability.

VI. CONCLUSION
A novel control approach for three-phase three-wire multifunctional grid-connected inverters was proposed in this paper. The proposed strategy can perform power factor correction based on requirements imposed by electrical utility, and the grid performance constraints can be fulfilled even under unbalanced and distorted voltage conditions. Such an approach goes beyond traditional control strategies that consider only current constraints, also being capable of enabling the full exploitation of an inverter's capability. A simple control algorithm was devised to implement the strategy, being suitable for applications under the intermittent nature of renewable generation and varying demand condition. As a result, the proposed algorithm can be implemented with little computational effort and low cost because does not require additional hardware circuits, just some line code is necessary.
The control approach has been assessed by simulations, experimental results and by a real case study of a commercial distribution system, showing its effectiveness in a working scenario of practical interest and provide proper information to perform the retrofit of smart inverters and power quality compensators. Finally, it is worth mentioning that the proposed approach was applied here to a three-phase threewire system, though it can be easily adapted to three-phase four-wire systems or single-phase systems.
Furthermore, it is highlighted that the present work assumed that the power converter had enough power and current capability to perform the established compensation tasks. Hence, the converter was able to inject the energy generated by the renewable source, simultaneously to the compensation of the power factor, in order to achieve the target grid-side value and avoid extra fees over the exceeding "non-active power" or low power factor.