## 2 Hybrid Energy System Model
### BESS and Power Converter Models  
BESS is a crucial device for the appropriate operation of HES because it provides operational flexibility to the whole system. The technology chosen in this work is the vanadium redox flow battery (VRFB) due to its easy scalability, which makes it appropriate for large-scale integration. The mathematical model adopted is shown in Equations (5)-(15), and it has been experimentally tested and validated in [35; 36; 37]. Battery voltage (\(U_{B(t)}\)) and efficiency (\(\eta_{B(t)}\)) are defined according to charging and discharging processes using Equations (5) and (6), respectively. \[U_{B(t)}=\left\{ \begin{array}{ll}U_{B(t)}^{ch};\ P_{B(t)}>0\\ U_{B(t)}^{dis};\ P_{B(t)}\leq 0\end{array} \right.\forall\ t=1,\ldots,T; \tag{5}\]  
\[\eta_{B(t)}=\left\{ \begin{array}{ll}\eta_{B(t)}^{ch};\ P_{B(t)}>0\\ \eta_{B(t)}^{dis};\ P_{B(t)}<0\end{array} \right.\forall\ t=1,\ldots,T. \tag{6}\]  
During charging process, when battery power (\(P_{B(t)}\)) is positive, battery voltage (\(U_{B(t)}^{ch}\)) is related to the state of charge (SOC) (\(SOC_{B(t)}\)) according to (7), while charging efficiency for voltage (\(\eta_{V(t)}^{ch}\)) and energy (\(\eta_{E(t)}^{ch}\)) are related to SOC and battery power as shown in (8) and (9), respectively. Then, global efficiency of charging phenomena (\(\eta_{B(t)}^{ch}\)) can be estimated using (10). \[U_{B(t)}^{ch}=\big{(}U_{ch}^{a}SOC_{B(t)}+U_{ch}^{b}\big{)}P_{B(t)}+U_{ch}^{c} SOC_{B(t)}+U_{ch}^{d}\ \forall\ t=1,\ldots,T; \tag{7}\]  
\[\eta_{V(t)}^{ch}=\frac{U_{ch}^{e}T_{E}\big{(}SOC_{B(t)}-U_{ch}^{f}\big{)}+U_{ ch}^{g}}{\big{(}U_{ch}^{h}SOC_{B(t)}+U_{ch}^{j}\big{)}P_{B(t)}+U_{ch}^{k}SOC_{B(t)}+U_{ ch}^{l}}\ \forall\ t=1,\ldots,T; \tag{8}\]  
\[\eta_{E(t)}^{ch}=\frac{\big{(}U_{ch}^{m}SOC_{B(t)}+U_{ch}^{m}\big{)}P_{B(t)}+U _{ch}^{p}SOC_{B(t)}-U_{ch}^{d}}{P_{B(t)}}\ \forall\ t=1,\ldots,T; \tag{9}\]  
\[\eta_{B(t)}^{ch}=\eta_{V(t)}^{ch}\eta_{E(t)}^{ch}\ \forall\ t=1,\ldots,T. \tag{10}\]  
During discharging process (\(P_{B(t)}<0\)), battery voltage (\(U_{B(t)}^{dis}\)) and SOC are related according to the linear expression shown in (11). Voltage and energy efficiencies (\(\eta_{V(t)}^{dis}\) and \(\eta_{E(t)}^{dis}\)) depend on battery power and SOC following (12) and (13), respectively. Thus, discharging efficiency (\(\eta_{B(t)}^{dis}\)) is estimated through the product of these variables (\(\eta_{V(t)}^{dis}\) and \(\eta_{E(t)}^{dis}\)), as suggested in (14). \[U_{B(t)}^{dis}=U_{dis}^{a}\big{|}P_{B(t)}\big{|}+U_{dis}^{b}SOC_{B(t)}+U_{dis }^{c}\ \forall\ t=1,\ldots,T; \tag{11}\]  
\[\eta_{V(t)}^{dis}=\frac{U_{dis}^{d}\big{|}P_{B(t)}\big{|}+U_{dis}^{e}SOC_{B( t)}+U_{dis}^{f}}{U_{dis}^{g}T_{E}\big{(}SOC_{B(t)}-U_{dis}^{h}\big{)}+U_{dis }^{l}}\ \forall\ t=1,\ldots,T; \tag{12}\]  
\[\eta_{E(t)}^{dis}=\frac{\big{|}P_{B(t)}\big{|}}{U_{dis}^{k}\big{|}P_{B(t)} \big{|}+U_{dis}^{l}SOC_{B(t)}\big{(}SOC_{B(t)}-1\big{)}+U_{dis}^{m}}\ \forall\ t=1,\ldots,T; \tag{13}\]  
\[\eta_{B(t)}^{dis}=\eta_{V(t)}^{dis}\eta_{E(t)}^{dis}\ \forall\ t=1,\ldots,T. \tag{14}\]SOC at a determined time interval (\(t\)) is defined using (15), which depends on the battery power and efficiency, calculated by following the equations previously described. \[SOC_{B(t)}=SOC_{B(t-1)}+\int\limits_{t-1}^{t}\!\!\left(\frac{P_{B(t)}\eta_{B(t)} }{E_{B}^{max}}\right)\!\!d\tau\ \forall\ t=1,\ldots,T. \tag{15}\]  
Additionally, some operational constrains of VRFB have to be fulfilled.