**1. Introduction**

Today, fossil fuels such as coal, oil and natural gas are the main sources of electrical energy generation. However, these fuels cause greenhouse gas emissions and environmental pollution. In addition, while the world energy demand is increasing year by year, fossil fuels' reserves are limited and are about to deplete. Nevertheless, new restrictions are performed by environmental policies to reduce greenhouse gases emissions [1]. The Paris agreement, which was signed by 192 countries plus the European Union, is a promising example to deal with climate change. Countries that signed the agreement are planning to reduce their greenhouse gases emissions [2]. Renewable energy resources (RESs) such as photovoltaic and wind energy systems are environmentally friendly and good alternatives to fossil fuel since they do not cause any harmful gas emissions.

The number of grid-connected RES installations has been increasing year by year. Along with many advantages, these systems have some disadvantages such as intermittency that can cause scheduling, frequency, and voltage regulation problems on the grid [3,4]. Conventional generation systems with fossil fuels have slower responses to regulate frequency deviation in the short term [5]. With the increase in the number and total capacity of the RES installation, these problems and risk on power system stability have become more severe. Installing larger RES systems may overcome this problem [4]. However, it results in high investment cost. Battery energy storage systems (BESS) show up as an effective solution for this problem [3]. A BESS can be advantageous to maintain the

**Citation:** Garip, S.; Ozdemir, S. Optimization of PV and Battery Energy Storage Size in Grid-Connected Microgrid. *Appl. Sci.* **2022**, *12*, 8247. https://doi.org/ 10.3390/app12168247

Academic Editors: Luis Hernández-Callejo, Jesús Armando Aguilar Jiménez and Carlos Meza Benavides

Received: 28 June 2022 Accepted: 16 August 2022 Published: 18 August 2022

**Publisher's Note:** MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

**Copyright:** © 2022 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https:// creativecommons.org/licenses/by/ 4.0/).

balance between supply and demand with its fast dynamic response characteristics compared to conventional generators or other types of energy storage systems [6]. Particularly modern distribution networks are attracting attention for the solution of nanogrid (NG) and microgrid (MG) challenges. Hereby, BESSs are considered as a significant element of modern MGs and smart grids [7].

The MG is a concept that enables effective integration of distributed generation (DG) resources [8]. It is a controllable small network that combines RESs, conventional sources and loads in both grid-connected (on-grid) and island mode (off-grid) [9]. Figure 1 demonstrates a typical MG with these two operation modes [10]. Since DGs' power output characteristics are different from conventional generation systems, the MG should handle power quality problems by itself such as unpredicted fluctuation, robustness of reactive power support, resilience and a reliable system. The BESS is a good choice for maintaining resiliency and reliability with fast and adaptable characteristics. BESS can store the remaining power for later use, thus compensating for unexpected power outages and fluctuations in the RES. Although BESSs and PVs have great advantages in the MG system, they also have some disadvantages. Size and cost are gaining importance as high capacity causes increases in cost and size, while low capacity may not be enough to prevent unexpected power problems and may not meet load demand. Consequently, BESS size must be carefully calculated to determine the optimum size for a given system [8]. Moreover, research has shown that BESSs that are optimally sized for the current loads provide the best performance [11]. Thus, system designers need to find the optimal BESS size according to the specific system to obtain an efficient, reliable, and economical MG system [9].

**Figure 1.** The structure of an AC microgrid.

In the literature, generally one parameter is kept constant and the other parameter is optimized in PV and BESS optimization studies. In most PV and BESS systems, the PV size is kept constant and the BESS size is optimized. A similar approach is used for structures with an energy management system (EMS), and most of them are proposed for island mode operation. BESS sizing is performed according to the system parameters with various methods. Some of the methods can be performed identically to any sized system [10]. Mathematical-based optimization methods are also used for sizing problems. Dynamic programming (DP) and linear programming (LP) are examples of mathematical methods [10]. DP is used in [12], but it is difficult to apply to large-scale systems [13]. LP optimization is chosen as a simpler method in [13], and it is implemented for a small energy storage system (ESS) in [14]. However, it has some problems when it is applied to large scale systems. As a result, LP and DP are not good tools for complex systems [10]. As a remedy, different optimization techniques that are named as probabilistic methods (PMs) have been developed. The Markov chain decision method (MCDM) is one of them and is used for battery sizing optimization due to its simple structure. Energy storage devices are scheduled optimally with an MCDM in [15]. However, probabilistic methods are effective when the number of optimized criteria is less (generally one) [10]. These methods are not suitable for optimizing the two parameters together in interaction with the energy management system in the structure that is the subject of this study.

Since RES output is uncertain, metaheuristic approaches are suggested in many applications. Metaheuristic methods give more accurate results on large and nonlinear optimization problems [16,17]. The Genetic Algorithm (GA) is used for cost reduction and optimization of the energy storage system in a hybrid energy system in [18]. The bottleneck of GA is that its results are not conclusive [13]. The Bat Algorithm (BA) is used to find optimum BESS size for a grid-connected low-voltage MG in [19]. The Grey Wolf Optimization (GWO) algorithm is chosen for optimum BESS sizing and decreasing fuel usage, and GWO performance is compared with BA and PSO in [20]. The Artificial Bee Colony algorithm (ABC) is used to calculation of optimal battery size and operation for revenue increasing in a hybrid power system [21]. The Grasshopper Optimization Algorithm (GOA) is another method used for optimal battery, PV, wind, and diesel sizing in a microgrid [22]. Particle Swarm Optimization (PSO) has simplicity and ease of use among other metaheuristic optimization algorithms, yet it can present a high convergence rate [8]. Its robustness of convergence comes from being less dependent on setting initial points among other methods. The PSO algorithm also needs less parameters than other metaheuristic algorithms. In addition to these, it needs lower data storage [8]. The PSO-based frequency control method for an off-grid microgrid is implemented to evaluate optimum BESS size and reduction in cost [23]. The PSO algorithm is used to find optimum battery size and minimum cost for a grid-connected residential system that currently has an available PV system [24]. Similarly, PSO is selected for battery capacity optimization and effective battery installation for an island mode microgrid in [25]. PSO is used for optimal sizing of wind, PV and tidal as a primary and battery as an auxiliary source considering the reliability index [25]. PSO is also proposed to determine optimal BESS with load shedding [5]. The objective of this paper is to enhance frequency control by load shedding, and thus, operation cost reduces. The cost optimization of a PV and BESS system in the grid-connected MG using PSO is proposed in [26]. However, this study does not use an energy management system.

In this paper, optimum energy storage and PV size considering cost minimization is determined based on the novel energy management method, and the PSO algorithm is proposed for a grid-connected microgrid. In past studies, various algorithms were used for different systems for optimization. According to the literature study, although the PSO algorithm is a common and well-known algorithm, it has not been used as an optimization algorithm for both PV and BESS sizing. In the majority of studies, one of the parameters is kept constant (mostly PV size), and the remaining parameters (mostly battery size) are optimized. In a limited number of studies, the PSO algorithm is used to determine optimal size of the PV system and BESS but only for island mode systems. Most of the remaining studies have not used cost minimization as an objective function or energy management system. A limited number of studies used cost minimization as an objective function or energy management system but with different optimization algorithms [1,8,9,11–13,15,16,18–27]. This paper presents cost minimization as an objective function by finding both optimum PV and BESS sizes and proposes a new optimal energy

management method for a grid-connected MG. It is applied to a grid-connected microgrid that consists of a PV system with battery storage. MG is allowed to import energy from the grid with penalty. Thus, by allowing a limited amount of energy to be taken from the grid, it provides a more optimum structure by minimizing the effects of possible instantaneous high power demands. This paper focuses on determining the optimum PV and BESS sizes when the MG supplies energy as much as possible to its loads. The purpose is to create self-sufficient MG with limited grid support by considering cost minimization and defining optimum BESS and PV sizes. Studies are carried out for two different scenarios. In addition, the proposed energy management system with a PSO-based method is compared with GA, which is a well-known optimization algorithms. The results show that the proposed algorithm can achieve optimum PV and BESS size with minimum cost by using the new energy management method with a PSO algorithm. The proposed energy management method provides more flexibility to system designers for various system constraints. This can be accomplished by its configurable parameters. Thus, the new energy management method with PSO can be applied for various systems.
