## 3 Modeling Approach
### Multi-Energy System
#### 3.2.2 Thermal Components  
The total thermal energy provided by the solar collectors (\(E_{SC_{tot}}\)) for each class \(k\) is computed as the energy generated by a single collector (\(E_{SC}\))--which is given as an input to the model--multiplied by the number of solar collectors in the class, \(N_{SC}\). \[E_{SC_{tot}}(k,t)=E_{SC}(k,t)\cdot N_{SC}(k)\quad\forall k,\forall t \tag{6}\]  
Further details about the specific flat-plate collector model used as a reference, and about how the collector output is obtained, are provided in Supplementary Information. It is worth noting that \(N_{SC}(k)\) is an optimization variable for each class and is not given as an input. Indeed, it is indirectly taken into account in Equation (3), due to its contribution to the definition of \(E_{Tank_{out}}(k,t)\) (Equation (7)). Hot-water tanks provide an option for thermal energy storage within the model, and can be fed by both solar collectors and electric resistance heating elements. The tanks are represented adopting a fully-mixed (or thermal capacity) model [46]: for each time-step \(t\) and for each class \(k\), the thermal energy stored in the tank (\(E_{SOC_{Tank}}(k,t)\)) is computed based on the balance reported in Equation (7). The latter considers the energy stored in the preceding step (\(E_{SOC_{Tank}}(k,t-1)\)), the energy supplied by solar collectors (\(E_{SC_{Tank}}\)) and by the electrical resistance (\(E_{Res,class}\cdot\eta_{Res}\), with \(\eta_{Res}=1\)), and the energy flow outside the tank (\(E_{Tank_{out}}\)). Energy losses due to the heat transfer between thermal storage and environment are taken into account by means of an efficiency parameter (\(\eta_{tank}=0.999\)), following the approach proposed by [PERSON] and [PERSON] [47]. \[ \begin{array}{l}E_{SOC_{Tank}}(k,t)=\\ E_{SOC_{Tank}}(k,t-1)\cdot\eta_{tank}+E_{SC_{tot}}(k,t)+E_{Res,class}(k,t)\cdot \eta_{Res}-E_{Tank_{out}}(k,t)\quad\forall k,\forall t\end{array}  \tag{7}\]  
A set of constraints is also defined, as shown in Equations (8)-(10). In particular:  
* The energy stored in the tank is constrained not to exceed the maximum capacity \(C_{SOC_{tank}}\) of the tank, for each class \(k\). \[E_{SOC_{Tank}}(k,t)\leq C_{SOC_{tank}}(k)\ \forall k,\forall t\] (8)
* The energy stored in the tank is constrained to be kept above a minimum value (defined as depth of discharge, \(D_{SOC}\)), defined as a percentage of the nominal tank capacity. \[E_{SOC_{Tank}}(k,t)\geq C_{SOC_{tank}}(k)\cdot D_{SOC}\quad\forall k,\forall t\] (9)
* The thermal energy flow out of the tank (\(E_{Tank_{out}}\)) is constrained to be lower than the tank maximum power of discharge (\(P_{out,max}\)) multiplied by a delta time (\(\Delta t\)) calibrated on the time-step. \[E_{Tank_{out}}(k,t)\leq P_{out,max}(k)\cdot\Delta t\quad\forall k,\forall t\] (10)  
It is worth noting that, in opposition to Battery Energy Storage System (BESS), where the depth of discharge is due to the fact that batteries have a minimum level of charge at which they can discharge during the functioning cycle as constrained by electrochemical limitations, in the case of thermal storage the depth of discharge is due to a different phenomenon. The energy contained in the water tank is defined by an energy balance to the mass of water \(E_{tank}=m_{water}\cdot\Delta T\). Following this equation, the level of zero energy corresponds to the tank containing water at ground temperature T\({}_{\rm gw}\). Since the user does not desire to use water at ground temperature, but at a minimum temperature T\({}_{\rm task}\), as defined inSection 3.1.2, the minimum level at which the tank can operate is defined by this desired temperature, resulting in the tank depth of discharge. Electric resistance heating elements are modeled inside hot-water tanks to maintain a minimum level of stored thermal energy (i.e., a minimum water temperature) as well as to serve as an additional backup system to satisfy the thermal demand when needed.