You are on page 1of 44

CHE 509: Process Dynamics

MODULE 6:
Empirical Modeling and Control of Amira Three Tank
System Using Artificial Neural Networks (ANN)

Ayorinde Bamimore, Ph.D.


Department of Chemical Engineering
Obafemi Awolowo University
Module Objectives
▪ To be able to model Amira three-tank
system using ANN models,
▪ To be able to control the Amira three-tank
system using ANN-based control
techniques,

Obafemi Awolowo University 2


Chemical Engineering
Amira Three-Tank System

q1 q2
Tank 3
Tank 2

H1
q13 q32
Pump

Pump
H3 𝑺𝒑 , 𝝁 𝟐
H2
1

2
𝑺𝒑 , 𝝁 𝟏 𝑺𝒑 , 𝝁𝟑
d1 d3 d2 q20

Figure 6.30: A schematic of the three tank system with labels

Obafemi Awolowo University 3


Chemical Engineering
Amira Three-Tank System

Figure 6.31: Photograph of the three-tank system

Obafemi Awolowo University 4


Chemical Engineering
Dynamic Model of the Three-Tank System

The change in the levels of water inside tanks 1, 2 and 3 are modeled by ODE:

𝒅𝒉𝟏 (6.50)
𝑨 = 𝝁𝟏 . 𝑺𝒑 . √𝟐𝒈. 𝒔𝒈𝒏(𝒉𝟏 − 𝒉𝟑 ). √|𝒉𝟏 − 𝒉𝟑 | + 𝒒𝟏 − 𝒅𝟏
𝒅𝒕
𝒅𝒉𝟐 (6.51)
𝑨 = 𝝁𝟑 . 𝑺𝒑 . √𝟐𝒈. 𝒔𝒈𝒏(𝒉𝟑 − 𝒉𝟐 ). √|𝒉𝟑 − 𝒉𝟐 |
𝒅𝒕

− 𝝁𝟐 . 𝑺𝒑 . √𝟐𝒈. 𝒔𝒈𝒏(𝒉𝟐 ). √|𝒉𝟐 | + 𝒒𝟐 − 𝒅𝟐

𝒅𝒉𝟑 (6.52)
𝑨 = 𝝁𝟏 . 𝑺𝒑 . √𝟐𝒈. 𝒔𝒈𝒏(𝒉𝟏 − 𝒉𝟑 ). √|𝒉𝟏 − 𝒉𝟑 |
𝒅𝒕

− 𝝁𝟑 . 𝑺𝒑 . √𝟐𝒈. 𝒔𝒈𝒏(𝒉𝟑 − 𝒉𝟐 ). √|𝒉𝟑 − 𝒉𝟐 |−𝒅𝟑

Obafemi Awolowo University 5


Chemical Engineering
Dynamic Model of the Three-Tank System

𝐴 =Cross-sectional area of the tank=149cm2


𝑆𝑝 =Cross-sectional area of the connecting pipes=0.5 cm2
The flow coefficients are given as
𝝁𝟏𝟎 = 𝟎. 𝟒𝟒, 𝝁𝟐𝟎 = 𝟎. 𝟖𝟕, 𝝁𝟑𝟎 = 𝟎. 𝟒𝟐
𝑔 =acceleration due to gravity=981cm2/s
Nominal operating point:
𝒄𝒎𝟑 𝒄𝒎𝟑
𝒒𝟏𝟎 = 𝟑𝟐 , 𝒒𝟐𝟎 = 𝟒𝟑
𝒔𝒆𝒄 𝒔𝒆𝒄
𝒉𝟏𝟎 = 𝟑𝟕. 𝟖 𝒄𝒎, 𝒉𝟐𝟎 = 𝟏𝟓. 𝟐 𝒄𝒎, 𝒉𝟑𝟎 = 𝟐𝟔. 𝟗𝟕 𝒄𝒎

Obafemi Awolowo University 6


Chemical Engineering
Linearized Model of the Three-Tank System

Linearizing Equations (6.50-6.52), and taking the leaks 𝑑𝑖 = 0 yields the following

linear state space model:


𝒅𝒉𝟏
𝒅𝒕 𝒉𝟏
𝒅𝒉𝟐 𝒒𝟏
𝒅𝒕
= 𝑨 [𝒉𝟐 ] + 𝑩 [𝒒 ] (6.53)
𝟐
𝒅𝒉𝟑 𝒉𝟑
[ 𝒅𝒕 ]

𝒉𝟏
𝒉 𝟏 𝟎 𝟎 𝒉
[ 𝟏] =[ ] [ 𝟐]
𝒉𝟐 𝟎 𝟏 𝟎
𝒉𝟑 (6.54)

Obafemi Awolowo University 7


Chemical Engineering
Linearized Model of the Three-Tank System

Where:

−𝟎. 𝟎𝟎𝟗𝟗𝟓 𝟎 𝟎. 𝟎𝟎𝟗𝟗𝟓


𝑨=[ 𝟎 −𝟎. 𝟎𝟐𝟓𝟕 𝟎. 𝟎𝟎𝟗𝟎𝟗],
𝟎. 𝟎𝟎𝟗𝟗𝟓 𝟎. 𝟎𝟎𝟗𝟎𝟗 −𝟎. 𝟎𝟏𝟗

𝟎. 𝟎𝟎𝟔𝟕𝟏 𝟎
𝑩=[ 𝟎 𝟎. 𝟎𝟎𝟔𝟕𝟏]
𝟎 𝟎

Obafemi Awolowo University 8


Chemical Engineering
Data collection for Identification, Validation and Testing

For the purpose of deriving control models, the SIMULINK model of the

experimental tank system was excited by simultaneous random inputs 𝑞1 and 𝑞2 .

The input signal 𝑞1 was designed to have a mean value of 28 cm3/sec and a

variance of 200 while 𝑞2 was designed with a mean value of 43 cm3/sec and a

variance of 1000. The switching time for both inputs was chosen as 200 seconds.

By sampling the process at every 1 second, 20000 data were collected and

plotted in Figure . Of the 20000 data collected, the first 14000 were used for

identification, the next 3000 for validation while the last 3000 were used for

testing.

Obafemi Awolowo University 9


Chemical Engineering
Data collection for Identification, Validation and Testing

Figure 6.32a: Simulink model of the three-tank system

Obafemi Awolowo University 10


Chemical Engineering
Data collection for Identification, Validation and Testing

70 40
60
30
50
Height 1[cm]

Height 2[cm]
40
20
30
20
10
10

0 0
0 0.5 1 1.5 2 0 0.5 1 1.5 2
4 4
x 10 x 10

70
80
60
Pump 1 flow [cm3/s]

Pump 2 flow [cm3/s]


50 60

40
40
30
20
20

10 0
0 0.5 1 1.5 2 0 0.5 1 1.5 2
T ime[Samples] 4 T ime[Samples] 4
x 10 x 10

Figure 6.32b: Input-output data collected

Obafemi Awolowo University 11


Chemical Engineering
Linear Model Validation

Figure 6.33:Validation results: Linear model prediction vs. process


output for 𝒉𝟏 and 𝒉𝟐

Obafemi Awolowo University 12


Chemical Engineering
Linear Model Validation

Figure 6.34: parity plots for 𝒉𝟏 and 𝒉𝟐

Obafemi Awolowo University 13


Chemical Engineering
FFNN model identification and Control of the three-tank-system

Due to the inability of the linear model to represent the process, a FFNN

model was therefore considered for the process. A feedforward multi-layer

perceptron (MLP) neural network model with the following topology is hereby

chosen with 8 inputs, 7 hidden layers and 2 output layer, as shown in Figure .

A nonlinear autoregressive exogenous (NARX) model of the following form is

chosen for the process:

ℎ (𝑘 − 1), ℎ2 (𝑘 − 1), 𝑞1 (𝑘 − 1), 𝑞2 (𝑘 − 1),


[ℎ̂1 (𝑘) ℎ̂2 (𝑘)] = 𝑓𝐹𝐹𝑁𝑁 ( 1 ) (6.53)
ℎ1 (𝑘 − 2), ℎ2 (𝑘 − 2), 𝑞1 (𝑘 − 2), 𝑞2 (𝑘 − 2),

Obafemi Awolowo University 14


Chemical Engineering
FFNN model identification and Control of the three-tank-system

Using the data set collected in Figure , a MLP ANN model was trained for the

process using the MATLAB ANN toolbox. The training algorithm chosen is

Levenberg-Marquardt. A comparison of the process output with the FFNN output

as shown in together with the computed MSE=0.0083 showed that the FFNN

gives a good representation of the process.

The final ANN model obtained after training is:

𝑦(𝑘) = 𝑊𝑜𝑢 [𝑓ℎ (𝑊𝑖𝑛 𝜓(𝑘 − 1) + 𝑏𝑖𝑛 )] + 𝑏𝑜𝑢𝑡 (6.54)

Obafemi Awolowo University 15


Chemical Engineering
FFNN model identification and Control of the three-tank-system

where

𝑦(𝑘) = [ℎ1 (𝑘) ℎ2 (𝑘)]

𝜓(𝑘 − 1) =

[ℎ1 (𝑘 − 1) ℎ2 (𝑘 − 1) ℎ1 (𝑘 − 2) ℎ2 (𝑘 − 2) 𝑞1 (𝑘 − 1) 𝑞2 (𝑘 − 1) 𝑞1 (𝑘 − 2) 𝑞2 (𝑘 −

The activation function is chosen as:

2
𝑓ℎ (𝑥 ) = ( −1
1+𝑒 −2𝑥 )

The model parameters can be requested for.

The i-step prediction model used for NMPC design is then

𝑦(𝑘 + 𝑖 ) = 𝑊𝑜𝑢𝑡 [𝑓ℎ (𝑊𝑖𝑛 𝜓(𝑘 + 𝑖 − 1) + 𝑏𝑖𝑛 )] + 𝑏𝑜𝑢𝑡


Obafemi Awolowo University 16
Chemical Engineering
FFNN Architecture Selected for the three-tank-system

𝒉𝟏 (𝒌 − 𝟏)

𝒉𝟐 (𝒌 − 𝟏)

𝒉𝟏 (𝒌 − 𝟐)
𝒉𝟏 (𝒌)

𝒉𝟐 (𝒌 − 𝟐)

𝒒𝟏 (𝒌 − 𝟏)
𝒉𝟐 (𝒌)

𝒒𝟐 (𝒌 − 𝟏)

𝒒𝟏 (𝒌 − 𝟐)

𝒒𝟐 (𝒌 − 𝟐)

Figure 6.35: FFNN topology selected for the three-tank system

Obafemi Awolowo University 17


Chemical Engineering
FFNN Model Validation

Figure 6.36:Validation results FFNN model prediction vs. process


output for 𝒉𝟏 and 𝒉𝟐

Obafemi Awolowo University 18


Chemical Engineering
FFNN Model Validation

Figure 6.37:Parity plots for 𝒉𝟏 and 𝒉𝟐

Obafemi Awolowo University 19


Chemical Engineering
RNN model identification and Control of the three-tank-system

RNN was equally considered for the control of the tank process, with its topology

selected as 2 inputs, 8 hidden layers and 2 output layer.

Using the data set collected in Figure , a RNN model was trained for the process

using the MATLAB ANN toolbox. The training algorithm chosen is Levenberg-

Marquardt. A comparison of the process output with the RNN output as shown in

together with the computed MSE=0.1493 showed that the RNN gives a good

representation of the process.

Obafemi Awolowo University 20


Chemical Engineering
RNN model identification and Control of the three-tank-system

The final RNN model obtained after training is:

𝑦(𝑘 + 1 + 𝑖 ) = 𝑊𝑜 𝑓ℎ (𝑊𝐼 𝑢(𝑘 + 𝑖 ) + 𝑊𝐿 𝐻(𝑘 + 𝑖 ) + 𝑏𝐼 ) + 𝑏𝑜

where

𝑦(𝑘) = [ℎ1 (𝑘) ℎ2 (𝑘)]

𝑢(𝑘) = [𝑞1 (𝑘) 𝑞2 (𝑘)]

The activation function is chosen as:

2
𝑓ℎ (𝑥 ) = ( −1
1+𝑒 −2𝑥 )

A comparison is made among the three model types considered for the control of

the three-tank process.


Obafemi Awolowo University 21
Chemical Engineering
RNN model identification and Control of the three-tank-system

FFNN gives the best accuracy with the lowest MSE of 0.0083, followed by RNN

with MSE of 0.1493, the linearized model gives the least accuracy with a MSE of

1.85.

Obafemi Awolowo University 22


Chemical Engineering
RNN Model Validation

Figure 6.38:Validation results: RNN model prediction vs. process output


for 𝒉𝟏 and 𝒉𝟐

Obafemi Awolowo University 23


Chemical Engineering
RNN Model Validation

Figure 6.39: Parity plots for 𝒉𝟏 and 𝒉𝟐

Obafemi Awolowo University 24


Chemical Engineering
FFNN-based Nonlinear Model

Figure 6.40a: Block diagram for implementing ANN model based NMPC

Obafemi Awolowo University 25


Chemical Engineering
NMPC control of the three-tank-system using FFNN and RNN

With both the identified FFNN and RNN models as the prediction models; and

the tuning parameters selected as in LMPC, a nonlinear predictive controller was

designed and implemented on the Simulink model of the tank system, with 𝑢(𝑘),

∆𝑢(𝑘) and Laguerre filter parameters as decision variables in the optimization

algorithms. The simulation results of implementing these control algorithms as

plotted in Figures 6.40(b) and 6.41 show an excellent setpoint tracking with no

overshoot and undershoot. The results are better than that of LMPC.

Obafemi Awolowo University 26


Chemical Engineering
Simulation Results

Figure 6.40b: Process inputs and outputs using FFNN-NMPC

Obafemi Awolowo University 27


Chemical Engineering
Simulation Results

Figure 6.41: Process inputs and outputs using RNN-NMPC

Obafemi Awolowo University 28


Chemical Engineering
Inverse-FFNN model Identification and Control of the Three-Tank-System

To design an inverse-FFNN model to be used as controller for the tank

system, a NARXN model was chosen to represent the inverse-FFNN model:

ℎ1 (𝑘 + 1) ℎ2 (𝑘 + 1)
ℎ1 (𝑘) ℎ2 (𝑘)
ℎ1 (𝑘 − 1) ℎ2 (𝑘 − 1)
[𝑞̂1 (𝑘) 𝑞̂2 (𝑘)] = 𝑓𝑖𝑛𝑣−𝑓𝑓𝑛𝑛 (6.56)
ℎ1 (𝑘 − 2) ℎ2 (𝑘 − 2)
𝑞1 (𝑘 − 1) 𝑞2 (𝑘 − 1)
(𝑞1 (𝑘 − 2) 𝑞2 (𝑘 − 2))

Obafemi Awolowo University 29


Chemical Engineering
Inverse-FFNN model Identification and Control of the Three-Tank-System

The input layers were selected as 12, the hidden layers 6 and the output layers 2

with its topology in Figure 6.42a. The final FFNN model obtained after training is:

𝑦(𝑘) = 𝑊𝑜𝑢𝑡 [𝑓ℎ (𝑊𝑖𝑛 𝜓(𝑘 − 1) + 𝑏𝑖𝑛 )] + 𝑏𝑜𝑢𝑡 (6.57)

where

𝑦(𝑘) = [𝑞̂1 (𝑘) 𝑞̂2 (𝑘)]T

Obafemi Awolowo University 30


Chemical Engineering
Inverse-FFNN model Identification and Control of the Three-Tank-System

𝜓(𝑘 − 1) = [ℎ1 (𝑘 + 1), ℎ1 (𝑘), ℎ1 (𝑘 − 1), ℎ1 (𝑘 − 2), 𝑞1 (𝑘 − 1), 𝑞1 (𝑘 − 2), 𝑞2 (𝑘 − 2),

𝑞2 (𝑘 − 1), ℎ2 (𝑘 − 2), ℎ2 (𝑘 − 1), ℎ2 (𝑘), ℎ2 (𝑘 + 1)] (6.58)

The activation function is chosen as:

2
𝑓ℎ (𝑥 ) = ( −1 (6.59)
1+𝑒 −2𝑥 )

Simulink block diagram (Fig. 6.42b) was used for the implementation of this

control scheme while Figure 6.43 gives the simulation results which are quite

satisfactory.

Obafemi Awolowo University 31


Chemical Engineering
FFNN nonlinear IMC control of the three-tank-system

It is implemented here a nonlinear IMC strategy which uses FFNN model for

prediction and Inverse FFNN model as the controller (Figure 6.44a). The

simulation results obtained are shown in Figure 6.44b. The results are quite

satisfactory except for the spikes observed in the control signals.

Obafemi Awolowo University 32


Chemical Engineering
Inverse-FFNN Model Architecture

𝒉𝟏 (𝒌 + 𝟏)

𝒉𝟏 (𝒌)

𝒉𝟏 (𝒌 − 𝟏)

𝒉𝟏 (𝒌 − 𝟐)

𝒒𝟏 (𝒌 − 𝟏)

𝒒𝟏 (𝒌 − 𝟐)
̂𝟏 (𝒌)
𝒒

𝒒𝟐 (𝒌 − 𝟐)

𝒒𝟐 (𝒌 − 𝟏) ̂𝟐 (𝒌)
𝒒

𝒉𝟐 (𝒌 − 𝟐)

Figure 6.42a: The topology of the


𝒉𝟐 (𝒌 − 𝟏)

𝒉𝟐 (𝒌)
inverse-FFNN model
𝒉𝟐 (𝒌 + 𝟏)

Obafemi Awolowo University 33


Chemical Engineering
NN-Inverse Model Controller Design

Figure 6.42b: Block diagram for implementing inverse-FFNN Controller

Obafemi Awolowo University 34


Chemical Engineering
Simulation Results

Figure 6.43: Process inputs and outputs using Inv-ANN as controller

Obafemi Awolowo University 35


Chemical Engineering
ANN model based Nonlinear Internal Model Control

M=ANN model
C=ANN-Inverse Model
P=Plant
F=Filter

Figure 6.44a: Block diagram for implementing ANN model based


nonlinear IMC

Obafemi Awolowo University 36


Chemical Engineering
Simulation Results

Figure 6.44b: Process inputs and outputs using FFNN nonlinear IMC
Obafemi Awolowo University 37
Chemical Engineering
Experimental Results

To verify the applicability of the proposed NMPC design procedures, the

designed controllers were implemented on the laboratory scale three tank

system. The experimental results obtained were plotted as Figures 6.45 – 6.49.

Obafemi Awolowo University 38


Chemical Engineering
Experimental Results

It is noteworthy that the experimental results were very similar to the simulation

results except for the Inverse-ANN controller and ANN-NIMC whose control

signals were changing very rapidily. This is because discrete time inverse-model

based controllers are always very sensitive to process noise and sampling time.

These results also confirm the practical implementability of the developed model-

based control algorithms in this work.

Obafemi Awolowo University 39


Chemical Engineering
Experimental Results

Figure 6.45: Experimental results of implementing First-Principle(FP)

model based - NMPC

Obafemi Awolowo University 40


Chemical Engineering
Experimental Results

Figure 6.46: Experimental results of implementing FFNN-NMPC

Obafemi Awolowo University 41


Chemical Engineering
Experimental Results

Figure 6.47: Experimental results of implementing RNN-NMPC

Obafemi Awolowo University 42


Chemical Engineering
Experimental Results

Figure 6.48: Experimental results of implementing Inverse-FFNN


control

Obafemi Awolowo University 43


Chemical Engineering
Experimental Results

Figure 6.49: Experimental results of implementing FFNN-based


Nonlinear IMC

Obafemi Awolowo University 44


Chemical Engineering

You might also like