# A Game Theoretic Approach for Energy Sharing in the Italian Renewable Energy Communities
## 2 Proposed REC Model
### Constrains: Energy Community Energy Balance  
The amount of energy that is offered to the energy community from the members that have a surplus at time \(t\) can be evaluated as:  
\[E_{ec}^{off}(t,y)=\sum_{i}^{N}E_{i}^{surplus}(t,y) \tag{9}\]  
The amount of energy that is requested to the energy community from the members that have a deficit at time \(t\) can be evaluated as:  
\[E_{ec}^{req}(t,y)=\sum_{i}^{N}E_{i}^{deficit}(t,y) \tag{10}\]  
In general, these two values are different and it is not possible for the community to manage all the energy required and offered by the users at each time step.  
The amount of energy the community can collect and redistribute in the same hour is equal to the minimum for each instant between the energy offered to the community and the energy request to the community. We define this quantity as energy shared in real time.  
\[E_{ec}^{sharedRT}(t,y)=\min(E_{ec}^{off}(t,y),E_{ec}^{req}(t,y)) \tag{11}\]  
Energy Storage System  
In the case the community does not have an energy storage system, the energy offered to the community but not requested by other users is sold to the market.  
\[E_{ec}^{\to market}(t,y)=E_{ec}^{off}(t,y)-E_{ec}^{sharedRT}(t,y) \tag{12}\]  
The energy requested to the community but not provided from other users is bought from the market.  
\[E_{ec}^{\leftarrow market}(t,y)=E_{ec}^{req}(t,y)-E_{ec}^{sharedRT}(t,y) \tag{13}\]  
The shared energy is equal to energy shared in real time.  
\[E_{ec}^{shared}(t,y)=E_{ec}^{sharedRT}(t,y) \tag{14}\]  
In the case when a centralized energy storage system (ESS) is considered, the amount of energy managed by the community can increase because the system can store the energy instead of selling it. Other than the shared energy in real time, a more general definition of shared energy can be specified as the energy consumed by the users coming from the community generation or from the ESS. The model of the ESS is technologically neutral and, depending on the value assigned to the parameters, can represent different types of storage (e.g., electrochemical, hydroelectric, compressed air, etc.).  
The maximum capacity of the ESS is:  
\[ESS_{cap}\leq ESS_{cap}^{max} \tag{15}\]The maximum charging power for the energy storage system is:  
\[E_{ec}^{\to ESS}(t,y)\leq\frac{ESS_{cap}}{EPR}\cdot 1h \tag{16}\]  
The maximum discharging power for the energy storage system is:  
\[E_{ec}^{\gets ESS}(t,y)\leq\frac{ESS_{cap}}{EPR}\cdot 1h \tag{17}\]  
The amount of energy stored into the system is defined with the following constrains:  
\[E_{ec}^{stored}(t,y)=\begin{cases}E_{ec}^{stored}(t-1,y)+E_{ec}^{\to ESS}(t,y) \cdot\eta_{CH}-\frac{E_{ec}^{\gets ESS}(t,y)}{\eta_{DIS}}&\text{if $t>1$}\\ E_{ec}^{stored}(8760,y)+E_{ec}^{\to ESS}(8760,y)\cdot\eta_{CH}-\frac{E_{ec}^{ \to ESS}(8760,y)}{\eta_{DIS}}&\text{if $t=1$}\end{cases} \tag{18}\]  
Furthermore, the energy stored within the battery has to respect SOC limits.  
\[E_{ec}^{stored}(t,y)\leq ESS_{cap} \tag{19}\]  
\[E_{ec}^{stored}(t,y)\geq ESS_{cap}\cdot SOC_{min} \tag{20}\]  
The energy sold to the market is the energy offered to the community that is not shared in real time and not stored.  
\[E_{ec}^{\to market}(t,y)=E_{ec}^{\gets off}(t,y)-E_{ec}^{sharedRT}(t,y)-E_{ec}^{ \to ESS}(t,y) \tag{21}\]  
The energy bought from the market is the energy request to the community not provided from other users in real time nor from the storage system.  
\[E_{ec}^{\gets market}(t,y)=E_{ec}^{req}(t,y)-E_{ec}^{sharedRT}(t,y)-E_{ec}^{ \gets ESS}(t,y) \tag{22}\]  
The energy that is evaluated as shared is equal to the energy shared in real time plus the extra energy provided from the storage.  
\[E_{ec}^{shared}(t,y)=E_{ec}^{sharedRT}(t,y)+E_{ec}^{\gets ESS}(t,y) \tag{23}\]