Optimal Allocation and Economic Analysis of Battery Energy Storage Systems: Self-Consumption Rate and Hosting Capacity Enhancement for Microgrids with High Renewable Penetration

Recent advances in using renewable energy resources make them more accessible and prevalent in microgrids (MGs) and nano grids (NGs) applications. Accordingly, much attention has been paid during the past few years to design and operate MGs with high renewable energy sources (RESs) penetration. Energy storage (ES) is the crucial enabler for reliable MG operation to help MGs become more resistant to disruptions, particularly with the increased penetration of RESs. In this regard, this paper formulates a two-stage optimization framework to improve a grid-connected MG performance. Firstly, the optimal allocation decisions of the battery ES systems (BESSs) are provided to enhance the self-consumption rate of the RESs and the hosting capacity (HC) of the MG. Secondly, an operation strategy with the results (number, location, and capacity) of the BESSs obtained from the first stage is handled as an objective function to minimize the MG’s total operation cost. The IEEE 33-bus radial system is modified to act as the MG with high RESs penetration. The problem is solved using a recent swarm intelligence optimization algorithm called the Harris hawks optimization (HHO) algorithm. The proposed optimal operation strategy considers numerous constraints, such as the charge-discharge balance, number and capacity limitations of the BESSs, and the different technical performance constraints of the MG. The results obtained verify the proposed optimization framework’s effectiveness for grid-connected MGs and validate the benefits gained from the appropriate allocation of BESSs. The results also indicate that oversized storage or using many unneeded storage units may adversely influence the MG’s total power losses.

utilization of batteries and keep the operation protected. Wu et al. [20] suggested a two-stage stochastic mixed-integer programming approach for determining the optimal size of multiple types of DGs to realize economic benefits while considering uncertainties in grid disturbance, load, and renewable generation. Feng et al. [21] presented an optimization approach based on multi-attribute utility theory to determine a hybrid ESS (HESS) optimal capacity to benefit from their complementary characteristics. The optimization approach combines both isolated and grid-connected modes of MG operation in the optimization problem formulation. In the grid-connected mode, the objective function was to minimize the operation cost, while in the isolated mode, improving the MG reliability was the goal. Some studies have also been devoted to obtaining ESS's optimal size and location to enhance MG performance [22][23][24][25]. For instance, Nojavan et al. [22] formulated a mixed-integer non-linear model to obtain ESS's optimal allocation considering a demand response (DR) program. The multi-objective function aimed to minimize the total investment and operation cost and minimize load expectation loss. Mostafa et al. [23] presented an optimization method based on the symbiotic organism search to determine the optimal location and size of ESS by minimizing the MG's total power loss while enhancing the MG voltage stability and the voltage profile of the MG buses. Chen and Duan [24] formulated an optimization approach based on the genetic algorithm for optimal allocation and economic analysis of ESSs and DGs in the MG, considering ESSs' and DGs' dynamic capacity adjustment to deal with the non-smooth cost functions to help supply the customer demand and secure the MG. The optimal allocation and economic analysis were determined. However, the HC in the presence of the ESSs was not discussed. Qiu et al. [25] formulated a two-stage stochastic planning model to allocate and analyze ESS presence in the MG, considering controllable loads. The optimal allocation decisions and economic analysis of the ESS were determined through a cost-benefit analysis approach. However, most of the existing studies have not investigated the impacts of ESSs-location, capacity, and number-on the SCR of the RESs, HC of the MG, and the transformer loading capacity.
To redress this gap, this paper formulates a two-stage optimization framework to improve a grid-connected MG performance. Firstly, the optimal allocation decisions of the battery ES systems (BESSs) are provided to enhance the SCR of the RESs and the HC of the MG. Secondly, an operation strategy with the results (location, number, and capacity) of the BESSs obtained from the first stage is handled as an objective function to minimize the total operation cost of the MG under investigation. The IEEE 33-bus radial system is modified to act as the MG with high RESs penetration. The problem is solved using a recent swarm intelligence optimization algorithm called the Harris hawks optimization (HHO) algorithm. The proposed optimal operation strategy considers numerous constraints, such as the charge-discharge balance, number and capacity limitations of the BESSs, and the different technical performance constraints of the MG. The main contribution of this work can be outlined as follows: • Investigation of the SCR of the RESs and HC of the MG in the presence of batteries.

•
Minimizing the total operation cost of the MG with high RESs penetration while optimizing the BESSs (location, capacity, and number) enhances the SCR of the RESs and HC of the MG.

•
Investigation of the impacts of the optimally allocated BESSs on the loading capacity of the main transformer feeding the MG. • Investigation of the impact of variation of efficiency and depth of discharge of the BESSs on the total operation cost and the power losses of the MG.
The rest of the paper is organized as follows: Section 2 describes the MG configuration. Section 3 explains the HC and its formulation. Section 4 provides the mathematical formulation of the problem. In Section 4, we present the HHO, which is used to solve the optimization problem. Section 5 presents the simulation results and discusses them. Finally, Section 6 presents a summary of the work done, the study's conclusions, and future concerns to be investigated.

Microgrid Configuration
The approach proposed in this work is employed on a modified IEEE 33-bus system introduced in [26]. The MG considered in this work comprises five photovoltaic (PV) units and five wind turbines (WTs), in addition to the MG central controller (MGCC), as shown in Figure 1. The MGCC is responsible for energy management (EM) of the main grid (utility), PV, and WT and the charging and discharging process of the BESSs to achieve the minimum MG's operating cost. The data of PV and WT units obtained from [26] are presented in Table 1.
Sustainability 2020, 12, x FOR PEER REVIEW 4 of 26 (WTs), in addition to the MG central controller (MGCC), as shown in Figure 1. The MGCC is responsible for energy management (EM) of the main grid (utility), PV, and WT and the charging and discharging process of the BESSs to achieve the minimum MG's operating cost. The data of PV and WT units obtained from [26] are presented in Table 1.

Photovoltaic (PV) System
The PV cell is the elementary construction utilized in the manufacture of a PV unit, in which the PV cells are connected in series and parallel to build a PV module. The output power of PV mainly depends on the operating conditions represented by the temperature and solar irradiation, as represented by Equation (1) [2].
where ℎ , , and are the output of the PV, rated power of the PV, and the number of PV units, respectively. , 0 , , and are the global irradiance, standard solar irradiance under standard test conditions, the temperature coefficient of the maximum power of the PV, and the ambient temperature. and denote the inverter efficiency and the relative efficiency of the PV, respectively.

Wind Turbine (WT) Unit
The output power of wind turbines (WTs) relates to the wind speed in a specific location and the power curve (given by the manufacturer data of the WTs), which is expressed as a function categorized into four parts as represented in Equation (2). The hourly wind speed is estimated using the Weibull distribution function from data provided in [2].

Photovoltaic (PV) System
The PV cell is the elementary construction utilized in the manufacture of a PV unit, in which the PV cells are connected in series and parallel to build a PV module. The output power of PV mainly depends on the operating conditions represented by the temperature and solar irradiation, as represented by Equation (1) [2].
where P PV h , P P R , and M PV are the output of the PV, rated power of the PV, and the number of PV units, respectively. W, W 0 , T co f f , and T ambient are the global irradiance, standard solar irradiance under standard test conditions, the temperature coefficient of the maximum power of the PV, and the ambient temperature. η v and η R denote the inverter efficiency and the relative efficiency of the PV, respectively.

Wind Turbine (WT) Unit
The output power of wind turbines (WTs) relates to the wind speed in a specific location and the power curve (given by the manufacturer data of the WTs), which is expressed as a function categorized into four parts as represented in Equation (2). The hourly wind speed is estimated using the Weibull distribution function from data provided in [2].
where P WT h and P WT R are the output and rated powers of the WTs, respectively. v WT,h , v RWT , v cut−in WT , and v cut−out WT express the time-step (hourly) wind speed at hour h, rated speed of the WT, cut-in speed of the WT, and the cut-out speed of the WT.

Battery Energy Storage System (BESS)
There are various types of battery storage (BS) technologies with different technical features, such as lead-acid (LA), lithium-ion (Li-ion), sodium-sulfur (NaS), nickel-cadmium (NiCd), and others [27]. Each BESS has its own features that may positively impact the HC measure, PQ performance metrics, peak load reduction, grid stability, and EM of MGs in different ways [2]. The cost and technical parameters of BS technologies, namely, NaS, Li-ion, NiCd, and LA, are presented in Table 2. It is notable from Table 2 that the Li-ion battery has a higher capital cost compared to the other battery types. The LA battery has lower efficiency and lifetime than the other batteries. The NaS battery has high efficiency (greater than 90%) and a long lifetime. NiCd has low efficiency, short lifetime, and high capital cost. Regarding NaS batteries, liquid sulfur and liquid sodium are used as positive and negative electrodes. The solid beta alumina ceramic is used as an electrolyte [2,28]. In the literature, some works recently investigated the cost model of different types of ES systems. For instance, Mostafa et al. [13] introduced an ES cost model that considers ES technologies and technical characteristics in an integrated framework that considers the ES technical and economic characteristics supported by in-market insight. It was proven that the NaS battery provides the lowest cost values compared to the values provided by the other batteries because of its high efficiency, long lifetime, and low replacement costs. Besides, Mostafa et al. [2] introduced an economic analysis model for optimal EM of MGs considering various RESs and BESS, and it was found that the NaS batteries are more substantial in decreasing the MG's operating cost than the other batteries due to their high efficiency and long lifetime. This is why the NaS battery was used in this work.
The capital cost (BS c ) of the BESS depends on the power (P BS ) and energy (E BS ) capacities as given in Equation (3).
where C P in ($/kW) and C E in ($/kWh) are the specific unit costs associated with the power and energy capacities of the BESS. in ($/kW) at the same hour, as represented by Equation (4).

Hosting Capacity (HC)
In the past, the electrical network was characterized by the unidirectional power flow from the primary grid to electrical loads. Nowadays, conventional power flow directions have changed dramatically due to the widespread use of DG technologies, particularly RESs such as PV and WT units [29]. However, the high penetration of RESs may adversely affect the electrical system's performance and result in numerous problems. Thus, enhancement of the HC of electrical systems, which expresses the maximum generation capacity from the RESs that the power system can host without exceeding the operational limits, is essential to increase the penetration level of RESs safely without exceeding any functional constraint. Figure 2 shows the concept of HC after the integration of RESs into a system. It is clear that supporting the HC of the power system helps increase the RES penetration level while satisfying the system operation constraints. units [29]. However, the high penetration of RESs may adversely affect the electrical system's performance and result in numerous problems. Thus, enhancement of the HC of electrical systems, which expresses the maximum generation capacity from the RESs that the power system can host without exceeding the operational limits, is essential to increase the penetration level of RESs safely without exceeding any functional constraint. Figure 2 shows the concept of HC after the integration of RESs into a system. It is clear that supporting the HC of the power system helps increase the RES penetration level while satisfying the system operation constraints. Mathematically, HC of RESs ( ) represents the ratio between the total injected output power by the RESs ( ) and the apparent load power ( ), as given in Equation (5) [30].
Also, the SCR of RESs ( ) represents the ratio between the actual energy provided by the RESs ( ) and the overall RESs energy produced ( ), as given in (6) [31]. In other words, the SCR refers to the share of the RESs produced energy used directly or indirectly to satisfy the local demands, in which SCR of 1 means that the full RESs production is used locally (e.g., the case for either a small RES capacity or a large RES capacity combined with BESS  Mathematically, HC of RESs (HC RESs ) represents the ratio between the total injected output power by the RESs (P RESs ) and the apparent load power (S load ), as given in Equation (5) [30].
Also, the SCR of RESs (ψ) represents the ratio between the actual energy provided by the RESs (E RESs ) and the overall RESs energy produced (E rated RESs ), as given in (6) [31]. In other words, the SCR refers to the share of the RESs produced energy used directly or indirectly to satisfy the local demands, in which SCR of 1 means that the full RESs production is used locally (e.g., the case for either a small RES capacity or a large RES capacity combined with BESS). H denotes the daily 24 h horizon.
From Equations (5) and (6), it can be noted that increased SCR using ES solutions leads to an increase in the HC, especially in the presence of batteries. Thus, supporting ES solutions' usage might be a good measure to promote the HC improvement in MGs and power systems. Furthermore, ES can enable the full grid-related benefits from self-consumption if ESSs are set right in a cost-effective manner.

Problem Formulation
This section presents the formulation of the two-stage optimization framework to find the optimal allocation of ESSs and the optimal operation strategy of the MG to enhance the SCR of the RESs, improve the HC, and minimize the total operation cost of the MG. It should be mentioned that the objective functions proposed in this work are not formulated in the literature. The mathematical formulation of the studied problem is given as follows:

Objective Function
The objective function (OF) is formulated in two stages. In the first stage, the optimal allocation decisions of BESSs were prepared to enhance the SCR of all RESs in the MG, as well as the HC, as given in Equation (7), where ψ(x) denotes the SCR of all RESs in the MG in the presence of batteries. In the second stage, the optimal operation strategies were prepared for the MG while considering the results of the first stage (location, size, and number of BESSs) to minimize the total operation cost of the MG as given in Equation (8) where T cost (x) expresses the operation cost of the utility ($/kWh), generation costs of WT and PV ($/kWh), and the total cost of BESSs per day (BSCD) ($/day).
where E RESs,h and E rated RESs,h represent the total energy generated from the RESs used in the MG at time h and the overall produced RESs energy at the same time h, respectively, where h is the time step in hours, and H denotes the 24 h horizon. P grid h , P WT h , and P PV h are the output powers of the grid, WT, and PV at h, respectively. b grid h , b WT h , and b PV h are the market energy price and the bidding prices of the WT and PV ($/kWh) at h, respectively [2].
Recalling Equation (3), the capital cost (BS c ) of the BESS depends on the P BS and E BS ; therefore, to obtain the replacement number of the BESS during the project lifetime; first, the total number of cycles performed through the BESS (B cycles ) is calculated by Equations (9) and (10) to determine the battery lifetime. Then, Equation (11) is used to get the lifetime of BESS (Li f e BS ) depending on the life cycle of the battery (B Li f ecycles ) and B cycles as given in [2,13].

of 25
Li f e BS = B Li f ecycles B cycles (11) where n B (h, j) indicates the cycles as a function of h and j, where j is the working day and j D where D denotes the total number of working days per year, set to 365 in this study. y a(h) is a binary variable that shows the status of the BESS at h and j, in which y a is equal to 0 when the BESS is discharging and 1 when the BESS is charging. Hence, the replacement number of BESS (RN BS ) during the project lifetime (Z) can be expressed as given in Equation (12).
where i is the interest rate used in financing the BESS. The objective functions are subject to the following constraints:

Power Limits of RESs
The generated power of the WT and PV units should be bounded by the upper and lower limits, as given in Equations (14) and (15) [2].
where P WT h, min and P PV h,min are the minimum generated power by the WT and PV units, respectively. On the other hand, P WT h,max and P PV h,max are the maximum generated power by the WT and PV units, respectively [23].

Power Balance Limit
The sum of power generated from the utility, WTs, PVs, and power discharged (P BS DIS,h ) from or the power charged to the battery (P BS CH,h ) should equal the total power demand P LOAD h , as given in (16).
where P losses b,h and Nb denote the active power loss of the bth line and the number of lines in the MG.

Load Flow Constraints
The power flow technique is implemented using two matrices-the branch-current to bus-voltage (BCBV) matrix and the bus injection to branch-current (BIBC) matrix. This technique is efficient when dealing with radial distribution systems. Details of the formulation of this technique can be found in [32]. The solution of the load flow of the MG can be determined by solving the following equations iteratively. The complex load (S j ) at each bus ( j) is represented by Equation (17). The corresponding equivalent current injection of each bus (I j ) is specified using S j and the node voltage V j as given in Equation (18). The solution can be determined by iteratively solving the following equations, where it denotes the iteration number.
where (MM) is the multiplication matrix of BCBV and BIBC matrices.

Voltage Limit
The root-mean-square (RMS) value of the voltage at each bus must be in its acceptable range, as represented by Equation (21).
where V bus min and V bus max represent the minimum and maximum voltage limits. The minimum and maximum voltage limits are considered as 0.95 and 1.05 p.u., respectively, in this study.

Line Capacity Constraint
The current flow in the MG's branches is limited by its thermal limit, as given in Equation (22).
where I line RMS and I line−max RMS represent the total current flowing in the line and the line's maximum current carrying capacity, respectively.

BESS Limits
The BESS constraints should be considered in the problem formulation. The constraint of P BS CH−h with respect to the maximum charging capacity limit P BS−max CH−h is represented by Equation (23) [2].
Similarly, Equation (24) represents the constraint of the P BS DIS−h with respect to the maximum discharging capacity limit P BS−max DIS−h .
Besides, the state of charge of the BESS (SOC h ) at h should be bounded by its upper and lower limits; thus: where SOC h min and SOC h max denote the minimum and maximum state of charge (SOC) of the BESS at h, respectively.
Also, the current hth SOC h is a function of the previous SOC h−1 as well as the discharge and charge quantity at h, as given in (26). The initial SOC SOC in is taken into account at the first hour (h = 1) as given in Equation (26). η BS and ∆h denote the BESS efficiency and length of the period (usually one hour), respectively.
However, the SOC at the end of the scheduling horizon must equal the initial SOC to maintain the SOC constant at the beginning of the scheduling horizon, as expressed in Equation (27).
Finally, the amount of the discharged power must equal the amount of the charged power while taking into account the battery efficiency η BS as expressed in Equation (28).

Harris Hawks Optimization (HHO) Algorithm
In 2019, Heidari et al. suggested a new novel population-based optimization technique called the Harris hawks optimization (HHO) [33,34]. The mathematical model of HHO mimics the hunting method of Harris hawks (large and lanky raptors with long legs and relatively long tails). A few hawks jump on a prey, often a rabbit, from different locations to shock it. In this coordinated attack, a leader hawk is surrounding the prey. The hawks can adjust their hunting methods based on the hunting environment and the rabbit's capability to escape. Algorithmically, the Harris hawks' hunting method depends on three phases-exploration (investigation), a changeover from exploration to exploitation, and globalization of search (exploitation). In the exploration process, the hawks scan the surrounding environment depending on their sharp vision to find rabbits. They perch randomly on the way in high places and wait to see a rabbit. When the hawks see a rabbit, they can attack it via two strategies. The first strategy relies on the cooperation between all hawks to shock the rabbit, while the second one relies on allowing the leader of the hawks to attack the rabbit based on the rabbit's capability to escape and the leader hawk's decision.
If an equal chance (q) is considered for each strategy, the hawks can sit based on the positions of the neighboring hawks to ensure a harmonized attack, as expressed in Equation (29), under the condition of q < 0.5. Otherwise, the hawks sit in random locations under the condition of q ≥ 0.5.
where H(it) represents the location vector of hawks at iteration it, H(it + 1) defines the location vector of hawks in the iteration it + 1, H rand (it) represents a randomly selected hawk from the current population, H Best (it) represents the position of prey (rabbit), M represents the total number of the hawks, LB and UB represent the upper and lower bounds of variables, and β, τ, ϕ, γ, and q are random numbers generated in the range of (0,1). Further, HHO can transfer from the exploration phase to the exploitation one by using the rabbit escaping energy (E), where the energy of the rabbit can be expressed as follows: where it, max represents the maximum number of iterations, and E o denotes the rabbit's random initial energy generated in the range of (−1,1) at each iteration. The HHO exploitation process has been modeled depending on the rabbit escaping energy and its escaping probability p, in which the successful escape occurs when the value of p is less than 0.5, and the unsuccessful escape occurs when p equal or greater than 0.5. According to the rabbit's escape scenario, the Harris hawks' hunting technique has two strategies: hard besiege or soft besiege to attack the rabbits. In the soft besiege, p ≥ 0.5 and |E| ≥ 0.5, the rabbit tries to escape using random misleading jumps, but finally, it fails. During these attempts, the hawks encircle the rabbit softly to make it more tired and then execute a sudden attack on it. This behavior is modeled as given in (31) and (32).
where ∆H(it) is the difference between the H Best (it) and the H(it) in iteration it. R expresses the random escape strength of the rabbit. On the other hand, in the hard besiege, p ≥ 0.5 and |E| < 0.5, i.e., the rabbit is tired and has low escape energy, and the hawks encircle the rabbit to execute a sudden attack. Equation (33) represents this behavior. A simple illustration of this step with one hawk is depicted in Figure 3, in which the main phases of the HHO can be shown in Figure 3. More advanced details about soft and hard siege tactics can be employed, as presented in [33]. The HHO algorithm flowchart is shown in Figure 4.

Results and Discussion
For the MG shown in Figure 1, Table 3 presents the bids of PV and WT units, in addition to the cost factors, efficiency, and lifecycle of the NaS batteries, which are used in this study.  Figure 5 shows the hourly predicted output power of the overall RESs, total load before and after the RESs connection, and the rated active power of the main transformer feeding the MG on a typical day.

RE
Bid of the WT ($/kWh) 1.72

NaS Battery
Capital power cost ($/kW) 350 Capital energy cost ($/kWh) 300 Efficiency (%) 95 Life cycles 4000 Lifetime (years) 15 Figure 5 shows the hourly predicted output power of the overall RESs, total load before and after the RESs connection, and the rated active power of the main transformer feeding the MG on a typical day. It is clear from Figure 5 that whenever DGs' output power increases, the main grid's output power decreases. It can also be seen from the same figure that a power reverse occurs when the total output power of the overall RES production is greater than the total load demand, as noted in the periods from hour 3 to hour 5, hour 7, and from hour 12 to hour 14. Besides, the overloading of the main transformer may occur when the total output power of the RESs is low, and the load demand is high. Figure 6 shows the hourly SCR of the RESs connected without integrating any NaS batteries (base case). The SCR of the WT and PV does not equal 100% at all the hours. The SCR of WT ranges between 87.7% to 95.0% from hour 3 to hour 5 and equals 96.6% at hour 7. Also, the SCR of PV is 32.4% to 70.9% in the period from hour 13 to hour 14. To make the WT and PV more cost-effective for It is clear from Figure 5 that whenever DGs' output power increases, the main grid's output power decreases. It can also be seen from the same figure that a power reverse occurs when the total output power of the overall RES production is greater than the total load demand, as noted in the periods from hour 3 to hour 5, hour 7, and from hour 12 to hour 14. Besides, the overloading of the main transformer may occur when the total output power of the RESs is low, and the load demand is high. Figure 6 shows the hourly SCR of the RESs connected without integrating any NaS batteries (base case). The SCR of the WT and PV does not equal 100% at all the hours. The SCR of WT ranges between 87.7% to 95.0% from hour 3 to hour 5 and equals 96.6% at hour 7. Also, the SCR of PV is 32.4% to 70.9% in the period from hour 13 to hour 14. To make the WT and PV more cost-effective for electricity production, the MG seeks to make the SCR of the WT and PV equal 100% at all hours during the day.
Sustainability 2020, 12, x FOR PEER REVIEW 13 of 26 electricity production, the MG seeks to make the SCR of the WT and PV equal 100% at all hours during the day. Accordingly, this work firstly determines the optimal allocation of BESSs to maximize the SCR of all the RESs connected while enhancing the HC of the MG. Secondly, using the results obtained from the first stage, the total operating cost of the MG with the batteries connected is minimized on the investigated typical day. Five cases are analyzed to show the effect of the increased number of Figure 6. The self-consumption rate (SCR) rate of the WT and PV without battery energy storage system (BESS) connection. Accordingly, this work firstly determines the optimal allocation of BESSs to maximize the SCR of all the RESs connected while enhancing the HC of the MG. Secondly, using the results obtained from the first stage, the total operating cost of the MG with the batteries connected is minimized on the investigated typical day. Five cases are analyzed to show the effect of the increased number of BESSs on the MG performance. Case 1: One BESS (NaS type) is installed; Case 2: Two BESSs are installed; Case 3: Three BESSs are installed, Case 4: Four BESSs are installed, and Case 5: Five BESSs are installed. Table 4 presents the optimal location and size of the BESSs obtained by the HHO algorithm in the five cases to maximize the SCR. After integrating one NaS battery or more to the MG, the SCR of the WT and PV increased to 100% at all hours during the day. In this regard, the BESS positively enhances the SCR of the RESs, then prices for applications in the MG may reduce, making such battery solutions more attractive to prosumers and operators alike.  Figure 7 shows the HC in the studied MG without NaS battery connection and NaS battery connection in the five cases. It can be seen that more RESs penetration can be supported by the increase in the number of batteries. As the RESs penetration increases from 9.33 MW in the base case without NaS battery connection to 10.75 MW in Case 1, 11.66 MW in Case 2, 12.25 MW in Case 3, 12.12 MW in Case 4, and to 11.73 MW in Case 5. It is clear from Figure 7 that HC of RESs considerably improves with integrating BESSs; besides, it can be seen from the same figure that the change in the number of BESSs has a significant effect on the HC.
Once we got the optimal BESS location, size, and number, the optimal energy management of the MG is determined by reducing the operating costs to assess the impact of the BESSs on the system performance from an economic point of view. Table 5 shows the results calculated for the operating cost of the MG with and without the BESS connection, in which the operating cost of the grid, PV, WT, the cost of each BESS, the total cost of BESS per day, and the total operating cost of the MG per day, are presented. It should be noted that the total operating cost in the base case represents are the costs associated with the MG upgrades and energy losses. BESS's total cost per day consists of the battery's capital and replacement costs during the project lifetime, in which the project lifetime is taken as 35 years, and the interest rate is set to 0.02 in this study. Recalling the life cycles of the NaS presented in Table 3 and the total number of cycles performed through the NaS battery per year, Li f e BS of the NaS battery is calculated to know the replacement number of the NaS battery through the project's lifetime, and the results obtained using the HHO algorithm are given in Table 5. Further, the percentage of saving in the operating costs in each case is calculated with respect to the corresponding operating cost of the base case. connection in the five cases. It can be seen that more RESs penetration can be supported by the increase in the number of batteries. As the RESs penetration increases from 9.33 MW in the base case without NaS battery connection to 10.75 MW in Case 1, 11.66 MW in Case 2, 12.25 MW in Case 3, 12.12 MW in Case 4, and to 11.73 MW in Case 5. It is clear from Figure 7 that HC of RESs considerably improves with integrating BESSs; besides, it can be seen from the same figure that the change in the number of BESSs has a significant effect on the HC. Once we got the optimal BESS location, size, and number, the optimal energy management of the MG is determined by reducing the operating costs to assess the impact of the BESSs on the system performance from an economic point of view. Table 5 shows the results calculated for the operating cost of the MG with and without the BESS connection, in which the operating cost of the grid, PV, WT, the cost of each BESS, the total cost of BESS per day, and the total operating cost of the MG per day, are presented. It should be noted that the total operating cost in the base case represents are the costs associated with the MG upgrades and energy losses. BESS's total cost per day consists of the battery's capital and replacement costs during the project lifetime, in which the project lifetime is taken as 35 years, and the interest rate is set to 0.02 in this study. Recalling the life cycles of the NaS presented in Table 3 and the total number of cycles performed through the NaS battery per year, of the NaS battery is calculated to know the replacement number of the NaS battery through the project's lifetime, and the results obtained using the HHO algorithm are given in Table 5. Further, the percentage of saving in the operating costs in each case is calculated with respect to the corresponding operating cost of the base case.  The results show that the total operating cost of the MG depends considerably on the number of BESS connected to the MG. It is clear from Table 5 that Case 3, with three BESSs integrated into the MG, provides the best saving percentage in the operating costs (31.7%). Figure 8 shows the optimal output powers of the grid, PV, WT, and BESS in Case 3 at each hour during the day. Also, Figure 9 shows the SOC of the three BESS at each hour during the day. Figures 8 and 9 show that the three BS units charge in the periods with low market prices and when the total load is not high to satisfy the MG technical performance constraints (such as the period from hour 1 to hour 7). When the BS units are fully charged, the BS units begin to discharge during the periods when the energy market price is high to minimize the MG's operating cost, such as the period from hour 16 to hour 21.  The transformer overloads may occur when the total output power of RESs is low and the total connected loads are high. The rated capacity ( ) and power of the transformer in the studied MG are 3500 kVA and 2976 kW, respectively. Figure 10 shows the transformer load rate in the investigated cases and the base case.  The transformer overloads may occur when the total output power of RESs is low and the total connected loads are high. The rated capacity ( ) and power of the transformer in the studied MG are 3500 kVA and 2976 kW, respectively. Figure 10 shows the transformer load rate in the investigated cases and the base case. The transformer overloads may occur when the total output power of RESs is low and the total connected loads are high. The rated capacity (S rated Tr ) and power P rated Tr of the transformer in the studied MG are 3500 kVA and 2976 kW, respectively. Figure 10 shows the transformer load rate in the investigated cases and the base case.
It is notable from Figure 10 that if the MG operates with no BESS, the transformer is overloaded from hour 8 to hour 11 and from hour 15 to hour 18. However, the transformer load rate does not exceed the transformer's rated power after integrating the RESs in the MG with BESSs. Consequently, storage plays a critical role in reducing the transformer load rate because it helps shift the load from peak hours to off-peak (valley) hours. Therefore, storage can be used to defer transformer reinforcement plans.
It is worthy to note from Figure 8 to Figure 10 that the BESSs charged in the periods with a low market price and light load demands (such as the first periods); therefore, in the cases with storage Sustainability 2020, 12, 10144 17 of 25 units connected, the power losses of the MG increases in these periods above the base case, as shown in Figure 11. It is also apparent in Figure 11 that the power losses are constant in all the investigated cases in the period from hour 8 to hour 12 because the SOC of BESSs is constant. However, the power losses decreased from hour 15 to hour 19 because the BESSs discharged. It is notable from Figure 10 that if the MG operates with no BESS, the transformer is overloaded from hour 8 to hour 11 and from hour 15 to hour 18. However, the transformer load rate does not exceed the transformer's rated power after integrating the RESs in the MG with BESSs. Consequently, storage plays a critical role in reducing the transformer load rate because it helps shift the load from peak hours to off-peak (valley) hours. Therefore, storage can be used to defer transformer reinforcement plans.
It is worthy to note from Figures 8 to 10 that the BESSs charged in the periods with a low market price and light load demands (such as the first periods); therefore, in the cases with storage units connected, the power losses of the MG increases in these periods above the base case, as shown in Figure 11. It is also apparent in Figure 11 that the power losses are constant in all the investigated cases in the period from hour 8 to hour 12 because the SOC of BESSs is constant. However, the power losses decreased from hour 15 to hour 19 because the BESSs discharged. The costs of energy losses differ based on the corresponding power losses value in each case. Accordingly, Figure 12 shows the total power losses of the MG during the day. It is notable from Figure 12 that total power losses of the MG during the day in Case 5 (1696.7 kW) exceeds the total power losses in the base case (1571.7 kW), and this indicates that oversized storage or using many unneeded storage units may adversely influence the total power losses of the MG. The costs of energy losses differ based on the corresponding power losses value in each case. Accordingly, Figure 12 shows the total power losses of the MG during the day. It is notable from Figure 12 that total power losses of the MG during the day in Case 5 (1696.7 kW) exceeds the total power losses in the base case (1571.7 kW), and this indicates that oversized storage or using many unneeded storage units may adversely influence the total power losses of the MG. The costs of energy losses differ based on the corresponding power losses value in each case. Accordingly, Figure 12 shows the total power losses of the MG during the day. It is notable from Figure 12 that total power losses of the MG during the day in Case 5 (1696.7 kW) exceeds the total power losses in the base case (1571.7 kW), and this indicates that oversized storage or using many unneeded storage units may adversely influence the total power losses of the MG.  Figure 13 shows the voltage profile of the MG buses at four selected durations with different loadings-at the fourth hour (51% loading) presented in Figure 13a, at the 10th hour (100% loading) shown in Figure 13b, at the 14th hour (88% loading) shown in Figure 13c, and the 21st hour (68% loading) shown in Figure 13d. It is worthy to note from Figure 13a that the MG's voltage profile in the base case with no storage is almost 1 per unit at all buses at the fourth hour because of the light loading. In the case of integrating storage in the MG, the BESSs charge at the fourth hour because the market price is low; thus, the buses' voltage profile decreases below the base case without violating the voltage limits. It is notable from Figure 13b that the MG's voltage profile at the 10th hour is the same in all cases because the SOC of the batteries is constant. Also, it can be seen from Figure 13c that  Figure 13 shows the voltage profile of the MG buses at four selected durations with different loadings-at the fourth hour (51% loading) presented in Figure 13a, at the 10th hour (100% loading) shown in Figure 13b, at the 14th hour (88% loading) shown in Figure 13c, and the 21st hour (68% loading) shown in Figure 13d. It is worthy to note from Figure 13a that the MG's voltage profile in the base case with no storage is almost 1 per unit at all buses at the fourth hour because of the light loading. In the case of integrating storage in the MG, the BESSs charge at the fourth hour because the market price is low; thus, the buses' voltage profile decreases below the base case without violating the voltage limits. It is notable from Figure 13b that the MG's voltage profile at the 10th hour is the same in all cases because the SOC of the batteries is constant. Also, it can be seen from Figure 13c that the voltage profile of the MG at the 14th hour gets lower because of the BESSs charging in this hour. Finally, it is clear from Figure 13d that the MG's voltage profile at the 21st hour enhanced beyond the base case because of the discharging of the BESSs. In this regard, the storage can improve the MG's voltage profile at any particular hour.
The number of charging/discharging cycles and depth of discharge of BESS have an important influence on the storage's lifetime. Datasheets of the BESS manufacturers are used to get the relationship between the number of charging/discharging cycles and the depth of discharge (DOD) of the NaS battery. Therefore, the effect of variation of these factors on the total operation cost and the total power losses was investigated. Table 6 shows the lifecycles obtained for the various DOD values [27].
It can be seen from Table 6 that the number of cycles of the batteries increases with the decrease of the permitted DOD value. Thus, the expected lifecycle of NaS will increase, and both the replacement number and total cost of NaS batteries will decrease. However, this does not mean the MG's total operation will be reduced because it depends on other factors, such as the output power of the RESs and the power imported/exported from the grid [35][36][37]. Figure 14 shows the variation of the total operation cost of the MG values and the percentage of saving with different efficiency and DOD values according to the NaS battery characteristics. It can be seen from Figure 14 that the total operation cost of MG decreases with the increase in storage efficiency. For example, increasing the storage efficiency from 75% to 95% would make the MG's total operation cost decrease from $141,157.1 to $132,122.2 at 100% DOD. Typically, it can be seen from the same figure that the percentage of saving increases with the increase of the efficiency of the storage system. Increasing the efficiency from 75% to 95% would increase the savings portion from 26.9% to 31.6% at 100% DOD. the voltage profile of the MG at the 14th hour gets lower because of the BESSs charging in this hour. Finally, it is clear from Figure 13d that the MG's voltage profile at the 21st hour enhanced beyond the base case because of the discharging of the BESSs. In this regard, the storage can improve the MG's voltage profile at any particular hour.    It is also clear from Figure 14 that the total operation cost of MG increases with the decrease in DOD of storage. For example, decreasing DOD from 100% to 50% would make MG's total operation cost increase from $132,122.2 to $157,170.2 at an efficiency of 95%. Typically, it can be seen from the same figure that the percentage of saving decreases with the decrease of the DOD of storage. Besides, decreasing the DOD from 100% to 50% would make the percentage of saving decline from 31.6% to 18.6% at an efficiency of 95%. We can also see from Figure 14 that the NaS battery with efficiency equals 95%, and 100% DOD had provided the best operation cost. Figure 15 shows the MG's total power losses per day with different efficiency and DOD values. It is clear from Figure 15 that the MG's total daily power losses decrease with the increase in storage efficiency. For example, increasing efficiency from 75% to 95% would make the MG's total power losses increase from 1632.8 kW to 1500.5 kW per day at 100% DOD. Typically, it can be seen from the same figure that the total power losses of the MG per day decrease with the decrease in DOD of storage. For example, decreasing DOD from 100% to 50% would make the MG's total power losses per day drop from 1500.5 kW/day to 1364.9 kW/day at an efficiency of 95%. It can be seen from the It is also clear from Figure 14 that the total operation cost of MG increases with the decrease in DOD of storage. For example, decreasing DOD from 100% to 50% would make MG's total operation cost increase from $132,122.2 to $157,170.2 at an efficiency of 95%. Typically, it can be seen from the same figure that the percentage of saving decreases with the decrease of the DOD of storage. Besides, decreasing the DOD from 100% to 50% would make the percentage of saving decline from 31.6% to 18.6% at an efficiency of 95%. We can also see from Figure 14 that the NaS battery with efficiency equals 95%, and 100% DOD had provided the best operation cost. Figure 15 shows the MG's total power losses per day with different efficiency and DOD values. It is clear from Figure 15 that the MG's total daily power losses decrease with the increase in storage efficiency. For example, increasing efficiency from 75% to 95% would make the MG's total power losses increase from 1632.8 kW to 1500.5 kW per day at 100% DOD. Typically, it can be seen from the same figure that the total power losses of the MG per day decrease with the decrease in DOD of storage. For example, decreasing DOD from 100% to 50% would make the MG's total power losses per day drop from 1500.5 kW/day to 1364.9 kW/day at an efficiency of 95%. It can be seen from the figure that the total power losses of the MG per day considerably decrease with the increase in the storage efficiency or decrease in the DOD.

Conclusions
Energy storage is the crucial enabler for reliable MGs operation. In this regard, this paper formulated a two-stage optimization framework to improve a grid-connected MG performance. The optimal allocation decisions of the BESSs using the HHO algorithm were provided to enhance the SCR of the RESs and the HC of the MG. Further, an operation strategy with the results (number, location, and capacity) of the BESSs obtained was handled as an objective function to minimize the MG's total operation cost. The contribution of this work can be outlined as follows:


This work's optimization framework is useful for decision-makers who want to address the storage economic feasibility while enhancing to-date energy performance metrics such as the SCR and the HC.  The obtained results show that the optimum number, location, and size of BESS strengthen the performance of the MG, support the SCR of the RESs, and improve the HC.  The increased SCR using storage solutions leads to an increase in the HC, especially in the presence of batteries. Thus, supporting storage solutions might be a good measure to promote HC improvement in MGs and power systems.  The total operating cost of the MG can be decreased considerably when a BESS is integrated into the MG, which can realize the better cost-effective performance of the systems and MGs with high penetration of RESs.

Conclusions
Energy storage is the crucial enabler for reliable MGs operation. In this regard, this paper formulated a two-stage optimization framework to improve a grid-connected MG performance. The optimal allocation decisions of the BESSs using the HHO algorithm were provided to enhance the SCR of the RESs and the HC of the MG. Further, an operation strategy with the results (number, location, and capacity) of the BESSs obtained was handled as an objective function to minimize the MG's total operation cost. The contribution of this work can be outlined as follows: • This work's optimization framework is useful for decision-makers who want to address the storage economic feasibility while enhancing to-date energy performance metrics such as the SCR and the HC.

•
The obtained results show that the optimum number, location, and size of BESS strengthen the performance of the MG, support the SCR of the RESs, and improve the HC.

•
The increased SCR using storage solutions leads to an increase in the HC, especially in the presence of batteries. Thus, supporting storage solutions might be a good measure to promote HC improvement in MGs and power systems.

•
The total operating cost of the MG can be decreased considerably when a BESS is integrated into the MG, which can realize the better cost-effective performance of the systems and MGs with high penetration of RESs.

•
The results show that the optimal number of BESSs should be investigated to achieve the minimum MG operating cost.

•
Transformer overloads may occur due to high load demands or low output power from RESs. Thus, the impact of energy storage on the load rate of the power transformer that links the grid and the MG was investigated, and we have found that energy storage can play a vital role in reducing the transformer overloading rate; therefore, it can be used to defer transformer size reinforcement plans.

•
The total operation cost of MG decreases with the increase in storage efficiency. The percentage of saving increases with the increase of the efficiency of the storage system. Increasing the efficiency from 75% to 95% would increase the savings portion from 26.9% to 31.6% at 100% DOD.

•
The total operation cost of MG increases with the decrease in DOD of storage. Thus, the percentage of saving decreases with the decrease of the DOD of storage.

•
The total power losses of the MG per day considerably decrease with the increase in the storage efficiency or decrease in the DOD.

•
The results obtained declare that oversized storage or using many unneeded storage units may adversely influence the MG's total power losses.
Finally, future works will address research and development activities for storage and demand management to push SCR and HC progress in MGs with high renewable penetration. Also, other optimization algorithms can be used to solve the problem presented in this work.