In this control engineering, control theory, and process control tutorial, we explain how to develop a dynamical model of a tank (reservoir) filled with a liquid and how to simulate such a model in Python. This is a classical problem for understanding the dynamics of fluid and process systems. The YouTube video accompanying this tutorial is given below.
Problem Formulation
The figure given below introduces the problem.
We consider a tank with a cross-section area of
- Derive a differential equation describing the change of the fluid level
as the function of time and as the function of . - For a given initial fluid level
and for a given time series of , numerically solve and simulate the solution of the derived differential equation in Python.
Modeling and Simulation of a Tank Model in Python
Consider the figure given below.
On the left part of the figure, we show the fluid level
The rate of change of the fluid volume during this time instant is
(1)
On the other hand, the term
(2)
is the velocity of the fluid in the tank.
On the other hand, in the general case, the flow is the product of the fluid velocity and the area through which the fluid flows. That is
(3)
where
(4)
On the other hand, since the output flow is passive, we can use a formula in our previous tutorial for the output flow. This formula is
(5)
where
(6)
where the constant
(7)
By substituting (6) in (4), we obtain the model of the tank system:
(8)
The last equation can be written in the following form
(9)
This is the final form we use for the simulation of the system in Python. The Python code for simulating the system is explained in the video above and after paying a small fee, the code can be accessed by using this link.
We assume the following simulation conditions. The initial height
The input flow is given in the figure below.
The simulated height
Next, we simulate the response of the system to the initial state. The results are shown below.