Table of contents
Principles of integrators for ODEs
The first part of this lesson introduced the formalism and the basic ideas behind integration algorithms.
We revisit the Euler algorithm and introduce much better algorithms, namely the Runge-Kutta schemes and the Verlet integrator.
Accuracy and performance of Euler and Runge-Kutta integrators
The second part shows how to assess the accuracy of integration algorithms and analyzes in more depth the simple Euler integrator and the Runge-Kutta methods, namely rk2
and rk4
. As examples we use the simple 1D harmonic oscillator with potential energy function \(U(x) = \frac{1}{2} k x^2\), an anharmonic oscillator (\(U(x) = \frac{1}{2} k x^2 (1-\frac{2}{3} \alpha x)\)), and a 6-th power oscillator (\(U(x) = \frac{1}{6} k x^6\)).
The Jupyter notebook 10-ODE_integrators.ipynb contains the lecture notes and implementations are in the module integrators.py.1
Verlet integrators
The third part introduces a different class of integrators: time reversible (and symplectic) integrators such as the velocity Verlet algorithm, which have worse accuracy than e.g. RK4 but long term stability.
- The notebook 10-ODE-integrators-verlet.ipynb implements the velocity Verlet algorithm and shows how to use it to calculate the orbit of the Earth around the sun.
Resources
- Computational Modelling: Chapter 2
- Computational Physics: Chapter 9
- scipy.integrate for high performance integration algorithms for Python, in particular see scipy.integrate.odeint() and scipy.integrate.ode().
- Weisstein, Eric W. “Ordinary Differential Equation.” From MathWorld — A Wolfram Web Resource.
- Numerical Recipes in C, WH Press, SA Teukolsky, WT Vetterling, BP Flannery. 2nd ed, 2002. Cambridge University Press. Chapter 16.
Footnotes
As usual,
git pull
the resources repository PHY432-resources to get a local copy of the notebook. Then copy the notebook and all other code into your work directory in order to complete the exercises. ↩