## 2 Problem Formulation
### Modeling and Sizing of PV and BES
#### 2.3.4 Sizing BES and PV  
BESS is installed at the same location of PV in RDS. Therefore, the optimal sizing of BESS with PV are presented in [42]. Therefore, the charging and discharging energies of batteries at time (t) are calculated by Equations (28) and (29).  
\[E_{\mathbf{BES}\mathbf{s}\mathbf{j}}^{\mathbf{D}\mathbf{C}\mathbf{S}\mathbf{j}}=\int_{0}^{t}\mathbf{P}_{\mathbf{BES} \mathbf{s}\mathbf{j}}^{\mathbf{D}\mathbf{C}\mathbf{S}\mathbf{j}}(\mathbf{t})dt=\sum_{T=1}^{24}\mathbf{P}_{\mathbf{ BES}\mathbf{s}\mathbf{j}}^{\mathbf{D}\mathbf{C}\mathbf{S}\mathbf{j}}(\mathbf{t})\Delta t \tag{28}\]  
\[E_{\mathbf{BES}\mathbf{s}\mathbf{j}}^{\mathbf{C}\mathbf{S}\mathbf{j}}=\int_{0}^{t}\mathbf{P}_{\mathbf{BES}\mathbf{ s}\mathbf{j}}^{\mathbf{C}\mathbf{j}}(\mathbf{t})dt=\sum_{t=1}^{24}\mathbf{P}_{\mathbf{BES}\mathbf{s}\mathbf{j}}^{ \mathbf{C}\mathbf{S}\mathbf{j}}(\mathbf{t})\Delta t \tag{29}\]  
\((\mathbf{E}_{\mathbf{PV}+\mathbf{BES}\mathbf{j}\mathbf{j}})\) is a combination energy of BESS and PV at bus (\(\mathbf{j}\)) which is determined by Equation (30). PV energy is determined by Equation (31).  
\[E_{\mathbf{(PV+BES)}\mathbf{j}}=E_{\mathbf{PV}\mathbf{j}}^{\mathbf{D}\mathbf{S}}+E_{\mathbf{BES}\mathbf{j}}^{ \mathbf{D}\mathbf{C}\mathbf{S}\mathbf{j}} \tag{30}\]  
\[E_{\mathbf{(PV)}\mathbf{j}}=E_{\mathbf{PV}\mathbf{j}}^{\mathbf{D}\mathbf{S}}+E_{\mathbf{BES}\mathbf{j}}^{\mathbf{ C}\mathbf{S}\mathbf{j}} \tag{31}\]  
where \(E_{\mathbf{BES}\mathbf{s}\mathbf{j}}^{\mathbf{D}\mathbf{C}\mathbf{S}\mathbf{j}}\) is the discharging energy of BESS to the distribution system (DS). \(E_{\mathbf{PV}\mathbf{j}}^{\mathbf{D}\mathbf{S}}\) is the injection power energy from PV to DS and \(E_{\mathbf{BES}\mathbf{s}\mathbf{j}}^{\mathbf{C}\mathbf{S}\mathbf{j}}\) the charging energy which is drawing from PV to BESS.  
Round-trip efficiency can be determined by the ratio of discharging energy to the charging energy as shown below:  
\[\eta_{\mathbf{BES}}=\frac{E_{\mathbf{BES}\mathbf{j}}^{\mathbf{D}\mathbf{C}\mathbf{S}\mathbf{j}}}{E_{\mathbf{ BES}\mathbf{j}}^{\mathbf{C}\mathbf{S}\mathbf{j}}} \tag{32}\]  
Consequently, PV energy is updated to Equation (33) as follows:  
\[E_{PV\mathbf{j}}=\frac{E_{\mathbf{(PV+BESS)}\mathbf{j}}-\left(1-\eta_{\mathbf{BESS}}\right)E _{\mathbf{PV}\mathbf{j}}^{\mathbf{G}\mathbf{G}\mathbf{S}\mathbf{j}}}{\eta_{\mathbf{BESS}}} \tag{33}\]  
\[P_{PV\mathbf{j}}=E_{PV}^{\mathbf{o}}E_{PV\mathbf{j}} \tag{34}\]  
\[K_{PV}^{\mathbf{o}}=\frac{P_{PV}^{\mathbf{o}}}{E_{PV}^{\mathbf{o}}} \tag{35}\]  
The high value of PV output during the day is evaluated by Equation (36).  
\[P_{PV\mathbf{j}}=K_{PV}^{\mathbf{o}}(\frac{E_{\mathbf{(PV+BESS)}\mathbf{j}}-\left(1-\eta_\mathbf{{BESS}}\right)E_{PV\mathbf{j}}^{\mathbf{G}\mathbf{G}\mathbf{S}\mathbf{j}}}{\eta_{\mathbf{BESS}}}) \tag{36}\]  
where, \(E_{PV}^{\mathbf{o}}\) and \(P_{PV}^{\mathbf{o}}\) are the energy and maximum output of PV during the day, respectively.  
BESS sizing is determined by Equation (37).  
\[E_{\mathbf{BES}\mathbf{j}}^{\mathbf{C}\mathbf{t}}=\frac{E_{\mathbf{(PV+BES)}\mathbf{j}}-E_{PV\mathbf{j}}^{ \mathbf{G}\mathbf{t}}}{\eta_{\mathbf{BESS}}} \tag{37}\]