# Maximizing Efficiency in Energy Trading Operations through IoT-Integrated Digital Twins
## 3 Proposed Architecture
### ESS Power Management for Optimal Energy Trading
In instances when the trade function is assigned a value of \(-1\), it is important to note that the acquired energy is exclusively applicable for immediate power supply purposes and cannot be kept within the battery\({}_{k}\) system. The energy that is left over following energy trading over the specified period \(t\) is commonly known as:  
\[\text{remained}=\{\text{remained}_{1},\text{remained}_{2},\text{remained}_{3 },\ldots,\text{remained}_{k}\} \tag{4}\]  
The term'remained' denotes the amount of energy still present in the battery of the \(k\) nano-grid at a given time, denoted as \(t\). The term'remained' is subject to a constraint that is determined by the effective system size (ESS) capability. The equation presented below represents the constraint:  
\[\text{remained}_{\text{min},k}\leq r_{k}\leq\text{remained}_{\text{max},k} \tag{5}\]  
The variable \(\text{remained}_{\text{max},k}\) denotes the maximum energy storage system (ESS) capacity in kilowatt-hour (kWh) for the \(i\) nano-grid. On the other hand, \(r_{\text{max},k}\) indicates the minimum ESS energy determined by the depth of discharge (DoD) to avoid excessive discharge. The energy transfer occurring among households (i.e., nano-grid) is denoted as \(\text{extra}_{k}(t)\), representing the amount of energy exchanged by the \(k\)th nano-grid at a specific time \(t\). The quantity of \(\text{extra}_{k}(t)\) will function as a conclusive determinant, simultaneously reflecting the magnitude of surplus energy within the nano-grid. If the total energy shared surpasses zero, the trade function will receive a numerical value of \(+1\). Moreover, the additional \(\text{extra}_{k}(t)\) value is also beneficial in assessing the quantity of extra energy accessible within the nano-grid. If the total energy surpasses zero, the trade function will become \(+1\); otherwise, it will be assigned a value of \(-1\). The subsequent limitations are imposed on the practice of energy sharing. The symbol \(\sum_{k}\text{extra}_{k}(t)\) represents the residual energy in \(N\). The energy exchanged within the nano-grid at a given time \(t\), denoted as \(\sum_{k}\text{extra}_{k}(t)\), must fall within the interval of 0, and the maximum allowable energy that can be shared during that specific time. The surplus energy solar power generates is commonly denoted as \(\sum_{k}\text{ photovoltaic}_{k}(t)\). The subsequent function defines the value of energy sharing. \[\text{extra}_{k}(t)= \begin{cases}\min(\text{photovoltaic}_{k}(t)-\text{EL}_{k}(t),A_{\text{max},i})&\text{if }H_{i}\in+1\\ 0&\text{if }H_{i}\in-1\end{cases}  \tag{6}\]  
The determination of the value of \(\text{extra}_{k}(t)\) is contingent upon two factors: (1) the maximum energy capacity of battery\({}_{i}\) at time \(t\), as indicated by the rated power of the DC-DC converter, and (2) the maximum remaining capacity of remained\({}_{\text{max},k}\). The phrase \(\text{extra}_{k}(t)\) refers to the released or discharged energy. The battery, denoted as battery\({}_{k}\), serves as the energy source for the \(k\)th nano-grid, as represented by the given expression. \[\text{dis}_{k}(t)= \begin{cases}0&\text{if }H_{i}\in+1\\ \min(\text{EL}_{k}(t)-\text{photovoltaic}_{k}(t),\text{EL}_{\text{max},k})&\text{if }H_{i}\in-1\end{cases}  \tag{7}\]  
The greatest amount of energy that can be released from \(e_{i}\) during a given period, written as \(\text{dis}_{\text{max},i}\), is determined based on the remaining energy in the energy storage system (ESS) and the power capacity of the bidirectional DC-DC converter. The determination of energy flow is made based on the utilization of the numerical values of +1 and \(-1\), which are outlined as follows:  
\[\text{remained}(t+1)= \begin{cases}\text{remained}(t)+\text{extra}_{k}(t)- \text{saved}_{k}(t)&\text{if }H_{k}\in+1\\ \text{remained}(t)-\text{rel}_{k}(t)&\text{if }H_{k}\in-1\end{cases}  \tag{8}\]  
To obtain energy (+1), the variable \(e_{i}(t)\) must adhere to two requirements.