## Appendix A Mathematical equations of the component models are given in this appendix.
### Storage Tank  
The model for the storage tank is shown in Figure 15. Mass and energy balance relationships for control volumes, heat transfer by water flow, and outlet water temperatures are expressed as follows. As an example, the mass balance relationship and heat transfer by water flow are shown in case that hot water is returned to the \(k\)th control volume (\(k=2,3,\ldots,J-1\)) after heat exchange for bath heating.  
Mass balance \[\dot{m}_{\text{STi}}^{\text{t}}=\dot{m}_{\text{STi1}}+\dot{m}_{\text{STo}}^{ \text{t}}\] (15) \[\dot{m}_{\text{STj-1}}=\dot{m}_{\text{STj}}(j=2,3,\ldots,k-1;k+1,k+ 2,\ldots,J-1)\] \[\dot{m}_{\text{STi-1}}+\dot{m}_{\text{STi}}^{\text{r}}=\dot{m}_{ \text{STk}}\] \[\dot{m}_{\text{STi}}^{\text{b}}+\dot{m}_{\text{STj-1}}=\dot{m}_{ \text{STo}}^{\text{b}}\]Energy balance  
\[\left.\begin{array}{l}\rho c\frac{V_{\text{ST}}}{J}\frac{\text{dT}_{\text{STI}}} {\text{dT}}=\dot{m}_{\text{STI}}^{\text{t}}cT_{\text{STI}}^{\text{t}}-\dot{m}_ {\text{STO}}^{\text{t}}cT_{\text{STO}}^{\text{t}}-\dot{Q}_{\text{STI}}\\ \quad\quad-\lambda_{1}S_{\text{ST}}\frac{T_{\text{STI}}-T_{\text{STI}}}{B_{ \text{STI}}/J}-U_{\text{ST}}\frac{A_{\text{ST}}+2S_{\text{STI}}}{J}\left(T_{ \text{STI}}-T^{\text{a}}\right)\\ \rho c\frac{V_{\text{ST}}}{J}\frac{\text{dT}_{\text{STI}}}{\text{dT}}=-\dot{Q }_{\text{STJ}}+\lambda_{j-1}S_{\text{ST}}\frac{T_{\text{STI}-1}-T_{\text{STJ}}} {B_{\text{STI}}/J}\\ \quad\quad-\lambda_{j}S_{\text{ST}}\frac{T_{\text{STI}}-T_{\text{STI}+1}}{B_{ \text{STI}}/J}+U_{\text{ST}}\frac{A_{\text{ST}}+2S_{\text{ST}}}{J}\left(T_{ \text{STJ}}-T^{\text{a}}\right)(j=2,3,\ldots,J)\\ \rho c\frac{V_{\text{ST}}}{J}\frac{\text{dT}_{\text{STI}}}{\text{dT}}=\dot{m }_{\text{STI}}^{\text{b}}cT_{\text{STI}}^{\text{b}}-\dot{m}_{\text{STO}}^{ \text{b}}cT_{\text{STO}}^{\text{b}}-\dot{Q}_{\text{STJ}}\\ \quad\quad+\lambda_{j-1}S_{\text{ST}}\frac{T_{\text{STI}-1}-T_{\text{STI}}}{B _{\text{STI}}/J}-U_{\text{ST}}\frac{A_{\text{ST}}+2S_{\text{ST}}}{J}\left(T_{ \text{STJ}}-T^{\text{a}}\right)\end{array}\right\} \tag{12}\]  
Heat transfer  
\[\dot{Q}_{\text{STI}} =\left\{\begin{array}{l}\dot{m}_{\text{STI}}cT_{\text{STI}}\left( \dot{m}_{\text{STI}}\geq 0\right)\\ \dot{m}_{\text{STI}}cT_{\text{STI}}\left(\dot{m}_{\text{STI}}<0\right)\\ \dot{Q}_{\text{STJ}}\end{array}\right\}\] (13) \[\dot{Q}_{\text{STJ}} =\left\{\begin{array}{l}-\dot{m}_{\text{STJ}-1}cT_{\text{STJ}-1} +\dot{m}_{\text{STJ}}cT_{\text{STJ}}\left(\dot{m}_{\text{STJ}-1}=\dot{m}_{ \text{STJ}}\geq 0\right)\\ -\dot{m}_{\text{STJ}-1}cT_{\text{STJ}}+\dot{m}_{\text{STJ}}cT_{\text{STJ}+1} \left(\dot{m}_{\text{STJ}-1}=\dot{m}_{\text{STJ}}<0\right)\\ \quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad\  
Energy balance  
\[\dot{m}_{\rm HEi}^{\rm h}cT_{\rm HEi}^{\rm h}-\dot{\rm Q}_{\rm HE}=\dot{m}_{ \rm HEo}^{\rm h}cT_{\rm HEo}^{\rm h}\] \[\dot{m}_{\rm HEi}^{\rm I}cT_{\rm HEi}^{\rm I}+\dot{\rm Q}_{\rm HE}= \dot{m}_{\rm HEo}^{\rm I}cT_{\rm HEo}^{\rm I}\]  
Heat exchange  
\[\dot{\rm Q}_{\rm HE}=\left\{\begin{array}{ll}U_{\rm HE}A_{\rm HE}\frac{(T_{ \rm HEi}^{\rm h}-T_{\rm HEo}^{\rm I})-(T_{\rm HEi}^{\rm h}-T_{\rm HEi}^{\rm I })}{\ln\left((T_{\rm HEi}^{\rm h}-T_{\rm HEo}^{\rm I})\right)(T_{\rm HEi}^{ \rm h}-T_{\rm HEi}^{\rm I})}&(T_{\rm HEi}^{\rm h}-T_{\rm HEo}^{\rm I}>T_{\rm HE }^{\rm h}-T_{\rm HEi}^{\rm I})\\ U_{\rm HE}A_{\rm HE}\frac{(T_{\rm HEi}^{\rm h}-T_{\rm HEi}^{\rm I})-(T_{ \rm HEi}^{\rm h}-T_{\rm HEi}^{\rm I})}{\ln\left((T_{\rm HEi}^{\rm h}-T_{ \rm HEi}^{\rm I})/(T_{\rm HEi}^{\rm I}-T_{\rm HEi}^{\rm I})\right)}&(T_{\rm HEi }^{\rm h}-T_{\rm HEo}^{\rm I}<T_{\rm HEo}^{\rm h}-T_{\rm HEi}^{\rm I})\\ U_{\rm HE}A_{\rm HE}(T_{\rm HEi}^{\rm h}-T_{\rm HEo}^{\rm I})&(T_{\rm HEi}^{ \rm h}-T_{\rm HEo}^{\rm I}=T_{\rm HEo}^{\rm I}-T_{\rm HEi}^{\rm I})\\ \end{array}\right. \tag{12}\]