We describe the application of adaptive (variable time step) integrators to stiff differential equations encountered in many applications. Linear harmonic oscillators subject to nonlinear thermal constraints can exhibit either stiff or smooth dynamics. Two closely related examples, Nosé's dynamics and Nosé–Hoover dynamics, are both based on Hamiltonian mechanics and generate microstates consistent with Gibbs' canonical ensemble. Nosé's dynamics is stiff and can present severe numerical difficulties. Nosé–Hoover dynamics, although it follows exactly the same trajectory, is smooth and relatively trouble-free. We emphasize the power of adaptive integrators to resolve stiff problems such as the Nosé dynamics for the harmonic oscillator. The solutions also illustrate the power of computer graphics to enrich numerical solutions.

1.
J. C.
Sprott
,
Chaos and Time-Series Analysis
(
Oxford U.P.
,
Oxford
,
2003
).
2.
Wm. G.
Hoover
,
Molecular Dynamics
, Lecture Notes in Physics (
Springer-Verlag
,
New York
,
1986
).
3.
Wm. G.
Hoover
,
Computational Statistical Mechanics
(
Elsevier
,
New York
,
1991
).
4.
S.
Nosé
, “
A unified formulation of the constant temperature molecular dynamics methods
,”
J. Chem. Phys.
81
,
511
519
(
1984
).
5.
S.
Nosé
, “
A molecular dynamics method for simulations in the canonical ensemble
,”
Mol. Phys.
52
,
255
268
(
1984
).
6.
H. A.
Posch
,
W. G.
Hoover
, and
F. J.
Vesely
, “
Canonical dynamics of the Nosé oscillator: Stability, order, and chaos
,”
Phys. Rev. A
33
,
4253
4265
(
1986
).
7.
W. G.
Hoover
, “
Canonical dynamics: Equilibrium phase-space distributions
,”
Phys. Rev. A
31
,
1695
1697
(
1995
).
8.
Wm. G.
Hoover
, “
Mécanique de Nonéquilibre à la Californienne
,”
Physica A
240
,
1
11
(
1997
).
9.
C. P.
Dettmann
and
G. P.
Morriss
, “
Hamiltonian reformulation and pairing of Lyapunov exponents for Nosé-Hoover dynamics
,”
Phys. Rev. E
55
,
3693
3696
(
1997
).
10.
W. G.
Hoover
and
B. L.
Holian
, “
Kinetic moments method for the canonical ensemble distribution
,”
Phys. Lett. A
211
,
253
257
(
1996
).
11.
D.
Kusnezov
,
A.
Bulgac
, and
W.
Bauer
, “
Canonical ensembles from chaos
,”
Ann. Phys.
(NY)
204
,
155
185
(
1990
).
12.
W. G.
Hoover
,
J. C.
Sprott
, and
P. K.
Patra
, “
Ergodic time-reversible chaos for Gibbs' canonical oscillator
,”
Phys. Lett. A
379
,
2935
2940
(
2015
).
13.
P. K.
Patra
and
B.
Bhattacharya
, “
A deterministic thermostat for controlling temperature using all degrees of freedom
,”
J. Chem. Phys.
140
,
064106
(
2014
).
14.

See, for example, <en.wikipedia.org/wiki/Runge-Kutta-Fehlberg_method> for a discussion of the Runge–Kutta-Fehlberg method.

15.

The Fortran compiler from the GNU Project is routinely used in numerical work with double precision arithmetic (about 16 decimal digits). For stiff problems quadruple precision (with about 34 decimal digits) is useful. To invoke the latter (which is about fifty times slower), the program code.f producing the executable code xcode should be compiled as gfortran  -O -o  xcode-freal-8-real-16   code.f rather than gfortran  -O -o   xcode   code.f.

16.
Wm. G.
Hoover
and
C. G.
Hoover
, “
Comparison of very smooth cell-model trajectories using five symplectic and two Runge–Kutta integrators
,”
Comput. Methods Sci. Technol.
12
,
109
116
(
2015
).
17.
R. L.
Davidchack
, “
Discretization errors in molecular dynamics simulations with deterministic and stochastic thermostats
,” e-print arXiv:1412.7067.
18.
Ch.
Dellago
and
H. A.
Posch
, “
Lyapunov exponents of systems with elastic hard collisions
,”
Phys. Rev. E
52
,
2401
2406
(
1995
).
19.
B. J.
Alder
and
T. E.
Wainwright
, “
Molecular motions
,”
Sci. Am.
201
,
113
126
(
1959
).
20.
W. G.
Hoover
and
H. A.
Posch
, “
Direct measurement of equilibrium and nonequilibrium Lyapunov spectra
,”
Phys. Lett. A
123
,
227
230
(
1987
).
21.
T.
Uzer
,
B.
Chirikov
,
F.
Vivaldi
, and
G.
Casati
, “
Joseph Ford
,”
Phys. Today
48
(
10
),
88
(
1995
).
22.
L.
Wang
and
X.-S.
Yang
, “
The invariant tori of knot type and the interlinked invariant tori in the Nosé-Hoover system
,”
Eur. Phys. J. B
88
,
78
82
(
2015
).
23.
L.
Wang
and
X.-S.
Yang
, “
A vast amount of invariant tori in the Nosé-Hoover oscillator
,”
Chaos
25
,
123110
(
2015
).
24.
P. K.
Patra
,
W. G.
Hoover
,
C. G.
Hoover
, and
J. C.
Sprott
, “
The equivalence of dissipation from Gibbs' entropy production with phase-volume loss in ergodic heat-conducting oscillators
,”
Int. J. Bifurcation Chaos
26
,
1650089-1-11
(
2016
).
25.

Piotr Pieranski's personal website is located at <etacar.put.poznan.pl/piotr.pieranski/Personal.html>.

26.
J. H. E.
Cartwright
, “
Nonlinear stiffness, Lyapunov exponents, and attractor dimension
,”
Phys. Lett. A
264
,
298
302
(
1999
).
AAPT members receive access to the American Journal of Physics and The Physics Teacher as a member benefit. To learn more about this member benefit and becoming an AAPT member, visit the Joining AAPT page.