Hot water tank

The hot water tank model developed for another project, is used in this work to act as a buffer in between the heating device and the heat consumer. It is a multinode stratified thermal tank model, where the tank volume is divided into a specified number of layers (nodes) of equal volume, each characterized by a specific temperature. A traditional density distribution approach is adopted where the water flowing into the tank enters the layer that best matches its density (i.e., temperature). The model assumes that the fluid streams are fully mixed before leaving each of the layers and the flows between the layers follow the law of mass conservation. Heat transfer to the surrounding environment from the walls of the tank, and the heat transfer between the layers have been considered.

Parametrization of the model

The schematic of the hot water tank model is shown in the figure below. The dimensions of the tank are specified in terms of its height, and either the volume or diameter. The tank can be parametrized with sensors in the model to record its temperature. The initial temperature of all the layers must be set at the beginning of the simulation.

The flows into and out of the tank are specified as the connections of the hot water tank model. The flow going to the heat pump (HP_out), the space heating demand (SH_out), and the domestic hot water demand (DHW_out) are connected to the bottom layer, the fourth layer and the top layer respectively in the example schematic shown below. As explained earlier, the flows coming into the tank are not connected to a fixed layer in the tank. They are connected to the layer with a temperature closest to that of the flow.

Schematic representation of the hot water tank model (example with 6 layers)

Schematic representation of the hot water tank model (example with 6 layers)

The heat transfer coefficient of the walls of the tank (htc_walls) is assumed to be 0.28 W/m2-K . The heat transfer coefficient for the heat transfer between the layers of the tank is assumed to be 1.5 times the thermal conductivity of water. The value is calculated as 0.897 W/m-K, considering the thermal conductivity of water to be 0.598 W/m-K. However, these values can be changed by modifying the parameters dictionary of the hot water tank model.

Calculation of the model

The initial temperature profile inside the tank can be specified at the time of initialization of the model. For flows coming into the tank, both the temperature and flow rate should be specified. For the flows going out of the tank, only the flow rate should be specified, as the temperature is obtained from the corresponding layer of the tank. The model ensures that the overall flow into and out of the tank is equal. The model then updates the temperatures of each layer based on the water flows through the specified connections, the heat transfer between the layers and the heat transfer to the surrounding environment. The model has the functionality to flip the layers to ensure a negative temperature gradient from the top to the bottom of the tank. Finally, the model updates the connections with respect to the updated layer temperatures. For the flows going out of the tank, the temperature is updated. For the flows coming into the tank, the corresponding layer is updated.

Example

An example scenario using the hot water tank simulator in the mosaik environment is available in the ‘run_tank.py’ file.

The simulation is configured as shown below. The inputs to the hot water tank model and the outputs from it are handled by ‘mosaik-csv’.

 5SIM_CONFIG = {
 6    'HotWaterTankSim': {
 7        'python': 'mosaik_components.heatpump.hotwatertank.hotwatertank_mosaik:HotWaterTankSimulator',
 8    },
 9    'CSV': {
10        'python': 'mosaik_csv:CSV',
11    },
12    'CSV_writer': {
13        'python': 'mosaik_csv_writer:CSVWriter'
14    },
15}
16
17world = mosaik.World(SIM_CONFIG)
18
19START = '01.01.2016 00:00'
20END = 7 * 15 * 60

The hot water tank model has one inlet connection (‘cc_in’) and one outlet connection (‘cc_out’). The required parameters and the initial values are set as shown below.

22# Hot water tank
23params = {
24    'height': 2100,
25    'diameter': 1200,
26    'T_env': 20.0,
27    'htc_walls': 0.28,
28    'htc_layers': 0.897,
29    'n_layers': 3,
30    'n_sensors': 3,
31    'connections': {
32        'cc_in': {'pos': 1500},
33        'cc_out': {'pos': 10},
34        }
35    }
36init_vals = {
37            'layers': {'T': [30, 50, 70]}
38        }
39# configure the simulator
40hwtsim = world.start('HotWaterTankSim', step_size=15*60, config=params)
41# Instantiate model
42hwt = hwtsim.HotWaterTank(params=params, init_vals=init_vals)

The mass flow and temperature timeseries for these connections, that are needed as inputs for the model, are available in the ‘tank_data.csv’ file.

44# Input data csv
45HWT_FLOW_DATA = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data', 'tank_data.csv')
46# configure the simulator
47csv = world.start('CSV', sim_start=START, datafile=HWT_FLOW_DATA)
48# Instantiate model
49csv_data = csv.HWT()

The output data is saved into ‘hwt_trial.csv’ file.

51# Output data storage
52# configure the simulator
53csv_sim_writer = world.start('CSV_writer', start_date='01.01.2020 00:00', date_format='%d.%m.%Y %H:%M',
54                             output_file='hwt_trial.csv')
55# Instantiate model
56csv_writer = csv_sim_writer.CSVWriter(buff_size=60 * 60)

The different entities are then connected and the simulation is executed.

58# Connect entities
59world.connect(csv_data, hwt, ('T_in', 'cc_in.T'), ('F_in', 'cc_in.F'), ('F_out', 'cc_out.F'))
60world.connect(hwt, csv_writer, 'cc_in.T', 'cc_in.F', 'cc_out.T', 'cc_out.F', 'sensor_00.T', 'sensor_01.T', 'sensor_02.T')
61
62# Run the simulation
63world.run(until=END)  # As fast as possilbe

Module Documentation

The hotwatertank module contains classes for the components of the hotwatertank (Layer, Connection, Sensor, HeatingRod) and a class for the hotwater tank itself (HotWaterTank).

class mosaik_components.heatpump.hotwatertank.hotwatertank.HotWaterTank(params, init_vals=None)

Simulation model of a hotwater tank.

Stratification is modelled by a number of Layer objects. Heat producers and consumers can be connected to the hotwatertank via Connection objects. The temperature at different positions in the tank can be accessed via Sensor objects.

Hotwater tank parameters are provided at instantiation by the dictionary params. This is an example, how the dictionary might look like:

params = {
    'height': 2100,
    'diameter': 1200,
    'T_env': 20.0,
    'htc_walls': 1.0,
    'htc_layers': 20,
    'n_layers': 3,
    'n_sensors': 3,
    'connections': {
        'cc_in': {'pos': 0},
        'cc_out': {'pos': 2099},
        'gcb_in': {'pos': 1700},
        'gcb_out': {'pos': 500}
        },
    'heating_rods': {
        'hr_1': {
            'pos': 1800,
            'P_th_stages': [0, 500, 1000, 2000, 3000]
            }
        }
    }

Explanation of the entries in the dictionary:

  • height: height of the tank in mm

  • diameter: diameter of the tank in mm

  • volume: alternatively to the diameter the volume of the tank in liter can be specified

  • T_env: ambient temperature in °C

  • htc: heat transfer coefficient of tank walls in W/(m2K)

  • htc_layers: imaginary heat transfer coefficient between layers in W/(m2K)

  • n_layers: number of layers, n layers of the same dimension are created

  • n_sensors: number of sensors, the sensors are equidistantly distributed in the hotwater tank, sensors are named ‘sensor_00’, ‘sensor_01’, …, ‘sensor_n-1’ with ‘sensor_00’ indexing the undermost sensor

  • connections: each connection is specified by an dictionary with a structure analog to the example

  • heating_rods: each heating rod is specified by an dictionary with a structure analog to the example

It is also possible to define layers and sensors explicitly:

params = {
    'height': 2100,
    'diameter': 1200,
    'T_env': 20.0,
    'htc_walls': 1.0,
    'htc_layers': 20,
    'layers': [
        {'bottom': 0, 'top': 500},
        {'bottom': 500, 'top': 1600},
        {'bottom': 1600, 'top': 2100}
        ],
    'sensors': {
        'sensor_1', {'pos': 200},
        'sensor_2', {'pos': 1900},
        },
    'connections': {
        'cc_in': {'pos': 0},
        'cc_out': {'pos': 2099},
        'gcb_in': {'pos': 1700},
        'gcb_out': {'pos': 500}
        },
    'heating_rods': {
        'hr_1': {
            'pos': 1800,
            'P_th_stages': [0, 500, 1000, 2000, 3000]
            }
        }
    }

Initial values for the temperature distribution in the tank or the initial el. power of the heating rod are provided by the dictionary init_vals, which might look like this:

{
    'layers': {'T': 50},
    'hr_1': { 'P_el': 2000}
}

this:

{
    'layers': {'T': [30, 50, 70]}
    'hr_1': { 'P_el': 2000}
}

or this:

{
    'layers': {'T': [30, 70]},
    'hr_1': { 'P_el': 2000}
}
  • T: initial temperature of tank in °C, alternatively a temperature range can be specified, whereby the lower limit defines the temperature of ther undermost layer and the upper limit the temperature of the uppermost layer, inbetween a linear temperature gradient is set, it is also possible to specify the temperature of each layer individually by passing a list of length n_layers

step(step_size, adapted_step_size_mode=False)

Perform simulation step with step size step_size

property snapshot

serialize to json

property snapshot_connections

serialize connections to json

property T_mean

Returns mean temperature of hotwatertank in °C

class mosaik_components.heatpump.hotwatertank.hotwatertank.Layer(params)

Layer of hotwater tank

Parameters:

layer_params

dictionary containing the following keys

  • T - initial temperature of layer in °C

  • bottom - bottom of layer relatively to hotwater tank bottom in mm

  • top - top of layer relatively to hotwater tank bottom in mm

  • diameter - diameter of layer in mm

  • bottom_top - must be True for the bottom or top layer of the tank. This information is needed to calculate the outer surface of the layer which in turn is needed to calculate heat losses to the environment.

class mosaik_components.heatpump.hotwatertank.hotwatertank.Sensor(params, layers)

Temperature sensor in the tank.

Parameters:

params – dictionary containing params which specify a sensor, so far it contains only one entry pos, which defines the position of the sensor above hotwater tank bottom

class mosaik_components.heatpump.hotwatertank.hotwatertank.Connection(params, layers)

Devices are connected to the hotwater tank via connections.

Each connection is associated with a Layer. For input connections (F>0) the corresponding layer is determined by temperature comparison. The layer whose temperature is closest to the connection temperature is the corresponding one. For output connections (F<0) the corresponding layer depends on the position of the connection. The corresponding layer of a connection is not fix, but may change during the simulation, if the flow or temperatures of the connection or the temperature of the layers changes.

class mosaik_components.heatpump.hotwatertank.hotwatertank.MassFlow(F, T)

Massflow

class mosaik_components.heatpump.hotwatertank.hotwatertank.HeatingRod(params, layers, init_vals=None)

Heating rod integrated into to the hotwater tank.

Heating rods are characterized by their position above tank level and their power stages. Efficiency is assumed to be constantly 100%.