You are on page 1of 6

MODELING AND SIMULATION OF TWO TANKS

IN CASCADES
Melissa Isabel Serpa Morón
Atlantic University, Master's Degree in Chemical Engineering..
Barranquilla, Colombia. 2021
mserpa@mail.uniatlantico.edu.co

Abstract
A literature review is carried out to propose a
mathematical model that describes the behavior of a
nonlinear system of two tanks connected in cascades. It
is linearized through numerical methods such as Taylor
Series and Jacobian Matrix, and the transfer functions
that describe the behavior of the system are obtained.
The analysis is developed thanks to the simulation of this
model carried out in Matlab software. The modeling and Ilustration 1. Points 1 and 2 to take into account in the considerations.
simulation of dynamic systems are necessary for the
representation of the nature of the system, to predict its  The gauge pressure between points 1 and 2 are
behavior, and to implement controllers to achieve the zero.
given requirements.  That m is the mass of the fluid particles between 1
and 2.
Keywords - Cascade tanks, Mathematical model,  That v is the exit velocity of particle 1 and 2.
Linearization, Simulation.
The following mathematical relation of energy conservation
I. INTRODUCTION was obtained.

As industry becomes more complex, the more important is 1


𝑚𝑣 2 = 𝑚𝑔𝐻 (1)
the role of fluids in industrial machines. One hundred years 2
ago, water was the only important fluid transported by
Therefore, if we want to know the velocity with which the
pipelines. However, today any fluid is transported through
particle exits the tank through this cross section, the velocity
pipes during its production, process, transport or use [1].
of the particle was cleared from equation 1 and we have that
Most physical systems are nonlinear in nature. However, it
𝑣 = √2𝑔𝐻 (2)
is possible to approximate these systems to consider them as
linear systems. This is achieved by numerical methods that
If we want to know the outflow for the case of a cross section
aim to help provide answers to problems by means of
which we will call "S" the volumetric flow of this section
sufficiently accurate models with a minimum of effort when
it is not possible to obtain a solution by analytical methods. will be given by:
[2] 𝑄 = 𝑆𝑣 (3)
II. THEORETICAL FRAMEWORK Where S is a constant. By replacing the velocity we are left
with the equation as follows:
Next, the system model is developed.
𝑄 = 𝑆√2𝑔𝐻 (4)
Static model of the level system
From equation 4 it can be considered that the root of twice
There are two cascade tanks which were modeled
the gravity is constant so this equation is as follows:
mathematically. As the system is non-linear, the
phenomenological equations were linearized using two 𝑄 = 𝑆 √2𝑔√𝐻 (5)
techniques: Taylor series and Jacobian matrix.
Where H represents the height of the tank, which will have
The following are the considerations taken into account
a dynamic behavior as it changes with respect to time.
when modeling a tank.
By combining the constant terms, equation 5 looks like this:

𝑄 = 𝐾√𝐻 (6)

Flow through a valve

In a general way the flow through a valve in steady state is


given by:

𝑄𝑣 = 𝐾𝑣 𝐴𝑠 √∆𝑃 (7)

Where Qv is the flow through the valve, Kv a constant, As is


the passage area, and ΔP is a differential pressure across the
valve, between the outlet and inlet pressure.

It can be concluded that the flow through the valve is


proportional to the valve opening area in the case where the
pressure differential is constant.

It is assumed that the valve that is operating has an


intelligent behavior, i.e., it will have a linear relationship
with the flow that is entering it, so it will also have a linear
Ilustration 2. System diagram.
relationship to the valve opening. Therefore, equation 7 is as
Tanque 2
follows:
𝑑ℎ2
𝑄𝑠 = 𝑆𝑎√2𝑔𝐻 (8) 𝐴2 = 𝑞𝑚 − 𝑞𝑜 (12)
𝑑𝑡
Where a is the opening of the valve. Applying the same procedure that was done with equation
10 for the second tank, we have that:
The same procedure is performed as in equation 4 and
condensed into a single equation which would result: 𝑑ℎ2
𝐴2 = 𝑘2 √ℎ1 − 𝑘3 𝑎2 √ℎ2 (13)
𝑑𝑡
𝑄𝑠 = 𝐾𝑎√𝐻 (9)
Having then the phenomenological equations of our model,
In view of the above, the two cascade tank model is we proceed to linearize it.
developed.
Linearization of the nonlinear system
Modeling of the two tanks
The first thing to do is to find the equilibrium point of the
Taking into account the system scheme (Illustration 2), the system.
equations for modeling each tank are made:
First tank
 Tank 1
Its differential equation, Equation 11, is taken, and to find
𝑑ℎ1 its equilibrium point it is indicated that the height of the first
𝐴1 = 𝑞𝑖 − 𝑞𝑚 (10)
𝑑𝑡 tank will not vary, it will remain constant, that is, it will be
Where qi which is the inlet flow rate given by the in equilibrium, which means that its derivative is zero.
relationship between the flow rate and the valve, assuming 𝑑ℎ1
that the supply to the tank is constant and that the supply has 𝐴1 = 𝑘1 𝑎1 − 𝑘2 √ℎ1
𝑑𝑡
a linear relationship to the valve opening, equation 10 is as
follows: The notation s is given to h1 to say that it is in steady state,
then it can be said that:
𝑑ℎ1
𝐴1 = 𝑘1 𝑎1 − 𝑘2 √ℎ1 (11)
𝑑𝑡 𝑘1 𝑎1 = 𝑘2 √ℎ1𝑠 (14)
Equation 11 would be the first differential equation And by solving h1s we can know the steady state height:
describing tank 1. It is noted that h1 is within a square root
so this equation is nonlinear.
𝑘1 𝑎1 2 It is observed that a differential equation was reached again,
ℎ1𝑠 = ( ) (15) which this time is linear.
𝑘2

 Second tank  Tank 2

We perform the same procedure as for the first tank by 𝑑ℎ1


𝐴1 = 𝑘2 √ℎ1 − 𝑘3 𝑎2 √ℎ2
taking its differential equation, Equation 13, to find the 𝑑𝑡
equilibrium point. It is then defined that the function that depends on both
𝑑ℎ2 height one and height two will be equal to the differential.
𝐴2 = 𝑘2 √ℎ1 − 𝑘3 𝑎2 √ℎ2
𝑑𝑡 𝑑ℎ2
𝐹 (ℎ1 , ℎ2 ) = 𝐴2
The s is placed on h2 to say that it is in steady state, then it 𝑑𝑡
can be said that: Applying Taylor's series, equation 18, to linearize our
system we are left with the following:
𝑘2 √ℎ1𝑠 = 𝑘3 𝑎2 √ℎ2𝑠 (16)
𝑑∆ℎ2 𝑘2 𝑘 3 𝑎2
And by clearing h2s we can know the steady state height: 𝐴2 = ∆ℎ1 − ∆ℎ2 (20)
𝑑𝑡 2√ℎ1 ∗
2√ℎ2 ∗
𝑘2 2 ℎ1𝑠
ℎ2𝑠 = (17) Now to treat these differential equations more easily
( 𝑘 3 𝑎2 ) 2
with algebraic equations and to find their transfer
Linearization by Taylor series function, the Laplace transform is used.

The Taylor series expansion is a series that can go to infinity  Tank 1


and is used to approximate mathematical models.
Applying the Laplace transform to equation 19 we get
1 𝑑2
𝐹(𝑥 ) = 𝐹 (𝑥 ∗ ) + ∇𝐹(𝑥 ∗ )∆𝑥 + | ∗ 2 𝑘2
2 𝑑𝑥 2 𝑥 ∆𝑥 𝐴1 𝑠∆ℎ1 (𝑠) = 𝑘1 ∆𝑎1 (𝑠) − ∆ℎ1 (𝑠)
1 𝑑3 2√ℎ1 ∗
+ | ∗ 3 +⋯
3! 𝑑𝑥 3 𝑥 ∆𝑥 Solving algebraically and taking out the common factor,
The nonlinear system of the two tanks will be represented as results in the following equation representing the transfer
a linear system, only the Taylor series will be taken up to the function
term where it is linear, the first term of the series which is
∆𝒉𝟏 (𝒔) 𝒌𝟏
also known as the Jacobian matrix. 𝑮𝟏 (𝒔) = =
∆𝒂𝟏 (𝒔) 𝑨 𝒔 + 𝒌𝟐
𝟏
𝐹 (𝑥) = 𝐹 (𝑥 ∗ ) + ∇𝐹 (𝑥 ∗ )∆𝑥 (18) 𝟐√𝒉𝟏 ∗
Where x* is to evaluate the function at the equilibrium point.  Tank 2
Then, Applying the Laplace transform to equation 20 we get
 Tank 1 𝑘2 𝑘 3 𝑎2
𝐴2 𝑠∆ℎ2 (𝑠) = ∗
∆ℎ1 (𝑠) − ∆ℎ2 (𝑠)
𝑑ℎ1 2√ℎ1 2√ℎ2 ∗
𝐴1 = 𝑘1 𝑎1 − 𝑘2 √ℎ1
𝑑𝑡 Solving algebraically and taking out the common factor
It is then defined that the function that depends on both the results in the following equation representing the transfer
valve opening and the height will be equal to the differential function

𝑑ℎ1 𝒌𝟏 𝒌𝟐
𝐹(𝑎1 , ℎ1 ) = 𝐴1
𝑑𝑡 ∆𝒉𝟐 (𝒔) 𝟐√𝒉𝟏 ∗
𝑮𝟐 (𝒔) = =
∆𝒂𝟏 (𝒔) 𝒌𝟐 𝒌 𝒂
Applying Taylor's series, equation 18, to linearize our (𝑨𝟏 𝒔 + ) (𝑨𝟐 𝒔 + 𝟑 𝟐∗ )
system we are left with the following: 𝟐√𝒉𝟏 ∗ 𝟐√𝒉𝟐

𝑑∆ℎ1 𝑘2 Now that we have the transfer functions we proceed to the


𝐴1 = 𝑘1 ∆𝑎1 − ∆ℎ1 (19) state space representation
𝑑𝑡 2√ℎ1 ∗
State space representation III. RESULTS AND ANALYSIS

Taking advantage of having the linear differential equations,


equations 19 and 20, which were obtained before applying Simulation of the model in MATLAB software
the Laplace transform to them, we proceed to make the state
space representation The model simulation stage is very important because based
on the results obtained it is possible to confirm that the
𝑘2 proposed model is representative or not of the system under
− 0 𝑘1 study.
∆ℎ̇ 2𝐴1 √ℎ1 ∗ ∆ℎ1
[ 1] = [ ] + [𝐴1 ] ∆𝑎1
∆ℎ̇ 2 𝑘2 𝑘 3 𝑎2 ∆ℎ2
The Matlab software was implemented to perform the

− 0
[ 2𝐴2 √ℎ1 2𝐴2 √ℎ2 ∗ ] simulation of the model. The following parameters were
taken into account:
Therefore,
K1 = 0.04 m3/s
∆ℎ
𝑦 = [0 1] [ 1 ] K2 = 0.03 m3/s
∆ℎ2 K3 = 0.055 m3/s
Linearization by JACOBIANA a1s = 0.5
a2s = 0.45
Another generic way to linearize nonlinear mathematical A1 = 1 m2
models is by using the Jacobian, which is simply the first A2 = 1.5 m2
term of the Taylor series expansion, with which the
linearized system expressed in the state space representation The analysis taken for the system is that the tank heights
can be obtained directly: depend directly on valve 1, i.e. the opening of valve two will
remain constant and valve 1 can be varied.
Taylor serie: 𝐹(𝑥 ) = 𝐹(𝑥 ∗ ) + ∇𝐹(𝑥 ∗ )∆𝑥

Jacobian : ∇𝐹(𝑥 ∗ )∆𝑥


𝜕𝐹1 𝜕𝐹1 𝜕𝐹1
∆ℎ̇ 𝜕∆ℎ1 𝜕∆ℎ2 ∆ℎ1 𝜕∆𝑎1
[ 1] = [ ]+ ∆𝑎1
∆ℎ̇ 2 𝜕𝐹2 𝜕𝐹2 ∆ℎ2 𝜕𝐹2
[𝜕∆ℎ1 𝜕∆ℎ2 ] [𝜕∆𝑎1 ]

The equations of each non-linear tank are taken into account:


1
𝐹1 (ℎ1 , ℎ2 , 𝑎1 ) = (𝑘 𝑎 − 𝑘2 √ℎ1 )
𝐴1 1 1
1
𝐹2 (ℎ1 , ℎ2 , 𝑎1 ) = (𝑘 √ℎ − 𝑘3 𝑎2 √ℎ2 )
𝐴2 2 1

The above equations are linearized using the Jacobian


matrix and the result is the same as the linearization with
Teylor series. Ilustración 3. Variación del nivel en los tanques dependiendo de la
abertura de la válvula 1
𝑘2
− 0 𝑘1 Illustration 3 shows a profile of how the height of the tanks
∆ℎ̇ 2𝐴1 √ℎ1 ∗ ∆ℎ1
[ 1] = [ ] + [𝐴1 ] ∆𝑎1 varies as the inlet valve is manipulated; an exponential
∆ℎ̇ 2 𝑘2 𝑘 3 𝑎2 ∆ℎ2
behavior is observed, and as the valve is opened, the heights

− 0
[ 2𝐴2 √ℎ1 2𝐴2 √ℎ2 ∗ ] of both tanks increase.
In conclusion, the Jacobian matrix is exactly the same as the The system was linearized in the Matlab program, taking
Taylor series, only that it is a more general way of into account the initial and final states. Additionally, the
expressing in state space. equations that describe the behavior were linearized thanks
to the software's Jacobian function.
After that, the linearized model is obtained in state spaces Illustration 4 shows that, taking a small variation or
and the transfer function for each tank. perturbation at the input of the system, the profile of the
linear system in red is very close to the nonlinear one, which
The nonlinear system was simulated taking into account a is the blue line.
very small variation in the input, for which the Matlab ODE
suite was used, which is a collection of five easy-to-use
finite difference codes for solving problems of initial values
given by first order systems of ordinary differential
equations and plotting their numerical solutions. initial
values given by first order systems of ordinary differential
equations and plotting their numerical solutions.

The Matlab suite handles different codes depending on the


particularities of the problem.

The codes ode23, ode45 and ode113 are designed to solve


non-rigid problems.

The two codes ode23s and ode15s are designed to solve rigid
and non-rigid problems.

The ode23 code was used for the resolution of the system,
which consists in a four-stage pair of embedded explicit
Runge–Kutta methods of orders 2 and 3 with Ilustration 5. Linear Vs. Non-Linear Model - Variation in the perturbation.
error control.
Illustration 5 shows the variation in the nonlinear system at
For the simulation of the linearized system, the equilibrium the moment of establishing a perturbation with a higher
points equations 15 and 17 were taken into account. A model value, in this case -0.05 was used and in the previous graph
was specified in which it is a function that will deliver as -0.0001. It is observed how it moves away from the
output the different state variables. equilibrium point in which the problem was linearized.

The simulation yielded the time parameter and the dynamic Therefore, it is analyzed that our system does not adequately
evolution of the states of height 1 and 2. A small variation represent the nonlinear dynamics of the system, if we move
in the system input was defined to see the behavior of the away so much we should linearize again at that point in order
linear and nonlinear system. The time and the result of the to have an adequate representation of our system.
linear output of the system were plotted and a comparison
between the models was made.

Ilustration 6. Linear Vs. Non-Linear Model - Higher variation in the


disturbance.

Ilustration 4. Linear Vs Non-Linear Model.


Figure 6 shows how with an even larger perturbation, in this
case -0.3, the model moves even further away and is not
representative.
IV. CONCLUSIÓN

In the review of the literature, several models of tank


systems were found: with or without iteration, positioned at
different levels; of one, two, three or more tanks; represented
by first and second order differential equations. The system
presented here was a two-tank system and the proposal to
use a linearized model to simulate it was presented.

The development of the mathematical modeling was carried


out to obtain a system of differential equations
representative of the behavior of the model of the two
cascade tanks, in which each one has a valve connected, the
first tank at the inlet and the second tank at the outlet.

After modeling, the next step was to perform the


linearization of the model by means of Taylor series, due to
the nonlinearity of the system.

The process to arrive at the simulation was carefully


developed through the corresponding coding using Matlab
software and obtaining satisfactory results with respect to
the behavior of the linear model when there is a small
disturbance in magnitude, while when there are significant
disturbances the model is so far away that it must be
linearized again at that point in order to have an adequate
representation of the system.

V. BIBLIOGRAPHY

[1] Crane,. (1989). Flujo de fluidos en válvulas, accesorios


y tuberías. McGrawHill, México.
[2] Torres, (2010). Métodos Numéricos.
[3] Dorf, R., & Bishop, R. (2005). Sistemas de control
moderno. Madrid: Prentica Hall.
[4] Anaya. M & Benitez. V. Modelado y Simulación de un
Sistema de Planta Industrial de Dos Tanques. Universidad
de Sonora.
[5] Medina. L. Modelado matemático, simulación, análisis y
control de un sistema hidráulico interactivo-tres tanques en
serie. Dialnet
[6] Castaño. S. Curso de Análisis de Sistemas. – Modelado
de dos tanques de nivel en Cascada

You might also like