Mathematica >

Components and Data Structures in NDSolve

Introduction

NDSolve is broken up into several basic steps. For advanced usage, it can sometimes be advantageous to access components to carry out each of these steps separately.
  • Equation processing and method selection
  • Method initialization
  • Numerical solution
  • Solution processing
NDSolve performs each of these steps internally, hiding the details from a casual user. However, for advanced usage it can sometimes be advantageous to access components to carry out each of these steps separately.
Here are the low-level functions that are used to break up these steps.
  • NDSolve`ProcessEquations
  • NDSolve`Iterate
  • NDSolve`ProcessSolutions
NDSolve`ProcessEquations classifies the differential system into initial value problem, boundary value problem, differential-algebraic problem, partial differential problem etc. It also chooses appropriate default integration methods and constructs the main NDSolve`StateData data structure.
NDSolve`Iterate advances the numerical solution. The first invocation (there can be several) initializes the numerical integration methods.
NDSolve`ProcessSolutions converts numerical data into an InterpolatingFunction to represent each solution.
Note that NDSolve`ProcessEquations can take a significant portion of the overall time to solve a differential system. In such cases, it can be useful to perform this step only once and use NDSolve`Reinitialize to repeatedly solve for different options or initial conditions.

Example

Process equations and set up data structures for solving the differential system.
In[1]:=
Click for copyable input
Out[1]=
Initialize the method ExplicitRungeKutta and integrate the system up to time 10. The return value of NDSolve`Iterate is Null in order to avoid extra references, which would lead to undesirable copying.
In[2]:=
Click for copyable input
Convert each set of solution data into an InterpolatingFunction.
In[3]:=
Click for copyable input
Out[3]=
Representing the solution as an InterpolatingFunction allows continuous output even for points that are not part of the numerical solution grid.
In[4]:=
Click for copyable input
Out[4]=