Process Simulation Using MATLAB
Process Simulation Using MATLAB
MATLAB
Most chemical process models are nonlinear and
rarely have analytical solutions. However, numerical
solutions ca be easily obtained using MATLAB
F2
F1
F1 = R1 h1 - h2
F2 = R2 h2
Parameter values
ft 2.5
R1 = 2.5
min
5 ft 2.5
R2 =
6 min
A1 = 5ft 2
A2 = 10 ft 2
d ( r A2 h2 )
= r F1 - r F2
dt
dh1 F - R1 h - h
2
f (h , h , F )
dt A1 A1 1
= 1 1 2
f
h
h
F
,
,
dh
R
R
(
)
2
1
2
2 1 2
h
h
h
1
2
2
dt A2
A2
h1 - h2 = 0
h1 - h2 -
R2
A2
h2 = 0
Question
What are the responses of tank height if the initial heights are
h1(0)=12 ft and h2(0)=7 ft ?
Assume the system is at steady-state initially. What are the
responses of tank height if
F changes from 5 to 7 ft3/min at t = 0
F has periodic oscillation of F = 5 + sin(0.2t)
F changes from 5 to 4 ft3/min at t = 20
12
F = 5 + sin(0.2t)
12
h1
h2
11
11
10
height
height
10
h1
h2
8
7
7
10
20
30
40
50
60
70
80
90
100
50
100
time
150
time
20
11
18
10
h1
h2
16
height
height
8
14
12
7
6
10
20
40
60
80
100
time
120
140
160
180
200
20
40
60
80
time
100
120
140 150
x& = f ( x, u )
A linear model is a subset of the general modeling equation.
The form of linear model is called as a state-space model.
x& = A x + Bu
x : state vector (its elements are referred to as state variables)
u : input vector of manipulated variables
Matrices A and B are constant matrices
Example: Consider two tanks in series where the flow out of the
first tank enters the second tank. Assume the flow out of each
tank is a linear function of the tank height
F
F1 = R1 h1
F1
F2 = R2 h2
F2
Material balance
dh1 F R1
=
- h1
dt
A1 A1
dh2 R1
R
=
h1 - 2 h2
dt
A2
A2
&
A1
h1
=
&
h2 R1
A
2
0
1
h
1 + A1 F
R2 h2
-
0
A2
x& = A x + B u
Additional equation associated with a state-space model
y = C x + Du
y : vector of output variables
Output variables are typically a subset of x. They are variables
that can be measured or are of particular interest in a
simulation study
Ex: Both tank height are outputs
1 0 h1
y=
= Cx
0 1 h2
( D = 0)
General form
dx1
= a11 x1 + a12 x2 + L + a1n xn + b11u1 + L + b1m u m
dt
M
M
dxn
= an1 x1 + an 2 x2 + L + ann xn + bn1u1 + L + bnm um
dt
y1 = c11 x1 + c12 x2 + L + c1n xn + d11u1 + L + d1m u m
M
Matrix form
x&1 a11 a12
M = M
M
x&n an1 an 2
y1 c11 c12
M = M
M
yr cr1 cr 2
L b1m u1
O M M
L bnm um
L d1m u1
O M M
L d rm um
x& = A x + Bu
y = Cx + Du
[y,t,x] = step(sys)
sys
[y,t,x] = impulse(sys)
sys
dimension of y : T x r x m
T = length of t
r = number of outputs
m = number of inputs
[y,t,x] = lsim(sys,u,t,x0)
sys t u
x0
State-Space
(Continuous)
A, B, C, D
Mux ()
Demux () (Signal Routing)
Mux:
Demux:
Exercise
u
x
0
0
2
2
2
2
y1 2 6 x1
y = 1 -1 x
2
2
Find the responses for
unit step input of u1
unit step input of u2
u1 = sin(t)
Using
MATLAB functions
Simulink