Professional Documents
Culture Documents
ChemProcessModelling With Matlab PDF
ChemProcessModelling With Matlab PDF
TABLE OF CONTENTS........................................................................................................................... 1
PREFACE................................................................................................................................................... 3
1
8 PARAMETER ESTIMATION ......................................................................................................81
8.1 INTRODUCTION .........................................................................................................................81
8.2 LINEAR REGRESSION ................................................................................................................81
8.3 NONLINEAR REGRESSION .........................................................................................................85
8.4 REGRESSION ANALYSIS ............................................................................................................87
8.5 SUMMARY ................................................................................................................................92
9 INDEX..............................................................................................................................................93
2
Preface
Process Simulation using MATLAB is a set of lecture notes for the course
Process Simulation at the Department of Chemical Engineering, Lund Institute of
Technology, Lund, Sweden. Current version contains eigth chapters on modelling,
simulation methods, simulation tools and on parameter estimation. There are
corresponding exercises for the chapters and they are found on the course home page at
the site.
http://www.chemeng.lth.se
The course is inspired by the textbook, Computational Methods for Process Simulation,
by Fred Ramirez. This book serves as a reference in the course.
Simulation techniques presented in the course are frequently solved using MATLAB.
The solutions to examples and exercises sometimes use predefined MATLAB functions,
while others are programmed by the user in MATLAB M-files. There is no need for a
deep knowledge about MATLAB before entering the course. There is no need for
additional toolboxes to solve the exercises in the course.
Bernt Nilsson
3
1 Development of Lumped Models
1.1 Introduction
The basic properties in process systems are the conservation of mass, energy and
momentum. In process modelling this is formulised into the development of
mathematical expressions representing balance equations of mass, energy and
momentum. Conservation of a property follows the general balance expression below
Sometimes the generation and consumption terms are expressed as only one production
term as
In + Production = Out + Accumulation
This principle is illustrated in Figure 1.1 below. The definition of the system boundary
is important in order to develop the different terms in the balance equations. The system
boundary can be over a macroscopic object or over a microscopic fluid element.
momentum
mass SYSTEM
energy energy
In + = + Out
Production Accumulation
mass
momentum
The most convenient way of developing models is to ignore the spatial aspects of the
system that is going to be modelled. This means that all spatial properties are lumped
together and the model describes the integral averaged value of the properties. This is
the reason why this kind of models is called lumped models or models of lumped
systems. Models that describe spatial properties are called distributed models but they
are discussed in a later chapter.
Model assumptions:
4
Total mass in the system is m. No limits on the amount of mass in the tank. m
can be infinite large and it can be negative.
The mass flow rates are expressed as w. In this particular case the mass flow
rates are independent of the mass inside the system.
The total mass balance over the control volume now becomes
Control
volume
Solution
120 kg/hr
The mass balances can often be rewritten into other variables. Below follows two
examples of such transformations.
5
pVM w
d
RT = w + w w
w e s
dt
VM w dp
= ww + we ws
RT dt
We see that the two component mass balances sum to form the total mass balance.
The ethanol component mass balance become
d (m )
= we ws s
dt
The conservation of mass is valid for each chemical component. It is often more
convenient to express it in composition instead of mass. This means that the component
mass balance must be rewritten using the rule for the derivative of a product.
d (m ) d dm
= m +
dt dt dt
This manipulation is just pure mathematics. Remember that the left hand side is the
component balance and the second part of the second term on the right hand side is the
total mass balance. Let us rewrite it as
6
d 1 d (m ) dm
=
dt m dt m dt
This means that both the total mass balance and the component balance are used to
derive an expression of the composition change.
The total mass balance from Example 1.1 and the component balance from
Example 1.4 are used together to derive the change of composition.
dm
= ww + we ws
dt
d (m )
= we ws s
dt
d (m ) d dm
= m +
dt dt dt
d 1
= (we ws ) (ww + we ws )
dt m m
=
we
(1 )
ww
m m
Note that this expression is only valid when the total mass is nonzero (positive).
Component mass balances are often rewritten into component mole balances, using m =
M n. It can further be rewritten using concentrations, using m =M n = M V c. This
means that a component mass balance can be transformed into a component mole
balance just by dividing all terms with the molar weight of the chemical component.
7
In = Out + Acc
dm
win = wout +
dt
q
d ( MVc)
Mqin cin = Mqout cout + c in V cout
dt
dc
qcin = qcout + MV
dt
Figure 1.3: A Mixing Tank
= (cin c )
dc q
dt V
= (C C1 )
dC1 dC1 q
qCin = qC1 + V1
dt dt V1 in
= (C1 C2 )
dC dC2 q
qC1 = qC2 + V2 2
dt dt V2
and rewritten on state-space form using matrices it becomes
q
0 q
d 1 V1
C C1
= + V1 Cin
dt C2 q q C
2 0
V2 V2
8
At steady state the accumulation terms are zero and in this case this is the same as
the concentration derivatives are zero. Instead we get the following algebraic
equation system (linear in this case). Note that the solution is trivial.
q
V 0
C
q
1 1 = V1 Cin
q q
C2 0
V2 V2
L, x6 V, y7
Figure 1.5: Six-plate adsorption column. left) column configuration, right) column tray
yi= axi + b
Let us put up the six component balances together with the equilibrium relation
In = Out
1: Lx0 + V (ax2 + b)= Lx1 + V (ax1 + b)
2: Lx1 + V (ax3 + b)= Lx2 + V (ax2 + b)
3: Lx2 + V ( ax4 + b)= Lx3 + V (ax3 + b)
4: Lx3 + V (ax5 + b)= Lx4 + V (ax4 + b)
5: Lx4 + V ( ax6 + b)= Lx5 + V (ax5 + b)
6: Lx5 + Vy7 = Lx6 + V (ax6 + b)
9
1.4 Energy Balances
In process systems chemical components are transformed into other chemicals under
energy changes. Energy is released or consumed in the reaction step and it is often
consumed in the separation step. Energy balances are important parts of the process
model in analysis and design. Total energy can be decomposed into different energy
forms, similar to the decomposition of total mass into component masses. The most
common decomposition of total energy is into thermal energy and mechanical energy.
There are other energy forms like electrical and magnetically energy.
U is the internal energy, K is the kinetic energy and P is the potential energy, all three
per mass unit. The three energy forms enter and leave the system in the process streams.
Energy can also be transferred into and from the system, Qin and Qout and it can be
produced in the system through reaction and phase change, Qp. The work done by the
system on the surroundings is shaft work, W, and pressure/volume work, WpV. The most
common situation is when the internal energy dominates the total energy balance. Then
kinetic and potential energy are neglected and we get
The enthalpy of a system can be expressed as the sum of the internal energy and the
pressure-volume
p
H =U +
If we use this and assume that the change of the pressure-volume is neglectable the
internal energy balance can be expressed as an enthalpy balance
p
d m H
p p
= in H out H + in p in out p out + Q P + Qin Qout W
dt in out in out
d (mH )
= in H in out H out + Q P + Qin Qout W
dt
10
The enthalpy in the tank is equal every where and that the outflow enthalpy is the
same as the tank enthalpy. The density is constant.
In = Out + Acc
d (Vh)
q in in hin = q out out hout +
dt
q
dh
qhin = qh +V Tin V Tout
dt
= (hin h )
dh q
Figure 1.6: A Mixing Tank
dt V
Assume also that the enthalpy can be expressed as proportional to the temperature
difference from reference temperature as
H = C p ,m T
d (C p , m (T T0 ))
= (C p , m (Tin T0 )in C p , m (T T0 ))
q
dt V
= (Tin T )
dT q
dt V
This is only valid under the assumption that the heat capacity is (or almost)
constant.
One major difference between mass and energy balances compared to momentum
balance is that momentum has direction. This means that we can put up one momentum
balance for each dimension in the modelling problem. Momentum balances becomes
11
much more important in distributed models and is the fundamental issue in
Computational Fluid Dynamics, which will be discussed more in a later chapter.
1.6 Summary
Lumped models are based on the assumption that spatial effects can be neglected.
Lumped models are often composed of a set of mass, component and thermal energy
balances. Under the assumption that we are studing steady-state behaviour the lumped
model results in a algebraic equation system, which is discussed in the next chapter.
Unsteady-state or transient behaviour studies results in a set of ordinary differential
equaitons in time. Simulation of unsteady-state models is discussed in chapter three.
12
2 Steady-State Simulation of Lumped Models
2.1 Introduction
A steady-state lumped model results in a set of algebraic equations. These algebraic equations
describe static relations between a set of variables. The equation system can be solved if
the number of equations is the same as the number of variables. For computational
reasons one often differs between linear and nonlinear equation systems. Nonlinear
steady-state lumped models can be written on a general form as
f 1(x1 , x 2 , ..,x n ) = 0
f 2 (x1 , x 2 , ..,x n ) = 0
...
f n (x1 , x 2 , ..,x n ) = 0
f(x) = 0
If the algebraic equation system is linear it can have the following representation
or
Ax = u
using matrix notation. First we discuss one numerical method for the solution of linear
algebraic equation system, namely Gaussian elimination, and then different nonlinear
equation solvers are discussed.
LU-decomposition
In MATLAB LU-decomposition is done by the command lu(A). The lu-command
returns the two triangular matrices, L and U, and a partitioning matrix, P. Partitioning is
done if the diagonal element, the pivots, becomes zero or very small and it is done by
reordering the rows. To solve the linear equation system, Ax = b, in MATLAB one can
write x = A\b. Note the backslash notation on the left hand side which is interpreted
as left division of vector b by matrix A. This command implicitly makes a lu-
decomposition with pivoting.
13
Example 2.1: Six-Plate Absorption Column
An absorption column with six plates is used to absorb a chemical component in a
vapour into a liquid. The liquid, L, enters at the top and the vapour, V, enters at
the bottom. It is assumed that the liquid and vapour flow rates do not change
through the column.
L, x0 V, y1
1
2 xi-1 yi
3
Tray i
4
5 xi yi+1
6
L, x6 V, y7
Figure 2.2: Six-plate adsorption column. left) column configuration, right) column tray
In = Out
Lxi 1 + Vyi +1= Lxi + Vyi
yi= axi + b
Let us put up the six component balances together with the equilibrium relation
In = Out
1: Lx0 + V (ax2 + b)= Lx1 + V (ax1 + b)
2: Lx1 + V (ax3 + b)= Lx2 + V (ax2 + b)
3: Lx2 + V (ax4 + b)= Lx3 + V (ax3 + b)
4: Lx3 + V (ax5 + b)= Lx4 + V (ax4 + b)
5: Lx4 + V ( ax6 + b)= Lx5 + V (ax5 + b)
6: Lx5 + Vy7 = Lx6 + V (ax6 + b)
This can now be rewritten with unknowns on the left and remember that x0 and y7
are known values.
14
( L + Va ) x1 + Vax2= Lx0
Lx1 ( L + Va ) x2 + Vax3= 0
Lx2 ( L + Va ) x3 + Vax4= 0
Lx3 ( L + Va ) x4 + Vax5= 0
Lx4 ( L + Va ) x5 + Vax6= 0
Lx5 ( L + Va ) x6 = Vy7
a = 0.72;
b = 0;
V = 66.7;
L = 40.8;
x0 = 0;
y7 = 0.3;
eyelow = diag(ones(1,5),-1);
A = -(L+V*a)*eye(6) + L*eyelow+ V*a*eyelow';
u = [-L*x0 0 0 0 0 -G*a*(y7-b)/a]';
x = A\u
x =
0.0921
0.1703
0.2368
0.2933
0.3413
0.3820
Note the creation of a matrix with ones on the lower off diagonal, eyelow. It is
also used to create the elements in the upper off diagonal and this is done by
transposing the matrix, eyelow'. Note also that the u-vector is defined as a row
but it is transposed at the end.
15
Example 2.3: Analysis of the Six-Plate Adsorption Column
The rank and the reciprocal condition number of the problem are calculated by the
following commands:
r = rank(A)
r =
6
c = rcond(A)
c =
0.0508
f(b) f(b)
a c a c
b b
f(a) f(a)
f(c)
16
Another simple method is the Regula Falsi or linear inverse interpolation. The idea is to
make an interpolation between two function values with different sign. The zero of the
interpolation is now used as a new function value. The method is illustrated on the right
in Figure 1.
fzero
The fzero method in MATLAB can be use for nonlinear problems in one unknown
variable. It is a combination of bisection and secant methods (using inverse quadratic
interpolation). The secant method is a simplified Newton method.
The Cpfun can now be used in the nonlinear equation solver fzero. The first
input variable to fzero is a string with name of the function (M-file). The
second is the starting guess of the unknown variable, in this case T.
T = fzero('Cpfun',600)
T =
443.5712
Note that fzero can only find the zero for a nonlinear function in one unknown.
In nonlinear problems with more than one unknown other types of solvers are needed.
One simple and often used method is direct substitution. It can be used in multi
dimensional problems but it is more used in problems with one unknown. The most
dominating method is a multidimensional version of the Newton method.
Direct substitution
A third simple method is called direct substitution and this is very common method.
The algebraic problem is rewritten as
0 = f ( x) = g ( x) x
and put on the following form
17
The procedure starts with a guess of x0. The initial guess is used to calculate g(x0) and
the answer is a new value of x, i.e. x1, and the procedure can now be repeated until x
converges. Direct substitution has problems for equation systems with derivatives
greater than one, as seen in Figure 1.3. The problem on the right converges quite rapidly
while the problem on the left diverges.
g(x1)
al
al
on
on
ag
ag
di
di
g(x0) g(x0)
g(x1)
g(x2)
x2 x1 x0 x0 x1 x2
Figure 2.3 - right) Converging direct substitution, left) Diverging direct substitution.
f ( x ) = f ( x 0 ) + f ' ( x 0 )( x1 x 0 ) + HOT
At the solution the function f is zero and let us through away higher order terms.
0 = f ( x 0 ) + f ' ( x 0 )( x1 x 0 )
The approximation can now be rewritten where a new x-value are calculated based on a
function evaluation, f, and its derivative, f'. The calculations are now repeated in order
to find a new even better value. A graphical interpretation is seen in Figure 2.4.
f ( x0 )
f ( x 0 ) = f ' ( x 0 )( x1 x 0 ) x1 = x 0
f ' ( x0 )
f'(x0)
x2 x1 x0
Figure 2.4 The Newton-Raphson method.
18
The Newton method converges to a solution if we start close enough. For some
problems it is hard to find good starting guesses in order to get a desired Newton
solution. Other problems can be slow converging rates and some times the derivative
goes to zero and the problem becomes singular.
Problems are very often multidimensional, i.e., contains more than one unknown.
Sometimes it is possible to rewrite multidimensional problems as a one-dimensional
problem by making symbolic manipulations. Even when it is possible it may be
undesirable.
A multidimensional nonlinear problem is written as iteration of a linear equation
system. Define J as the Jacobian matrix, which is a matrix with the partial derivatives as
elements
f 1 f 1
x 1 x 2 x0
f ' ( x ) x0 = J ( x 0 ) =
x0
f 2 f 2
x 1 x 2 x0
x0
Note that the notation x1 and x2 is the definition of the two unknowns. Make a
multidimensional Newton method and rewrite it as a linear equation system
f ( x 0 ) = J ( x 0 )( x 1 x 0 ) J ( x 0 ) x 1 = J ( x 0 ) x 0 f ( x 0 )
F, CA0, T0 F, CA, T
TC
Figure 2.5 - Continuous stirred tank reactor.
A steady-state model with one component material balance and one energy
balance is as follows
19
In + Prod = Out
FC A 0 + VR = FC A
FC p C A 0 + ( H )VR = FC p C A + kA(T TC )
Ea
R = k 0C A e RT
1 1
50 ( )
0=1 e 2
1 1
50 ( )
0=(0 ) u1( c ) + e 2
function [res]=cstrss(x)
% CSTRSS is a dimensionless steady-state
% lumped model of an exothermic continuous
% stirred tank reactor. See Ramirez ex. 2.3
% parameters
u1=2;
nyc=1.75;
ny0=1.75;
% unknown variables
ksi=x(1);
ny=x(2);
% equations
P=ksi.*exp(50*(0.5-1./ny));
Us=u1.*(ny-nyc);
res=[1-ksi-P; (ny0-ny)-Us+P];
function [J]=cstrssJ(x)
% CSTRSSJ calculates the Jacobian for the
% dimensionless steady-state lumped model
% for an exothermic continuous stirred
% tank reactor. See Ramirez ex. 2.3
% parameters
u1=2;
nyc=1.75;
ny0=1.75;
% equations
ksi=x(1);
ny=x(2);
% equations
Pksi=exp(50*(0.5-1./ny));
Pny=(50./ny.^2)*ksi*exp(50*(0.5-1./ny));
Usny=u1;
J=[-1-Pksi, -Pny; Pksi, -ny-Usny+Pny];
20
This is now solved by the new2dim function
newsol
Advanced Newton solvers have routines for numerical differentiation. The newsol
MATLAB M-file is a method of this kind and it is a modification of a solver developed
by C.T.Kelley, called nsol. The user only have to specify the problem on residual
form as r = f(x), i.e. a set of algebraic equations. The numerical Jacobian is calculated
by the diffjac function and it is possible to change the updating mechanism of the
numerical Jacobian. There is no Newton solver in the basic MATLAB program but
there is one solver in Optimization toolbox called fsolve which is similar to
newsol.
The newsol Newton solver is used in the following ways. The solver only needs the
name of the user defined function and a column vector of initial guesses and it returns
the solution column vector as
There are some optional input arguments to newsol which makes it possible to set
tolerances, tol=[rtol atol] (relative/absolute tolerance), and to specify the Jacobian
update mechanism, param=[40 1 0 0], for more information use the help command. It
is possible to parameterise the function with the mpar input argument. This means that it
is possible to set parameters from the outside in the user defined function. The method
returns the solution, sol, the solution history, solhist, and an error indicator for a
successful iteration, ierr. It is also possible to return variables from the user defined
function to the outside through a fourth output variable, like mvar. A complete function
call to newsol look as follows
[sol,solhist,ierr,mvar]=newsol('cstrss',[1 1]',tol,param,mpar);
2.5 Summary
In the course we solve linear equation systems with Gaussian elimination as x = A\b.
Nonlinear equations can be solved by fzero, the predefined MATLAB function. The
nonlinear equation system solver, newsol, is used frequently throughout the course.
The solver is available on the course home page on the web.
21
3 Dynamic Simulation of Lumped Models
3.1 Introduction
An unsteady-state lumped model results in a set of ordinary differential equations, ODEs. These
equations describe time-dependent relations between a set of variables. Nonlinear
unsteady-state lumped models can often be written as ODEs on state-space form with
derivatives of the states explicitly on the RHS like
dx1
= f 1 ( x1 ,..., xn , u1 ,..., un )
dt
...
dxn
= f n ( x1 ,..., xn , u1 ,..., un )
dt
dx
= f ( x, u )
dt
dx1
= a11 x1 + a12 x2 +...+ a1n xn + b1u
dt
...
dxn
= an1 x1 + an 2 x2 +...+ ann xn + bn u
dt
dx
= Ax + Bu
dt
The difference between linear and nonlinear ODEs is not an important issue here as it
were in the steady-state case. Solvers of ODE systems are categorised into one-
step/multi-step methods and into explicit/implicit methods. The different methods and
their properties are briefly discussed in this chapter. First, explicit one-step solvers are
discussed, as they are simple and commonly used, followed by a short discussion about
implicit one-step solvers. Finally, the multi-step methods are discussed.
22
calculate a new step, i.e. a direct calculation without internal iteration or equation
solving.
Euler method
The simplest ODE solver uses the Euler method. Assume an ODE expressed on state-
space form as,
dx
= f ( x)
dt
dx
x (t + h) = x (t ) + ( t ) h + ( t ) h 2 x ( t + h) x ( t ) + f ( x ( t )) h
dt
One drawback with this method is that the error decreases proportional to the step-size.
This results in small step-sizes in order to keep the error low. A related problem is that
the solution can become unstable if the step-size is to large, see Ramirez section 3.1.
Assume a linear ODE written on state-space form and that it is stable, i.e. K > 0.
dx
= Kx
dt
x i + 1 = x i h Kx i = (1 h K ) x i
The stability of this discrete system is determined by the size of the coefficient in front
of the state variable, x. This coefficient is the eigenvalue for this simple system. If the
coefficient is less than one then the solution decreases and the solution is stable and if it
is larger than one then the solution x increases for each calculation and the solution is
unstable.
1 h K < 1 x i + 1 = (1 h K ) x i < x i x 0
1 h K > 1 x i + 1 = (1 h K ) x i > x i x
2
1 hK = 1 hK = 2 h =
K
23
The step-size for the Euler method for a linear ODE must be less than a given value in
order to give a stable solution.
2
h<
K
Example 3.1: Concentration Dynamics in a Mixing Tank Using the Euler Method
A tank with constant volume, V=1, and inflow, q=1 and inflow concentration
cin= 1, has the initial concentration equal to zero.
d (Vc )
= q in cin q out c out
dt
= q(c in c )
dc
V
dt
= (c in c )
dc q Figure 3.1: A Mixing Tank
dt V
function [dc]=onetank(t,c)
% ONETANK is a model of the concentration variation
% in a continuous tank.
% parameters
cin = 1;
q = 1;
V = 1;
% equations
dc = -q/V*c + q/V*cin;
[t,y]=eulers('onetank',0,10,0,20);
TY = [t' y']
TY =
0 0
0.5000 0.5000
1.0000 0.7500
1.5000 0.8750
2.0000 0.9375
2.5000 0.9688
3.0000 0.9844
3.5000 0.9922
4.0000 0.9961
4.5000 0.9980
5.0000 0.9990
5.5000 0.9995
6.0000 0.9998
6.5000 0.9999
7.0000 0.9999
7.5000 1.0000
8.0000 1.0000
8.5000 1.0000
9.0000 1.0000
9.5000 1.0000
10.0000 1.0000
24
2
1.8
1.6
c 1.4
o
n
1.2
c
e
n 1
tr
a
0.8
ti
o
n 0.6
0.4
0.2
0
0 2 4 6 8 10
time
Figure 3.2: Simulation of the concentration in a tank using Eulers method (5, 10, 20 and 100 steps).
The solution is shown in Figure 3.2. The plot illustrates the solutions with 5, 10, 20 and
100 steps. Figure 3.2 indicates that the solutions depend on the choice of step-size. The
solution goes unstable for step-sizes larger then 2. The solution based on 100 steps
(step-size = 0.1) are close to the exact solution.
Runge-Kutta methods
To increase the step-size the derivative approximation must include higher order terms.
In Runge-Kutta methods this is done by taking the average of a number of function
derivatives in the current step. The local error decrease with the number of derivatives
used. A fourth order Runge-Kutta solver called rk4, found in Mathews Numerical
Methods, is used to simulate the mixing tank example below.
1
0.9
0.8
c 0.7
o
n
0.6
c
e
n 0.5
tr
a
0.4
ti
o
n 0.3
0.2
0.1
0
0 2 4 6 8 10
time
Figure 3.3: Simulation of a tank using Eulers method (1000 steps) and RK4 method (10 steps)
25
in this case that the Runge-Kutta method performs very well. It uses only 1% of
the steps compared with Euler. On the other hand it uses 4 function evaluations in
each step, i.e. 40 function evaluations which is 4% compared to the 1000 function
evaluations in the Euler method used in this case. An Euler solution based on 10
steps is seen in Figure 3.2.
Below follows a brief presentation of a second order Runge-Kutta method. The basic
Runge-Kutta formula is as follows.
x ( t + h ) = x ( t ) + h e ( x ( t ))
A new step is explicitly expressed as a function of the previous step. The choice of the
e ( x (t )) function is different for different RK methods. A second order RK method has
the following expression
= ak 1 + bk 2
k1 = f (ti , xi )
k 2 = f ( t i + ph , x i + q x i ) = f ( t i + ph , x i + qhk 1 )
Make a Taylor expansion of the second function evaluation, k2. (HOT represents higher
order terms.)
Now use the two function evaluation expressions in the Runge-Kutta formula
x (t + h) = x (t ) + h(ak1 + bk2 )
(
xi +1 = xi + h af ( t i , xi ) + bf ( t i , xi ) )
( )
+ h 2 bpf t ( ti , xi ) + bqf ( t i , xi ) f x ( ti , xi ) + ( h 3 )
In order to find the parameters, a, b, p and q the RK formula is compared with a Taylor
expansion of the original ODE
x ( ti +1 ) = x ( ti ) + hf ( ti , x ( t ) i )
h2
+ ( f ( t , x ( t ) i ) + f x ( ti , x ( t ) i ) f ( ti , x ( t ) i ) ) + ( h 3 )
2 t i
We now have two expressions, one is the RK approximation and the other is the Taylor
expansion of the original equation. If the different terms in the both expressions are
assumed to be equal then we get the following expressions
26
x ( ti +1 ) = xi
f ( ti , x ( t ) i ) = ( a + b) f ( ti , xi )
1
( f ( t , x ( t ) i ) + f x ( t i , x ( t ) i ) f ( ti , x ( t ) i ) ) =
2 t i
(bpf (t , x(t ) ) + bqf
t i i x ( ti , x ( t ) i ) f ( ti , x ( t ) i ) )
This means that three RK parameters are given when the fourth parameter is assumed. If
we choose b=0 then it gives the Euler method. If we choose b=1 instead then it gives
a=0 and p=q=0.5 which is a midpoint approximation. The choice b=0.5 results in
a=0.5 and p=q=1. This RK method uses two function evaluations, one on each side of
the interval.
The Runge-Kutta method discussed above is a second order method based on two
function evaluations on the interval. Other RK methods like fourth order RK4 methods
uses four function evaluations on the interval. The error decreases with the order, i.e.
the number of function evaluation on the interval.
Variable Step-Size
To keep the step-size fixed at a given value is not common practice. Instead almost all
professional methods have variable step-sizes based on some kind of step-size control.
The step-size control is often based on the required error tolerance of the problem.
Runge-Kutta solvers have error estimators included in the code. These estimators must
have higher order than the actual solver. Therefore a second-order Runge-Kutta is
equipped with a third-order error estimator and a solver like this is called rk23 or as in
MATLAB ode23. In MATLAB there is also a fourth-order Runge-Kutta solver called
ode45. (In MATLAB 4 and older versions there are two kinds of ODE-solvers, ode23
and ode45. These are not used in this course. Instead there are new ode23 and
ode45 in the MATLAB ODE Suite. From a user point of view the only difference is
the set of input variables.)
RK methods in MATLAB
ODE-solvers in MATLAB have the following simplified syntax:
[T,Y] = ODE23('F',TSPAN,Y0);
TSPAN is a vector with the start and stop time, e.g. [0 10], and Y0 is the initial values.
[t,y]=ode23('onetank',[0 10],0);
27
TY=[t y]
TY =
0 0
0.0001 0.0001
0.0005 0.0005
0.0025 0.0025
0.0125 0.0124
0.0625 0.0606
0.1791 0.1640
0.3485 0.2943
0.5668 0.4328
0.8350 0.5663
1.1574 0.6860
1.5431 0.7868
2.0077 0.8664
2.5790 0.9251
3.3139 0.9649
4.3139 0.9883
5.3139 0.9961
6.3139 0.9987
7.3139 0.9996
8.3139 0.9999
9.3139 1.0000
10.0000 1.0000
xi+1 = xi + h f(xi).
Implicit solvers are based on the idea to use the new step in the function evaluation to
generate the new step, like
xi+1 = xi + h f(xi+1),
which in turn generates an implicit equation system. This means that an implicit method
solves a nonlinear equation system in each step. This results in very good stability
properties. In MATLAB, ode23s is an implicit second-order Rosenbrock solver.
Figure 3.4: Two-tank series left) same volumes right) different volumes.
Material balances over one chemical component in the two tanks becomes
28
In = Out + Acc
= (C C1 )
dC dC1 q
qCin = qC1 + V1 1
dt dt V1 in
= (C1 C2 )
dC dC2 q
qC1 = qC2 + V2 2
dt dt V2
The first case solved by ode23 is seen on the left in Figure 3.5. The solution by
ode23s of the second case is seen on the right in the same figure.
function [dc]=twotanks(t,c)
% TWOTANKS is a model of the concentration variation
% in a tank series of 2 tanks.
% parameters
c0 = 1;
q = 1;
V1 = 0.5;
Vtot = 1;
V2 = Vtot - V1;
% equations
dc = [-q/V1 0; q/V2 -q/V2]*c + [q/V1; 0]*c0;
Numerical statistics is clearly illustrated in the table below. In the first case the
two solvers take almost the same amount of steps but the nonlinear solver in the
implicit ode23s makes almost twice as much floating point operations, called
flops, compared with the explicit Runge-Kutta ode23. In the second case the
implicit ode23s takes some more steps and require 20% more flops compared
with the first case. The explicit ode23 needs almost 15 times more flops and
needs an enormous amount of steps.
Table 3.1: Number of steps and floting point operations during the solution of a two-tank problem
with stiffness properies.
V1 = 0.5 V1 =0.001
ode23 33 steps, 4968 flops 3995 steps, 63932 flops
ode23s 35 steps, 9453 flops 41 steps, 11143 flops
29
14 1.4
1.2 12
1 1
0.8 08
0.6 0.6
04 0.4
02 02
0 0
0 2 4 6 8 10 0 2 4 6 8 10
time time
Figure 3.5: Simulation of a two-tank series left) tanks with equal sizes
right)volume of first tank is 0.1% of the second
The implicit solver is superior in cases when fast dynamics die out and the interesting
dynamics is slow. Problems with these kinds of characteristics are called stiff problems.
Note that a simulation of the second case between 0 and 0.01 is not a stiff problem.
Adams Methods
Explicit multi-step methods are often called Adams-Bashforth methods. These methods
are rarely used because they have very small stability regions and they require very
small step-sizes. Methods like this are often modified. The explicit multi-step formula is
used as a prediction of the new step. This predicted value is then used in an implicit
multi-step formula, which correct the predicted value. This method uses direct
substitution to solve the nonlinear equation. In this way we get a semi-implicit multi-
step method with good performance. Methods like this are called predictor-corrector
methods or Adams-Bashforth-Moulton methods or just Adams methods. These methods
can also include variable step-size and variable order, both controlled by error
tolerances. In MATLAB there is a variable step-size variable order multi-step method
(Adams-Bashforth-Moulton) called ode113.
30
Table 3.2: Number of steps and floting point operations during the solution of a two-tank problem
with high accuracy.
default tolerances halved tolerances
ode23 33 steps, 6463 flops 251 steps, 40180 flops
ode45 81 steps, 13539 flops 201 steps, 31539 flops
ode113 46 steps, 13056 flops 95 steps, 25576 flops
Gear methods
True implicit multi-step methods are often based on backward difference formula, so
called BDF-methods. These methods were developed by Gear and are also called Gear
methods. The methods use a number of previous steps to approximate the derivatives,
backward differences. In MATLAB there is one BDF-method called ode15s. This
method is a variable order method between 1 and 5. BDF-methods with order higher
then 6 become unstable. ode15s has quasi-constant step-size control which means that
the step-size is fixed as long as possible. When the step-size is changed the solver must
recompute a number of previous steps. The ode15s method is very good on stiff
problems. Specially when the number of states increase then it performs better than
ode23s. (ode15s is actually a NDF-method which means numerical difference formula
and it uses numerical calculated derivatives instead of using previous function calls
direct.)
Table 3.3: Number of steps and floting point operations during the solution of a multi component
tank problem.
2 state system 8 state system
ode23s 35 steps, 9453 flops 41 steps, 170647 flops
ode15s 49 steps, 10701 flops 65 steps, 59228 flops
31
dx1
= f ( x1 , x 2 )
dt
0 = g ( x1 , x 2 )
The problem is a set of differential equations, f, and a set of algebraic equations, g. The
algebraic equations have to be fulfilled in each time step that the differential equations
as solved. These kinds of problems can be solved by implicit ODE-methods with
modified step-size control. In MATLAB the methods ode23t and ode15s can solve
DAE problems.
dx1
1* = f1 ( x1 , x 2 ) 1 0 dx dx
dt
dx 2 0 0 dt = f ( x) M dt = f ( x)
0* = f 2 ( x1 , x 2 )
dt
The matrix on the left hand side, M, is called the mass matrix. For DAE problems the
mass matrix is singular. To solve DAE problems in MATLAB the right hand side is
described in an m-file as usual and the mass matrix is defined in the options using
odeset.
M=[. . .];
options=odeset(Mass,M)
[t,y]=ode15s(@func,[0,1],x0,options);
In = Out + Acc
qC in = qC1 0 = q (C in C1 )
dC 2 dC 2
qC1 = qC 2 + V2 =
q
(C1 C 2 )
dt dt V2
This problem is solved using ode15s as follows. Define the right hand side of the
DAE syetm, i.e., the differential and algebric equations.
function dx=DynTankSeries(t,x)
c1=x(1);
c2=x(2);
cin=1;
q=1;
V2=1;
32
res=q*(cin-c1);
dc2=q/V2*(c1-c2);
dx=[res;dc2];
Then define the mass matrix and call the DAE solver.
The DAE solvers in MATLAB can not solve all kinds of DAE problems. They can only
solve index 1 problems. The index of a DAE problem is the number of timed the
equation system have to be differentiated in order to be a set of ODE:s. In the example
above the first equation only have to be differentiated once in order to be an ODE. The
derivative of the first concentration is equal to the derivative of the second
concentration. In general this is not the case and the solvers fail to solve the problems
indicating in the error message that the index is higher than one.
3.7 Summary
33
The ODE solvers in MATLAB6 are categorised in the table below. In ordinary
simulation problems the low order methods can be used, ode23 and ode23s. In
process simulation, high order stiff problems often occur in which ode15s is
preferable. These three methods are probably the ones that are used in the Process
Simulation course. The ode15s and ode23t can handle differential-algebraic
equation systems, DAE, but this is not discussed futher in the course.
34
4 Development of Distributed Models
4.1 Introduction
In the previous chapters process models are based on balance equations of mass, energy
and momentum over a lumped system. Inside the system the properties are uniform with
no spatial change. Lumped systems are well mixed and they have no spatial dependent
behaviour. In this chapter we are going to develop models for systems with spatial
change. The behaviour is distributed in the space dimension and therefore they are
called distributed systems or distributed parameter models. The development is similar
to lumped model development. The difference is that the balance equations are set up
for arbitrary small fluid elements or infinite small control volumes.
y z y
x x
Below we are discussing distributed models based on mass, energy and momentum
balances first in one space dimension, in this case x-dimension, and second very briefly
present balances in three dimensions.
For simplicity let us assume a convective flow of mass only in the positive x-direction.
The inflow of mass can be expressed as the density times the volume flow rate. In this
case the element surface, yz, times the velocity in x-dimension.
yz ( v x ) x
35
The outflow at x+x becomes
yz ( v x ) x + x
There is no generation of mass and therefore the total mass balance is as follows
Acc = In Out
d ( xyz )
dt
(
= yz ( v x ) x ( v x ) x + x )
Assume that the volume boundaries are time independent. This means that the control
volume derivative is zero and it is possible to divide all terms with the volume. Then let
the volume size goes to zero, i.e. take the limit when V goes to zero, and use the
definition of derivation. In the simple example with flow only in the x-direction the
total mass balance becomes
d v x x vx
(vx )
= x + x
=
d t x
t x
An equation, like the one on the right above, with derivatives in more the one
independent variable is called a partial differential equation, shortly just called PDE.
This particular PDE, with first order derivative in space and time, is called convective
type PDE or first order hyperbolic PDE.
In the general case there is a flow field in all directions giving changes in all directions.
Convection in three dimensions is just the sum of the individual convection terms.
= v x + v y + vz = ( v )
t x y z
Note the velocity vector v and the divergence of the velocity, the nabla operator. Below
follows a tube example based on an alternative development of the total mass balance. It
is based in the integral form of the ideas presented above.
0 L
36
The accumulation of mass in the control volume is the time derivative of the
volume integral of the density.
z + dz
d
Accumulation of mass =
dt ( A )d
z
The inlet and outlet of mass is in this case only convection dependent
Inlet of mass = v z A z
Outlet of mass = v z + dz A z + dz
The inlet and outlet terms are put on the same side and can be rewritten as the
primitive function of the integral of its derivative. We see that there is the same
integral on both sides of the equation.
z + dz z + dz
(v A )
d
dt ( A )d = vz A z vz + dz A [
z + dz = v A ] z + dz
z
=
d
z z
If the boundaries, z and z+dz, are time independent then the time derivative in the
accumulation term can be moved inside the integral.
(v )
z + dz z + dz
A
z
t
d = A z
d
Let us now remove the integral on the both sides and the result is a partial
differential equation.
(v )
=
t z
We see that the development in Example 4.1 results in the same equation.
Diffusion
In systems with molecular diffusion effects there will be additional terms in the mass
balance. Often one can assume that the molecular flux is proportional to the
concentration gradient described in Fick's first law.
37
dc A
J A = DAB
dx
This expression assumes a binary mixture where component A diffuse in a solvent B.
Let us derive a component balance with only molecular diffusion as diving force for the
fluid control volume in Figure 4.1. The mass of component A in the control volume is
the product of mole weight and concentration.
d
(M Ac A xyz )
dt
dc
yz (M A J A )x = yz M A DAB A
dx x
dc
yz (M A J A )x + x = yz M A DAB A
dx x + x
Let us now put these three terms together in a component mass balance of component
A.
d
(M Ac A xyz ) = yz (M A J A )x yz (M A J A )x+ x
dt
Divide all terms with the control volume and the mole weight. Let the volume size go to
zero.
dc A
=
1
((J A )x (J A )x +x ) c A = J A
dt x t x
38
The flux J can be expressed as Fick's first law which results in Fick's second law.
cA J c 2 cA
= A = DAB A = DAB
t x x x x2
A partial differential equation with a second order derivative in space and first order in
time is called a parabolic PDE. It is also some times called diffusion type PDE or heat
equation.
cA 2 cA
= D AB
t x2
Dispersion
In flow systems there appear a phenomenon called dispersion. This occurs in problems
with turbulent flow, flow in complicated passages such as packed beds or porous media.
Dispersion is mathematically expressed similar to diffusion.
dc A
J ax = Dax
dx
The major difference is that the dispersion coefficient, Dax, is flow dependent while the
diffusion coefficient is not. Below follows an example with dispersion in a tubular
reactor.
cL
c0
dc
Inlet of mole = vz Ac z Dax A
d z
39
dc
Outlet of mole = vz + dz Acz + dz Dax A
d + dzz
z + dz
Production of mole = (rA) d
z
(rA) d
dc dc d
v z Ac z + Dax A
d z
+ = v z + dz Ac z + dz + Dax A
d
+
dt ( Ac )d
z + dzz z
z + dz z + dz
c c
t ( Ac )d = vz Ac z Dax A z
vz + dz Ac z + dz + Dax A
+ (rA) d =
z + dzz z
z + dz z + dz
c
[
= v Ac ] z + dz
+ Dax A
z
+ (rA) d =
z
z
c
Dax A
z + dz
(v Ac ) z + dz
z + dz
d + (rA) d
= z
d + z
z
Remove all integrals and we get a partial differential equation with a second order
space derivative term.
c (vc ) 2c
= + Dax 2 + r
t z z
This kind of partial differential equation has one convective term (hyperbolic),
one dispersion term (parabolic) and one reactive term. It is a hyperbolic-parabolic
PDE.
Assume that the total energy is composed of internal energy and kinetic energy.
Accumulation of potential energy is neglected together with other energy forms.
d v2
U + xyz
dt 2
40
U represents the internal energy per mass unit. The difference between the convection
of energy in the x-direction is
v2 v2
ec = v x U + z y x v x U + z y x + x
2 2
Work done by the fluid element against the surroundings consists of work against
volume forces (gravity) and work against surface forces, such as pressure
ew = xyz (v x g x ) + pv x y x x pv x y x x + x
ev = yz ( xx v x ) x yz ( xx v x ) x + x
Put all terms together and taking the limit of the volume that goes to zero gives the
following energy balance
v2 v2 qx
U + =
t 2
vx U +
x 2 x
+ v x g x
x
( pv x ) ( v )
x xx x
This is a general distributed energy balance in on space dimension. Some special cases
are discussed below before the general case in three dimensions is presented.
H H
= v x
t x
41
Conduction
A third case is with no convection and only conduction. Let us assume that the heat
conduction follows the Fourie's law, where the heat flux is proportional to the
temperature gradient.
dT
q x =
dx
Using the general energy balance from above it beconmes
H q T 2T
= x = =
t x x x x2
Heat equation
For small temperature changes we can assume constant heat capacity, Cp,m, resulting in
the following energy balance expressed in temperature
T 2T
=
t C p ,m x 2
v2 v2
U + = v U + q + ( v g) ( pv ) ( v ) : v
t 2 2
d ( HxA)
dt
( )
= A H v x H v x + x + xLs Q
d C pT C p (T Tr )v x C p (T Tr )v x + x Ls Q
= +
dt x A
T T LQ
= v + s
t x Cp A
42
Use the knowledge of constant heat capacity and let the element size go to zero
and we get the last equation with a accumulation term on the left and a negative
convection term and one constant heat source term.
q x = k (Ts T )
T T kLs
= v + (Ts T )
t x C p A
d
( xyzvx )
dt
(
f m = mv + = yz v x v x x v x v x x + x
) + yz( xx x xx x + x
)
Forces on the control volume is composed of pressure forces and gravity forces
(
f f = Ap + mg = yz p x p x + x + g x xyz )
These terms can be put together to form the distributed momentum balance
d vx vx vx x vx vx xx x xx p x p x + x
= x + x
+ x + x
+ + gx
dt x x x
Once again take the limit of the volume that goes to zero and the one-dimensional
momentum balance becomes
43
( vx ) v x v x xx p
= + gx
t x x x
( v )
= vv p + g
t
where v and g are vectors. Note also that vv is a dyad (matrix variable) and is a tensor
(matrix variable).
Newtonian viscosity
Assume that the stress is proportional to the velocity gradient. This is called the
Newton's law and fluid is a Newtonian fluid
vx
xx =
x
The parameter is the viscosity coefficient.
Navier-Stokes Equation
Assume a Newtonian fluid and constant density, i.e. incompressible fluid. Then the
general momentum balance becomes the famous Navier-Stokes equation. Below it is
derived for the one-dimensional case, i.e. for the x-dimension (no gravity)
vx v v 2 vx p
= x x +
t x x2 x
v
= vv + 2 v p + g
t
44
4.6 Summary
Distributed models are derived from balance equaitons on infinite small fluid elements
resulting in descriptions with spatial behaviour. Equations with special behaviour are
called partial differential equations. Here we focus upon models with one dominating
space dimension. Steady-state assumption results in differential equaitons with
boundary condition, so called bounday value problem, BVP, which are presented in the
next chapter. In chapter six simulations of unsteady-state distributed models are
discussed.
45
5 Steady-State Simulation of Distributed System
5.1 Introduction
A steady-state distributed model results in a set of differential equations. Systems in one space
dimension become a set of ordinary differential equations, ODEs, and systems in two or more
space dimensions become a set of partial differential equations, PDEs. These differential
equations describe static relations between a set of variables and how these variables
change in space. Properties are often known on the border of the space. For instance in a
tube the inlet conditions are often known. These properties on the border are called
boundary conditions or boundary values. A steady-state distributed system simulation is
also called a boundary value problem, BVP.
A steady-state distributed system in one space dimension, z, can be expressed as (a set
of ODEs)
dx
= f(z,x)
dz
where the space dimension is between a<z<b. The corresponding boundary conditions,
called BCs, are
A x(a) + B x(b) = C
where A, B and C are matrices (if the BCs are linear). The number of boundary
conditions, BCs, is the same as the number of states (derivatives) in the ODEs. A split
boundary value problem means that the BCs are described in separate equations, e.g.,
x(a) and x(b) do not occur in the same equation. For a tube the description of the inlet
conditions are described in one set of BC equations and the condition of the outlet in
other BC equations
Two different types of methods for simulation of steady-state distributed systems are
presented here; the first is the shooting method and the second is the finite difference
method, FDM. The shooting method is limited to ODEs and the FDM can be applied to
both ODEs and PDEs.
Initial-Value Problem
Special cases of BVPs are problems with BCs only at the first boundary. This means
that the solution is found by just integration of the ODEs in space using the BCs as
initial values. The BVP becomes an IVP (initial-value problem).
46
At the inlet the concentration is known to be c0 which means that the boundary
condition is
c A ( z = 0) = c0
Assume a case with v=1 and k = 10. The inlet concentration is c0 = 1 and the
reactor length is L = 0.35.
The reactor profile can now be found with the following commands:
[t,y]=ode23('tubex1',[0 0.35],1);
plot(t,y)
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
reactor length
47
The previous case where BCs are known only at the inlet results in an IVP. This is a
special case of BVP. In the general case we have a mixture of BCs at the beginning and
at the end of the interval. The idea of shooting is very simple and straightforward.
The question is how to make clever guesses in step 1. The procedure 1-3 can be viewed
as a nonlinear problem where a guess results in a residual. The general shooting
technique is just a nonlinear equation problem from this point of view. In each iteration
the equation solver calculates a new guess using the residual. This residual is calculated
by an ODE solver that integrates the ODE between a and b.
Two shooting problems are special. The first is when all boundary conditions are at one
side as discussed above. The second is when the ODE is linear. For linear ODEs
superposition is valid. This means that one can shoot the problem with one BC at the
time and add them together afterwards.
c0=fzero('funcex2',1)
c0 =
1.6664
fzero needs many guesses to find this value (more than 20). The profiles form
the different guesses are illustrated in on the left in Figure 5.3.
c0n = newsol('funcex2',1)
c0n =
1.6664
The Newton solver only needs two guesses, the initial guess and the right guess.
The two profiles are found on the right in Figure 5.3.
48
2 1.8
1.8 1.6
1.6
1.4
1.4
1.2
1.2
1
1
0.8
0.8
0.6
0.6
0.4
0.4
0.2 0.2
0 0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35 0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
reactor length reactor length
Figure 5.3: Reactor profiles from shooting methods using left) fzero and right) newsol.
d2y dy
2 + a1 + a2 y = b
dz dz
dy d 2 y dx1
Introduce = x1 . The second-order derivative becomes = . The second-order
dz dz 2 dz
ODE can now be rewritten as
dy
= x1
dz
dx1
= a1 x1 a2 y + b
dz
dc d 2c
v = D 2 kc
dz dz
49
The reactor is assumed to have the following boundary conditions.
dc
D = v (c cin ) at z = 0
dz
dc
=0 at z = L
dz
To solve the second order ODE it has to be expressed on state-space form as two
first order ODEs. This is done by defining a new state as the derivative of the
concentration.
dc
= x1
dz
dx1 v k
= x1 + c
dz D D
v
x1 = (c cin ) at z = 0
D
x1 = 0 at z = L
function [dx]=tubex3(t,x)
% TUBex3 is a dispersion tubular reactor
% with first-order kinetics
x1 = x(1,1); c = x(2,1);
v = 1; k = 10; D = 0.1;
dx1= v/D * x1 + k/D * c;
dc = x1;
dx = [dx1; dc];
The newsol uses funcex3 to find the right derivative, x1, of the concentration
at that inlet that gives a derivative at the outlet that is zero.
x0 = newsol('funcex3', 1)
x0 =
0.6182
50
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
reactor length
dc d 2c
v =D 2 kc
2
dzz dzz
dc
= 0 at zz = 0
dzz
dc
D = v (c cin ) at zz = L
dzz
51
function [dx]=tubex4(t,x)
% TUBex4b is a dispersion tubular reactor
% with second-order kinetics in backward coordinates
x1 = x(1,1); c = x(2,1);
v = 1; k = 10; D = 0.1;
dx1= -v/D * x1 - k/D * c^2;
dc = -x1;
dx = [dx1; dc];
The initial condition is x1 = 0 and c N gets a stating value. At the end point (the
inlet, zz = L) the boundary condition must be fulfilled. The residual function
becomes
function [res]=funcex4(cN)
[z,x]=ode23('tubex4',[0 0.35],[0; cN]);
x10 = x(max(size(z)),1);
c0 = x(max(size(z)),2);
res = x10 - 1/0.1*(c0 - 1);
0.75
0.7
0.65
0.6
0.55
0.5
0.45
0.4
0.35
0.3
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
reactor lenght (backward)
Here x10 is the value of the derivative at the end point, inlet in this case, and c0
is the concentration at the inlet.
x10 =
0.3018
The concentration profile for the backward direction of the tubular reactor with
dispersion and second order reaction is seen in Figure 5.5.
52
5.3 Finite Difference Method
Another way to solve BVPs is to divide the space dimension into a set of mesh points
and to approximate the derivatives as differences between successive mesh points.
These approximations are put into the ODE and we get one equation for each mesh
point. This results in a large algebraic equation system. The basic steps for a finite
difference method are as follows:
1. Choose a mesh on the interval [a , b] , a = x0 < x1 < x2 <... < x N < x N +1 = b . The mesh
has N internal grid points. It is often convenient to choose a fixed mesh grid which
ba
means that h = and that xi +1 = xi + h .
N +1
2. Approximate the derivatives by a difference methods. The most common method is
the centered-difference approximation. For a first order derivative it is:
dx xi +1 xi 1
.
dz 2h
3. Apply the approximation to the ODE for each mesh point. This results in N
equations. Note that points outside the interval, like x-1 and xN+2, can occur in the
equations.
4. Apply the approximations also on the BC. Derive equations for the points outside the
interval. This is called method of fictitious points.
5. Solve the algebraic equation system. If the ODE and BCs are linear the equation
system also is linear and can be solved by Gaussian elimination. If the ODE and/or
BC are nonlinear the equation system is also nonlinear and requires a nonlinear
solver like a Newton method.
Centered-Difference Approximations
The most common finite difference approxiamtion is the centered-difference method.
Derivatives are approximated by a relation between grid point values around the point
where the derivatives are calculated. The simplest centered-difference method is of
second order. Different finite difference approximations can be derived using Taylor
expansions. First order approximations are based on Euler approximations as (forward
or backward)
dx xi +1 xi dx xi xi 1
or
dz h dz h
xi +1 xi xi xi 1
dx + x xi + xi xi 1 xi +1 xi 1
h h = i +1 =
dz 2 2h 2h
The second order derivative can be approximated by the difference between two simple
derivative approximations as
53
dx dx xi +1 xi xi xi 1
2
d x dz i dz i 1 h h x 2 xi + xi 1
= = i +1
dz 2 h h h2
x x x x
Figure 5.6: Simple grid of the tubular reactor (2 internal grid points).
dx xi +1 xi 1 d 2 x xi +1 2 xi + xi 1
and
dz 2h dz 2 h2
Step 3, apply the discritization on equation: Replace the derivatives with these
approximations. The ODE
dc d2x
v = D 2 kc
dz dz
ci +1 ci 1 c 2ci + ci 1
v = D i +1 kci
2h h2
It can be rewritten as
ci +1 2ci + ci 1 c c
D 2 v i +1 i 1 kci = 0
h 2h
54
2 1 0 0 c0 0 1 0 0 c0 1 0 0 0 c0 b0
D
1 2 1
0 c1 1 0 1
0 c1 0 1 0 0 c1 0
v k + = 0
h 0
2
1 2 1 c2 2h 0 1 0 1 c2 0 0 1 0 c2 0
0 0 1 2 c3 0 0 1 0 c3 0 0 0 1 c3 b3
D v
b0 = 2 + c1
h 2h
D v
b3 = 2 c4
h 2h
Step 4, apply discritization on BC:s: At the boundaries the BCs must be fulfilled.
dc
D = v (c cin ) at z = 0
dz
dc
=0 at z = L
dz
c1 c1
D = v (c0 cin ) at z = 0
2h
c4 c2
=0 at z = L
2h
2hv
c1 = c1 (c c )
D 0 in
c4 = c2
Apply this on matrix form and we get a system of four linear equations
hv 2hv
2 1 + D 2 0 0 c0 D 2 0 0 c0 1 0 0 0 c0 d 0
c 0 c1 0
D 1 2 1
c
0 1 v 1 0 1 0 1 k 0 1 0
=
h2 c 2 h 0
1 0 1 c2 0 0 1 0 c2 0
0 1 2 1 2
c 0
0 0 2 2 3 0 0 0 c3 0 0 0 1 c3 0
D v 2hv
d0 = 2 + c
h 2h D in
55
Step 5, solve the algebraic system: Now include everything in a linear equation
system, which of course can be solved by Gaussian elimination.
D hv v 2hv D v
2 h 2 1 + D 2h D k 2
h 2 2h
0 0 2v v 2
c0 cin
D v D D v c h D
+ 2 2 k 0
h 2 2h h h 2 2h 1 = 0
D v D D v c2
+ 2 2 k
h 2 2h c3
0 0
h 2 2h h
D D 0
0 0 2 2 2 2 k
h h
This matrix is useful in order to create the other ones needed. The matrix below is
the discretization of the second derivative.
A1 = eyelow' - eyelow
A1 =
0 1 0 0
-1 0 1 0
0 -1 0 1
0 0 -1 0
A0 = eye(N+2)
A0 =
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
The boundary conditions are just added to the matrices defined above.
A2(1,1) = -2*(1+h*v/D);
A2(1,2) = 2;
A2(N+2,N+1) = 2;
56
A1(1,1) = 2*h*v/D;
A1(1,2) = 0;
A1(N+2,N+1) = 0;
Aode = D/h^2 * A2 - v/2/h * A1 - k * A0
Aode =
-51.8367 14.6939 0 0
11.6327 -24.6939 3.0612 0
0 11.6327 -24.6939 3.0612
0 0 14.6939 -24.6939
The matrix Aode is the final discretization matrix for this problem. The boundary
conditions also result in a b-vector
The problem is a linear equation system and it is easy to solve with Gaussian
elimination using the backward division in MATLAB.
c=Aode\b
c =
0.6107
0.3070
0.1561
0.0929
The solution is seen in Figure 5.7 and it is based on 2 internal points and the two
boundary points. A solution based on 100 internal points is also seen in the plot
below.
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
reactor length
Figure 5.7: Tubular reactor with dispersion with N=2 and N=100 internal grid points.
57
Example 5.6: Nonlinear Tubular Reactor with Dispersion
The tubular reactor from Example 5.4 can also be solved by finite difference
method. The major difference compared to Example 5.5 is that here the equations
must be expressed on residual form and solved by a nonlinear solver. The function
eqex6 below contains similar calculations as in Example 5.5 but expressed in an
M-file. The difference is the nonlinear term and the residual calculation at the end.
function [res]=eqex6(c)
% EQex6 is a finite difference approx of the tubular
% reactor with dispersin and 2-order kinetics
v = 1; k = 10; D = 0.1; L=0.35; cin = 1;
N = 10;
h = L/(N+1);
eyelow = [zeros(1,N+2);eye(N+1) zeros(N+1,1)];
A2 = -2*eye(N+2) + eyelow + eyelow';
A1 = eyelow' - eyelow;
%boundary conditions
A2(1,1) = -2*(1+h*v/D);
A2(1,2) = 2;
A2(N+2,N+1) = 2;
A1(1,1) = 2*h*v/D;
A1(1,2) = 0;
A1(N+2,N+1) = 0;
%ODE approx
Aodem = D/h^2 * A2 - v/2/h * A1;
b = (-2*v/h - v^2/D)*[1;zeros(N+1,1)] * cin;
% equation on residual form
res = Aodem*c - k*c.^2 - b;
The nonlinear equation system can now be solved by a Newton solver, like
newsol. In this case an initial guess is made as a line between 1 and 0.3.
c0 = (1:(0.3-1)/11:0.3)';
c = newsol('eqex6', c0)
c =
0.7068
0.6240
0.5567
0.5012
0.4550
0.4162
0.3836
0.3565
0.3343
0.3172
0.3057
0.3011
The solution is seen in Figure 5.8. Note that we do not have problems with the
unstable ODE and there is no requirement on rewriting the problem.
58
0.75
0.7
0.65
0.6
0.55
0.5
0.45
0.4
0.35
0.3
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
reactor length
Figure 5.9: Nonlinear tubular reactor solved with finite differences and a Newton solver
(10 internal grid points).
5.4 Summary
Steady-state distributed systems in one space dimension have been solved by two
different methods, namely the shooting method and the finite difference method. Both
methods have advantages and drawbacks. For linear systems the shooting method
solution becomes simple. If the system is nonlinear the choice is not so obvious. If the
ODE is unstable the shooting method requires that the problem have to be rewritten to a
stable one. The advantages with finite difference methods are that they can be used in
two and three space dimensions. It can also be used in the method of lines, MOL, which
is used to solve unsteady-state distributed system.
59
6 Dynamic Simulation of Distributed Systems
6.1 Introduction
An unsteady-state distributed model results in a set of partial differential equations.
There are two kinds of unsteady-state PDEs, namely parabolic and hyperbolic.
Parabolic PDEs are also called diffusion-type PDEs and hyperbolic for wave-type
PDEs. The behaviour of these two kinds of PDEs are indicated by the names. Diffusion-
type PDEs smooth out the initial conditions in space while wave-type PDEs instead just
let the initial condition travel in space as a wave. In process applications conduction,
viscosity and dispersion are like diffusion in material momentum and energy balances.
Convection in material, momentum and energy balances creates wave behaviour. Note
that PDEs are equations that describe a variable in two or more dimentions. A variable
in two dimensions is a surface and the PDE describes how this surface is changing in
the two coordinates.
Diffusion-type PDE or parabolic PDE can be described as
y (t , z) 2 y (t , z) y (t , z)
=A +B + Cy (t , z )
t z 2
z
with initial and boundary conditions. It is first order in time and second in space.
Wave-type PDE or hyperbolic PDE can be described as
2 y (t , z) 2 y (t , z ) y (t , z)
= A +B + Cy (t , z )
t 2
z 2
z
with initial and boundary conditions. It is second order in both time and space.
A special type is the convection-type PDE or first-order hyperbolic PDE, which is first-
order both in time and space.
y (t , z) y (t , z)
=B + Cy (t , z )
t z
The dominating technique for numerically solving parabolic and hyperbolic PDEs is the
method of lines, MOL. The idea of MOL is to discretize the PDE in space, which results
in a set of ODEs in time. These ODEs are then solved by an ordinary ODE solver
discussed earlier in the course. There are different space discretization methods and
here we are going to use finite difference approximation, which has also been discussed
earlier in the course.
60
The basic steps for a finite difference approximation in space are as follows:
1. Choose a mesh on the interval [a , b] , a = x0 < x1 < x2 <... < x N < x N +1 = b . The
mesh has N internal grid points. It is often convenient to choose a fixed mesh grid,
ba
which means that h = and that xi +1 = xi + h .
N +1
2. Approximate the derivatives by a difference method. Approximations of
convection and diffusion terms are discussed later.
3. Apply the derivative approximations on the PDE for each mesh point. This results
in N ODEs for the internal mesh points.
4. a) Neumann BC: Apply the approximation on the PDE at the boundary and on the
BC. Derive equations for the points outside the interval. This is called method of
fictitious points.
b) Dirichlet BC: The value on the boundary is known and no equation is needed.
5. Put up the ODE system of N+Nb ODEs, where N is the number of internal points
and Nb the number of Neumann BCs.
6. Solve the ODEs. It is almost always stiff and requires ode15s and it is also often
sparse.
Convection terms
The convection term can not be treated in the same way as first order derivatives as in
Finite Difference Methods used in static PDE problems. Instead the convection term is
discretized upwind, which means that it is approximated in the opposite flow direction.
A first order derivative is approximated using a backward Euler approximation.
x xi xi 1
z h
Diffusion terms
The second order diffusion term can be approximated by the same methods as in steady-
state problems. Centered-difference approximation looks like
2 x xi +1 2 xi + xi 1
z2 h2
Note that diffusion terms can be of first-order if the discretization is done in cylindrical
or spherical coordinates. Diffusion term in a sphere is approximated below
1 2 x 2 x 2 x xi +1 2 xi + xi 1 2 xi +1 xi 1
r = + +
r2 r r r2 r r h2 ih 2h
61
Both parts in the diffusion term are approximated by centered-difference.
T T
t
= v +
4U
(T T )
z Cpd s
with T = T0 for all t>0 as the boundary condition at the inlet and with T = T(z) at
t=0 as the initial condition.
Ts
Step 1, selection of grid: Assume a uniform fixed grid on the interval [0,L], from
L0
the inlet to the outlet. The mesh-size becomes h = .
N +1
Step 2, selection of discritization method: The convection term is discritized with
backward difference
T Ti Ti 1
z h
Step 3, apply on equation: Replace the space derivative with this approximation
and the PDE becomes a set of ODEs
T Ti 1
(T T )
dTi 4U
= v i +
dt h Cpd s i
This means that we have done step 1, 2 and 3 in the procedure presented above.
Step 4, apply on BC: The boundary condition is a known value at the inlet, T0,
which means that step 4 is a direct application of the ODE above.
Step 5, put up the ODE system: The heat exchanger is simulated with the
following parameters:velocity, v = 10; heat transfer, U = 2500; density,
= 3000 ; heat capacity, C p = 4.18 ; tube diameter, d = 0.1; tune length, L = 0.5;
steam temperature, Ts = 120 and finally the inlet temperature, T0 = 25 . The
MATLAB function becomes
function [dT]=shex(t,T)
% SHEX is a steam-heated plug-flow heat exchanger
% approximated with finite differences
v = 10; U = 2500;
rho = 1000; Cp = 4.18; D = 0.1; L = 0.5;
Ts = 120; T0 = 25;
62
% grid
N = 100;
h = L/(N+1);
% convection term discretization
A1 = eye(N+1) - [zeros(1,N+1); eye(N) zeros(N,1)];
% boundary condition
b = [1; zeros(N,1)]*T0;
% PDE
dT = -v/h * A1*T + 4*U/(rho*Cp*D)*(Ts - T) + v/h*b;
A1 =
1 0 0 0 0 0 0 0 0 0 0
-1 1 0 0 0 0 0 0 0 0 0
0 -1 1 0 0 0 0 0 0 0 0
0 0 -1 1 0 0 0 0 0 0 0
0 0 0 -1 1 0 0 0 0 0 0
0 0 0 0 -1 1 0 0 0 0 0
0 0 0 0 0 -1 1 0 0 0 0
0 0 0 0 0 0 -1 1 0 0 0
0 0 0 0 0 0 0 -1 1 0 0
0 0 0 0 0 0 0 0 -1 1 0
0 0 0 0 0 0 0 0 0 -1 1
Step 6, solve the ODE system: The function can be simulated by the following
command
[t,y]=ode15s('shex',[0 0.1],25*ones(11,1));
Two solutions with different gridding are seen in the figure below. The one on the
left is based on 10 grid points and the on on the right is based on 100 grid points.
We see that the profiles are similar in the two cases.
Grid point temperature transients (10 internal grid points) Grid point temperature transients (100 internal grid points)
90 100
80 90
80
70
70
temperature
temperature
60
60
50
50
40
40
30 30
20 20
0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1 0 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
time time
Figure 6.2 - Temperature transients at grid points; left) N = 10, right) N = 100
The temperature profiles at specific times in Figure 6.3 is plotted with the
following command and
63
Temperature profiles at different time (10 internal grid points)
90
80 time = 0.1000
70
time = 0.0240
temperature
60
time = 0.0142
50
time = 0.0072
40
time = 0.0025
30
time = 0
20
1 2 3 4 5 6 7 8 9 10 11
tube lenght
T 2 T
=
t z2
T
= T Tin at z = 0
z
T
=0 at z = L
z
Tin x x x x x x x
In step 1 we define the mesh. The BCs means that the values on the boundaries
are unknown and they become variable. Define an uniform grid of N internal grid
points together with two boundary points, 0 and N+1, and make a centered-
difference approximation of the diffusion term.
Step 2 is the definition of the discretization matrix, A2. To apply the discretization
is straightforward in this case (step 3). Note that there are 7 grid points, 5 internal
grid points and one boundary grid point at each side. In the definition below we
first define a help matrix, eyelow.
64
N = 5;
Nn = N + 2;
eyelow = [zeros(1,Nn); eye(Nn-1) zeros(Nn-1,1)]
A2 = -2*eye(Nn) + eyelow + eyelow'
eyelow =
0 0 0 0 0 0 0
1 0 0 0 0 0 0
0 1 0 0 0 0 0
0 0 1 0 0 0 0
0 0 0 1 0 0 0
0 0 0 0 1 0 0
0 0 0 0 0 1 0
A2 =
-2 1 0 0 0 0 0
1 -2 1 0 0 0 0
0 1 -2 1 0 0 0
0 0 1 -2 1 0 0
0 0 0 1 -2 1 0
0 0 0 0 1 -2 1
0 0 0 0 0 1 -2
T T T
= T Tin 1 1 = T0 Tin T1 = T1 (T0 Tin )
2h
z 2h
T1 2T0 + T1 ( T0 Tin )
2h
dT0 T 2T0 + T1 dT0
= 1 2 = 2
dt h dt h
h
2T1 2 1 + T0
dT0 2
= 2 + Tin
dt h h
T T TN
= 0 N +2 = 0 TN + 2 = TN
z 2h
In step 5 we put together the boundary condition equations and the discretization
matrix.
L = 0.5;
alpha = 1e-3;
Tin = 25;
65
h = L/(N+1);
A2(1,1) = -2*(1 + h/alpha);
A2(1,2) = 2;
A2(Nn,Nn-1) = 2
b = 2/h*[1; zeros(Nn-1,1)]*Tin
A2 =
-168.6667 2.0000 0 0 0 0 0
1.0000 -2.0000 1.0000 0 0 0 0
0 1.0000 -2.0000 1.0000 0 0 0
0 0 1.0000 -2.0000 1.0000 0 0
0 0 0 1.0000 -2.0000 1.0000 0
0 0 0 0 1.0000 -2.0000 1.0000
0 0 0 0 0 2.0000 -2.0000
b =
600
0
0
0
0
0
0
The ODE system is described in the hotrod MATLAB function below. It is now
easy to recognize the different statements.
function [dT]=hotrod(t,T)
% HOTROD is a model of heat conduction in a
% one dimensional rod. MOL with centered-difference.
% parameters
L = 0.5; alpha = 1e-3; Tin = 50;
% gridding
N = 5;
Nn = N + 2;
h = L/(N+1);
% discretization
eyelow = [zeros(1,Nn); eye(Nn-1) zeros(Nn-1,1)];
A2 = -2*eye(Nn) + eyelow + eyelow';
% boundary conditions
A2(1,1) = -2*(1 + h/alpha);
A2(1,2) = 2;
A2(Nn,Nn-1) = 2;
b = 2/h*[1; zeros(Nn-1,1)]*Tin;
% ODE system
dT = alpha/h^2*A2*T + b;
The rod can now be solved by ode15s and plotted by the commands below.
66
Te m p e r a tu re s in th e R o d (5 in te rn a l g r id p o in ts )
50
45
40
temperature
35
30
25
0 50 100 150 200
tim e
Figure6.5: Temperature transients in hot rod (5 internal and 2 boundary grid points).
The temperature transients in the different grid points are seen in Figure 6.5. Note
that the first grid point is very fast compared to the rest. The last grid point is also
quite fast because it follows the second last grid point closely.
[t,y]=ode15s('hotrod',[0 200],25*ones(7,1));
plot(t,y)
A 3-D plot of the transients in time and profiles in space is seen in Figure 6.6
below. It is easy to make plots like this in MATLAB with the mesh and surf
comands.
50
45
temperature
40
35
30
200
25
0 150
5
10 100
15 50
20
25 0 time
rod length
Figure 6.6: 3-D plot of the temperature profile transients in the hot rod example
67
c 1 2 T
= r D
t r2 r r
c
=0 at r = 0
r
c
D = k (c cb ) at r = R
r
c 1 2 c 1 2 2 c c 2 c 2 c
= 2 r D = 2 D r + 2 r = D 2+
t r r r r r2 r r r r
2 c 2 c ci +1 2ci + ci 1 2 ci +1 ci 1
2+ +
r r r h2 ih 2h
ci c 2ci + ci 1 2 ci +1 ci 1
= D i +1 +
t h2 ih 2h
cN +2 cN
= k (cN +1 cb ) cN + 2 = c N + (c c )
2hk
D
2h D N +1 b
This results in an expression for the fictuous point N+2 as a function of the point
on the boundary N+1 and an internal point N. The PDE has a singularity at r = 0.
The equation must be rewritten for this grid point. It is a direct application of
l'Hospitals rule, see Persson and Biers "Analys i en variabel" page 392. When r
goes to zero the expression becomes a second order term.
c
lim 2 c r r 2 c
=2 =2 2
r0 r r r
(r)
r
then the PDE becomes for the grid point in the centre
68
c0 c 2c0 + c1 c 2c0 + c1
= D 1 +2 1
t h 2
h2
The boundary condition at zero gives the following relation for the fictitious point
1
c c c
= 0 1 1 = 0 c1 = c1
r 2h
dc0 c 2c0 + c1
= D 3 1
dt h2
dci c 2ci + ci 1 2 ci +1 ci 1
= D i +1 +
dt h2 ih 2h
cN +
2hk
(c N +1 cb ) 2c N +1 + c N
cN +
2hk
(c N +1 cb ) c N
= D +
d c N +1 D 2 D
dt h 2
R 2h
6.4 Summary
Unsteady-state distributed systems have been solved by the method of lines, MOL. It is
based on finite difference approximations in the space dimension. This is the most
common way to solve parabolic PDEs in one space dimension. The PDE is discretized
in space by the user and it results in a set of ODEs. This ODE system is solved by an
ordinary ode-solver like ode15s.
69
7 Computer Aided Process Engineering
7.1 Introduction
Computer Aided Engineering, CAE, in general and Computer Aided Process
Engineering, CAPE, in particular are fields that change rapidly. The development in
computer technology makes it possible to solve larger and larger problems. The
software development makes it easier to model and describe advanced problems. This
trend will continue. The most advanced chemical engineering problems that was solved
for hours with large mainframe computers twenty years ago and it took one day to
describe the problem are solved today in a few seconds and it take only five minutes
describe the problem. This is done on cheap computer almost available for every
engineer. We can only imagine what kind of problems that can be solved in ten years.
Commercial programs for CAPE can be divided into four main categories.
1. General engineering programs for technical computing, statistical analysis,
curve drawing etc. are of course important tools.
2. CAD programs are often general Computer Aided Design programs that are
used for drawing of Process and Instrumentation Diagrams, P/I-D, and for
construction of processing equipments.
3. Flowsheeting programs for calculation of process streams, equipment
dimensions and process economics. These are used for evaluation of different
process designs.
4. CFD programs are special programs for Computational Fluid Dynamics and
can simulate static, and sometimes dynamic, fluid behaviour in two and three
dimensions.
70
view the 3D structure of polymers and biomolecules. This class of tools will not be
discussed future in this course.
7.2 Flowsheeting
The major chemical engineering tools are called flowsheeting programs. The first
flowsheeting programs appeared all ready in the late fifties and were FORTRAN
subroutines that calculated mass and energy balances over different kinds of unit
operations. Flowsheeting programs of today contain a large set of process equipment,
physical property descriptions and physical parameter databases. The actual simulation
code is a small fraction of the programs and sometimes these flowsheeting programs are
used as databases for simulations in other software.
By tradition flowsheeting programs solve steady-state lumped systems and a common
definition of flowsheeting is
"The use of computer aids to perform steady-state heat and material balancing,
and sizing and costing calculations for a chemical process".
This definition is changing and the dominating flowsheeting programs today can
include dynamics and sometimes also distributed parameter systems, i.e. PDEs. There
are also special flowsheeting programs that can perform process synthesis, i.e. optimal
process design.
Steady-State Flowsheeting
All programs that are called flowsheeting programs can solve steady-state material and
energy balances. Most flowsheeting programs contain a library of modules that solves
different unit operations. It also contains a library of different thermodynamic models
together with a database for physical properties of common chemical components. The
user needs to specify data for the different unit operation modules, chemical
components in the process, and how the modules are connected, a so-called flowsheet.
The solver can now solve the problem, by calling different libraries of unit operation
modules and thermodynamic models. The mathematical models for the process
equipment are predefined in the programming code of the modules. The principle
structure is found in Figure 7.1 below.
71
The different parts of a flowsheeting program is as follows:
User Defined Data. The problem is specified in a graphical user interface where
you describe your flowsheet by "drag and drop" of modules from the library. Data
are entered in specialised pop up forms and pull down menus.
Unit Operations. The majority of commonly used unit operations are often
available in the program. Often one kind of modules can be used in a number of
different ways, which increases the number of available unit operations. Some
programs allow the user to specify their own unit operations modules.
Database. In the major programs there are a lot of data for a large number of
chemical components. More advanced programs can handle solids and
electrolytes which are quite complicated.
Solve. The actual solver is only a marginal part of the software. The solver can
work with different solution strategies, i.e. sequential and/or simultaneous.
Output Data. Some programs generate a solution report in a predefined style.
There are programs that interactively calculate and present results in the graphical
user interface.
The dominating strategy of today is the simultaneous modular solution strategy. This
means that the steady state solution is derived through iteration. Two different iteration
problems can be derived.
72
Recycle loops results in a problem where a set of modules is connected in a loop.
To choose a proper variable to start the iteration is called tearing. When the
iteration variable is selected it gets an initial guess and the loop is calculated and
the iteration variable gets a new value. If this value is used directly this becomes a
direct substitution method. A special method of this kind is the Wegstein method
often used in flowsheeting programs.
Adjust loops are defined in order to specify design criterion. A parameter in the
flowsheet is manipulated by an iteration method based in the value of another
flowsheeting variable. In HYSYS this adjusts loop iteration method is a secant
method, which is a simplified Newton method.
ASPEN PLUS is a product from ASPEN Tech. This is one of the most used and
advanced flowsheeting programs. There are a lot of add-on modules
for special purposes and it can handle solids and electrolytes. It is
possible to add on user defined unit operations and user-defined
components and their physical data. It is used in research at the
department of Chemical Engineering I. ASPEN is quite expensive.
http://www.aspentec.com/
CHEMCAD III is a product from Chempute Software and it is a small and cheap
flowsheeting package with limitations.
http://www.chemstations.net/index.html
HYSYS Process is a product from HYPROTECH. It is an interactive and integrated
environment with a number of add-on modules. HYSYS is used in
the under graduate courses at the Chemical Engineering program.
http://www.hyprotech.com/
PRO/II is a product from Simulation Science Inc. It is one of the major
flowsheeting programs in the petrochemical industry.
http://www.simsci.com/
Dynamic Flowsheeting
By tradition flowsheeting programs handle steady-state problems which means that
dynamic simulation is quite new in these programs. One of the first dynamic simulation
tools was SPEEDUP, developed at Imperial Collage, London, and this is now a product
at ASPEN Tech. The dynamic simulation problems are solved using general ODE
solvers. In general there are explicit methods, like Euler and Runge-Kutta methods, and
there are implicit solves, like Gears method.
73
Below follows a list of some commercial dynamic flowsheeting programs. The list is
not complete. HYSYS is used in our under graduate courses and ASPEN Dynamics is
used in our research projects.
ASPEN Dynamics is a product from ASPEN Tech. This is a new software that
integrated ASPEN PLUS and SPEEDUP. It is used in research at
the department of Chemical Engineering I.
http://www.aspentec.com/
gPROMS is a product from Process Systems Enterprice. It is developed at
Imperial Collage, London, and is an advanced simulation tool that
can handle both ODEs and simple PDEs. It can also handle
sequences and batch procedures. gPROMS is available at the
department of Chemical Engineering I.
http://www.psenterprise.com/
HYSYS Plant is a product from HYPROTECH. It is an interactive and integrated
environment for both steady state and dynamic simulation with a
number of add on modules. HYSYS is used in the under graduate
courses at Chemical Engineering program.
http://www.hyprotech.com/
SPEEDUP is a product from ASPEN Tech. SPEEDUP is developed at
Imperial Collage, London. It is an open modelling language that
allows the user to specify their own models is a modelling
language. It is today integrated into ASPEN.
http://www.aspentec.com/
Process Synthesis
In some special process design situations is possible to make simultaneous process
optimisation and process design. This is sometimes called process synthesis. This
means that the structure of the flowsheet is manipulated through the optimisation
procedure. One such situation is the optimal design of a heat recovery plant section of
connected heat exchangers. It is possible to find simultaneously the structure of
connected heat exchanges together with the optimal sizing and operation conditions.
This is called pinch technology. One such program is Super Target from Linnhoff
March, which is used at the department.
Other synthesis situations under development are sequences of distillation columns,
particular in petrochemical industry and optimal structure of tubular and tank reactors in
series and parallel.
ASPEN
One of the dominating flowsheeting programs on the market today is ASPEN. It is a
family of different modules build around the steady state solver ASPEN PLUS. It was
first developed at MIT, Cambrige, USA, in the seventies. ASPEN has a large database
and can simulate many unit operations under different conditions. The interface to an
ASPEN PLUS simulation is seen in Figure 2. A resent developed module is the ASPEN
Dynamics. It is possible to convert an ASPEN PLUS simulation into an ASPEN
Dynamics problem and simulate the dynamic behaviour. The interface to ASPEN
Dynamics together with the corresponding simulation to the previous figure is
illustrated in Figure 3.
74
Figure 7.2: The interface to ASPEN PLUS. In this case a simulation problem with two distillation
columns.
Figure 7.3: The interface to ASPEN Dynamics. Two distillation column problem with control system.
75
7.3 Computational Fluid Dynamics
Relaxation methods are iteration methods for linear equations. These are good for
very large equation systems.
Multigrid technique solves first the system with a few finite volumes (or elements).
This solution is used as the initial guess of a finer grid and so on.
Gaussian elimination, sparse or not, solves the equation system exactly and calculates
every variable. These iteration methods give an approximated solution and for large
problems the iteration converge quite rapidly compared with an exact solution of every
variable.
76
CFD programs
Below follows a list of some commercial CFD programs. The list is not complete.
FIDAP
One CFD program is Fidap and it is based on the finite element method. In CFD
problems it is important to define the geometry in 2 or 3 dimensions. This requires good
graphical tools and a high-level geometry language to facilitate the problem definition.
When the geometry is specified the mesh of grid points is defined. It often requires
some physical and numerical insight to define an efficient grid. Some advanced CFD
programs make automatic grid generation. In Figure 4 the geometry and mesh of a flow
problem is illustrated. The interface to Fidap is illustrated in Figure 5. The solution of
the flow problem in Figure 4 is seen in a colourful plot. The actual flow problem is
defined on a user oriented description language. The user fills in a form with different
check button for the problem specification.
77
Figure 7.4: Geometry and mesh description in a CFD program.
78
7.4 HYSYS a flowsheeting program
HYSYS is an interactive and intuitive process simulator for steady state and dynamic
problems. It is developed by Hyprotech Inc. and it is a modern program design and
implementation of a flowsheeting program. HYSYS has a graphical interface based on
menus, pop up forms, click buttons etc., which facilitates the flowsheet development.
Solution Strategy
HYSYS solution strategy and methods work in a flexible way. This flexibility makes
the process of building a simulation both interactive and intuitive. The solution strategy
can be characterised as follows
Event driven. HYSYS makes a calculation after the user supplies each piece
of information. This facility can be turned off.
Interactive information dialogue. HYSYS interactively indicates the status
of the solution. Different modules indicate if they need more information to be
solved and streams indicate if they propagate information to the new module.
Modular operation. Each unit operation and stream can perform all
necessary calculations, weather the information is specified in the operation
itself, or communicated from attached streams.
Object oriented solution algorithm. The objects, i.e. unit operations and
streams, work independent and the total solution is build up gradually. There is
no sequential calculation order that the solver must follow.
HYSYS Environments
The HYSYS environments allow you to access and input information in a certain area
or "environment" of the program, while the other areas are put on "hold" until you are
finished working in the area of interest. The relations between the environments are
seen in Figure 6. The five environments are:
Basis Definition and modification of the Fluid Packages is done in Basis. The
Fluid Packages are definitions of the chemical components present in the
simulation and selection of proper thermodynamic property package.
Oil Characterisation Definitions of assays and blends of petroleum fluids.
Optional.
Main Flowsheet Definition of the topology of the main simulation flowsheet.
The main flowsheet, called PFD (process flowsheet diagram), contains unit
operation objects and can also contain sub-flowsheets and columns.
Sub-Flowsheet A part of the PFD can be a sub-flowsheet, connected to the main
flowsheet through streams.
Column Special sub-flowsheets for column descriptions.
The user has to define at least a Basis environment in a form of a Fluid Package. After
that the user has to define the flowsheet in the PFD in the Main Flowsheet environment.
79
HYSYS Flowsheets and Sub-Flowsheets
As mentioned above in HYSYS it is possible to define parts of the flowsheet inside a
sub-flowsheet. This decreases the complexity of the main flowsheet for large problems.
It is also possible to define sub-flowsheets inside sub-flowsheets creating a hierarchy of
flowsheets. Column environment is a special sub-flowsheet for column definitions and
it functions in the same way. It is not possible to define sub-flowsheets inside column
environments.
Create a
new case
Basis Oil
Environment Envirnment
Sub-Flowsheet
Column Main Flowsheet Environment
Environment Environment
7.5 Summary
Computer tools for modelling, analysis and design for chemical process engineering are
vital for solving today's industrial needs. Flowsheeting programs, that can be used to
describe and solve process configurations on the unit operation level, are special
computer tool developed in process industry. In the course we are using HYSYS as an
example of a flowsheeting tool. More detailed studies on microscopic level require the
use of tool from computational fluid dynamics, CFD. These tools are becoming to be
common in process engineering in the near future.
80
8 Parameter Estimation
8.1 Introduction
Development and numerical solutions of models have been discussed in great detail in
the previous chapters. Before we can do anything with our models we have to validate
the models against data from the real system. Here we will discuss estimation of
parameters in models derived from first principle, i.e. in the way presented previously.
There are other ways of parameter estimation like black-box identification, where the
structure of the model is unimportant as long as the model predicts the behaviour.
Let us assume that we have a set of experimental responses, y, measured at a set of
conditions, x. We also assume that there is a relationship, f, between y and x, which is
parameterised by a set of parameters, . The measurement is not perfect so it has a
measurement error .
y = f ( , x) +
Regression is the procedure, which finds the unknown parameter vector, , which
minimizes . If the relationship between y and is linear then the procedure is called
linear regression and the problem becomes a linear equation system. If the relationship
is nonlinear in the parameters the procedure to find becomes iterative and this
procedure is called nonlinear regression. Below we will also discuss the statistical
analysis of the resulted regression.
yi = kxi + l + i
This means that there are two parameters, k and l, in the relationship (slope and
intercept). Assume that we have N number of measurements. Put up all measurements
in a matrix representation as indicated below.
y1 x1 1 x1 1 1
y x x 1 k
2 = k 2 + l + 2 = 2 + 2 Y = X +
... ... ... ... ... l ...
yN xN N xN 1 N
Y = X
81
Under certain conditions, is normalised distributed with zero mean, the optimal
regression is performed by minimization the square error of the differences between
measurements and model responses, the residual R.
Q = ri =R T R where R = Y Y = Y X
The Q is minimised when this derivative is zero. The parameter derivative of R is just -
XT .
Q
=2
R
R=0 (
2 X T Y X = 0 )
Multiply the last expression with XT and derive an expression for the parameter vector
.
(
X T Y X T X = 0 )
( )
X T X = X T Y
This last expression is the linear regression based on least square. Note that in linear
regression the linearity is in the parameters and not in the x and y relationship, which is
the meaning of linearity in the previous chapters.
= (X T X ) X T Y
1
1.5
1
0 1 2 3 4 5 6
82
The model is assumed to be linear and the regression is as follows
k
yi = kxi + l + i y = [x 1] = X = X T X ( )
1
XTy
l
The data in table 8.1 can now be put into the matrix formulation and the estimated
parameters becomes, k = 0.7188 and l = 1.1939. The MATLAB commands are as
follows
X=[x 1];
b=(X'*X)\(X'*y);
Polynomial estimation
Traditional polynomials are linear in the parameters and can directly be represented as
y = an x n + an 1 x n 1 + ... + a1 x + a0
Measurements can now be put into matrix form where the x and powers of x forms the
X-matrix
x1n 1 an 1
n 1
x1 ... x1
n
1 an 1 2
n 1
x2 x2 ... x2
yi = an xi + an 1 xi + ... + a1 xi + a0 + i = ... ... ... + ...
n n 1
... ... ...
n
x N 1
n 1
xN 1 ... x N 1 1 a1 N 1
xn n 1
1 a0 N
N xN ... x N
X=[x.^2 x 1];
b=(X'*X)\(X'*y);
83
Another useful method is polyval for the evaluation of the polynomial at specific
points. In Statistic toolbox there is a graphical interface to these functions called
polytool. Try it!
p1=polyfit(x,y,1)
p1 =
0.7188 1.1939
p2=polyfit(x,y,2)
p2 =
0.0045 0.6915 1.2166
ln k
y = k1e k2 x ln y = ln k1 xk 2 ln y = [1 x ] 1
k2
ln k
y = k1 x k2 ln y = ln k1 + k 2 ln x ln y = [1 ln x ] 1
k2
1
kx 1 1 k 1 1 1 k1
y= 1 = + 2 = 1
k2 + x y k1 k1 x y x k 2
k1
As we see becomes all these nonlinear expressions just simple linear regression
problems after transformation. The drawback is that the transformation also transforms
the measurement error. This means that the error is unevenly weight in the actual
regression making that result slightly disturbed.
Kd
qmax c 1 K c 1 1 qmax
q= = d + = 1
Kd + c q qmax c qmax c q c 1
qmax
84
Table 8.2: Data in Example 8.4
90
c q
80
0.0203 9.1898
0.0498 27.9678 70
0.3106 37.4374 60
0.5325 47.9383 50
0.7612 57.7252 40
0.9304 69.4346
30
1.1123 80.2992
20
1.4304 85.3483
1.7798 88.5122 10
2.2330 86.8252 0
0 0.5 1 1.5 2 2.5
Kd
q 0.0123 q 81.1
max = max =
1 0.0019 K d 0.150
qmax
f ( X , )
f ( X , i +1 ) f ( X , i ) +
(
i +1 i )
The partial derivative is the parameter Jacobian, which we denote J. Assume that we
still would like to minimize the least square of the residuals we get the following.
Q
=2
R
R=0 2
R
R = 0 2 J T Y f ( X , ) = 0 ( )
If we use both these expressions by putting the linearization into the least square
expression we get
(
2 J iT Y f ( X , i ) J i i +1 i = 0 ( ))
i i ( i +1 i )
J T J = J T Y f ( X , ) i ( i )
i +1 = i + (J J i ) J Y f ( X , i )
T
i
1 T
i ( )
85
A more convenient expression is to recognize that the last term is the residual with the
i:th parameter guess and only express the parameter step, .
(
i = J iT J i )
1
J iT Ri
The similarity with linear regression is obvious. The Jacobian corresponds to the X-
matrix and the residual vector to the Y-vector. The nonlinear regression procedure
begins with an initial guess of the parameter vector. This makes it possible to calculate
the model response and the corresponding residual. It is also possible to calculate the
Jacobian, which makes it possible to calculate a parameter step. The new parameter
vector can now be used in the procedure until the parameter step is small and the
iteration can be stopped. This is called the Gauss-Newton method. In other words the
Gauss-Newton method solves a linear regression problem in each iteration step.
nonlinreg
We have developed a simple MATLAB function that performs a nonlinear regression. It
is called nonlinreg and has four input arguments, the independent x vector,
measurement vector y, the model function name and the initial parameter guess, b0.
b=nonlinreg(x,y,'model',b0)
function q = Langmuir(b,c)
q=b(1)*c./(b(2)+c);
b=nonlinreg(c,q,'Langmuir',[90; 0.5])
The result becomes qmax = 115.2695 and Kd = 0.6055. The prediction of the
estimated model is seen in the figure below, Figure 8.3.
86
100
90
80
70
60
50
40
30
20
10
0
0 0.5 1 1.5 2 2.5
If the measurement error, , is normally distributed and with zero mean, i.e. N(0,2),
then the least square estimation is normally distributed and unbiased.
[]
E = and []
Var = 2 (X T X )
1
If the regression is nonlinear then X can be replaced by J, the Jacobian, in the last
expression. The last expression is the covariance matrix of the parameter estimation.
The variance is estimated using the sum of squares of the residuals
Q
2 =
N P
and N is the number of measurements and P the number of parameters that is estimated.
The difference, N-P, is called the degree of freedom.
linreg
To facilitate the use of regression in the course there is a M-file, called linreg, which
makes a linear regression and computes some regression properties. The function has
only two input arguments, the X-matrix and the measurement vector, y. It returns the
parameter vector b.
b = linreg(X,y)
87
Additional outputs are the estimated variance, s2, and the covariance matrix, cov.
[b,s2,cov] = linreg(X,y)
nonlinreg
This function for nonlinear regression, presented earlier, also has additional input and
output arguments. The complete function call is as follows.
[b,r,J,s2,cov] = nonlinreg(x,y,'model',b0,nlopt)
There is an additional input argument, nlopt, which makes it possible to change the
method parameters, like the parameter error tolerance and maximal number of
iterations. For more detail read the help file. The new output arguments are the resulting
residual, r, the parameter Jacobian, J, estimated variance, s2, and the parameter
covariance matrix, cov.
(
si = 2 X T X )
ii
1
0.4
N-P = 20
0.35 N-P = 10
N-P = 5
0.3
0.25
0.2
0.15
95 %
0.1
0.05
0
-3 -2 -1 0 1 2 3
Figure 8.4: The Student T distribution for three different degrees of freedom.
The confidence interval discussed above is only for valid for one individual parameter.
A better measure is the joint 1- marginal confidence region. This gives an estimation
of the simultaneous variation of the parameter. The simultaneous parameter distribution
is F distributed. The joint variation has the following 1- marginal confidence region
88
Finv ( , P, N P )
P
2 2 1 +
N P
Finv is the inverse of the F cumulative distribution. In the general nonlinear case this is
hard to compute. For the linear case it is possible to compute the joint variation as an
ellipsoid.
( ) X X ( ) P F
T T 2
inv ( , P, N P )
It is possible to do the same kind of calculations for a linearized version of a nonlinear
model and X is replaced by the Jacobian in the expression above. It only creates a joint
confidence interval that is an approximation. There are two functions in KATtools for
this namely confpar and confparplot. The first function calculates the individual
confidence interval
bci=confpar(XorJ,y,b,s2,cov,alpha)
and the correlation and joint confidence region for the parameters specified in jpc.
[bci,corr,bjcr]=confpar(XorJ,y,b,s2,cov,alpha,jpc)
The second command, confparplot, uses confpar and makes a plot with the
individual confidence intervals as a square and the joint confidence region as an
ellipsoid. Note that they can be used for both linreg and nonlinreg results.
x p x p s xTp ( X T X ) 1 x p Tinv 1 , N P
2
89
6 6
1.3 1.29
5 5
0.7 0.71
4 4
3 3
2 2
1 1
0 2 4 6 0 2 4 6
6 6
1.28 1.26
5 5
0.719 0.738
4 4
3 3
2 2
1 1
0 2 4 6 0 2 4 6
Figure 8.5: Four different data sets with different errors and corresponding
parameter estimates. See Example 8.6.
1 1
0.9 0.9
0.8 0.8
0.7 0.7
0.6 0.6
0.5 0.5
0.5 1 1.5 2 0.5 1 1.5 2
1 1
0.9 0.9
0.8 0.8
0.7 0.7
0.6 0.6
0.5 0.5
0.5 1 1.5 2 0.5 1 1.5 2
Figure 8.6: Parameter confidence intervals, the squares, and joint parameter
confidence region, the ellipsoid. See Example 8.6
Here s is the standard error, xp is the independent variable at the prediction. In the
nonlinear case X can be replaced by J. A more interesting result is the confidence band
for the response function at any x. Note that the joint distribution is F distributed.
90
y x s xT ( X T X ) 1 x PFinv ( , P, N P )
ypredci=confpred(XorJ,y,b,s2,ypred,xpred,alpha)
ypred and xpred are the dependent and independent variables of the prediction. The
output variable, ypredci, is a vector with three columns with the lower and upper
confidence bands. Additional input arguments make it possible to calculate the
confidence interval for a specific point (points).
[ypredci,ypointci]=confpred(XorJ,y,b,s2,ypred,xpred,
alpha,ypoint,xpoint)
6 6
5 5
4 4
3 3
2 2
1 1
0 2 4 6 0 2 4 6
6 8
5
6
4
4
3
2
2
1 0
0 2 4 6 0 2 4 6
Figure 8.7: Prediction confidence regions for Example 8.7. Note different scales.
91
Example 8.8: Regression analysis of adsorption isotherm estimation
Nonlinear regression was performed, in Example 8.5, on adsorption data
estimating parameters in a Langmuir model. Below are the prediction confidence
band shown in Figure 8.8 and parameter confidence plots in Figure 8.9.
120
100
80
60
40
20
0
0 0.5 1 1.5 2 2.5
Figure 8.8: Prediction with 95% confidence band on nonlinear estimation from Example 8.5
1.4
1.2
0.8
0.6
0.4
0.2
-0.2
Kd 70 80 90 100 110 120 130 140 150 160
qmax
Figure 8.9: Parameter confidence interval and joint parameter confidence region for the
nonlinear estimation from Example 8.5
8.5 Summary
Modelling and simulation relay strongly on its validity to the real process it tries to
predict. If the model is badly validated to data the study has low changes to be a
success. The parameter estimation and model validation is important. This is composed
of three different tasks:
1. Numerical methods that do the parameter estimation,
2. Statistical theory that gives insight on the quality of the estimation
3. Model validation that help you to select a proper model.
92
9 Index
Energy Balances ............................................. 40
A
estimated variance .......................................... 89
Adams methods ...............................................30 Euler method ................................ 22, 23, 24, 26
Adams-Bashforth methods .........................30 stability ...................................................... 23
Adams-Bashforth-Moulton methods ..........30 eulers.......................................................... 24
algebraic equations..........................................13
F
ASPEN ...........................................................75
ASPEN Dynamics..........................................74 FEMLAB ....................................................... 78
ASPEN PLUS ................................................73 Fick's first law................................................. 38
Fick's second law ............................................ 39
B
fictitious point................................................. 69
backslash notation...........................................14 FIDAP............................................................ 78
backward Euler approximation .......................61 Finite Difference Method ............................... 53
Backward Shooting .........................................51 finite difference techniques ............................ 60
BDF-methods ..................................................31 Finite element method .................................. 77
bisection method .............................................16 Finite volume method................................... 77
boundary conditions........................................46 fixed mesh grid ............................................... 53
Boundary Conditions ......................................44 Flow-3D ......................................................... 78
boundary values ..............................................46 Flowsheeting............................................ 70, 71
FLUENT ........................................................ 78
C
flux model ....................................................... 45
CAD................................................................70 fsolve.......................................................... 21
CAPE ..............................................................70 fzero ...................................................... 17, 48
centered-difference approximation .................53
Centered-Difference Approximations .............53 G
CFD ..........................................................70, 77 Gaussian elimination ................................ 13, 56
CFX ................................................................78 Gauss-Newton method.................................... 87
CHEMCAD III..............................................73 Gear methods.................................................. 31
Component Mass Balance.................................6 General Shooting Method............................... 48
Component Mass Balances .............................38 gPROMS........................................................ 74
Computational fluid dynamics ........................77
Computer Aided Engineering .........................70 H
condition number ......................................15, 16 Heat equation ................................................ 42
Conduction.....................................................42 homogenous Neumann ................................... 65
confpar........................................................90 hyperbolic PDE ........................................ 36, 60
confpred .....................................................92 HYSYS ........................................................... 80
Conservation .....................................................4 HYSYS Plant................................................. 74
convective type PDE .......................................36 HYSYS Process............................................. 73
covariance matrix ............................................89
I
D
Implicit solvers ............................................... 28
DAE ................................................................32 index of a DAE problem................................. 33
DAE solvers ....................................................33
derivative of a product ......................................6 J
difference approximation Jacobian .......................................................... 86
centered ....................................53, 60, 61, 64 Jacobian matrix............................................... 19
differential-algebraic equation system ............32
Diffusion .........................................................37 L
Diffusion-type PDE .........................................60 l'Hospitals rule ................................................ 68
direct substitution......................................17, 73 linear regression............................................. 82
Dirichlet ..........................................................45 linreg.......................................................... 88
Dispersion ................................................39, 49 LU-decomposition .......................................... 13
distributed parameter models .........................35
divergence .......................................................36 M
93
MOL ............................................................... 60 Regula Falsi ....................................................17
Momentum Balances ................................ 11, 43 Relaxation methods .........................................77
Multigrid technique ........................................ 77 residual............................................................83
Multi-Step Methods........................................ 30 Robin .........................................................45, 65
Runge-Kutta
N
ode45 ..........................................................27
nabla operator ................................................. 36 Runge-Kutta method
Navier-Stokes Equation ............................... 44 midpoint approximation .............................27
newsol..................................... 19, 21, 48, 50, 58 ode23........................................................27
Newton method ............................................... 18 Runge-Kutta method
convergens ................................................. 19 Euler method ..............................................27
multi dimensional....................................... 19 Runge-Kutta method
Newtonian viscosity ...................................... 44 rk23 ..........................................................27
nonlinear regression....................................... 82 Runge-Kutta methods......................................25
Nonlinear Regression ..................................... 86
S
nonlinear solvers............................................. 16
nonlinreg............................................. 87, 89 secant method .................................................73
Sequential Modular.........................................72
O
Shooting Method.............................................46
ode113 ............................................................ 30 Simultaneous Solution.....................................72
ode15s............................................................. 31 SPEEDUP ......................................................74
ode23 ............................................................ 28 split boundary value........................................46
ode23s.......................................................... 28 square error .....................................................83
ode23t.......................................................... 33 state-space form ............8, 22, 23, 29, 32, 49, 50
ode23tb ....................................................... 33 steady-state distributed model.........................46
ODEs .............................................................. 22 step-size...........................................................24
ordinary differential equation ........................ 47 Stiff Problems .................................................28
ordinary differential equations........................ 22 Super Target....................................................74
surf ...............................................................67
P
T
parabolic PDE.......................................... 39, 60
Parameter confidence regions ..................... 89 Taylor expansion.............................................23
Parameter Estimation...................................... 82 Taylor expansions ...........................................53
partial differential equation............................ 36 tearing .............................................................73
partial differential equations .......................... 60 Tubular reactor ...............................................39
PDE ................................................................ 36 U
pinch technology............................................. 74
pivots............................................................... 13 upwind.............................................................61
polyfit ....................................................... 84 V
Polynomial fit ................................................. 84
polytool ..................................................... 85 variable step-size.............................................27
polyval ....................................................... 85 Variable Step-Size...........................................27
Prediction confidence regions...................... 90 variance...........................................................88
predictor-corrector methods .......................... 30 von Neuman ....................................................45
PRO/II ........................................................... 74 W
process synthesis ............................................ 74
Wave-type PDE ...............................................60
R
X
rank ................................................................. 16
rcond ............................................................ 15 x = A\b........................................................14
Regression ...................................................... 82
94