What is the best ODE solver for stability and speed?

475 Views Asked by At

I'm going to build a ODE solver in C-code and I'm looking for an ODE solver that are robust against stiff ODE:s and very fast. But still, it also need to have a very good accuracy. I would be happy if it got 0.1% accuracy.

I have been looking at:

  • Forward Euler
  • Runge Kutta 4th order
  • Dormand Prince
  • Heun's method

The ODE solver will be applied onto an embedded system such as STM32 ARM Cortex.

2

There are 2 best solutions below

2
On BEST ANSWER

No explicit method is robust against stiff equations. All your enumerated methods are explicit.

Step size selection will always be a very sensible topic. Fixed step sizes over the long term will almost always be wrong on some segment of the integration interval. Methods with adaptive step-size control like the embedded DoPri methods provide some automation for this aspect, but you still need to prepare the problem so that the assumptions implicit in the error estimate for the step-size control are met.

For stiff problems you will want an implicit method. Doing that efficiently implies implementing a version of Newton's method, usually it is a simplified Newton method with a sparingly updated Jacobian. Now additionally to the step size controller you get the heuristics of the non-linear solver and its assumptions that you have to consider in the problem construction.

As example for the preparation of the problem, think of some system where the first component has values in the $1000$nds and the second component has values that are small multiples of $0.1$. If you treat both components uniformly, then the errors in the first component will blot out the second component, potentially generating errors in the second component that are larger than its values. So it would be better to rescale the problem so that both components present a value range from $1$ to $10$ to the ODE solver. Changing the time scale so that the derivatives have the same range as the values also might be helpful.

0
On

It depends on the equation. May I suggest the books Solving Ordinary Differential Equations I and II by Hairer and Wanner to guide you in your choice.