Attached image shows the principal structure of the three-tank system. The plant consists of three cylinders $T_1$, $T_2$, and $T_3$ with the cross section $S_A$. These tanks are connected serially with each other by pipes with the cross section $S_n$. A single outflow valve with the cross section $S_n$ is located at tank 2. The outflowing liquid (usually distilled water) is collected in a reservoir, which supplies the pumps 1 and 2. $H_{max}$ denotes the highest possible liquid level. The control input signals are the pump liquid flow rates $Q_1$ and $Q_2$ , the output signals are the liquid levels $h_1$ and $h_2$ .
Define the following variables and the parameters: $az_i$ : outflow coefficients of tank $i$ ; $h_1$ , $h_2$ , $h_3$ : liquid levels (m); $Q_{13}$ : flow rate from tank 1 to tank 3 $(m^3/sec)$ ; $Q_{32}$ : flow rate from tank 3 to tank 2 $(m^3/sec)$ ; $Q_{20}$ : flow rate from tank 2 to reservoir $(m^3/sec)$ ; $Q_1$ , $Q_2$ : supplying flow rates $(m^3/sec)$ ; $S_A$ : section of cylinder $(m^2)$ ; $S_1$ : section of leak opening $(m^2)$ ; $S_n$ : section of connection pipe $(m^2)$. Then, the dynamics of the three-tank system is expressed by a set of differential equations
$$\eqalignno{S_{A}\displaystyle{{dh_{1}}\over{dt}}=&\,Q_{1}(t)-Q_{13}(t)\cr S_{A}\displaystyle{{dh_{3}}\over{dt}}=&\, Q_{13}(t)-Q_{32}(t)\cr S_{A}\displaystyle{{dh_{2}}\over{dt}}=&\, Q_{2}(t)+Q_{32}(t)-Q_{20}(t)\cr Q_{13}(t)=&\,\alpha z_{1}S_{n}sgn(h_{1}(t)-h_{3}(t))\sqrt{(2g\left\vert h_{1}(t)-h_{3}(t)\right\vert}\cr Q_{32}(t)=&\,\alpha z_{3}S_{n}sgn(h_{3}(t)-h_{2}(t))\sqrt{2g\left\vert h_{3}(t)-h_{2}(t)\right\vert}\cr Q_{20}(t)=&\,\alpha z_{2}S_{n}sgn(h_{2}(t))\sqrt{2g\left\vert h_{2}(t)\right\vert},}$$
where $\alpha_1$, $\alpha_2$, $\alpha_3$: outflow coefficients (dimensionless, real values ranging from 0 to 1), $g$: earth acceleration $(m/s^2)$, $sgn(z)$: sign of the argument $z$.
In the simulation, the discretized model of three-tank system is obtained by first-order Euler's method, the sampling period is 1 s and the simulation time is 1500 s. The parameters of three-tank system are given in the table below. The initial conditions are $h_1(1)=0$, $h_2(1)=0$, $h_3(1)=0$, $Q_1(1)=0$, and $Q_2(1)=0$.
| $S_A$ |
$0.0154m^2$ |
| $S_n$ |
$5 \times 10^{-5}m^2$ |
| $H_{max}$ |
$0.6m$ |
| $Q_{max}$ |
$0.0001m^3/s$ |
| $\alpha_1$ |
$.22$ |
| $\alpha_2$ |
$.28$ |
| $\alpha_3$ |
$.27$ |