## 3 Modeling Approach
### Multi-Energy System  
The MESpy model, accessible at the GitHub Repository [45], builds on the existing concept developed by [PERSON] et al. [16] for purely electric micro-grids, by adding a complementary thermal energy system model comprising solar thermal energy conversion technologies (flat-plate solar thermal collectors), thermal storage (hot-water tanks) and traditional back-up systems (LPG boilers). Thermal technologies are not connected by any centralized heat distribution network, and thus direct heat consumption remains bound to the site of generation. Nevertheless, the electric and thermal systems are interconnected by means of electric resistance heating elements that are modeled inside hot-water tanks, thus allowing a \"smart\" electric recharge of the thermal storage that gives rise to a more flexible MES, as shown by the sketch in Figure 3. Such electric resistance heating elements are also interpreted as standalone components to model electric heaters in the multi-good micro-grid configuration. The main inputs and output of MESpy are summarized in Table 1. \begin{table}
\begin{tabular}{c c} \hline \hline
**Inputs** & **Outputs** \\ \hline PV panel output & Optimal system size \\ \hline Solar collector output & Net Present Cost (NPC) \\ \hline Electric load profile & Levelized Cost of Energy (LCOE) \\ \hline Thermal load profile & Electric dispatch strategy \\ \hline Economic parameters & Thermal dispatch strategy \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Main inputs and outputs of the Multi-Energy System model. Figure 3: Schematic representation of the integrated electric and thermal energy system model. The thermal energy system is not a single centralized entity but rather the aggregate of multiple user-scale individual systems, which are modeled for each user within each user class and only connected through the electricity grid, in the absence of a heat distribution network. Further details about the specific technical characteristics of the modeled technologies, and about PV panels' and solar collectors' outputs, are available in Figure 3.  
It is worth noting that, while the electric energy system consists of a single entity, the thermal energy system is composed of multiple user-scale energy systems, which reproduce topographically constrained generation and consumption for each user within each user class. In other terms, the model considers each thermal user class \(k\) (as listed above: commercial activities, domestic, public offices, and school) as a separate system consisting of the aggregate of \(N_{k}\) user-scale subsystems (where \(N_{k}\) is the number of users within the \(k\)-th class). Indeed, the thermal energy balance (Equation (3)) satisfies independently the thermal demand (in this case DHW only) for each thermal user class \(k\), and for each time step \(t\). \[ \begin{array}{ll}E_{\text{Th, class demand}}(k,t)\\ \hskip 14.226378 pt=\ E_{\text{{\it boiler}}}(k,t)+E_{\text{{\it Tank}}_{\text{{\it out}}}}(k,t)-E_{\text{{\it Curt}}}(k,t)\\ \hskip 14.226378 pt+E_{\text{{\it lost load,th}}}(k,t)\ \forall k,\forall t \end{array}  \tag{3}\]  
where \(E_{\text{{\it boiler}}}\) is the energy supplied by the LPG boilers, \(E_{\text{{\it Tank}}_{\text{{\it out}}}}\) the energy supplied by the hot water tank, \(E_{\text{{\it Curt}}}\) is the fraction of the excess energy produced by solar collectors that cannot be stored in the tank, and \(E_{\text{{\it lost load,th}}}\) is the accepted fraction of unmet thermal load--which we set at 1% for all the scenarios.