comparison of 4 numerical solvers for stiff and hybrid

8
Comparison of 4 Numerical Solvers for Stiff and Hybrid Systems Simulation Liu Liu, Felix Felgner, and Georg Frey Chair of Automation, Saarland University Saarbrücken, Germany { liu.liu | felix.felgner | georg.frey }@aut.uni-saarland.de Abstract Numerical simulation of stiff and hybrid systems is widely used in various engineering domains. Numerical solvers, originally designed for purely continuous problems, are not sufficient for these systems. Modern simulation environments provide necessary modifications and extensions to solve the problem. The implementation details of solvers and run time systems greatly affect the performance of simulations regarding accuracy, velocity of simulation, compactness of results, and efficiency. Since no all-powerful solver exists, we assess four popular solvers (DASSL, LSODAR, DOPRI5, RADAU IIA), included in the all-purpose simulator Dymola ® for different problems with continuous, stiff, and hybrid behavior. Key traits, including the number of steps, accuracy, CPU time and the event handling capability, are examined and advice for solver selection is given. 1. Introduction Modern modeling and simulation environments, e.g. Dymola ® , provide a flexible graphical user interface to model a system and translate the resulting model into an equation system. Depending on the modeled problem and modeling approach, the equation systems to be solved can be ordinary differential equations (ODEs), differential algebraic equations (DAEs) or hybrid differential algebraic equations (HDAEs). There are several numerical solvers available for ODEs and DAEs. Despite the relatively mature tool support, a remaining problem bothers the users under most circumstances. How to choose an appropriate numerical solver for a particular problem? It is a question of efficiency, accuracy and correctness of the numerical solution. This paper presents a comparison of four well-established numerical solvers in the context of numerical simulation: two of the solvers apply multi-step methods (DASSL, LSODAR); the other two apply single-step Runge-Kutta methods, one implicit (RADAU IIA), one explicit (DOPRI5). Not only the final performance of each solver is presented, but also the underlying mathematical theory is summarized. On the basis of different benchmark models, the comparison results help the readers to choose a suitable solver for individual problems. This paper is organized as follows: Chapter 2 presents the motivation of the work. Chapter 3 introduces the theoretical background of numerical solvers. Chapter 4 presents a systematic assessment of different solvers, which is carried out on three essential model types: normal (non-stiff) continuous, stiff continuous and stiff hybrid models. Finally, Chapter 5 summarizes the results and gives a conclusion. 2. Motivation In the context of numerical simulation, the main concerns are accuracy and efficiency. Naturally, it is a trade-off problem, which gets worse if the complexity of the studied system rises. Even with normal continuous systems, different solvers already display diverse performances. Regarding hybrid and/or stiff system simulation, our general-purpose benchmark study has to consider two additional basic issues: the handling of events and stiffness. Further, more case-specific issues, such as chattering, event iteration or Dirac pulses, are omitted here; in [11], for instance, they were discussed in an overview of several simulation packages, including Dymola ® . 2.1. Event handling Event handling is the key issue in hybrid system simulation. Basically, the run time system (simulator) observes all conditional statements at every time step during the numerical solution process. If a conditional statement becomes true from time step t n to t n+1 , the numerical solver is stopped at time step t n , i.e. an event is detected. A root-finder algorithm is executed to localize the event time ] , [ 1 E n n t t t . After that, the numerical solver is restarted and executes from t n to t E . At time t E , new initial conditions are estimated and the numerical solving process proceeds as normal. Event handling is a time-consuming process. If the conditional statement depends on dependent variables, the numerical solver has to be executed several times during the root finding process. Furthermore, the 978-1-4244-6849-2/10/$26.00 ©2010 IEEE

Upload: others

Post on 13-Jun-2022

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Comparison of 4 Numerical Solvers for Stiff and Hybrid

Comparison of 4 Numerical Solvers for Stiff and Hybrid Systems Simulation

Liu Liu, Felix Felgner, and Georg Frey Chair of Automation, Saarland University

Saarbrücken, Germany { liu.liu | felix.felgner | georg.frey }@aut.uni-saarland.de

Abstract

Numerical simulation of stiff and hybrid systems is widely used in various engineering domains. Numerical solvers, originally designed for purely continuous problems, are not sufficient for these systems. Modern simulation environments provide necessary modifications and extensions to solve the problem. The implementation details of solvers and run time systems greatly affect the performance of simulations regarding accuracy, velocity of simulation, compactness of results, and efficiency. Since no all-powerful solver exists, we assess four popular solvers (DASSL, LSODAR, DOPRI5, RADAU IIA), included in the all-purpose simulator Dymola® for different problems with continuous, stiff, and hybrid behavior. Key traits, including the number of steps, accuracy, CPU time and the event handling capability, are examined and advice for solver selection is given.

1. Introduction

Modern modeling and simulation environments, e.g. Dymola®, provide a flexible graphical user interface to model a system and translate the resulting model into an equation system. Depending on the modeled problem and modeling approach, the equation systems to be solved can be ordinary differential equations (ODEs), differential algebraic equations (DAEs) or hybrid differential algebraic equations (HDAEs).

There are several numerical solvers available for ODEs and DAEs. Despite the relatively mature tool support, a remaining problem bothers the users under most circumstances. How to choose an appropriate numerical solver for a particular problem? It is a question of efficiency, accuracy and correctness of the numerical solution.

This paper presents a comparison of four well-established numerical solvers in the context of numerical simulation: two of the solvers apply multi-step methods (DASSL, LSODAR); the other two apply single-step Runge-Kutta methods, one implicit (RADAU IIA), one explicit (DOPRI5). Not only the final performance of each solver is presented, but also the underlying mathematical theory is summarized. On

the basis of different benchmark models, the comparison results help the readers to choose a suitable solver for individual problems.

This paper is organized as follows: Chapter 2 presents the motivation of the work. Chapter 3 introduces the theoretical background of numerical solvers. Chapter 4 presents a systematic assessment of different solvers, which is carried out on three essential model types: normal (non-stiff) continuous, stiff continuous and stiff hybrid models. Finally, Chapter 5 summarizes the results and gives a conclusion.

2. Motivation

In the context of numerical simulation, the main concerns are accuracy and efficiency. Naturally, it is a trade-off problem, which gets worse if the complexity of the studied system rises.

Even with normal continuous systems, different solvers already display diverse performances. Regarding hybrid and/or stiff system simulation, our general-purpose benchmark study has to consider two additional basic issues: the handling of events and stiffness.

Further, more case-specific issues, such as chattering, event iteration or Dirac pulses, are omitted here; in [11], for instance, they were discussed in an overview of several simulation packages, including Dymola®.

2.1. Event handling Event handling is the key issue in hybrid system

simulation. Basically, the run time system (simulator) observes all conditional statements at every time step during the numerical solution process. If a conditional statement becomes true from time step tn to tn+1, the numerical solver is stopped at time step tn, i.e. an event is detected. A root-finder algorithm is executed to localize the event time ],[ 1E nn ttt . After that, the numerical solver is restarted and executes from tn to tE. At time tE, new initial conditions are estimated and the numerical solving process proceeds as normal.

Event handling is a time-consuming process. If the conditional statement depends on dependent variables, the numerical solver has to be executed several times during the root finding process. Furthermore, the

978-1-4244-6849-2/10/$26.00 ©2010 IEEE

Page 2: Comparison of 4 Numerical Solvers for Stiff and Hybrid

restart of a numerical solver usually derogates the successive efficiency of the time step control as excessively small initial steps are taken. Last but not least, successful event detection in some cases requires very high accuracy of the numerical solution. These cases include highly frequent events and event conditions defined near an extremum of a dependent variable.

Consequently, the efficiency of event handling mainly depends on the step size control of the solver.

2.2. Stiffness Although the term “stiff system” is widely used and

discussed, there exists no unified definition of it. Depending on the respective point of view, the definition can be phrased quantitatively, qualitatively, or pragmatically.

Definition 1: “An ODE system is called stiff if, when solved with any n-th order accurate integration algorithm and a local error tolerance of 10–n, the step size of the algorithm is forced down to below a value indicated by the local error estimate due to constraints imposed on it by the limited size of the numerically stable region.” [10]

Definition 2: “An IVP (Initial Value Problem) is stiff in some interval [0, b] if the step size needed to maintain stability of forward Euler method is much smaller than the step size required to represent the solution accuracy.” [2]

Definition 3: “Stiff equations are equations where certain implicit methods, in particular BDF, perform better, usually tremendously better, than explicit ones.” [3], [9]

Definition 1 and 2 reflect that the stiffness depends not only on the differential equation itself, but also on accuracy criteria and on the integration interval. I.e. a system can be stiff if low accuracy is required but not stiff if high accuracy is needed. Furthermore, definition 3 gives general advice regarding the method selection for handling stiff systems.

Extending the definition of stiffness to hybrid systems must involve the concept of events. Consulting the definition 2, we define a stiff hybrid system by

Definition 4: A hybrid system is stiff in some interval [0, b] if the step size needed to successfully detect all the events is much smaller than the step size required to represent the solution accuracy.

Obviously, a hybrid system is always stiff if highly frequent events appear during the integration interval. At present, there exists no effective method to handle this problem since the step size is rather restricted by the frequency of events than by the rest of the system. But in any case, the choice of the numerical solver with its respective step size control is crucial for the performance in stiff hybrid system simulation.

3. Mathematical foundations of numerical simulation

Numerical simulation consists of two main parts: the mathematical modeling, and the solving the mathematic model using numerical methods.

3.1. Essential forms of equation systems The continuous-time behavior in technical systems

is mostly governed by general laws of nature, often supplemented by empirical laws. Mathematically, these governing principles are expressed as an equation system which makes use of two essential formalisms: 1. ordinary differential equations such as

,0),,( xxtf (1) 2. algebraic equations such as

.0),( xtg (2) Herein, t is the independent variable; x is an

N dimensional vector of dependent system variables; x is decomposable into the sub-vectors xS, containing N – M state variables, and xA, containing M algebraic variables; the derivatives of xS―and only them―are contained in the (N – M) dimensional state derivative vector x :

),(: AS xxx , Sd

d: xx

t . (3)

The entire system of equations defining the continuous-time behavior can be written as:

.

),(

),(

),,(

),,(

),,(1

1

0

x

x

xx

xx

xxF

tg

tg

tf

tf

t

M

MN

(4)

Based on (4), this paper distinguishes three forms of equation systems which have to be managed by modern solvers: ODEs, DAEs and HDAEs.

Ordinary Differential Equations (ODEs): A system of ODEs a special case of the system (4) where the number of algebraic equations is zero (M = 0).

Differential Algebraic Equations (DAEs): A system of DAEs is the set of equations defined in (4), where both scalar differential equations and algebraic constrains actually appear (0 < M < N). An example of a DAE system is a pendulum: A point mass m in the (x1, x2) plane, with the gravity acceleration g in the negative x2 direction, is attached to a massless rod of the length l with the tensile force x3. The behavior is given by the DAE system (5). The third equation is an algebraic constraint. Moreover, this system is a so-called high-index DAE problem; it must undergo a reduction algorithm reducing the index to 1 or 0 before, the problem is accessible to common DAE or ODE solvers [2].

Page 3: Comparison of 4 Numerical Solvers for Stiff and Hybrid

.

;d

d

;d

d

222

21

32

22

2

31

21

2

lxx

mgxl

x

t

xm

xl

x

t

xm

(5)

Hybrid Differential Algebraic Equations (HDAEs): A HDAE system contains a set of S DAE systems in the form of (4), combined with Boolean conditions by which, at any time t, exactly one DAE system 0),,()( xxF ti is activated:

0

),(

),(

),,(

),,(

),,(),,(

)(

)(1

)(

)(1

)(

x

x

xx

xx

xxFxxF

tg

tg

tf

tf

tt

iM

i

iMN

i

i

);,( xtCi Si ,,2,1 ).,(0 S, xIx t

(6)

At discrete time-events, the integer-valued function C triggers the switches from one DAE system i to another one; the respective switching condition may depend on the time t and/or on the dependent variables in x. During the switch, the state variables xS are (re)initialized by the function I.

Due to limited capabilities of current simulations tools (e.g. Dymola®), we consider both the number of differentiated state variables, N – M, and the number of algebraic variables, M, to be fixed for the entire HDAE system. In this regard, a HDAE system is a special case of a hybrid automaton with identical continuous variables in each discrete state and neither discrete inputs nor outputs.

A simple example of an HDAE is a bouncing ball which, when hitting the floor, reverses the direction of its velocity.

HDAEs are particularly common in the modeling of computational systems, e.g. sampling control systems with a time event at each sampling instant and with state events indicating the switching between different control strategies.

3.2. Numerical solvers There are different requirements for solving

differential equations mentioned in Chapter 3.1. For ODEs, by using symbolic manipulation the implicit form of ODEs can be converted to an explicit state space form, the task of the solvers is to integrate the right hand expressions. For DAEs, since not all the dependent variables presents in derivative form, derivatives have to be calculated. Using certain DAE solver e.g. DASSL, DAE problem with index 1 can be directly solved. Otherwise, the simulator (runtime system) can solve algebraic constrains, g(t, x) in (4),

numerically and use a normal ODE solver for f(t, x). For hybrid DAEs, the event-handling capability is required additionally. In the following section, the principles of several popular numerical solvers are illustrated. The Euler method is illustrated for explanation the basic of numerical approximation.

Radau IIA is a 3-stage implicit Runge-Kutta method. It solves DAEs which have to brought into the form Mx' = F*(t, x), where M is a constant, square matrix which may be singular. In contrast to the one-step Euler methods, Runge-Kutta methods achieve higher-order accuracy by using intermediate steps. For more details on Runge-Kutta methods, reference [3] is suggested.

The general s-stage explicit Runge-Kutta method is described by the following equations (7), (8):

)

,(

),(

),(

),(

11,

23211*

2321313*

3

1212*

2

*1

11

sss

snsns

nn

nn

nn

s

iiinn

ha

hahahct

hahahct

hahct

t

bh

k

kkxFk

kkxFk

kxFk

xFk

kxx

  (7)

The coefficients b, c and a are usually arranged in a Butcher tableau:

ss

sssss

bbbb

aaac

aac

ac

121

121

32313

212

0

  (8)

The s-stage implicit Runge-Kutta method is described by

),(1

*

11

s

jjijnini

s

iiinn

ahhct

bh

kxFk

kxx

(9)

The Butcher tableau for the implicit Runge-Kutta method is given by

s

sssss

s

s

bbb

aaac

aaac

aaac

21

21

222212

112111

(10)

The implicit Runge-Kutta method produces the equations (9), in which the unknown vector xn+1 appears on both sides. These equations have to be solved by means of an additional numeric routine, e.g. the Newton-Raphson method.

Page 4: Comparison of 4 Numerical Solvers for Stiff and Hybrid

The Butcher tabeleau of Radau IIA applied in this survey is given by (11):

91

36616

36616

91

36616

36616

1

225632

3606788

18006196396

1064

225632

18006196396

3606788

1064

(11)

Radau IIA implements a variable step size control strategy. The principle of variable step size control takes the user-defined tolerance tol, the local error vector err and the previous step size hold into consideration, i.e. hnew = hnew(hold, tol, err). According to different implementations, the step size control may vary in some details.

DOPRI5 (named after its inventors Dormand and

Prince) is a 5th-order explicit Runge-Kutta method for ODEs, i.e. for Mx' = F*(t,x) with regular M. In contrast to Radau IIA, the unknown xn+1 is explicitly given as described in (7), which makes DOPRI5 less stable. The corresponding Butcher tableau, in the form of (8), is estimated according to Dormand and Prince [4].

DASSL (Differential Algebraic System Solver) is a

DAE solver for index 0 and 1 DAEs of the form:

0

0

xx

xx

xxF

)(

)(

),,(

0

0

t

t

t 0

(12)

DASSL uses a k-th order backward differentiation formula (BDF) to approximate the derivative in (12), where k ranges from 1 to 5. The order k and step size h are determined on every step based on the behavior of the solution [1].

DASSL begins every time step by making an initial guess of the solution and its derivative at tn+1 by evaluating a predictor polynomial and the derivative of the predictor polynomial at tn+1. The predictor polynomial )(P

1 tnw is the polynomial which interpolates xn–i for i = 0, 1, …, k:

ininn t xw )(P1   (13)

The predictor values for x and x are presented as:

)(

)(

1P

1)0(

1

1P

1)0(1

nnn

nnn

t

t

wx

wx  (14)

After that, a corrector formula is formed using the fixed leading coefficient form of the k-th order BDF method. The solution to the corrector formula is the vector xn+1 such that the corrector polynomial )(C

1 tnw and its derivative satisfy the DAE at tn+1 and the corrector polynomial match the predictor polynomial at k equally spaced points behind tn+1 [1]:

0

))(),(,(

)()(

)(

1C

11C

11

11P

111C

1

11C

1

nnnnn

nnnnnn

nnn

ttt

ihtiht

t

wwF

ww

xw

  (15)

The polynomials are presented in DASSL in terms of modified divided differences of x. There are more than 13 quantities that need to be calculated at every time step. The complexity of the calculation is proportional to the order k. 1nx can be solved for after some manipulation. To get 1nx , the equation

k

js

nnn

snnn

j

ht

1

)0(11

1

)0(111

1

))(,,(

0xxxxF

  (16)

is solved using a modified Newton iteration. After the Newton iteration has achieved a defined

stopping criterion, a normalized error is estimated with the difference between the final result from iteration and the initial guess. Based on the error, DASSL decides whether the step is accepted; if not, the solution of the current time step is repeated from (13) to the Newton iteration of (16) with reduced h and k raised by 1.

For next time step, the new order k is decided by comparing specific error terms at orders k–2, k–1, k and k+1. The order is raised or lowered depending on whether these terms form an increasing or decreasing sequence.

The new step size h for is given by

oldnew rhh   (17)

where r is a function of the estimated error, the given tolerance tol and the order k of the previous step.

There are some constraints on the step size control. After a successful step, the step size is only increased if it can be doubled, and it can be reduced by a factor between [0.5, 0.9]. After an unsuccessful step, the factor varies in [0.25, 0.9]. Additionally, there exist bounds for the maximal and the minimal step size.

DASSL yields a very good stability because of the conservative selection method using in order and step size control. From the practice experience, DASSL successfully solves most of the DAEs and ODEs. However, it requires a relatively high number of steps.

LSODAR (Livermore Solver for Ordinary Differential

Equations with Automatic Method Switching and Root Finder) is an ODE solver with automatic method switching and root finding. The automatic method switching determines whether a problem can be solved more efficiently using a class of methods

suited for non-stiff problems or a class of methods designed for stiff problems [6], [7], [8],. For a non-stiff problem, a variable-step, variable-order Adams-Moulton (AM) method of orders 1 to 12 is

Page 5: Comparison of 4 Numerical Solvers for Stiff and Hybrid

used. For a stiff problem, a multistep BDF method of orders 1 to 5 is used. The AM method computes the next step based on k (order) previous steps. It is specified as follows:

),(

1

011

jjj

k

iininn

t

b

xFF

Fxx

  (18)

AM is an implicit method and uses Newton method to solve the implicit equation [4]. It is relatively effective if low accuracy is required.

The BDF method used by LSODAR differs from the one used by DASSL regarding the calculation of the coefficients. It is remarkable that LSODAR implements the order selection and step size control less conservatively than DASSL, which means more efficiency can be achieved by LSODAR.

3.3. Summary of solver characteristics We have glanced through some numerical solvers.

A short comparison of them is presented in Table 1

DASSL LSODAR RADAU IIA DOPRI5

single step method ■ ■ Multi steps method ■ ■ Explicit ■ Implicit ■ ■ ■ Conservativeness of step size control

very high high medium medium

Table 1. Characteristics of numerical solvers.

4. Benchmark tests

In the following benchmark tests, each of the four solvers was examined on three model types: a non-stiff continuous, a stiff continuous and a stiff hybrid model. The tests are executed on computer with Intel CPU [email protected] running on Windows 7. Dymola 7.3 with Microsoft C compiler was used.

4.1. Common settings and testing criteria In order to get a consistent test results, the solver

settings in Dymola® are determined as follows: Unselecting “Equidistant time grid”. The numerical

solvers decide the steps by themselves, i.e. no interpolation points are required.

For assessing the overall CPU-time of the simulation, no result file is produced. This allows the measurements not being affected by the delays of writing data on the hard drive. Following characteristics of solver are compared:

CPU time for a simulation: ttotal. Number of result points of a simulation: Nresult. Average error Erravg. Since in our “artificial”

models, the solution of a state variable can be

calculated analytically, the exact solution at each step is given as xexact,i. The average error is estimated from all successful steps (Nresult) of a simulation. Erravg is defined as:

result

0 exact,

solver,exact,

resultavg

1 N

i i

ii

x

xx

NErr   (19)

Efficiency of a numerical solver ηsolver. Depending on the different methods, the numerical solvers accomplish one step of the solution with several intermediate calculation steps. We define a criterion to indicate the efficiency of a numerical solver as:

i.steps

resultsolver N

N   (20)

where Ni.steps is the total number of intermediate calculation steps during simulation.

The number of intermediate steps for one solution step indicates how many times the numerical solver is required to calculate the dependent variables until the values are accepted. In a hybrid simulation, this includes also the steps needed to localize the events.

The tests are repeated using different tolerances. The tolerance tol is a user input for the numerical solver. It is the relative error allowed to the numerical solution and affects several important method-specific parameters of the numerical solver such as the step size selection, the order selection, etc. In our tests, tol varies from 10–10 to 10–1.

For assessing the CPU time ttotal, the models are simulated for 10,000 seconds. This setting minimizes uncertain influences such as the time of memory allocation etc. Consequently, Nresult, Ni.steps and ηsolver are assessed from 10,000-second datasets. The Erravg and the histograms of Ni.steps are estimated from a simulation of 10 seconds of model time.

4.2. Non-stiff continuous model An non-stiff continuous model is given in (21)

1)0(

)10sin(

1

12

1

x

xx

tx

  (21)

The test results are given in Figure 1. The average error Erravg of x1 reaches 10–2 at tol = 10–3, i.e. the actual error is greater than the tolerance. For DASSL and LSODAR, the error is about one order of magnitude larger than the tolerance. In general, the methods of the Runge-Kutta family produce more accurate solutions. Generally, we consider the solution to be trustworthy if the tol is set smaller than 10–3.

The solvers produce different numbers of result points, Nresult for the same tolerance. Except for DASSL, the solvers reveal relatively smooth gradients. DASSL in contrast, produces an excessive number of results points for higher accuracy requirement.

Page 6: Comparison of 4 Numerical Solvers for Stiff and Hybrid

The histogram of Nresult describes the distribution of results points against the model time with a discretization step of 0.1 s: The initial steps of DASSL are almost 1/10 of the other solvers on an average. After the initial phase, step sizes vary in a small range. Whereas the step size of DASSL is still 5 to 6 times smaller than that of the others.

The efficiency ηsolver of DASSL and LSODAR are decreasing at high tolerances, where these two solvers try to use bigger steps, which are partly rejected.

Figure 1. Results (non-stiff continuous model).

In contrast, RADAU IIA and DOPRI5 have almost the same efficiency for all tolerance settings. It must be noted, however, that low efficiency does not necessarily mean low performance.

The CPU times only show great differences at small tolerance. Except for LSODAR, the CPU times rise nearly exponentially with decreasing tolerance. Although DASSL produces most steps, the CPU time is lower than that of the two Runge-Kutta methods.

Figure 2. Results (stiff continuous model).

1.0E-11

1.0E-09

1.0E-07

1.0E-05

1.0E-03

1.0E-01

1.0E+01

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Average error Erravg

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0.0E+00

5.0E+05

1.0E+06

1.5E+06

2.0E+06

2.5E+06

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Number of results point Nresult

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0

10

20

30

40

50

60

70

0 2 4 6 8 10

Histogram of Nresult for tol = 1E-10 DASSLLSODARRADAU IIADOPRI5

Nresult = 2456

Nresult = 487Nresult = 694Nresult = 541

model time / s

0%

10%

20%

30%

40%

50%

60%

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Efficiency ηsolver

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0

5

10

15

20

25

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

CPU time ttotal / sDASSLLSODARRADAU IIADOPRI5

tolerance tol

1.0E-15

1.0E-12

1.0E-09

1.0E-06

1.0E-03

1.0E+00

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Average error Erravg

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0.0E+00

1.0E+06

2.0E+06

3.0E+06

4.0E+06

5.0E+06

6.0E+06

7.0E+06

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Number of results point Nresult

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0

100

200

300

400

500

0 2 4 6 8 10

Histogram of Nresult for tol = 1E-10

DASSL

LSODAR

RADAU IIA

DOPRI5

Nresult = 2749Nresult = 2376

Nresult = 745Nresult = 6158

model time / s

0%

10%

20%

30%

40%

50%

60%

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Efficiency ηsolver

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0

50

100

150

200

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

CPU time ttotal / s

DASSLLSODARRADAU IIADOPRI5

tolerance tol

Page 7: Comparison of 4 Numerical Solvers for Stiff and Hybrid

4.3. Stiff continuous model

We extend the model in (21) by a stiff ODE:

2)0(

2000

3

33

x

xx  (22)

x3 rapidly will reach the steady-state position x3 = 0 through a short transient phase. It is expected that a solver uses smaller steps during transient phases and larger steps in (quasi) steady-state phases.

Figure 2 contains the set of test results for the stiff model. For the stiff problem ηsolver remains almost the same as for non-stiff system. Again, Erravg is estimated for x1. Although DOPRI5 suffers a stability problem on x3, it produces very exact value of x1 due to very small steps. Consequently, DOPRI5 produces the largest number of result. LSODAR changes the method for stiff problems, where the BDF-based method shows comparable performance to DASSL. The performance of RADAU IIA is similar as for the non-stiff model. Generally, DOPRI5―as an explicit method―is not suited for stiff problems.

4.4. Stiff hybrid model A stiff hybrid model (according to definition 4, cf.

section 2.2) is extended from (21) by an event condition and a switch of equations on x2:

1.1 if ,1

1.1 if ,

11

11

2xx

xxx   (23)

The results in Figure 3 are only represented within that range of tolerance, in which the respective solver detected all events: for DASSL up to tol = 10–2, for LSODAR and RADAU IIA up to tol = 10–3, whereas for DOPRI only up to tol = 10–6. With the Runge-Kutta methods, Erravg is greater than for the continuous models, whereas with DASSL and LSODAR, errors remain almost unchanged. The number of results points of DASSL and LSODAR are almost doubled. In contrast, for the Runge-Kutta methods, the number of results remains almost the same as for the non-stiff model (21). The histogram of Nresult explains the reason: At every occurrence of an event, solvers are restarted with the same initial step size, i.e. the initial phase of the non-stiff model is repeated. The consequence is a large number of steps needed for localizing the events. As a result, the efficiencies of DASSL and LSODAR drop from 50 % below 30 %. In contrast, Runge-Kutta methods, with almost constant step sizes during the simulations, deliver Nresult and ηsolver as in model (21).

5. Summary and Conclusion

In order to summarize the various results to a general survey, we define four criteria indicating the performance of the four numeric solvers:

Accuracy: avg1 / ErrtolC

Velocity of simulation: total2 /1 tC

Compactness of results: result3 /1 NC

Efficiency: solver4 C

All criteria are normalized to a [0, 1] scale. C1 is set to the maximum of 1 in all cases where tolErr avg . C2 and C3 are normalized with respect to the smallest values of ttotal and Nresult among all tests. C3 indicates the memory consumption of a simulation. C4 is already normalized by the definition of solver in (20).

Figure 3. Results (hybrid stiff model).

1.0E-10

1.0E-08

1.0E-06

1.0E-04

1.0E-02

1.0E+00

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Average error Erravg

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0.0E+00

1.0E+06

2.0E+06

3.0E+06

4.0E+06

5.0E+06

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Number of results point Nresult

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0

20

40

60

80

0 2 4 6 8 10

Histogram of Nresult for tol = 1E-10

DASSL LSODAR RADAU IIA DOPRI5

model time / s

Nresult = 4124 Nresult = 1913 Nresult = 738 Nresult = 535

0%

10%

20%

30%

40%

50%

60%

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

Efficiency ηsolver

DASSLLSODARRADAU IIADOPRI5

tolerance tol

0

5

10

15

20

25

1.0E-10 1.0E-08 1.0E-06 1.0E-04 1.0E-02

CPU time ttotal / s

DASSL

LSODAR

RADAU IIA

DOPRI5

tolerance tol

Page 8: Comparison of 4 Numerical Solvers for Stiff and Hybrid

The comparison is given in Kiviat graphs for the non-stiff continuous model, the stiff continuous model and the stiff hybrid model, each with tolerance settings of tol := 10–4 and tol := 10–10 (Table 2).

Obviously, there exists no general all-powerful solver for all three model types.

In all cases, the CPU-time and memory consumption increase rapidly with the decreasing tolerance.

Generally, all solvers show better performance for the continuous models than for the hybrid model.

References

[1] K. E. Brenan, S. L. Campbell, L. R. Petzold, Numerical Solution of Initial-Value Problems in Differential-Algebraic Equations, Elsevier Science Publishing, 1989.

[2] U. M. Ascher, L. R. Petzold, Computer Methods for Ordinary Differential Equations and Differential-Algebraic Equations. SIAM, 1998.

[3] E. Hairer, G. Wanner, Solving Ordinary Differential Equations II-Stiff and Differential-Algebraic Problems, Springer-Verlag, 1991.

[4] E. Hairer, S. P. Nørsett, G. Wanner, Solving Ordinary Differential Equations I-Nonstiff Problems, Springer-Verlag, 2008.

[5] P. Fritzson, Principles of Object-Oriented Modeling and Simulation with Modelica 2.1, Wiley, 2004.

[6] A. C. Hindmarsh, "ODEPACK, A Systematized Collection of ODE Solvers," IMACS Transactions on Scientific Computation , Vol.1, pp. 55-64,1983.

[7] K. Radhakrishnan and A. C. Hindmarsh, "Description and Use of LSODE, the Livermore Solver for Ordinary Differential Equations", LLNL report UCRL-ID-113855, December 1993.

[8] L. R. Petzold, “Automatic Selection of Methods for Solving Stiff and Nonstiff systems of Ordinary Differential Equations”, Sandia National Laboratories Report SAND80-8230, September, 1980.

[9] C. F. Curtiss and J. O. Hirschfelder, “Integration of Stiff Equations”, Proceedings of the National Academy of Sciences of the United States of America, vol 38, pp. 235-243, 1952.

[10] F. E. Cellier, E. Kofman, Continuous System Simulation, Springer, 2006.

[11] P. J. Mosterman, “An Overview of Hybrid Simulation Phenomena and Their Support by Simulation Packages”. In Hybrid Systems: Computation and Control '99, pp. 165-177, 1999.

Non stiff continuous model Stiff continuous model Stiff hybrid model

tol=

1E-4

tol=

1E-1

0

DASSL LSODAR RADAU IIA DOPRI5

Table 2. Comparison of the numerical solver performances.

Accuracy

Vel

ocity

Compactness

Eff

icie

ncy

Accuracy

Vel

ocity

Compactness

Eff

icie

ncy

Accuracy

Vel

oci

ty

Compactness

Eff

icie

ncy

Accuracy

Vel

ocity

Compactness

Eff

icie

ncy

Accuracy

Vel

ocity

Compactness

Eff

icie

ncy

Accuracy

Vel

ocity

Compactness

Eff

icie

ncy

DOPRI5 fails to

detect all events