4.5.2. Power losses

Power losses including real, reactive, and apparent power losses of the distribution network were compared in the cases with BESS and without BESS. The following equations are computed.

$$P\_{\mathcal{L}} = \sum\_{i=1}^{T} \sum\_{l=1}^{M} P\_{\mathcal{L}}^{l} \tag{24}$$

$$Q\_{\rm L} = \sum\_{i=1}^{T} \sum\_{l=1}^{M} Q\_{\rm L}^{l} \tag{25}$$

$$S\_{\mathcal{L}} = \sum\_{i=1}^{T} \sum\_{l=1}^{M} S\_{L}^{l} \tag{26}$$

where *P*L, *Q*L, and *S*<sup>L</sup> are the active power loss, reactive power loss, and apparent power loss, respectively. *l* is the number of branches. *T* is the total period. *M* is the total number of branches.

#### 4.5.3. Peak Demand Comparison

In this research, the direction of the active power flow at the slack bus of the distribution network was investigated. If the active power flow is positive, the power flows into the distribution network while the negative active power flow represents the power flow flowing out from the distribution network.

#### **5. Simulation Results**

This work aimed to find the optimal siting and sizing of the BESS for a distribution network by minimizing the costs incurred in the distribution network, consisting of voltage regulation costs, costs due to power losses, and peak demand costs within 24 h. The simulation was operated in MATLAB interfaced with MATPOWER 7.0, and the computer specification was an Intel® Core™ i3-6100U 2.30 GHz, RAM 8 GB, Windows 10 Pro 64-bit Operating System. GA and PSO were applied to solve the optimization problems, and their performance was compared. The parameters of the algorithms were as follows: population = 60, maximum iterations = 1000, crossover percentage = 50%, and mutation rate = 0.02. The simulation results are provided in the following subsections.

## *5.1. Comparison of the Optimal Siting and Sizing of the BESS Installation*

The BESS was chosen to be installed at one bus from the 2nd to 33rd bus to find the best location of the BESS installation providing the minimum objective function value. After the BESS installation simulation, three locations providing the minimum objective function values of the GA and PSO are shown in Table 1. It can be seen that the best location of the BESS installation of both GA and PSO was the 6th bus. The power of the BESS of GA was more than that of PSO of about 0.01 MW while the energy capacity of GA was less than that of PSO at around 0.75 MWh. The lifetime of the BESS of each algorithm was equal to 8.8 years.



In addition to obtaining the optimal siting and sizing of the BESS, the appropriate operation of the BESS is also important to consider. From Figure 3a, the state of energy (SOE) of the BESS indicating the stored energy in the BESS for 24 h is illustrated. The power of the BESS is shown in Figure 3b, presenting the charging rate or discharging rate of the BESS at each hour. It was noticeable that from 1 a.m. to 8 a.m., the energy of thee BESS gradually decreased because the BESS was in a discharging state at a low rate, and energy was at the minimum capacity from 8 a.m. to 9 a.m. From 9 a.m. to 6 p.m., the BESS changed status from discharging state to charging state, and during this time, the BESS had a maximum charging rate that was equal to 1.99 MW at 2 p.m. for GA and 1.98 MW at 1 p.m. for PSO. The BESS changed status again from 6 p.m. to 12 p.m. where a maximum discharging rate occurred at 10 p.m. for both GA and PSO that was equal to 1.67 MW for GA and 1.73 MW for PSO.

**Figure 3.** *Cont.*

**Figure 3.** Battery energy storage system (BESS) operation. (**a**) State of energy (SOE) of BESS; (**b**) Power of BESS.
