Optimal distribution of the fundamental non-efficient load current terms between the energy gateways connected in grid-tied microgrids

Main objective of this paper is the optimal distribution of the fundamental non-efficient load current terms between the inverters —Energy Gateways (EGs)— connected in grid-tied microgrids (MGs). The main feature of the presented approach is the use of the EGs as controlled current sources that can compensate fundamental non-efficient load current terms in addition to the generation of fundamental positive-sequence active current, avoiding the use of shunt active power filters. The approach relies on the so-called System of Constant References (SoCR) that is based on the symmetrical components decomposition and dq0 transformation. SoCR procedure decouples efficient and non-efficient components of the instantaneous load currents, transforming all of them into six constant references. The optimization algorithm uses a new approach for the calculation of the peak currents in each phase, avoiding non-convex problems when determining the currents of the EGs considering their operating limits. A medium-power size MG that includes photovoltaic and wind generators, as well as, a battery energy storage system is considered to evaluate the capabilities of the proposal. There were evaluated four scenarios: baseline, balanced distribution, proportional distribution, and optimal distribution. All scenarios, except optimal distribution scenario, surpass the current limits for the EGs connected. The results highlight the benefits of using the EGs as active agents in MG efficient operation and demonstrate how the optimization approach achieves the goal of maintaining the generation capabilities of EGs at the same time that compensates the non-efficient current terms demanded by the load.


Introduction
Microgrids (MGs) based on renewable energy sources have been described as the base brick of modern electric systems [1,2]. Their adoption is an alternative to achieve high standards of power quality and efficiency in distribution power networks, while satisfying the growing energy demand. However, new challenges have emerged due to the intrinsic intermittency of renewable energy sources, leading in some cases to a deterioration of the electrical grid reliability or even causing some instability problems [3,4]. Hence, MG optimal operation while minimizing its side effects is still a topic of active research [4,5].
An important issue in MGs is the problem related to fundamental unbalance and reactive power demand [2,6,7]. For instance, in a grid-tied MG the problems related to non-efficient power terms are transferred to the power network and the following two problems could arise: 1) reactive power is transferred to the distribution network, therefore, the power network capacity for the feeding of active power decreases; and 2) unbalance could limit the power availability in one or two MG branches due to a phase or phases overloading [6,8]. Additionally, other loads connected to the power network could be affected by these non-efficient powers.
There are several problems related to the unbalance in electrical machines, namely, vibrations, overheating, and torque loss. For these reasons, power quality issues are among the most challenging topics of controlling an MG [6,9].
In grid-tied MGs, unbalance and reactive powers have been traditionally compensated by means of Shunt Active Power Filters (SAPFs), where the SAPF supplies all the non-efficient power terms demanded by the loads in the power line in which the SAPF is connected. A review concerning unbalance and reactive power compensation strategies was presented in [10]. Even though installing an SAPF is a good option to compensate the non-efficient power terms in grid-tied MGs, as stated in [11][12][13], adopting SAPFs increase the total cost of the MG because it requires an additional device connected in the MG.
In order to reduce the cost of grid-tied MGs, researchers and developers have shifted their focus on an active utilization of grid-tied energy gates (EGs) due to their flexibility [6,10]. Basically, the existing EGs distributed along the MG could compensate the non-efficient powers of the load by avoiding their flow to the power network, with [14][15][16] showing the trend to include ancillary services in EGs. In general terms, EGs in MGs have the possibility to play the same role as SAPFs, enhancing electric power quality and increasing the global efficiency of the system [17]. Evidence of the relative success of the EGs application as active agents in the non-efficient powers compensation can be found in the literature. Accordingly, developments for photovoltaic (PV) [18,19], wind [20], and battery energy storage system (BESS) combined with ancillary services for power quality improvement [21,22] have been presented. Although these papers report some improvements in power quality, the approach followed by most of them is to compensate all non-efficient powers in the MG from a single EG, without considering current or power limits in its output. With this method, the EG should be of higher power and is therefore equivalent to including an SAPF in the MG. It is well known that the requirement of higher capacity in an EG increases its cost. Moreover, using only one EG would miss the opportunity to better utilize the total apparent power capacity distributed in the MG. In contrast, this paper proposes an optimization-based approach for the distribution of the non-efficient current terms between the EGs of the MG exploiting better their versatility as active power filters. The apparent power limits of each EG are incorporated as constraints in the optimization problem without affecting the active power that each EG can generate from renewable sources. In this way, power quality issues in MGs are mitigated without requiring EGs of higher capacity.
The distribution among the EGs of a MG of the non-efficient load currents that cause the existence of unbalance and reactive power can be performed using different optimization models, as shown in [8,9,[23][24][25][26][27][28]. In [24], a cooperative optimization approach without centralized supervision or additional control units was presented. MG capabilities are extended without requiring further infrastructural investments, minimizing energy losses in the distribution lines looking for full utilization of EGs by means of Token Ring Control, but neglecting power quality issues. In [25], authors proposed an optimization based on a conservative power theory, where the MG center controller (MGCC) sends commands to the EGs looking for selective elimination of the main causes affecting the power quality.
In [26], authors enhanced the system load capacity under unbalance load conditions by implementing a power routing mechanism for the EGs by means of MG supervisory control. Nonetheless, in the proposed method, active and reactive powers are coupled, which could imply a more complex signal processing. A multi-objective optimization model is proposed in [9], being focused on active power losses, voltage deviation, and the calculation of a power imbalance factor. The proposed optimization model applies to stand-alone and grid-tied MGs. However, the proposed power imbalance factor does not guarantee an unbalance compensation and the paper prioritizes the reduction of active power losses for an MG with a long distance between the EGs. There are cases where the optimization is aimed at finding a better cost function in systems with load imbalances, while trying to obtain a voltage improvement to increase the quality of power supply [23,27]. A single-phase multi-objective optimization model for unbalance power compensation is presented for a three-phase system in [8], but the model applies only for the single-phase EGs connected in the MG.
Finally, in [28], the authors proposed a method for the distribution of the non-efficient power terms between the EGs using an instantaneous power theory, but the MGCC must handle a complex data set. This can become in a limitation if this technology wants to be adopted in commercial applications because it would require a more sophisticated hardware. The paper deals with interesting topics such as distributed and decoupled compensation of unbalance and reactive powers in low-voltage networks, fully-controllable power flow control at the point of common coupling (PCC) of the MG with the power network, coordinated control of four-leg EGs in three-phase four-wire grids, and a proportional current sharing among four-leg EGs. The author claims to be the first one that separates the active current term from the reactive and unbalance current components in the MG context considering four-leg inverters. Although, [28] implemented first a methodology to distribute non-efficient current terms between EGs, an optimization method is still needed in an MG, considering EGs nominal apparent power capacities.
As the main contribution, this paper aims to overcome most of the previous mentioned limitations by proposing an optimization model for the sharing of non-efficient fundamental load currents compensation among the connected EGs in a MG. The model considers the apparent power limits of each EG without affecting the active power that each can generate from the renewable sources, improving power quality issues in MGs. The approach is based on symmetrical components and transformation following the ideas presented by [29]. Then, an optimal decomposition of the currents is performed to obtain a System of Constant Reference (SoCR) that allows to represent the fundamental non-efficient load currents by means of six constant terms, denoted as constant references (CR). One of the SoCR terms is related to the fundamental positive-sequence active power, while the others are related to the reactive and unbalance powers that must be reduced or compensated in the MG to achieve high quality standards of power quality and efficiency.
In summary, this paper improves the previous approaches as follows: • A general approach to exploit the versatility of the EGs is provided in such a way that the fundamental positive-sequence active power is supplied to the load and, at the same time, the non-efficient fundamental load currents are compensated in an optimal way. • The current limits of the EG are incorporated as hard constraints in the optimization problem keeping the MG operation safe without surpassing at any time the maximum capacity of the EGs. • Unbalance compensation is enhanced. This paper is organized as follows. Section 2 presents the proposed SoCR approach to represent fundamental unbalanced current systems, being divided in three subsections: 2.1 elaborates on the fundamentals of SoCR; 2.2 illustrates the methodology for SoCR implementation; and 2.3 shows peak current calculation for the sharing optimization algorithm. Section 3 describes an optimization method based on SoCR for distribution of fundamental non-efficient currents among EGs in an MG. Section 4 presents the results of the SoCR implementation considering four different distribution scenarios of the non-efficient currents. First, in 4.1, how the SoCR performs the representation of unbalanced currents is presented, and the decoupling between the fundamental positive-sequence active current and the fundamental non-efficient currents is shown. Then, in 4.2 and 4.3, balanced and proportional approaches for the distribution of non-efficient currents are developed. Finally, in 4.4, results concerning the optimal approach are described. Section 5 discusses a comparison between the proposed scenarios while section 6 concludes the paper, detailing the main benefits of our proposal.

SoCR procedure for decoupling the fundamental efficient/non-efficient load current terms
A generic MG is shown in Fig. 1, with n distributed sources of energy based on EGs and m different loads. This section develops a procedure for the representation of a fundamental unbalanced current system in six constant references. It starts presenting the graphical origin of the SoCR and the notation used in the paper, followed by the equations used for the implementation of the SoCR in a simulation, and it finally introduces the equation for the peak current calculation.

Proposed System of Constant References (SoCR)
Throughout this paper, instantaneous symmetrical components decomposition methodology and transformation are used for the so-called SoCR derivation considering an MG with only fundamental positive-sequence voltages in which EGs and linear unbalanced loads are connected, without harmonic power flows [29,30]. The SoCR is a procedure that consists of the decomposition of an instantaneous three-phase fundamental current system (top plot in Fig. 2) into six constant terms (bottom plot in Fig. 2), where one term represents the fundamental positive-sequence active current (denoted as 1 ) and the rest of terms are representing all the fundamental non-efficient current terms, related to reactive and unbalance powers. This methodology can be applied to small MGs with a low inductive reactance/resistance ( ∕ ) ratio in the line impedance, which avoids a significant voltage phase shift among the EGs [31,28].
The three-phase currents in any point of the MG can be represented by means of a matrix representation as appears in Equation degrees between them, forming a fundamental positive-sequence system in which phase a is considered the origin of the angles, being included as in the top plot in Fig. 2.  Throughout the paper, Equation (1) is conveniently expressed considering the use of transformation (Equation (2)) as follows: The proposed SoCR decomposition is applied over the instantaneous three-phase fundamental currents measured in the EGs ( ), loads ( ), and the MG ( ), following the four steps shown in Fig. 2. The first step consists of measuring , the instantaneous three-phase currents, which is decomposed into its symmetrical components, where 1 , 1 , and 1 are the positive-sequence currents, denoted as ; 2 , 2 , and 2 are the negative-sequence currents, denoted as ; and 0 , 0 , and 0 are the zero-sequence currents, denoted as . The third step shown in Fig. 2 generates a modified zero-sequence system, denoted as , in which a phase delay of 2 3 and 4 3 are respectively applied to b and c zero-sequence components, obtaining the terms denoted as 0 , 0 and 0 , which constitute a balanced system of positive-sequence. The fourth step consists of the application of positive or negative transformation to the corresponding sequence components, respectively. The complete SoCR procedure to obtain the six constant terms from a three-phase instantaneous currents is presented in the following subsection.

SoCR implementation
The calculation of the symmetrical components is usually presented using the operator . This operator can be instantaneously calculated using Equation (3) [32,33].
Instantaneous symmetrical components decomposition is done by means of Equations (4), (5), and (6), as it was presented in [32], where the signal with the super-index 2 is related to the signal with 2 phase-lag.
The generation of the modified zero-sequence system, , is showed in Equation (7), in which a balanced system of positive-sequence is obtained adding a phase delay of 2 3 to 0 , and a phase delay of 4 3 to 0 . The approach was presented in [30,29,34], being based in the method developed in [32,33]. It is important to highlight that 0 = 0 = 0 because when applying the transformation in Equation (7), and components corresponding to 0 are equal to 0 and this particularly phenomenon allows finding the currents peak values.
The fourth step shown in Fig. 2 consists of applying the positive transformation showed in Equation (8) to Equations (4) and (7) and the negative transformation showed in Equation (9) to Equation (5) [35].
Once the procedure for obtaining the SoCR has been presented, Equations for the six CR calculation are presented in Equation (10).
The transformation of a balanced three-phase system, as it is the case of , , and return constant values. Due to this, each symmetrical component of Equation (10) can be represented in complex values as shown in Equation (11), using the scalar 2 ) for generating 2 3 of phase-lag, and (− 1 2 − √ 3 2 ) for generating 4 3 of phase-lag.
Given the SoCR procedure, the six constant references can be concatenated as the vector shown in Equation (12), that facilitates its mathematical manipulation when writing the optimization problem for a simulator or a microcontroller. The term represents the electrical output line of a device where SoCR is applied, where the types of devices can be classified attending to the power flows as follows: generator (PV or wind), consumption of energy (loads), and bidirectional devices like the BESS or the same MG.
Current term denoted as 1 is related to the fundamental positive-sequence active power, so the rest of terms defined in Equation (13) represent the non-efficient current terms in the device and can be used as compensating current vector if are supplied by EGs to reduce in the MG the adverse effects produced by the flows of the non-efficient load current terms.

Peak currents calculation
Compensation of fundamental non-efficient load current terms using distributed EGs must be done considering the rated maximum current of the EGs and without affecting its capacity as a source of energy in the MG. The peak value of the compensating currents assigned to the EGs must be controlled to avoid overcurrents. Each peak current is calculated using Equation (14), where , and are written as function of ⃖⃖⃖⃖⃖⃗ terms, as it is presented in Equation (11).
Equation (15) permits to calculate the maximum values for , , and as a function of direct and quadrature components. This expression is useful for representing linear unbalanced systems in terms of the six ⃖⃖⃖⃖⃖ ⃗ proposed in this paper.
Square peak values are calculated using Equation (16). Square values are used to avoid the use of square roots in the optimization problem which yields to a non-convex problem.

Optimization problem formulation for non-efficient load current distribution between EGs in a grid-tied MG
It is important to present how SoCR is used for distribution of non-efficient fundamental current among EGs in an MG. In the following sections the grid-tied MG depicted in Fig. 3 is considered. This MG is composed of loads (a residential building), a PV system, a wind system, and a BESS. The MG operation is managed by means of the MGCC. The PV system, the wind system, and the BESS are the so-called Energy Gateways (EGs), operating as energy interfaces between the non-conventional sources and the MG. The main function of these EGs is, in addition to supply fundamental positive-sequence active power into the MG, to compensate all the fundamental non-efficient load current terms. The problem that arises is how to establish the control set-points of each EG to distribute the compensation of the non-efficient currents flowing through the MG. The SAPF shown as removed in Fig. 3 represents  that the MG does not need the SAPF to compensate the fundamental non-efficient load current terms, a role that will be taken over by the existing EGs in the MG.
In general, considering an MG connected to a power network with which it exchanges currents represented by ⃖⃖⃖⃖⃖⃗ , with EGs ( ) and loads ( ), from the SoCR perspective, fulfills the relationship of Equation (17). It is important to remark that Equation (17) assumes that current flows from the power network to the MG, from the EGs to the MG, and from the MG to the load, as it is presented in Fig. 3. This assumption states the sign of the terms appearing in the following equation.
Where ⃖⃖⃖⃖⃖⃗ , ⃖⃖⃖⃖⃖⃗ , and ⃖⃖⃖⃖⃖⃗ are respectively representing the current terms in the MG, the EGs, and the loads. Equation (17) corresponds to current Kirchhoff's law.
With regards to 1 , a positive value means that the power network is providing fundamental positive-sequence active power to the MG, a negative value means that the power network is receiving fundamental positive-sequence active power, and a zero value means there is not energy exchange between MG and power network; i.e., the MG is self-sufficient. ⃖⃖⃖⃖⃖ ⃗ calculation considers the direction of the current flow, therefore, it is important to consider sensor polarity and EG connection. As ⃖⃖⃖⃖⃖ ⃗ − are related to fundamental non-efficient current terms, the MGCC operates to reduce or cancel the terms contained in ⃖⃖⃖⃖⃖ ⃗ − in the proximity of the loads that demand ⃖⃖⃖⃖⃖ ⃗ − . To achieve this objective, ⃖⃖⃖⃖⃖ ⃗ − terms must be distributed among the EGs present in the MG trying to reach an operating condition in which ⃖⃖⃖⃖⃖ ⃗ − are equal to zero, existing only 1 upstream the MG. Regarding the non-efficient load currents in an MG, the most common solution to improve power quality in an electrical power system is the inclusion of an SAPF in the installation, in the surroundings of the loads that demand the non-efficient current terms. The approach developed in this work uses the EGs present in the MG to achieve the same compensation characteristics as the SAPF-based solution. The distribution of the non-efficient load current terms between the EGs is achieved by considering the remaining current capacities of the EGs after supplying the available fundamental positive-sequence active power, which could cover the active power demanded by the loads or could be exported to other parts of the power network. This approach has two main advantages: 1) it avoids the installation of SAPFs, reducing costs and simplifying the complexity of the MG, and 2) it takes advantage of the flexibility of the EGs to improve the power quality of the MG, even in the case of partial compensation of the non-efficient load currents.
The distribution of ⃖⃖⃖⃖⃖ ⃗ − between the EGs connected to the MG requires to consider the following: 1) the EGs assigned to the compensation must have some remaining current capacity, and 2) the maximum current capacity of the EGs may not be exceeded in any case, otherwise, some of the devices of the MG may be damaged and the MG could be disconnected. The ⃖⃖⃖⃖⃖ ⃗ are obtained by means of the transformation and symmetrical components decomposition, which are linear transformations. Therefore, the SoCR satisfies the superposition property of linear systems and Equation (17) can be applied for the distributed compensation of the non-efficient load current terms because the inverse operation of each transformation is guaranteed.
The optimization problem starts considering the current balance established by Equation (17). Because 1 term is related to the fundamental positive-sequence active power, it does not matter whether it is supplied by the power network, the EGs, or as combination of both. It is normally preferred that the EGs supply this 1 to maximize the utilization of the MG, and it is common for the EGs to have remaining current capacity to also supply ⃖⃖⃖⃖⃖ ⃗ − (in whole or in part) to the MG. In order to enhance the power quality in the MG, ⃖⃖⃖⃖⃖ ⃗ − must be equal or as close as possible to ⃖ ⃗ 0. Excluding 1 in equation (17), the following equation arises: where ⃖⃖⃖⃖⃖ ⃗ However, quadratic functions are commonly preferred as objective functions in optimization problems because their potential to result in convex optimization problems. In this sense, the squared Euclidean Distance, denoted as ‖⋅‖ 2 , is applied to the above equality, looking for a parametric equation that can be turned into a constrained optimization problem, as shown in Equation (19).
To complete the optimization problem formulation, some additional constraints must be defined. These constraints account for the peak current being delivered by the EGs, that have to be smaller than its maximum current capacity ( ). Consequently, the constrained optimization problem to be solved can be written by means of the objective function presented in Equation (20) and their respective constrains for EGs, defined in Equation (21).  (20). The second step is an optimization current block that uses the argmin function (please see, Equation (20)). In the optimization process, the first argmin value corresponding to the ⃖⃖⃖⃖⃖ ⃗ − measured in the EGs is used for beginning the iterations. In the third step, ⃖⃖⃖⃖⃖ ⃗ are respectively assigned to the EGs, which change their set-points to improve the power quality in the MG. Fourth block consists on converting the obtained ⃖⃖⃖⃖⃖ ⃗ in the reference frame applying the inverse process of figure 2. For doing this, first it is applied positive sequence inverse transformation to [ 0 , 0 ], [ 1 , 1 ] and [ 2 , 2 ]. Second, it is obtained the zero-sequence components ( 0 = 0 , 0 = 0 , and 0 = 0 ). Third, it adds the symmetrical components to find the instantaneous value that each inverter must have. Fourth, it establishes the instantaneous references to each EG. The first and third blocks must have the same expression because the first one decomposes each signal measured from the EGs, the loads, and the MG, while the third block reconstructs the signal that must follow each EG. It can be noted that the inputs and outputs of each block are different. The current of the MG is measured to monitor, and the current of each EG is measured to determine the active power and use the last distribution of inefficiencies in the optimization algorithm that requires a starting point.

Results
The methodology for distributing ⃖⃖⃖⃖⃖ ⃗ − between EGs is validated in a grid-tied MG with a nominal voltage equal to 120 V (line to neutral) at 60 Hz, only including the fundamental positive-sequence voltage components. The target peak value for the instantaneous output current of PV and BESS is 35 A, equivalent to 8909 VA, while for wind generation it is set at 25 A, equivalent to 6364 VA. This is a common scenario for medium power size MGs and takes relevance when linear unbalanced loads overload one or two phases.  Table 1 corresponds to the current values after MG load connection ( > 0.05 s) that includes the peak values and their corresponding decomposition in the six constant references.   Fig. 5a shows the instantaneous load currents that are represented by ( , , and ) and Fig. 5b shows ⃖⃖⃖⃖⃖⃗ ( 1 , 1 , 2 , 2 , 0 , and 0 ). A proportional signal of is added in the following time domain plots to include the origin of angles of the three-phase system. After the load connection and the short transient due to the inductive parts of the load, terms reach their steady-state values which yields to constant values for the ⃖⃖⃖⃖⃖⃗ obtained with the SoCR decomposition, validating the SoCR suitability to represent linear unbalanced systems. It is observed that the term related to the active power ( 1 ) is the largest of all the ⃖⃖⃖⃖⃖ ⃗ obtained and the load unbalance is clearly identified since all the ⃖⃖⃖⃖⃖ ⃗ − terms are non-zero.  Table 2 shows the steady-state peak values of 1 in the four considered scenarios. The first column corresponds to the EGs of the system (Load, PV, W, BESS, and MG). Second and third columns correspond to 1 for baseline scenario before and after load connection in t=0.05 s respectively. Fourth and fifth columns correspond to 1 for the other scenarios before and after load connection in t=0.05 s respectively. In the baseline scenario, before the load connection, the BEES supply to the MG only fundamental positive-sequence active current terms. After the load connection, both BESS and MG supply the current terms demanded by the load, being the responsibility of the BESS to deliver the non-efficient components demanded by the load. All the scenarios simulated are considering the same values of 1 in the MG, before and after the load connection, as it is shown in the last row in Table 2. The summation of 1 of EGs in all the scenarios is equal to 1 in the baseline scenario, as shown by the values of the last two columns in Table 2, before and after load connection respectively. The 1 =30 A was established near the looking for a critical distribution problem of ⃖⃖⃖⃖⃖ ⃗ − values. Wind power was decreased in respect of PV and BESS looking for a hard restriction in the distribution of ⃖⃖⃖⃖⃖ ⃗ − between EGs and to represent a real MG with different EGs capacities. The values of 1 =17 A and 1 =-12 A are set, with the condition that the total sum of the EGs' currents is 35 A and with the BESS absorbing power for the MG.
and ⃖⃖⃖⃖⃖ ⃗ are presented in Fig. 6. All the peak values in Fig. 6 are equal to 1 shown in Table 2. During the interval in which the load is disconnected ( <0.05 s), 1 is supplying current to the MG, that operates as a load that injects the active power supplied by the BESS into the power network, as it is shown by the negative sign of 1 = -35 A in Table 2, the 180º phase shift between and in Fig. 6a, or the negative value of 1 in Fig. 6b. After the load connection ( >0.05 s), the MG supply 1 =34.42 A, that summed up with 1 from the BESS (a total of 35 A) permits covering the load current 1 =69.42 A. The null phase shift between and in Fig. 6a or the positive value of 1 in Fig. 6b clearly shows that the power network is operating as a source of energy for >0.05 s. In any case, the MG is operating with the best power quality, without non-efficient current terms flowing through it, as it is shown in Fig. 6b (all ⃖⃖⃖⃖⃖ ⃗ − are null).

Baseline scenario
This baseline scenario demonstrates that the SoCR method is a suitable tool for the decomposing of fundamental unbalanced currents to implement selective compensation strategies of the fundamental non-efficient load current terms represented in ⃖⃖⃖⃖⃖ ⃗ − , taking advantage of the flexibility of EGs. It is assumed that only the BESS is available in the MG and has the capability to simultaneously supply 1 = 35 A to the MG and to compensate all ⃖⃖⃖⃖⃖ ⃗ − . From the measurement of the currents in the load and their subsequent decomposition following Equations (4) to (10), the MGCC sets ⃖⃖⃖⃖⃖ ⃗ − terms in the BESS controller. Table 3 contains the six reference values ( ⃖⃖⃖⃖⃖ ⃗ ) after the load connection in =0.05 s in the baseline scenario for load (second column), BESS (third column), and MG (fourth column). Table 3 shows how ⃖⃖⃖⃖⃖ ⃗ − are equal to ⃖⃖⃖⃖⃖ ⃗ − , fulfilling Equation (18). 1 is supplied between the BESS ( 1 = 35 A), keeping the value scheduled by the MGCC, and the MG ( 1 = 34.42 A). As can be seen in the last column of Table 3, the power network is only supplying 1 , with a null value in all the non-efficient current terms, as corresponds to the verification of Equation (17) and as shown in Fig. 6.  Fig. 7 corresponds to the current supplied by the BESS and their corresponding decomposition in the six constant references for baseline scenario. Fig. 7a presents the BESS currents in the time domain. Until the load connection, the BESS is supplying a constant fundamental positive-sequence active power to the grid ( and are in phase). After the load connection, the active power generated by the BESS remains at the same value, as can be observed by the value of 1 which is constant and equal to 35 A during the whole simulation. The compensation of the non-efficient load current terms explains the presence of ⃖⃖⃖⃖⃖ ⃗ − after the load connection, as is showed in Fig. 7b. The BESS output currents in the time domain ( ) are unbalanced and include phase shifts that compensates all ⃖⃖⃖⃖⃖ ⃗ − terms. The main problem with these current waveforms is the maximum value of , that arrives to 75.16 A (2.16 times greater than the target limiting current =35 A), being this value the one that determines the apparent power rating of the EGs, although the BESS output currents in phases a or b are smaller. This means that if only one EG of the MG is supplying all ⃖⃖⃖⃖⃖ ⃗ − at once, this device can be easily overloaded and consequently the operating condition leads to an EG outage and the MG would present a lower power quality. Regarding the SoCR baseline simulation, the simulated results demonstrate how a three-phase system can be represented by means of constant references ( ⃖⃖⃖⃖⃖ ⃗ ), with a perfect decoupling of the efficient term ( 1 ) from the non-efficient terms, represented by ⃖⃖⃖⃖⃖ ⃗ − . The uncoupling between 1 and ⃖⃖⃖⃖⃖ ⃗ − allows the distribution of the non-efficient current terms among the EGs present in the MG. The solution usually proposed in the literature consists of the inclusion of one shunt active power filter, as in [19,22], although this solution requires an over-sized device that leads to over costs or a low use of the installed infrastructure capacity.

Balanced distribution scenario
The balanced distribution scenario assumes that ⃖⃖⃖⃖⃖ ⃗ − , presented in Table 3, is equally distributed among the three EGs, The results obtained for this distribution approach are outlined in Table 4 and plotted in Fig. 8. The operating conditions detailed in Table 4 before the load connection, for < 0.05 s, are common to the following scenarios, matching with the values of 1 shown in Table 2. Maximum peak current values of EGs during the simulation of this scenario are reported in Table 4 attending the load state. Negative values in Table 4 for BESS represent the storage of energy. Fig. 8 presents the currents of the EGs in the time domain. Fig. 8a corresponds to , Fig. 8b corresponds to , and Fig. 8c  corresponds to ; where is included in the plots as two horizontal dashed lines. Before the load connection and are in phase with their corresponding phase voltage, as corresponds when EGs are generating only fundamental positive-sequence active power, while present a phase shift of 180º due to the BESS is storing energy. After the load connection and the distribution of ⃖⃖⃖⃖⃖ ⃗ − between the EGs, the phase currents in the EGs are unbalanced and present different phase shifts. Furthermore, some phase currents of the EGs are exceeding their corresponding maximum rated current, denoted as . The values that overcome the rated limits are , with 41.32 A for a = 35 A, and , with 29.63 A for a = 25 A, being both represented in bold characters in Table 4.
Regarding the balanced distribution scenario, results obtained demonstrate how ⃖⃖⃖⃖⃖ ⃗ − distribution among EGs of an MG system can be done. The value of the maximum currents of all EGs in this scenario is smaller than with the obtained in the baseline scenario, where only one EG was compensating the non-efficient currents and its peak value of current in one phase was 75.6 A. Despite this, some instantaneous phase currents are exceeding the corresponding rated values set by , so this distribution approach is not valid if the limits of operation of EGs are considered.

Proportional distribution scenario
To avoid the problem of exceeding the values of , the proportional distribution approach contemplates the availability of each EGs in ⃖⃖⃖⃖⃖ ⃗ − compensation. Considering the values shown in Table 5 before the load connection, the current availability for compensation is equal to 5 A, 8 Fig. 9a, Fig. 9b, and Fig. 9c respectively; reporting in Table 5 the maximum values reached in their corresponding phases.
As highlighted in Table 5 and can be seen in Fig. 9, after the load connection the PV generator is operating very close of but = 37.59 A and = 25.13 A are exceeding their values, equal to 35 A and 25 A respectively. The results obtained show that with the proportional distribution scenario, the distribution of ⃖⃖⃖⃖⃖ ⃗ − can establish peak current values not allowed for the EGs, which should be considered by the MGCC to avoid problems with the operation of the MG itself and to achieve the highest possible power quality with the available resources. Main advantage of the proportional distribution scenario approach with respect to the balanced distribution scenario is in the reduction of the over-currents in the EGs concerning to , where = 37.59 A and = 25.13 A are replacing the values obtained with the previous scenario ( = 41.32 A and = 29.63 A). Despite this reduction in the peak currents, the proportional distribution scenario approach does not permit to operate the MG in its optimal conditions if the values of are considered, resulting in a ⃖⃖⃖⃖⃖ ⃗ − not null, that is not the most efficient behavior of the MG.

Optimal distribution scenario
Previous approaches to distribute ⃖⃖⃖⃖⃖ ⃗ − between EGs present problems if the values of are considered. The optimal distribution approach overcomes this situation by means of the optimization model presented in Equation (20). The proposed optimization method guarantees the best ⃖⃖⃖⃖⃖ ⃗ − distribution among EGs without exceeding . This optimization model requires setting a starting condition (SC), choosing to use the non-efficient current terms applied to the EGs after load connection in the proportional distribution scenario, as shown in Equation (22). This SC was selected because it is the nearest known value to the final solution. This optimization problem has three EGs, with five non-efficient current terms in each, so there are fifteen variables and fifteen constraints.
The optimization method proposed in Equation (20) was solved in Python, an open-source software, with Scipy library, which is based in Trust Region Methods presented in [36]. The optimal solution for non-efficient distribution, considering the selected SC detailed in Equation (22), is reported in Table 6, where the SoCR terms for each MG element after the load connection are reported as a SoCR vector ( ⃖⃖⃖⃖⃖ ⃗ ). In this Table, the second column is the sum of the last four columns ( ⃖⃖⃖⃖⃖ ⃗ = ⃖⃖⃖⃖⃖ ⃗ + ⃖⃖⃖⃖⃖ ⃗ + ⃖⃖⃖⃖⃖ ⃗ + ⃖⃖⃖⃖⃖ ⃗ ), fulfilling Equation (17).
Instantaneous currents in the EGs for the optimal distribution approach are plotted in Fig. 10; where Fig. 10a corresponds to , Fig. 10b corresponds to , and Fig. 10c corresponds to . The is included in the plots as two horizontal dashed lines. The peak value of each phase current is shown in Table 7. The solution obtained shows that all are smaller than theirs , optimizing the distribution of the fundamental non-efficient load current terms between the EGs present in the MG. Phase a of the PV generator presents a current of 30.8 A, smaller than the maximum of 35 A available for this EG. The difference in the BESS is smaller, with 31.5 A in phase c with respect to the maximum of 35 A. The smallest margin is seen in the wind generator, in which the current of phase c is 23.6 A when the maximum for this EG is 25 A.    Regarding the proposed optimal solution, the optimization method guarantees EGs limit even if the ⃖⃖⃖⃖⃖ ⃗ − terms are bigger than EGs capacities because the minimization in this optimization problem looks for ⃖⃖⃖⃖⃖ ⃗ − equal to zero. However, if the target is not reached, the result guarantees the minimum values for ⃖⃖⃖⃖⃖ ⃗ − . It can be concluded that in this scenario ⃖⃖⃖⃖⃖ ⃗ − distribution among EGs was the best of all analyzed in this paper.

Discussion
Four scenarios have been simulated to demonstrate the validity of the SoCR proposal and the optimization procedure developed to distribute ⃖⃖⃖⃖⃖ ⃗ − between the EGs connected in an MG, trying to improve the power quality in the MG and reaching the operating condition in which the non-efficient current terms in the MG are null ( ⃖⃖⃖⃖⃖ ⃗ − = 0). Characteristics of the linear unbalanced load are kept constant in the four scenarios, varying the operating conditions of the EGs present in the MG, that includes a PV, a wind generator, and a BESS. The maximum instantaneous current targets at the output of the PV and wind generator are set at 35 A and 25 A respectively. The BESS can supply or consume fundamental positive-sequence active power at the same time that provide ⃖⃖⃖⃖⃖ ⃗ − to the MG, with a maximum instantaneous output current target equal to 35 A. Limits are imposed on the maximum instantaneous currents of the EGs to study the effect of current distribution under different operating conditions of an MG. Not considering the maximum ratings of EGs is a problem in an MG because exceeding the limit can cause the EG to shut down, which implies a loss of the renewable energy source or the BESS, and the circulation of non-efficient currents through the MG ( ⃖⃖⃖⃖⃖ ⃗ − ≠ 0). Table 8 is a summary of peak currents in the EGs for the four presented scenarios. The baseline scenario analyzed first only uses the BESS and the load to verify the suitability of the SoCR to correctly represent the load current terms ( ⃖⃖⃖⃖⃖ ⃗ ) and study the case where a single EG is in charge of compensating all ⃖⃖⃖⃖⃖ ⃗ − , such as when an SAPF is installed in the MG. Under these operating conditions in the MG, the current target of the BESS is largely exceeded in phases a and b when the load is connected, as highlighted by the bold values included in Table 8 for the baseline scenario column. This case in which only one EG compensates all ⃖⃖⃖⃖⃖ ⃗ − requires a very oversized EG when other existing EGs in the MG could collaborate in improving the operating conditions of the MG.
The second approach proposes a balanced distribution of the fundamental non-efficient load current terms considering all the EGs in the MG, which in the case studied corresponds to one third of ⃖⃖⃖⃖⃖ ⃗ − for each EG. As is shown in Table 8, the peak phase currents in the BESS decrease in the balanced distribution scenario with respect to the baseline scenario, although PV and wind overcome as it is presented in bold in the values given for phase c of these EGs. Although the distribution of ⃖⃖⃖⃖⃖ ⃗ − improves between the EGs with the balanced distribution, the problem of exceeding the maximum current targets of the EGs remains. The proportional distribution scenario assigns ⃖⃖⃖⃖⃖ ⃗ − among EGs based on their remaining capacity depending on 1 and . The proportional distribution has better behavior than both previous scenarios; however, current in phase a in wind and BESS exceed their corresponding , as it is shown in bold in the fifth column of Table 8. Although the proportional distribution scenario does not achieve that all EGs work within the targets set for their corresponding peak current, it is important to highlight that phase a of has still some remaining capacity, which suggests that wind and BESS currents in phase a could be reduced to be within their nominal values.
An improvement of the point of operation of the MG is achieved in the optimal distribution scenario, being based on the optimization model presented in Equation (20). This scenario looks for ⃖⃖⃖⃖⃖ ⃗ − minimizing, considering EGs limits as constraints and ensuring that are not exceeded, as shown in Table 8. If the EG remaining capacities do not allow completely supplying ⃖⃖⃖⃖⃖ ⃗ − , the ⃖⃖⃖⃖⃖ ⃗ − would be different to zero while the MG continues in operation. The optimal distribution scenario is the preferred compensation approach because it has the best ⃖⃖⃖⃖⃖ ⃗ − distribution, can be implemented in autonomous form in an MG using an MGCC, permits to operate EGs without exceeding their current limits, and adapts to the instantaneous operating conditions present in the MG.
The simulation of the proposed scenarios leads to conclude that SoCR sets a benchmark for distribution of ⃖⃖⃖⃖⃖ ⃗ − among EGs improving the power quality in the MG. The use of EGs as distributed power active filters avoid the installation of an active power filter only focused on the compensation of the non-efficient load current terms. The SoCR procedure also shown that ⃖⃖⃖⃖⃖ ⃗ − distribution between the EGs can increase the equipment usage in MGs. For instance, PV is only used for part of the day, and with our proposal it could be in operation during the whole day. SoCR could be applied in commercial EGs, facilitating the adoption of MGs and leading to significant economic and environmental cost reductions in electric power systems by making better use of the capabilities of existing equipment.

Conclusion
An optimization model for non-efficient current distribution in a grid-tied MG has been developed and simulated in a small size MG considering only fundamental positive-sequence voltages. The grid-tied MG is composed of three EGs and a linear unbalanced load. The non-efficient load current distribution uses a system of six constant reference terms denoted as SoCR, being applied in this work to improve power quality in the MG. SoCR is based on symmetrical components and transformation allowing representing a linear unbalanced system and decoupling fundamental active current from fundamental non-efficient current terms. After application of SoCR to the load currents, fundamental non-efficient current terms can be distributed between EGs without affecting the renewable resources, in which EGs current limit are considered. A new method of calculating the peak currents in each phase is proposed in the article. The approach avoids the use of square roots in the calculation of the output currents (generation + compensation) that each EG must provide. In this way the optimization algorithm can determine the currents of the EGs considering their operating limits without the non-convex problems that appears during the calculations of the optimization algorithm.
The SoCR distribution was applied in an MG throughout an MGCC which distributes the non-efficient current terms. Although this paper presents an optimization model that attempts to find the best distribution of the fundamental non-efficient load current terms between EGS, three previous scenarios were analyzed to show the power quality improvement in MGs when considering the current capabilities of the EGs under different SoCR approaches. However, if the current in one of the phases of any EG is exceeded, the corresponding EG could be disconnected by circuit breakers that affect renewable resources.
Four different scenarios for the distribution of compensation are simulated to show SoCR behavior: baseline, balanced, proportional, and optimal. In those scenarios, all SoCR of the fundamental non-efficient load current terms are obtained and used as part of the current references for PV, wind, and BESS in different distribution scenarios of the compensation of the non-efficient terms.
Baseline scenario is used for SoCR methodology validation, with the BESS operating as an SAPF (compensation of all the fundamental non-efficient load current terms) at the same time that supply fundamental positive-sequence active current to the MG (operating as a source of fundamental positive-sequence active power). This scenario allows showing the decoupling phenomena among fundamental positive-sequence active current and ⃖⃖⃖⃖⃖ ⃗ − . Although this scenario enhances power quality in the MG, the target was overcome, so if only one EG is used for providing non-efficient load current terms, the EG size would increase.
The three EGs present in the MG are used in the second scenario, in which a balanced distribution of ⃖⃖⃖⃖⃖ ⃗ − between the EGs is proposed. Despite this distribution enhances power quality in the MG and performs the compensation using all EGs, target are exceeded. The proportional distribution scenario considers the current remaining capabilities of the EGs, calculated as the target minus the fundamental positive-sequence active current. ⃖⃖⃖⃖⃖ ⃗ − are distributed considering the remaining current of the EGs, obtaining an important reduction in the phase currents of the EGs. Regardless of this benefit, target are also exceeded in this scenario and the MG is not operating in the best operating conditions.
The contribution of this article to the improvement of the performance of the MG consists of the use of an optimization model for the distribution of ⃖⃖⃖⃖⃖ ⃗ − between the EGs present in the MG. The optimal distribution scenario considers EG limits as constraints, and achieves ⃖⃖⃖⃖⃖ ⃗ − = 0 better than the other distribution scenarios analyzed in this work and keeping the EGs in smaller rated values than the other scenarios. For those reasons, optimal distribution scenario is the best presented distribution because the optimal scenario was the only one that did not exceed the limits. Moreover, it is important to remark that all simulation enhanced power quality conditions in the MG, it means that after non-efficient distribution using SoCR methodology, there are not reactive and unbalance currents upstream MG.
The proposed use of SoCR methodology and the optimization model for distribution of non-efficient current terms reduce cost and amount of elements for manufacturing equipment; also, if SoCR for non-efficient current distribution is implemented in commercial EGs, this methodology potentializes the energy transition in MG implementation.

CRediT authorship contribution statement
Benavides-Córdoba Santiago, Urrea-Quintero Jorge-Humberto, Muñoz-Galeano Nicolás, Cano-Quintero Juan-B, and Segui-Chilet Salvador: Conceived and designed the experiments; Performed the experiments; Analyzed and interpreted the data; Contributed reagents, materials, analysis tools or data; Wrote the paper.

Declaration of competing interest
The authors declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.