solver

A solver is a software algorithm that solves a system of ordinary differential equations. The choice of solver is crucial for complex models. Below we describe some of the terms defining different solvers implemented in Ecolego.

The solvers in Ecolego can be categorized into having a time stepping scheme being either fixed-step or variable-step. The fixed-time-step algorithms are very simple compared to the variable-step and they use a fixed constant time step *h* defined previous to the computations. Thus the fixed-step solver will compute values at times . The quality of the solution therefore depends on the choice of a small enough *h*. Though too small choice of *h* might give too long computation time.

The variable-step solvers uses algorithms to adapt the size of the time-steps to maintain a certain error tolerance. It may take larger time steps when the solution vary slowly whilst adapting and taking smaller time-steps as soon as the solution begins to vary faster.

Variable-step-size solvers are recommended before the fixed-step-size solvers because they usually are much faster, more reliable and ensures that numerical instability does not occur.

The size of the error tolerance levels specified for the numerical solution affects the accuracy of the computed solution. But it also affects the speed of the computation. The accuracy and the speed are negatively correlated; i.e. the better quality you want of the solution, the more you need to wait for the simulation to finish.

In the variable-step-size ODE solvers in Ecolego the time-stepping is adaptively adjusted to maintain the estimated truncation error below a specified tolerance level. A truncation error is the error that occurs when an “infinite process is exchanged with an finite”, i.e. when an infinite series is approximated by a partial sum, or when a function is approximated by a straight line. The tolerance levels are specified in relative and absolute terms.

- relative error tolerance ≥ | (y
_{true}- y_{estimated}) / y_{true}| - absolute error tolerance ≥ | y
_{true}- y_{estimated}|

So the relative error tolerance level measures the error relative to each state. It is recommended to specify a relative accuracy of at least 1%, otherwise there are a risk that the error estimation formulas computes incorrect error estimates and thus the adaptive step size control will not work and the computed solution will not have the accuracy specified. The default value of 1.0e-3 implies that the computed state is accurate within 0.1%

As can be seen from the definition of the relative error tolerance it is not defined when the solution y is 0. This is a situation when the absolute error tolerance is used. It is also used to avoid situations where the solver has to work hard to achieve a high relative accuracy for solution components that are of little interest or influence when small.

Apart from the speed issue when using small error tolerance levels it may also be impossible to solve due to limitations in floating point numbers. That is; you cannot request a truncation error smaller than the roundoff error of the computer. If impossible accuracy is defined the computation will take a long time and the solution will have worse accuracy than if looser tolerance levels where defined.

In Ecolego it is possible to define the absolute error tolerance explicitly for each solution component (i.e. for each material in each Compartment). If not defined explicitly the solver use the value defined in the Simulation settings menu. When the scales differ by many orders of magnitude it could be a good idea to specify tolerance levels for each component, this could easily happen if components include variables of different physical units.

For problems that are stiff or when there exists periodic components in the problem, the error estimate may be significantly inaccurate. To detect erroneous solutions it is recommended to repeat the computation with different error tolerances.

An explicit method uses only things that are known to find out the new value *y _{n+1}* at the next time-step. An implicit method on the other hand always has to solve an equation to obtain

An extra overhead in computational time burdens the implicit method but has an advantage in being able to solve stiff problems in reasonable time. That is; the implicit method is much more stable for these kind of problems and therefore can take larger time-steps *h* than the explicit method can.

But for non-stiff problems the explicit methods are much more suitable.

It seems to be difficult to make a proper definition of a stiff problem but the following quote wraps it up pretty well:

*“A problem is stiff if the solution being sought is varying slowly, but there are nearby solutions that vary rapidly, so the numerical method must take small steps to obtain satisfactory results.”*

Cleve Moler

A problem that is stiff requires a special type of solver. In Ecolego the following solveras are appropriate for stiff problems: NDF, BDF, RADAU5, Rosenbrock and TR-BDF2, and Trapezoidal for moderately stiff problems.

It is quite common that the type of problems to be solved in Ecolego are stiff. This is often due to the large differences in time scales of the decay and other modelled processes in the problem.

The *local error* of a method is the error you get when performing one step of the method. I.e. the difference *(δ ^{h}_{n+k})* between the result given by the method

The order of a method *p* is then defined as:

*δ ^{h}_{n+k} = Ο(h^{p+1}), as h → 0.*

The *global error* is the error sustained in all the steps one needs to reach a fixed time *t*. The global error of a *p*th order one-step method is *Ο(h ^{p})*.

The solver algorithms can also be categorized to be either one-step or multistep methods. A one-step method has no “memory”. So to compute the next solution point a one-step method only requires the current solution point (as an initial value), and does not use any other previously computed solution points. In other words, it treats each new time step computation as an initial value problem.

A multistep method on the other hand, has a “memory” in the sense that it uses the *k+1* previously computed solution values to compute the next solution value. One-step methods are usually used to start up the multistep methods.

The multistep methods needs in general fewer evaluations of the differential equation function *f* per time step than the one-step methods. This since it reuses the values stored from previous time steps. But the one-step methods are often faster than the multistep methods. Use multistep methods when problem is smooth and require high accuracy.

solver.txt · Last modified: 2019/11/18 13:34 (external edit)