# Optimization of PV and Battery Energy Storage Size in Grid-Connected Microgrid
## 4 Results and Discussion
(Cost can be seen on the second y-axis in Figure 6a,b. The y1-axis and y2-axis scales are different). Since loads are supplied mostly from the grid, the cost is increasing. After defined the maximum grid cost is exceeded, the total system cost increases faster due to the penalty factor, and the system can obtain supply mostly from renewable energy resources (because increasing the rate of renewable energy use decreases the system total cost). After 200 iterations, calculations were performed by the energy management algorithm. It was found that the optimum PV and BESS module counts were 47 and 28, respectively, and the total cost was USD 40.972 for case 1. Similarly, it was found that the optimum PV and BESS module counts were 24 and 28, respectively, and the total cost was USD 24.186 for case 2. To prove the results obtained from the proposed method, the total cost variation of the system according to different PV and battery sizes and penalty factor are given in Figure 7a,b, respectively. At the first point in Figure 7a, there are 45 PV modules and five battery modules. The total system cost at this first point is USD 49.993. In the first area (depicted in Figure 7a), while the number of PV modules is decreasing, the number of battery modules is increasing. It should be considered that the energy cost penalty highly affects the total system cost. The total system cost is increasing slowly until the sixth calculation point. Then, when the number of PV modules is too low, the system cost increases rapidly. At the eighth calculation point, there are five PV modules and 40 battery modules, and this is the highest cost in the figure, which is USD 127.040. At this point, there are not enough PV modules to supply the loads, and there are not enough PV modules to charge this amount of battery modules. Thus, the loads are supplied from the grid for a longer period. At this longer period, as an option, the cost can be increased excessively or the maximum limit can be set in order to prevent taking more energy from the grid. In this study, the maximum level of energy cost that can be taken from the grid has been determined. After reaching the maximum allowable grid supply limit cost, the energy management algorithm cuts off the electricity. Eventually, the total cost will be high in this situation. In the second area, while the number of PV modules has increased, the number of battery modules is low. In this case, the total cost is decreasing because there will be more PV modules to generate energy to supply the loads in the daytime. PV modules can also charge batteries when the number of PV and battery modules are closer to the optimum point. Thus, BESS can supply the loads at night when there is no PV energy. In the third area, both the number of PV and battery modules are increased. The total cost decreases, but at the 18 th point, it increases again due to the increased number of battery modules. At the fourth calculation area, both the numbers of PV and battery modules are decreased, and the total cost also starts to decrease. Finally, the number of PV and battery modules reaches the optimum point, such that the total cost is at the lowest value at the 20 th point. There are 47 PV modules and 28 battery modules. Total system cost is USD 40.972 at the 20 th point. The same study was carried out for case 2. It can be seen from Figure 7b that the cost of the system for 24 PV modules and 28 batteries is USD 24.186. This means that the loads of the MG can be fully supplied by PV and BESS in the daytime, and they can be supplied by BESS most of the night. Therefore, MG can be supplied mostly by its RES, and its dependency to the grid is low. However, the total system cost rises as the number of battery and PV modules continues to decrease because the system needs to import more energy from the grid, which increases the grid supply cost. Another reason is that as the number of both PV and battery modules continues to decrease, the longer the blackout durations occur and thus the penalty cost increases.