*Model Implementation*

The model was implemented in Matlab®/Simulink® (The MathWorks Inc., Natick, MA, USA) one of the most widely used proprietary calculation software systems, to estimate mass flow rates, temperature, and pressure in each node (respecting causal coupling with physical models of other components).

By considering the typical causality of state-determined systems, the inputs to the storage model are as follows:


**Figure 3.** Schematic representation of nodal approach for stratified storage tank, showing incoming, outgoing, and vertical mass flows.

The entry node for each incoming flow is calculated through a dedicated algorithm which, by comparing the incoming flow temperature with the temperature of the ith node, directs the flow toward the next node with the same or a higher temperature. Therefore, the storage model should consist of at least two nodes.

A mask was created which allows the user to set the general properties of the tank such as the geometrical characteristics (height, thickness, and diameter), specifications of the insulation materials, fluid properties (i.e., thermal conductivity and initial temperature), number and dimension of nodes, and convection properties.

The model is composed of two macro sections: (i) one aimed at the calculation of thermal and geometrical characteristics (i.e., overall heat loss coefficient U, area A and conduction constant k) and (ii) one intended to solve the node balance equations.

For a proper simulation, each node sub model needs several inputs, as shown in Figure 4, including the temperature of both the previous and following nodes (Ti−<sup>1</sup> and Ti+1). Some parameters are derived from the model dialogue mask (Ui, Ai, ki), some are boundary terms equal for all nodes (i.e., Tamb), and others come from the previous and following nodes. The node outputs are the water temperature (Ti), the vertical mass flow rate toward the next node and where it exists, the mass flow rate which has not entered any node and is directed to the next one ( . mi+1). The model gives the temperature, the outgoing mass flow rate from the last node (bottom of the tank) and the outcoming pressure as the output.

**Figure 4.** Main input and output parameters for ith node.
