Flat model of a tank

Wolfram Language

Click for copyable input


This is a flat model of the following one-tank system with a controller:

The water level, h, in the tank is a function of the flow in and out from the tank, and the tank area:

The input flow is constant the first 150 seconds and then triples:

where flowLevel is a parameter. By controlling the output flow the tank level is held at a desired reference value. The following PI controller is used in the model:

where K is the controller gain and T is the integrator time constant. Finally the output flow is limited between a minimum value, minFlow, and a maximum, maxFlow.

By simulating the model for 350 seconds we can see that the tank level starts to increase reaching and passing the desired reference level. When the desired level is passed the outflow is opened and after 150 seconds the level has stabilized. However at this moment the input flow is suddenly increased and the water level is therefore increased before the controller manages to stabilize it again. This is illustrated in the figure below:

The TankPI model is a component based model of the same system.

For a step by step tutorial see Hierarchical Model—Tank System.

Parameters (7)


Value: 0.15

Type: Real (m³/s)

Description: Scaling of input flow


Value: 1.0

Type: Real (m²)

Description: Tank bottom area


Value: 0.1

Type: Real (V/m)

Description: PI controller gain


Value: 10

Type: Real (s)

Description: PI controller integrator time constant


Value: 0.0

Type: Real (m³/s)

Description: Minimum flow through output valve


Value: 0.5

Type: Real (m³/s)

Description: Maximum flow through output valve


Value: 0.25

Type: Real (m)

Description: Reference level for control