**2. Battery Energy Storage Systems Formulation**

ESS technology can store electrical energy in several forms. For instance, electrical energy can be stored in the mechanical form such as pumped hydro, compressed air and flywheel; in the electromagnetic form such as a supercapacitor; in the thermal form such as steam accumulator, molten salt storage, and liquid nitrogen engine; and in the electrochemical form such as flow battery, rechargeable battery, and ultra-battery. The selection of each ESS technology depends on the purpose and physical suitability. In this work, the BESS was chosen to be installed in the distribution network with RESs, and the operation of the BESS was simulated by using the Fourier series.

#### *2.1. Battery Energy Storage Systems (BESSs)*

Various types of BESSs such as lead-acid, UltraBattery, NaS, Li-ion, Ni-Cd, and vanadium redox batteries have been widely used for storing electrical energy [28–31]. Li-ion batteries are more popularly used to store electrical energy in many countries such as Germany [32]. Additionally, the price of Li-ion batteries has tended to decrease due to the development of their use in electric vehicles (EVs) [33]. The important characteristics of Li-ion batteries are their high capacity and energy per volume, fast charge and discharge, and low self-discharge rate. From the characteristics of the

Li-ion battery above-mentioned, it requires less installation space, has a rapid response to supply or store the electrical energy, and has low energy loss rate from self-discharging. Therefore, this work applied a Li-ion battery as the BESS.

Several factors affecting the lifespan of a Li-ion battery that should be considered include the temperature, number of duty cycles of the battery, and depth of discharge (DOD). Therefore, for a long life Li-ion battery, good heat dissipation is required where the optimum temperature for the Li-ion battery is around 15–35 ◦C. Frequent charging and discharging should be avoided, and the a suitable value of DOD is 80% of the total capacity of the battery. Charging or discharging rates should not be too high because the higher charging or discharging rates cause a higher battery temperature, which results in the short lifespan of the battery [34]. In addition, the imbalance charging of each battery cell of the BESS due to the initial unequal state of charge (SOC), which is defined by the battery's present amount of charge divided by its rated charge capacity, may cause some damage to the BESS, a capacity reduction of the BESS, and the deterioration of the BESS. However, this can be avoided by using battery charge equalization systems (BCEs) [35].

## *2.2. Battery Energy Storage System Simulation*

The BESS simulation presented in this work considered the rates of charge or discharge of the BESS at equal intervals within the considered period of 24 h. These 24 h can be equally divided such as 1 h, 30 min, or 15 min, which can obtain the rate of charge or discharge of BESS at *m* values including 24, 48, and 96, respectively. Therefore, the rates of charge and discharge in the considered period (*CiT*) can be formulated as the following equation.

$$\mathbf{C}\_{IT} = \begin{bmatrix} E\_B(1) \\ \vdots \\ E\_B(m) \end{bmatrix} \tag{1}$$

where *EB*(*t*) is the electrical energy in BESS (MWh) at time *t* = 1, 2, 3, ... , *m*.

To find the values of *EB*(*t*) at each time *t*, the Fourier series is applied to express the state of energy (SOE) in the total considered intervals. The state of energy of the BESS can be obtained by substituting the Fourier coefficient (*CiF*) from Equation (2) into Equation (3) to find the values of *EB*(*t*).

$$\mathbf{C}\_{\rm IF} = \begin{vmatrix} a\_{1\prime}b\_1 \\ \vdots \\ a\_{n\prime}b\_n \end{vmatrix} \tag{2}$$

$$E\_B(t) = a\_0 + a\_1 \cos\left(\frac{2\pi t}{T}\right) + b\_1 \sin\left(\frac{2\pi t}{T}\right) + \dots + a\_{\text{fl}} \cos\left(\frac{2\pi nt}{T}\right) + b\_{\text{fl}} \sin\left(\frac{2\pi nt}{T}\right) \tag{3}$$

where *a*0, *an*, *bn*, *n*, and *T* are the constant Fourier coefficient, Fourier cosine coefficients, Fourier sine coefficients, the number of Fourier coefficients (set to 8 [14]), and total period, respectively.

The constant Fourier coefficient (*a*0) does not affect the charge or discharge power of BESS due to its constant value. It can be added after calculating the Fourier coefficients (*CiF*) to ensure that the SOE of BESS is not negative or lower than the minimum depth of discharge (*DODmin*).

To compute the rate of charge and discharge from the SOE of BESS (*EB*(*t*)) at each time *t*, Equations (4)–(6) are calculated. Suppose *PB*(*t*) is the charge rate or discharge rate at time *t*. The positive value of *PB*(*t*) means the BESS is charging while a negative value means the BESS is discharging.

$$
\Delta E\_B = E\_B(t) - E\_B(t-1) \tag{4}
$$

$$P\_B(t) = \Delta E\_B / (\Delta t \times \eta\_c), \quad P\_B(t) > 0 \tag{5}$$

$$P\_B(t) = \left(\Delta E\_B \times \eta\_d\right) / \Delta t, \quad P\_B(t) < 0 \tag{6}$$

where <sup>η</sup>*<sup>c</sup>* <sup>=</sup> <sup>η</sup>*<sup>d</sup>* <sup>=</sup> <sup>√</sup>η*bat*, <sup>η</sup>*bat* <sup>=</sup> 0.9 (the total efficiency of the BESS), *PB*, <sup>Δ</sup>*<sup>t</sup>* are battery charging efficiency, battery discharging efficiency, battery round trip cycling efficiency, battery power (MW), and sampling time interval, respectively.

The optimal size of the BESS can be found by Equation (7).

$$BatterySize\,\left(\text{unit.h}\right) = \frac{\left|E\_B^{\text{max}} - E\_B^{\text{min}}\right|}{DOD\_{\text{max}}}\tag{7}$$

where *DODmax* = 0.8 is the maximum depth of discharge value; and *Emax <sup>B</sup>* and *Emin <sup>B</sup>* are the maximum and minimum battery energy values, respectively. The unit of the energy capacity of the BESS depends on the unit of *Emax <sup>B</sup>* and *<sup>E</sup>min <sup>B</sup>* .

Generally, each round of battery discharge where the energy discharging is equal to the battery capacity is called one operation cycle of a battery. However, to simply calculate the battery cycle, the summation of both charging and discharging energies for all considered time intervals are included, and its average value is instead computed by dividing by 2 (charging and discharging) as in Equation (8) [14]. The lifespan of the BESS can then be evaluated from Equation (9) [14].

$$\text{Cycles} = \frac{1}{2} \times \left( \frac{\sum\_{t=1}^{T} \left| E\_B(t) - E\_B(t-1) \right|}{DOD\_{\text{max}} \times BatterySize} \right) \tag{8}$$

$$\text{Lifespan (years)} = \text{Cycle} \text{Life} \newline \text{(Cycles} \times D) \tag{9}$$

where *Cycles* is the daily cycles of BESS; *CycleLife* = 3221 is the nominal cycles life of the Li-ion battery [34]; *D* = 365 is the number of operating days of BESS; and *Lifespan* is the lifespan of the BESS (years).
