A new index 2 Runge-Kutta method for the simulation of batch and discontinuous processes

6
Computers &Chemical Engineering Computers and Chemical Engineering 24 (2000) 625-630 www.elsevier.com/locate/compchemeng A new index 2 Runge-Kutta method for the simulation of batch and discontinuous processes Russell Williams ap*, Ian Cameron a, Kevin Burrage b a The CAPE Centre, Department of Chemical Engineering, The University of Queensland, Brisbane 4072, Australia b Advanced Computational Modelling Centre, Department of Mathematics, The University of Queensland, Brisbane 4072, Australia Abstract A solver capable of handling discontinuous differential-algebraic equations, up to a different index of 2, has been implemented in the process simulator NIMBUS. This solver is constructed from a Runge-Kutta method and so, unlike other high index solvers, does not require symbolic differentiation of the equation set. This paper outlines the solver, its implementation, and compares its performance with that of other solvers. 0 2000 Elsevier Science Ltd. All rights reserved. 1. Introduction Dynamic models of continuous processes are increas- ingly used for control, design and other purposes. Dy- namic descriptions allow advanced design methods and what-if predictions without physically altering the plant. Dynamic modelling often results in a set of differen- tial algebraic equations (DAEs). The integration prob- lem is then to solve dx -& = f(t, x, Y, PI, xkl) = x0, (1) 0 = g(t, x, Y, P), YGO) = Yo, (2) for time, t, between to and tf where x are state variables, y are algebraic variables and p represents design parameters within the model. Many numerical methods, notably Backward Differ- ence Formulae (BDF) and Runge-Kutta methods, ex- ist to solve this problem provided that the matrix agi/azj is nonsingular. That is to say, the problem must be of differential index 1. Such a description is inadequate when considering more general chemical process operations. Start-up and shutdown, (von Westerholt, Beard & Melsheimer, 1991) intermittent and batch processes (Williams, Newell & Bailey, 1998) or the operation of safety equipment (Dimitriadis, Shah dz Pantelides, 1997), include discon- * Corresponding author. tinuous events (the opening, closing or saturation of valves, etc). The resulting problem is considered a hybrid dynamical system (HDS) as it is described by the interaction of a continuous and discrete system. A simple example is the overflowing tank of Fig. 1. These problems exhibit several special characteristics, (i) not all equations need change between states of the model (as in the above example), (ii) discrete modelling must be expressive to include complex behaviour, such as the logic of a supervisory control system, and (iii) equations of high differential index can occur more easily, as observed in Barton and Park (1997). These issues have begun to be addressed. Modelling languages have been developed to describe discontinu- ous systems, (Barton, 1992), allowing individual equa- tions to change and a wide range of discrete behaviour to be described. Further, efficient discontinuity han- dling for DAEs was considered in Park and Barton (1996). High index problems are currently differentiated until an index 1 system can be formulated (Mattsson & SBderlind, 1993). High index problems occur when algebraic equations are introduced which constrain the value of differential variables. The derivatives of these variables are then implied and the number of ‘free’ variables reduced. This is illustrated in Fig. 1 where the tank’s height is fixed during overflow, implying dh/dt = 0. The number of differentiations required to achieve a pure ODE system is the differential index of the equa- tion set. A typical DAE requires one differentiation, 0098-1354/00/$- see front matter 0 2000 Elsevier Science Ltd. All rights reserved. PII: SOO98-1354(00)00349-S

Transcript of A new index 2 Runge-Kutta method for the simulation of batch and discontinuous processes

Computers & Chemical Engineering

Computers and Chemical Engineering 24 (2000) 625-630 www.elsevier.com/locate/compchemeng

A new index 2 Runge-Kutta method for the simulation of batch and discontinuous processes

Russell Williams ap*, Ian Cameron a, Kevin Burrage b

a The CAPE Centre, Department of Chemical Engineering, The University of Queensland, Brisbane 4072, Australia b Advanced Computational Modelling Centre, Department of Mathematics, The University of Queensland, Brisbane 4072, Australia

Abstract

A solver capable of handling discontinuous differential-algebraic equations, up to a different index of 2, has been implemented in the process simulator NIMBUS. This solver is constructed from a Runge-Kutta method and so, unlike other high index solvers, does not require symbolic differentiation of the equation set. This paper outlines the solver, its implementation, and compares its performance with that of other solvers. 0 2000 Elsevier Science Ltd. All rights reserved.

1. Introduction

Dynamic models of continuous processes are increas-

ingly used for control, design and other purposes. Dy- namic descriptions allow advanced design methods and what-if predictions without physically altering the plant.

Dynamic modelling often results in a set of differen- tial algebraic equations (DAEs). The integration prob- lem is then to solve

dx -& = f(t, x, Y, PI, xkl) = x0, (1)

0 = g(t, x, Y, P), YGO) = Yo, (2)

for time, t, between to and tf where x are state variables, y are algebraic variables and p represents design parameters within the model.

Many numerical methods, notably Backward Differ- ence Formulae (BDF) and Runge-Kutta methods, ex- ist to solve this problem provided that the matrix agi/azj is nonsingular. That is to say, the problem must be of differential index 1.

Such a description is inadequate when considering more general chemical process operations. Start-up and shutdown, (von Westerholt, Beard & Melsheimer, 1991) intermittent and batch processes (Williams, Newell & Bailey, 1998) or the operation of safety equipment (Dimitriadis, Shah dz Pantelides, 1997), include discon-

* Corresponding author.

tinuous events (the opening, closing or saturation of valves, etc). The resulting problem is considered a hybrid dynamical system (HDS) as it is described by the interaction of a continuous and discrete system. A simple example is the overflowing tank of Fig. 1.

These problems exhibit several special characteristics, (i) not all equations need change between states of the model (as in the above example), (ii) discrete modelling must be expressive to include complex behaviour, such as the logic of a supervisory control system, and (iii) equations of high differential index can occur more easily, as observed in Barton and Park (1997).

These issues have begun to be addressed. Modelling languages have been developed to describe discontinu- ous systems, (Barton, 1992), allowing individual equa- tions to change and a wide range of discrete behaviour to be described. Further, efficient discontinuity han- dling for DAEs was considered in Park and Barton (1996). High index problems are currently differentiated until an index 1 system can be formulated (Mattsson & SBderlind, 1993).

High index problems occur when algebraic equations are introduced which constrain the value of differential variables. The derivatives of these variables are then implied and the number of ‘free’ variables reduced. This is illustrated in Fig. 1 where the tank’s height is fixed during overflow, implying dh/dt = 0.

The number of differentiations required to achieve a pure ODE system is the differential index of the equa- tion set. A typical DAE requires one differentiation,

0098-1354/00/$ - see front matter 0 2000 Elsevier Science Ltd. All rights reserved. PII: SOO98-1354(00)00349-S

626 R. Williams et al. /Computers and Chemical Engineering 24 (2000) 625-630

making it index 1. The example above requires two and so is index 2.

Ultimately better modelling can reduce the index, (Unger, Krijner & Marquardt, 1995) but within the solver (Mattsson & Soderlind, 1993) proposes to reduce the index through symbolic differentiation. In hybrid systems this is potentially expensive as event frequency increases (consider a periodically sampled control sys- tem). Besides the repeatedly incurred cost, such manip- ulations are not possible if third party software or external routines are required to calculate chemical properties.

The authors have introduced a numerical solver to the process simulator, NIMBUS, capable of solving discontinuous DAEs using a Runge-Kutta numerical method, where the differential index of the equation set can be up to index 2. This is done without requiring differentiation of the equation set.

Following is a brief introduction to the description of hybrid dynamical systems considered by our solver. The paper then describes the implementation of the solver particularly the Runge-Kutta method used, including its index 2 capability. Finally, numerical tests are per- formed and compared with a discrete-event-capable BDF method.

2. Description of hybrid dynamical systems

Our present concern is the numerical solution of these systems. Therefore, we reduce the representation to a continuous system under the influence of a discrete controller.

We consider the continuous system to be a set of DAEs of the form

dx z = f(4 x, Y, P, $3

h dh,Fl-~2-F

dt FI = f(t) 3

F2 = f(h)

F2

h > bank

;

Fs < 0

Fig. 1. The hybrid model for an overflowing tank.

(3)

0 = f&f, x, Y1 P, 4, (4)

where the new variable, z, represents discrete variables output from the discrete controller.

To allow flexible description, discrete behaviour is modelled according to the grafcet international stan- dard (International Electrotechnic Commission, 1993). This provides a natural interface between the continu- ous and discrete systems. Thus, we define conditions as relational expressions of the form

r#, x, Y, P, z>, (5)

(for instance, (h > htank)) where r = (~~1 is the full set of conditions. Each event represents a logical combination of conditions,

L(t) = P(r(4 x, Y, p, ZN, (6)

where P is a logical proposition (such as (p > p,) A (T < T,)). L is, then, the vector of all possible events within the model. The current state, q, of the grafcet is defined by the set of currently active actions. The set of active actions changes as events become true, so the evolution of the state of the grafcet is given by

4+ = 6 4) (7)

where q and q+ are the states before and after firing, respectively.

When an action becomes active, a set of assignments specifies changes in variables (state, discrete or parame- ter). Thus the grafcet acts on variables according to

x+ = r(x, q, q+1, (8)

Y+ = ?(Y> 41 qfh (9)

z+ = u(z, q, q+). (10)

Each state change involves firing all active actions whose events are true. All actions must occur before any further events can fire.

We consider firing and the consequent actions to be zero time events (i.e. they take no time to occur).

3. Hybrid solver description

We wish to solve the above model for a given initial continuous and discrete state (i.e. x = x(t& y = y(to) and z = z(Q).

As discrete simulation is considered a zero time event, discrete simulation need only be performed when an event occurs. All hybrid dynamical solvers, there- fore, currently consist of three portions.

DAE solver: A standard numerical integrator determining be- haviour of continuous variables.

Event handler:

R. Williams et al. /Computers and Chemical Engineering 24 (2000) 625-630 621

A mechanism for detecting and locating currently active events which change their logical state.

Discrete simulator: A means for solving the discrete system, perform- ing actions and triggering events until a new stable state is reached.

Following is a description of each of these portions as implemented in our solver.

3.1. DAE solver

An effective DAE solver for hybrid systems is (i) generally implicit, allowing simultaneous solution of algebraic and differential variables; (ii) offers an inter- polant at an appropriate accuracy for use in event location and (iii) has an efficient, high order restart of the integrator (of importance when many discontinu- ities occur (Tyreus, 1997)).

Finally, the ability to handle problems of higher differential index would be advantageous.

Existing discontinuous DAE solvers have been con- structed from BDF methods (Park & Barton, 1996) since these are of high order and offer cheap differential and algebraic interpolants. However, restart is re- stricted to order 1 behaviour, stability properties are often poorer than equivalent Runge-Kutta methods are generally limited to problems of differential index 1 (Petzold, 1982) without the use of symbolic differentiation.

Alternatively, Runge-Kutta methods do not use past solutions to achieve high order, potentially reducing restart costs. Recent work by Hairer, Lubich and Roche (1989) found order conditions for the solution of higher index problems. However Runge-Kutta meth- ods do not offer natural interpolants and computa- tional costs for fully implicit methods can be large.

Our solver utilises a stiffly accurate, four stage, ex- plicit stage diagonally implicit Runge-Kutta (ES- DIRK) method of order 3. Memory and iteration costs due to implicit solution are no more than for BDF methods due to the diagonally implicit form and a stiffIy accurate method will ensure algebraic constraints are satisfied. While a detailed derivation of this method is given in Williams, Burrage, Cameron and Kerr (2000), it will be briefly outlined below.

3.1.1. Derivation If we designate the stage solution for the nth step as

Xni, Yai and the solution from the previous step as x,, yn, a Runge-Kutta method requires that we solve

X,i = X, + h f: Orvf(tn + cih, X,, Y,, P, Z),

j=l

i=2 ,***, 4,

0 = g(t, + c,h, Xni, Ynh p, Z).

(11)

(12)

The constants in these equations can be listed in a Butcher tableau of the form

0 I 0

which incorporates the explicit first stage (X,, = x, and Y,, = y,), stiff accuracy (x, + r = X,, and y,, + I = Yn4) and is diagonally implicit.

From Hairer, Norsett and Wanner (1991), we can assume

C(2) Ck

: ACk-‘=- kc1 2

k’ ’ (14)

B(3) : bTCk-- =;, k= 1, . . . . 3. (15)

which ensure order 2 in the stage solutions and order 3 for the overall method, respectively.

The method can be of order 3 for index 2 problems by satisfying conditions derived in Hairer et al. (1989). However, these conditions are given assuming that A is non-singular which is not true for our method.

Noting that the first term in the summation of Eq. (11) f(t,, Xnl, Znl, p, z), was calculated in the previous step and is fixed throughout iterations, we designate this term as T,, and rewrite Eq. (11) in the form

i=l >***, 3 (16)

where

(17)

Recognising this as a Nordsieck method, it is clear that in this formulation the stage order can always be two. The theory as developed in Hairer et al. (1989) can then be applied in a completely similar manner to this class of Nordsieck multivalue methods.

Given the above, the additional order conditions we must apply for index 2 methods are then found accord- ing to Hairer et al. (1989). These are summarised in the assumptions

A,(3) : p;ip = 1 7 k= 1, . . . . 3 (18)

A,(3) : LTA-le=i;T&-2e , i;T;i--@ = k,

k=2,3 (19)

where e = [l,l,llT, 6 = [b2,b3,~lT and ?: = [c2,c3,11T. As- sumption Eq. (18) ensures order 3 in the differentials while Eq. (19) provides order 2 in the algebraics.

Remaining coefficients and determined by requiring A stability of the method and specifying the second

628 R. Williams et al. /Computers and Chemical Engineering 24 (2000) 625-630

stage as an embedded order 2 solution for error con- trol. Upon solving the above order conditions, the resulting Butcher tableau for the method has the form

010

(20)

Such a method solves index 2 DAEs without requir- ing symbolic differentiation of the equation set.

3.1.2. Interpolants Unlike BDF methods, Runge-Kutta methods do not

naturally offer interpolants for algebraic variables. Two interpolation methods were considered, the first being a simple divided difference formula using the high order stage solutions. Solutions for the differentials then form a her-mite interpolant.

An alternative interpolant can be created by applying assumptions C(2) and B(3) to create a method with step length Bh. The equation for the interpolant is then

d L P’Y,+hb,%+hb,- dyn+t dt +hhdt (21)

z” = z, + hb,z:, + hb&-;, + hb,z;+ 1,

where, bj =A(@.

(22)

Through Eq. (12) does not determine algebraic derivatives, their value can be back-calculated by apply- ing Eq. (11) to the algebraic variables and solving for their derivatives, providing derivatives of the explicit stage (z;) are available. Then,

(23)

Due to the higher stage order and the first step typically being conservative, we substitute Z,,, 1: Z,, into Eq. (23) and solve for the remaining gradients. This provides an estimate of z;, which is then used as the first stage of the next step. Thereafter, values are found directly from Eq. (11) as z; + i = ZL,.

Numerical comparisons between these two inter- polants suggested the latter was a more reliable inter- polant for event location as it offered error proportional behaviour, in keeping with the Runge- Kutta method.

3.1.3. Re-initialisation Consistent initial conditions will satisfy the system

described by Eqs. (3) and (4) upon restart of the numerical integrator, including any ‘hidden constraints’ implied if the equation set is of high index. In so doing, error control and convergence problems are prevented.

We assume that the modeller has exactly calculated changes to differential variables across a discontinuity as these are typically conserved properties in process engineering problems. Thus, we fix differential variables

across the discontinuity and allow algebraics to vary. Index 1 systems are, then, fully defined and can be solved through Newton iteration.

Higher index problems implicitly (a) introduce addi- tional equations and (b) specify the derivatives of some differential variables. We wish to avoid symbolic differ- entiation, so the method discussed in Kroner, Mar- quardt and Gilles (1992) is attractive. Here subsets of the equation requiring differentiation are identified structurally and numerical derivatives formed. Those differential variables now determined by a constraint are no longer considered fixed and a Newton iteration can again be used.

The re-initialisation of index 2 problems is currently being implemented in the solver.

3.2. Event handler

The method for event detection and location is de- scribed in Williams and Cameron (1998). Based on the algorithm of Park and Barton (1996), the only differ- ence is that the algorithm does not perform re-initialisa- tion until after the discrete simulation has been performed. This does not address the issue of disconti- nuity sticking discussed in Park and Barton (1996) but has not proven a problem in tests so far.

3.3. Discrete simulation

Simulation of the discrete system is implemented in accordance with International Electrotechnic Commis- sion (1993).

4. Experimental comparison

The performance of this solver, constructed on a Runge-Kutta numerical method, was compared with a variable order BDF method on a number of typical discontinuous problems. Example results appear below.

In each case, calculated values were compared with a solution calculated at a tolerance of 10 - l4 using the BDF method (unless otherwise indicated). The number of discontinuities detected was also monitored to detect discontinuity sticking or a lack of event detection but no such problems occurred. Errors were calculated as the minimum number of significant correct digits,

scd: = - log,, (!lycal;::Ytll,).

(24)

4.1. Compressor with saturated valve

Preston and Berzins (1991) describe a compressor experiencing a sudden peak in load. This causes the

R. Williams .et al. /Computers and Chemical Engineering 24 (2000) 625-630 629

0 4 0 * 7 0 0 am

Sc&arEffottasNumtmrofFunchCalk

,#I I 2 3 4 6 0 7 * 0

Fig. 2. Plots of solver performance for Preston’s compressor problem.

10'

1 1 -16

e

*L 10’ 4

sohwEnortasCPUl-ime

IzzEJ t

4.0 6 0.0 fA 0.0 7 7.4

Sohw Effti as Number of Fundka Calls

‘#*, c

t 4

Fig. 3. Plots of solver performance for the index 2 form of Preston’s compressor problem.

valve controlling pressure to saturate, resulting in two discontinuous events. The results of the comparison appear in Fig. 2.

We note that the BDF method struggled to find a solution at lower tolerances as it did not detect sudden changes in the system’s transient behaviour. - Solution of an index 2 form of this model (Hairer et al., 1989) was compared with RADAU v, a fully implicit Runge-Kutta method which is order 3 for index 2 problems (Hairer et al., 1991), as the BDF method used did not provide symbolic differentiation. The results appear in Fig. 3.

4.2. Batch prefermenter

This model was introduced in Williams et al. (1998) and describes a prefermenter used to produce volatile fatty acids for waste water treatment. The model in- volves 20 differential and three algebraic variables and results appear in Fig. 4. For these tests, five events occur with a large amount of transient behaviour due to changing concentrations. BDF could not provide higher precision solutions so the ‘exact’ result is calcu- lated by the DIRK2 method.

5. Discussion

The results demonstrate the solver’s ability to handle events efficiently, particularly at lower tolerances, and

!3ohrEflortasCPUllma

I 3 4

20 6 7 LI

Fig. 4. Plots of solver performance on a batch prefermenter model.

630 R. Williams et al. /Computers and Chemical Engineering 24 (2000) 625-630

its index 2 capability. Analysis of the solution costs suggested the BDF method was slightly more efficient because restart was still a small proportion of the overall effort. Any gains made by our method’s high order restart would be minimal, while BDF achieves higher order at lower cost by using past solutions.

The difficulties encountered with the BDF method were surprising. For Preston’s compressor problem this seemed due to implementational issues regarding initial stepsize selection, rather than any stability problems of the method. The same might not be true for the prefer- menter problem as its dynamics are stiff and may result in poorer performance.

The new method’s performance on index 2 problems has been satisfactory, particularly in comparison to the fully implicit RADAU method which involves higher computational and memory costs. It would still be of interest to compare performance of the new solver to a BDF method, which performs symbolic differentiation.

The above problems are still small in industrial terms and so other models are currently being developed to test the methods with larger numbers of equations and events. Also, discontinuous index 2 problems can only be tested when the index 2 restart has been implemented.

6. Conclusion

This paper has introduced a numerical solver imple- mented in the process simulation package NIMBUS ca- pable of handling hybrid dynamical systems. The use of an ESDIRK method allows higher order restart and the solution of index 2 equation sets without numerical differentiation, in contrast to methods based on BDF integration.

Numerical tests indicate performance comparable to existing methods. Future work will fully implement the reinitialisation procedure to handle index 2 equation sets and further testing will be performed.

Acknowledgements

The authors thank Bob Newell for discussions about implementation within NIMBUS and for developing the grafcet language representation. We acknowledge sup- port under ARC A8901937 grant.

References

Barton, P. I. (1992). The modelling and simulation of combined

discrete/continuous processes. PhD thesis. Imperial College,

London.

Barton, P. I. & Park, T. (1997). Analysis and control of combined

discrete/continuous systems: progress and challenges in the chem-

ical processing industry. American Institute of Chemical Engineer- ing Symposium Series.

Dimitriadis, V. D., Shah, N., & Pantelides, C. C. (1997). Modelling

and safety verification of discrete/continuous processing systems.

American Institute of Chemical Engineering Journal, 34(4), 1041-

1059.

Hairer, E., Lubich, C., & Roche, M. (1989). The numerical solution

of differential-algebraic systems by Runge-Kutta methods. In

Lecture notes in mathematics, vol. 1409. Berlin: Springer-Verlag.

Hairer, E., Nsrsett, S. P., & Wanner, G. (1991). Solving ordinary differential equations, vol. 2. Berlin: Springer-Verlag.

International electrotechnic commission, (1993). Programmable con-

trollers - part 3: programming languages (pp. 113 1 - 1133). Publi-

cation.

KrBner, A., Marquardt, W., & Gilles, E. D. (1992). Computing

consistent initial conditions for differential-algebraic equations.

Computers in Chemical Engineering, 16(Suppl.), S 13 1 -S 138. Mattsson, S. E., & Siiderlind, G. (1993). Index reduction in differen-

tial-algebraic equations using dummy derivatives. SIAM Journal on Scienttjic Computing, 14(3), 677-692.

Park, T., & Barton, P. I. (1996). State event location in differential-al-

gebraic models. ACM Transactions on Modelling and Computer Simulation, 6(2), 137-165.

Petzold, L. R. (1982). Differential algebraic equations are not ODE’s,

SIAM Journal on Scientific and Statistical Computing, 3, 367-384. Preston, A. J., & Berzins, M. (1991). Algorithms for the location of

discontinuities in dynamic simulation problems. Computers in chemical engineering, IS(lO), 701-713.

Tyreus, B. D. (1997). Interactive, dynamic simulation using extrapo-

lation methods. Computers in Chemical Engineering, 21 (Suppl.),

s173-s179.

Unger, J., Kroner, A, & Marquardt, W. (1995). Structural analysis of

differential-algebraic equation systems - theory and applica-

tions. Computers in Chemical Engineering, 19(8), 867-882. Westerholt, E. von, Beard, J. N., & Melsheimer, S. S. (1991). Time-

optimal startup control algorithm for batch processes. Industrial and Engineering Chemistry Research, 30(6), 1205-1212.

Williams, R., Burrage, K., Cameron, I. & Kerr, M. (2000). A

four-stage index 2 diagonally implicit Runge-Kutta method. Ap- plied Numerical Mathematics (in press).

Williams, R. & Cameron, I. (1998). Comparison of multi-step and

Runge-Kutta numerical methods when simulating bath pro-

cesses. In Chemeca’98 - proceedings number 189.1, Port Dou-

glas. Australia (proceedings on CDROM). Williams, R., Newell, R. & Bailey, J. (1998). Modelling and valida-

tion of a batch prefermenter using a reduced model of prefermen-

tation. In Chemeca’ 98 - proceedings, number 189. Port

Douglas, Australia (proceedings on CDROM).