SE3
Prof. Davide Manca – Politecnico di Milano
Dynamics and Control of Chemical Processes
Solution to Lab #3
Design of a control system
changes linearly with the level:
System representation
Data:
3 2 1
2 2
2 1
9.4 m s 30 m
50 m 1.2 s m F
iA A r
A
2h
2A
1h
1F
ir
1LC
F
oI.C.:
2
6.6 m h
F
o1.43
2F
o h
Tasks
1. Determination of the parameters of the proportional and the proportional- integral control systems by means of the Cohen-Coon method assuming there is a step disturbance on the inlet flowrate, such that it doubles. The task of the control system is to keep the steady state, i.e. to keep constant the level in the second tank. Assume that the system is in steady state when the step disturbance occurs.
2. Evaluate the system dynamics in closed loop.
Controlled variable:
Level of the second tank
Manipulated variable:
Valve opening =
= second tank outlet flowrate
Control philosophy
Design of a control system with Cohen-Coon method
• Assign a step disturbance on the variable that could change during the plants operations (inlet flowrate);
• Find the dynamics of the controlled variable (liquid level in the second tank) in open-loop, i.e. without the control system;
• Find the characteristic parameters of the system:
time delay: ;
gain of the system ;
Characteristic time to reach the new steady state: .
• Find the control system parameters according to specific formulas.
t
d
K
Controller parameters
1 1
3
d c
d
K t
K t
1 0.9
12 30 3
9 20
d c
d
d
I d
d
K t
K t t t
t
Proportional control
Proportional-integral control
Characteristic parameters of the system
time
t
d h
2 ,
2 s old
h
,
2 s new
h
, ,
2 2
s new s old
new old
i i
h h
K F F
old = steady state condition before the disturbance new = steady state condition after the disturbance
Gain of the system:
Evaluation of the open-loop dynamics
1 2
1 1
1
1 2
2 2
1 i
o
h h A dh F
dt r
h h
A dh F
dt r
A
2h
2A
1h
1F
ir
1F
oLC
Dynamics of the system
1.43
2F
o h
Open-loop outlet flow rate law:
Evaluation of the steady state conditions
1 2
1
1 2
1
0
0
s s
s i
s s
s o
h h
F r
h h
r F
3
1 1 2
9.4 m s
17.9 m
s s
o i
s s s
i
F F
h r F h
System dynamics for a step disturbance
Parametri del sistema
0.696
=115.6
=8.8114
D
K
0 200 400 600
6 8 10 12 14
Tempo [s]
Altezza liquido [m]
System parameters:
0.696s m
2115.6 s
D
8.8s K
Time [s]
Liquid level [m]
Open-loop dynamics
0 200 400 600
0 10 20 30 40
Tempo [s]
Altezza liquido [m]
Serbatoio 1 Serbatoio 2
35.7 m
13.1 m
Time [s]
Liquid level [m]
Tank 2 Tank 1
Proportional controller model
s
2 2 s
o c
F F K h h
The general form of the model of the proportional control is:
s c SP
c c K y y
Where is the bias, i.e. the value of the manipulated variable when the
controlled variable is at the set-point. In this case a valve on the inlet flowrate is manipulated and the net result is the modification of the second tank outlet
flowrate.
Assuming a linear relationship between the valve opening degree and the outlet flowrate, the controller model can be re-written as:
c
sThe model of the system becomes:
1 2
1 1
1
1 2
2
i
s s
h h A dh F
dt r
h h
A dh F K h h
Proportional control
Open-loop P control
0 200 400 600
6 8 10 12 14
Tempo [s]
Altezza liquido [m]
Time [s]
Liquid level [m]
Proportional-Integral controller model
s
2 2 s
c 0t
2
2 s
o c
I
F F K h h K h t h dt
c 0t
s c SP SP
I
c c K y y K y t y dt
Assuming a linear relationship between the valve opening degree and the outlet flowrate, the controller model can be re-written as:
The model of the system becomes:
1 2
1 1
1
1 2
2
2 2 2 2 2
0 i
s s c t s
o c
h h A dh F
dt r
h h K
A dh F K h h h h dt
dt r
The general form of the model of the proportional-integral control is:
Integral evaluation
PROBLEM: the integral should be evaluated at the current time-step of the ODE system integrator.
The definite integral can be numerically evaluated by means of the trapezoidal rule. For example:
h
2t t
2 2
2
2
2 0 0 2
2
t s t s
I
h t h dt h t h h The error is toohigh!!
Integral evaluation
It is possible to reduce the numerical error by increasing the number of trapezoids used to fit the integral:
h
2t
2 2
2
2
2 0 1
1 2
2
t s N s
n
I h t h dt t h n t h n t h
Number of steps (a priori assigned)
Behaviour of a general integrator
• The integrator calls the function of the differential system is written (Sisdif in the following) at non-equispaced time steps;
• The integrator can re-call the Sisdif at former time steps than the last one;
• Not all the evaluations of the Sisdif contribute to the problem solution. Some of them can be used, for instance, for the evaluation of the Jacobian matrix.
Furthermore, if the error overcomes the tolerance, the integration steps fails and it is not used for the solution estimation. In this case, the integration step is reduced.
Behaviour of a general integrator
h
2t t
: successful time step
: failed step decrease of the integration step
Solution procedure
1. The integral is solved for equispaced intervals (ex. ), i.e. the integration horizon is broken into equispaced sub-intervals:
h
2t t
t 0 t
1 s
t
2. The differential system is solved in each one of these intervals, evaluating the integral at each step made by the integrator as sum of trapezoids. As
reference value to compute the integral, the value of the integral in the first sure former step is used.
Assume to start from time and to integrate up to . The integral has been formerly computed. The integrator will proceed step-by-step up to reach . In the intermediate steps, the integral is evaluated as:
with
1
1
2 2 1 2 2 1
2
22
t s s
t
t t
I h t h dt I t h t h t h
t t
1t t
2
1I t
t t
21 2
t t t
Solution procedure
Solution procedure
First integration step
t1 t1 t2
2
1h t
2
1h t
1 1 1 1
2 1 2 1 2 2 2 t t s
I t I t h t h t h
2 1 2 1
2 2 2 1 2 2 2 t t s
I t I t h t h t h
t1 t2 t2
2
1h t
2
2h t Second integration step
MATLAB implementation
2
2 2
2 2 t
sI t dt I t h t h t t h
2
2 2
2 2
I t d I t h t h t h
s Main
Sisdif
0 dt
MATLAB implementation (Main)
Variable initialization:
t(1) = 0.; % Time vector[s]
h1(1) = h1_s; % Level of tank 1 in steady state [m]
h2(1) = h2_s; % Level of tank 2 in steady state [m]
integral = 0.;
dt = 1.; % Integration step[s]
tSpan = [0. dt];
h0 = [h1_s h2_s]; % Initial conditions
System dynamics evaluation:
for i = 2:nStep clear t y
options = odeset('RelTol',1E-8,'AbsTol',1E-10,'OutputFcn',@Printo);
[t,y] = ...
ode45(@(t,y)Sisdif(t,y,A1,A2,r1,Fi,Fo_s,h2_s,Kc,tauI, ...
t(i-1),h2(i-1),integral),tSpan,h0,options);
dim = length(t);
t(i) = t(dim);
h1(i) = y(dim,1);
h2(i) = y(dim,2);
integral = integral + (h2(i)+h2(i-1)-2*h2_s) * dt/2;
tSpan = tSpan + dt;
h0 = [h1(i) h2(i)];
MATLAB implementation (Main)
MATLAB implementation (Sisdif)
function dy =
Sisdif(t,y,A1,A2,r1,Fi,Fo_s,h2_s,Kc, ...
tauI,tPrec,h2Prec,integralPrec)
dy = zeros(2,1);
h1 = y(1);
h2 = y(2);
integral = integralPrec+(h2Prec+h2-2*h2_s)*(t-tPrec)/2;
dy(1) = (Fi – (h1-h2)/r1) / A1;
dy(2) = ((h1-h2)/r1-(Fo_s + Kc*(h2-h2_s)+ ...
Kc/tauI*integral))/A2;
Remark: do not overwrite integralPrec because it comes from the Main
MATLAB implementation (Sisdif)
function status = Printo(t,y,flag) global integral tOld fOld h2_s
if strcmp(flag, 'init') % initialization of the integration elseif strcmp(flag, 'done')% the integration is complete 'tEND' else % integration is in progress
h2 = y(2);
er = h2_s - h2;% measure the error at every step
fNew = er; % I define fNew the current value of the error tNew = t; % Memorize the last integration time
integral = integral + (fOld + fNew) * (tNew - tOld) / 2.;
% trapezoids
fOld = fNew; % the new becomes the old for the next step
Proportional-Integral controller
0 200 400 600
6 8 10 12 14
Tempo [s]
Altezza liquido [m]
Open-loop P control PI control
Time [s]
Liquid level [m]
Proportional-Integral controller
P control PI control
0 50 100 150 200
6.5 7 7.5
8 8.5
9
Time [s]
Liquid level [m]
0 50 100 150 200
6 7 8 9 10
Time [s]
Liquid level [m]
Set point