WOLFRAM LANGUAGE TUTORIAL

"StiffnessSwitching" Method for NDSolve

Introduction

The basic idea behind the "StiffnessSwitching" method is to provide an automatic means of switching between a nonstiff and a stiff solver.

The "StiffnessTest" and "NonstiffTest" options (described within "Stiffness Detection in NDSolve") provides a useful means of detecting when a problem appears to be stiff.

The "StiffnessSwitching" method traps any failure code generated by "StiffnessTest" and switches to an alternative solver. The "StiffnessSwitching" method also uses the method specified in the "NonstiffTest" option to switch back from a stiff to a nonstiff method.

"Extrapolation" provides a powerful technique for computing highly accurate solutions using dynamic order and step size selection (see "Extrapolation Method for NDSolve" for more details) and is therefore used as the default choice in "StiffnessSwitching".

Examples

This loads some useful packages.
In[1]:=
Click for copyable input
This selects a stiff problem and specifies a longer integration time interval than the default specified by NDSolveProblem.
In[3]:=
Click for copyable input
The default "Extrapolation" base method is not appropriate for stiff problems and gives up quite quickly.
In[5]:=
Click for copyable input
Out[5]=
Instead of giving up, the "StiffnessSwitching" method continues the integration with a stiff solver.
In[6]:=
Click for copyable input
Out[6]=

The "StiffnessSwitching" method uses a pair of extrapolation methods as the default. The nonstiff solver uses the "ExplicitModifiedMidpoint" base method, and the stiff solver uses the "LinearlyImplicitEuler" base method.

For small values of the AccuracyGoal and PrecisionGoal tolerances, it is sometimes preferable to use an explicit RungeKutta method for the nonstiff solver.

The "ExplicitRungeKutta" method eventually gives up when the problem is considered to be stiff.
In[7]:=
Click for copyable input
Out[7]=
This sets the "ExplicitRungeKutta" method as a submethod of "StiffnessSwitching".
In[8]:=
Click for copyable input
Out[8]=
A switch to the stiff solver occurs at , and a plot of the step sizes used shows that the stiff solver takes much larger steps.
In[9]:=
Click for copyable input
Out[9]=

Option Summary

option name
default value
Method{Automatic,Automatic}specify the methods to use for the nonstiff and stiff solvers respectively
"NonstiffTest"Automaticspecify the method to use for deciding whether to switch to a nonstiff solver

Options of the method "StiffnessSwitching".

Translate this page: