# Maximizing Efficiency in Energy Trading Operations through IoT-Integrated Digital Twins
## 3 Proposed Architecture
### ESS Power Management for Optimal Energy Trading  
Nano-grids connect with the primary utility grid through specialized converters, namely bi-directional direct current to alternating current (BD-DC-AC) converters, to maintain an equilibrium in energy distribution. In surplus energy inside a nano-grid system, the converter is designed to transition into a mode whereby excess energy is redirected and transmitted back to the primary grid. Conversely, when the energy supply in a nano-grid is insufficient, the converter draws energy from the primary grid. The definitions of the acronyms employed in the ideal energy storage system (ESS) for nano-grid residences are located in Table 2.  
\[H=\{H_{1},H_{2},H_{3},\ldots,H_{k}\} \tag{1}\]  
The symbol \(\pm 1\) represents the energy exchange through buying and selling. For instance, assigning a value of '+1' to a nano-grid indicates that the nano-grid possesses a surplus of energy that can be exchanged with other nano-grids in the peer-to-peer (P2P) network. Alternatively, when the allocated value is '\(-1\)', it signifies that the nano-grid is deficient in energy to fulfill its energy demands. Consequently, it must obtain energy from other interconnected nano-grids (with priority given to them) or the utility grid. The term \"battery\" pertains to the assemblage of energy storage technologies implemented within every nano-grid. To illustrate,  
\[battery=\{battery_{1},battery_{2},battery_{3},\ldots,battery_{k}\} \tag{2}\] \begin{table}
\begin{tabular}{c c} \hline \hline
**Term** & **Description** \\ \hline H & Participating nano-grid houses \\ \hline battery & ESS system installed in-house \\ \hline k & Index of house \\ \hline A & Self-adequate energy \\ \hline EL & Energy load \\ \hline Photovoltaic & Photovoltaic power \\ \hline remained & Remaining power \\ \hline surplus & Surplus energy owned by N \\ \hline rel & Releasing power \\ \hline saved & Energy saved in ESS \\ \hline sold & Sold energy \\ \hline distributed & Energy distributed by all nano-grids \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Description of terms. In the present scenario, the variable \(i\) represents the aggregate quantity of energy storage systems (ESSs), tantamount to the number of residences outfitted with a nano-grid. Let \(t\) represent a specific time interval, whereas \(L\) represents the load demand. Hence, the variable \(\text{EL}_{k}(t)\) denotes the load demand for the \(i\)th nano-grid at a given time \(t\). The variable photovoltaic\({}_{k}(t)\) denotes the power produced by the photovoltaic (PV) system in the \(k\)th nano-grid at a given time \(t\). This power can be utilized for either charging battery\({}_{k}\) or fulfilling the energy demand \(\text{EL}_{k}(t)\). Furthermore, any surplus energy generated by the photovoltaic (PV) system has the potential to be traded with other nano-grids experiencing a shortage. The energy produced by the photovoltaic (PV) system to meet the power requirements of its nano-grid is commonly known as self-supplied energy. This term is defined as follows:  
\[\text{extra}_{k}(t)=\min\{\text{EL}_{k}(t)\times\text{photovoltaic}_{k}(t)\} \tag{3}\]  
The energy storage system (ESS) unit consists of batteries used to store energy produced by the photovoltaic (PV) system and a bi-directional DC-DC converter. The energy in the battery at a given time interval, denoted \(\text{remained}_{k}(t)\), is commonly referred to as leftover energy. The following scenarios are considered for peer-to-peer (P2P) energy sharing/trading:  
1. In a situation when the trading function yields a positive value of \(+1\), priority will be assigned to the exporting of energy through photovoltaic\({}_{k}(t)\). This implies that any surplus energy the photovoltaic system produces at time \(t\) will be used for trading. In the event of a lack of further energy, the stored energy within a battery\((t)\) at time \(t\) is employed for trading. 2.