You are on page 1of 9

Symplectic integrators: An introduction

Denis Donnelly and Edwin Rogers

Citation: Am. J. Phys. 73, 938 (2005); doi: 10.1119/1.2034523


View online: http://dx.doi.org/10.1119/1.2034523
View Table of Contents: http://ajp.aapt.org/resource/1/AJPIAS/v73/i10
Published by the American Association of Physics Teachers

Related Articles
What It's Like to Edit TPT
Phys. Teach. 50, 391 (2012)
Grading Homework to Emphasize Problem-Solving Process Skills
Phys. Teach. 50, 424 (2012)
Getting almost everything right
Phys. Teach. 50, 326 (2012)
Oersted Medal Address 2012: Narrative and Witz in Physics
Am. J. Phys. 80, 468 (2012)
Amicable separation
Phys. Teach. 50, 311 (2012)

Additional information on Am. J. Phys.


Journal Homepage: http://ajp.aapt.org/
Journal Information: http://ajp.aapt.org/about/about_the_journal
Top downloads: http://ajp.aapt.org/most_downloaded
Information for Authors: http://ajp.dickinson.edu/Contributors/contGenInfo.html

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission
Symplectic integrators: An introduction
Denis Donnellya兲
Department of Physics, Siena College, Loudonville, New York 12211
Edwin Rogersb兲
Department of Mathematics, Siena College, Loudonville, New York 12211
共Received 26 February 2004; accepted 21 July 2005兲
Symplectic integrators very nearly conserve the total energy and are particularly useful when
treating long times. We demonstrate some of the properties of these integrators by exploring the
structure of first-, second-, and fourth-order symplectic integrators and apply them to the simple
harmonic oscillator. We consider numeric, geometric, and analytic aspects of the integrators with
particular attention to the computed energies. © 2005 American Association of Physics Teachers.
关DOI: 10.1119/1.2034523兴

I. INTRODUCTION trate how the symplectic structure of phase space is pre-


served by the symplectic algorithms and how higher order
It is frequently necessary to follow the evolution of a dy- symplectic methods can be generated.
namical system by means of a numerical integration for long In Sec. II we briefly discuss linear symplectic structures
times. In this case, if the system is described by a time- and introduce the notion of a symplectic map. In Secs. III–V
independent Hamiltonian, symplectic integration methods we discuss the symplectic Euler method and its adjoint, the
can be superior to general purpose ordinary differential equa- velocity Verlet method, and a fourth-order method.
tion solvers. For example, Runge-Kutta methods do not con-
serve the total energy. If we apply the fourth-order fixed step
II. SYMPLECTIC FUNCTIONS AND ALGORITHMS
Runge-Kutta method to the simple harmonic oscillator, the
computed energy value drifts from the true value and the The setting for Hamiltonian mechanics is a 2n-
results are surprisingly poor. These results are dramatically dimensional set of points with coordinates 共q , p兲
improved using an adaptive step size, but this method is = 共q1 , q2 , . . . , qn , p1 , p2 , . . . , pn兲. The dynamics is defined once
computationally more costly and the computed energy con- a Hamiltonian function, H共q , p兲, is specified. Each point of
tinues to drift from the true energy, albeit more slowly. In
the set, called the phase space, represents a possible state of
this paper, we introduce several simple symplectic algo-
the system. As the system evolves from a given set of initial
rithms and show that these algorithms do not exhibit this
conditions, the associated states form a curve in phase space
problem.
whose tangent vector at each point is 共H p , −Hq兲. The identi-
Symplectic methods belong to the larger class of geomet-
ric numerical integration algorithms. These algorithms are fication of the tangent vector to the curve of states with the
constructed so that they preserve certain geometrical proper- vector 共H p , −Hq兲,
ties inherent in the system. Symplectic methods are so dq dp
named because, when applied to problems in Hamiltonian = H p, = − Hq , 共2.1兲
dt dt
mechanics, the algorithms preserve the linear symplectic
structure inherent in the phase space representation of the is the geometric interpretation of Hamilton’s equations.
We introduce the matrix J = 共 −ln n0 兲, set z = 共q , p兲, and write
dynamics. The first of these methods was developed by de 0l

Vogelaere.1 These methods were later developed indepen- Hamilton’s equations in the matrix form
dently by Ruth,2 who constructed symplectic integrators
while investigating the dynamics of particle accelerators. d
Since then, symplectic algorithms have been employed in z = J ⵜ H共z兲. 共2.2兲
dt
fields such as molecular dynamics and astronomy.3–12 Early
on, it was observed that for such methods, the error in the Implicit in Hamilton’s equations is a skew-symmetric, bi-
energy remains bounded over significant times 共see, for ex- linear function of vectors, called the linear symplectic struc-
ample, Ref. 7兲. This fact, and the relative simplicity of the ture, defined as follows: For vectors v and w, 关v , w兴
algorithms, initiated further development of symplectic = 共Jv , w兲, where 共,兲 is the usual Euclidean inner product. The
methods and their applications. symplectic structure has a simple geometric interpretation.
In this article, we introduce simple first-, second-, and For a system with N degrees of freedom, 关v , w兴 is a sum of N
fourth-order symplectic integrators and examine their struc- terms. Each term represents an area. Each individual area is
ture for the simple harmonic oscillator from a numerical, the projection of the parallelogram determined by v and w on
geometric, and analytic standpoint. The advantage of this its coordinate plane with coordinates 共qi , pi兲. For a system
one-dimensional example is that the dynamics associated with one degree of freedom, such as the harmonic oscillator,
with the numerical algorithms can be solved analytically, al- this sum of areas reduces to the area of a single parallelo-
lowing for a direct analysis of the numerical solutions. The gram determined by v and w. The geometry that results from
numerical approach permits us to gain an intuitive under- the inclusion of such a linear symplectic structure on a
standing of the methods and how they can be combined to 2n-dimensional linear space is called a symplectic geometry.
improve the energy conserving properties of the algorithms. When we solve Hamilton’s equations with a given initial
Following the approach by Neri13 and Yoshida,14,15 we illus- condition z0, a function, ␸共t , z0兲, called the phase flow, is

938 Am. J. Phys. 73 共10兲, October 2005 http://aapt.org/ajp © 2005 American Association of Physics Teachers 938

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission
defined. This function defines the state of the system at time ⳵ ⳵
t 艌 0. Alternately, we can think of ␸共t , z0兲 as a function, ␸t, DH = T⬘共p兲 − V⬘共q兲 . 共2.11兲
⳵q ⳵p
that sends each point to the corresponding state at time t.
Henri Poincarè discovered that the phase flow has the fol- If we apply Eq. 共2.7兲, we see that

冉 冊
lowing property. If f ⬘共z兲 denotes the Jacobian matrix of par-
T⬘共p兲
tial derivatives, ⳵ f i共z兲 / ⳵z j, of the function f共z兲 D Hz = = J ⵜ H共z兲. 共2.12兲
= f共z1 , z2 , . . . , z2n兲 =共f 1共z1 , z2 , . . . , z2n兲 , f 2共z1 , z2 , . . . , z2n兲 , . . . , − V⬘共q兲
f 2n共z1 , z2 , . . . , z2n兲兲, the matrix ␸t⬘共z兲 satisfies For the harmonic oscillator with the Hamiltonian H共q , p兲
关␸t⬘共z兲v, ␸t⬘共z兲w兴 = 关v,w兴, 共2.3兲 = 21 共q2 + p2兲, we have

for all vectors v and w. Because applying the Jacobian ma-


trix ␸t⬘共z兲 to the vectors v and w generates a corresponding
d
dt
z = D Hz =
p
−q
冉 冊
= Jz, 共2.13兲
vector pair vt and wt at the later time t, Eq. 共2.3兲 asserts that
which is a simple linear equation whose solution gives the
the sum of the areas of the projections remains constant in
phase flow:
time. Thus, the phase flow preserves the linear symplectic
structure. In general, a function f of phase space satisfies this
condition if and only if etDH = etJ = 冉 cos共t兲 sin共t兲
− sin共t兲 cos共t兲
冊 . 共2.14兲
f ⬘共z兲TJf ⬘共z兲 = J. 共2.4兲
If Eq. 共2.4兲 holds, we call f symplectic.
For a given time step, ⌬t, a numerical algorithm z1
= A共⌬t , z0兲 can be thought of as a function on phase space. III. FIRST-ORDER METHODS
The algorithm is called symplectic if the function A is sym- As an introduction to symplectic algorithms, we begin
plectic. Thus, symplectic algorithms share the same symplec- with simple first-order methods. In general, a method is
tic structure preserving property as the phase flows they ap- nth-order for a differential equation y ⬘ = f共y兲, y共t0兲 = y 0, if
proximate.
y 1 − y共t0 + ⌬t兲 = O共⌬tn+1兲 as ⌬t → 0, where y 1 is the result of
There are various ways that we can construct symplectic
algorithms. One method14,16–22 will be used in Secs. II–IV applying the particular numerical method to the initial state
and depends on the following construction. By employing y 0 for one time step. First-order methods are not likely to be
the Poisson bracket, we can rewrite the basic dynamical used in any serious computation, but they provide a simple
equation in a form that emphasizes the Lie algebraic struc- illustration of the differences between symplectic and non-
ture that is implicit in symplectic geometry. For the functions symplectic algorithms.
f and g, the Poisson bracket, 兵f , g其, is defined by The most familiar of the first-order methods is the classic
explicit Euler method:
n
⳵ f ⳵g ⳵ f ⳵g qi+1 = qi + pi⌬t, 共3.1a兲
兵f,g其 = 兺 − . 共2.5兲
i=1 ⳵qi ⳵ pi ⳵ pi ⳵qi
pi+1 = pi + Fi⌬t. 共3.1b兲
The Poisson bracket is related to the symplectic structure as
follows: This one-step algorithm does not conserve the total energy.
For oscillatory systems such as the harmonic oscillator, the
兵f,g其 = 共J ⵜ g,ⵜf兲 = 关ⵜg,ⵜf兴. 共2.6兲 numerical solution that is obtained with this method diverges
with each iteration from the true solution. In particular, the
For a given function, H, we define the differential operator
amplitude of the oscillations increases and the energy and the
共the Liouville operator兲
phase space area 共see Fig. 1兲 increase monotonically with the
DH f = 兵f,H其, 共2.7兲 same factor of 1 + ⌬t2 for each iteration:

and use the same notation when f is a vector, with the un- Ei+1 = Ei共1 + ⌬t2兲. 共3.2兲
derstanding that in this case DH acts on each component of f. The implicit Euler method, given by
Then Hamilton’s equations may be written as
qi+1 = qi + pi+1⌬t, 共3.3a兲
d
z共t兲 = DHz共t兲, 共2.8兲
dt pi+1 = pi + Fi+1⌬t, 共3.3b兲
which has the formal solution is comparable in error. With this method, the amplitude de-
creases, and the energy and area decrease by the same factor:
z共t兲 = e tDH
z共0兲, 共2.9兲
1
providing the representation e for the phase flow ␸t 共for
tDH
Ei+1 = Ei . 共3.4兲
example, see Refs. 14 and 18 by Yoshida兲. 1 + ⌬t2
For Hamiltonian functions of the form For the harmonic oscillator, we find the 1 + ⌬t2 factor as-
H共q,p兲 = V共q兲 + T共p兲, 共2.10兲 sociated with the Euler methods by expressing the equation
of motion in terms of Hamilton’s equations. The explicit Eu-
the operator DH takes the form ler method is

939 Am. J. Phys., Vol. 73, No. 10, October 2005 D. Donnelly and E. Rogers 939

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission
冉 冊冉qi+1
pi+1
=
1 − ⌬t2 ⌬t
− ⌬t 1
冊冉 冊 qi
pi
. 共3.10兲

We see that the algorithm is symplectic:

冉 1 − ⌬t2 ⌬t
− ⌬t 1
冊 冉 冊冉
T
0
−1 0
1 1 − ⌬t2 ⌬t
− ⌬t 1
冊冉 冊=
0
−1 0
1
.

共3.11兲
We will refer to this method as the symplectic Euler method.
Partitioning in this way is an example of the splitting
method,17 where the differential equation of interest is di-
vided into two, hopefully simpler, equations whose solutions
can be combined into the solution of the original equation.
For Hamiltonian systems with a separable Hamiltonian,
Fig. 1. A position-momentum phase plot using the explicit Euler method to H共q , p兲 = T共p兲 + V共q兲, the equations of motion have the form
determine the motion associated with the simple harmonic oscillator. The
area in phase space increases by 1 + ⌬t2 with each iteration as the phase
trajectory spirals outward. The boxes provide an example of the growth of
d
dt
z共t兲 = DHz共t兲 =
T⬘共p兲
− V⬘共q兲
冉 冊
冉 冊冉 冊
the area. The initial conditions in all the figures are a nonzero displacement
共q = 0.2兲 and a zero velocity 共p = 0兲. T⬘共p兲 0
= +
0 − V⬘共q兲
= DTz共t兲 + DVz共t兲. 共3.12兲

冉 冊冉qi+1
=
1 ⌬t
冊冉 冊qi
, 共3.5兲 Equation 共3.12兲 leads to the division
pi+1 − ⌬t 1 pi
which is the first-order approximation of the exact solution
d
dt
z共t兲 = DTz共t兲 =
T⬘共p兲
0
, 冉 冊 共3.13a兲

冉 冊冉qi+1
pi+1
=
cos共⌬t兲 sin共⌬t兲
− sin共⌬t兲 cos共⌬t兲
冊冉 冊qi
pi
. 共3.6兲 d
dt
z共t兲 = DVz共t兲 =
0
− V⬘共q兲
冉 冊
. 共3.13b兲

A simple calculation shows that the explicit Euler method is Equation 共3.13兲 is easily solved for a given initial state z0.
not symplectic, because the test for symplecticity, Eq. 共2.4兲, The solutions are given by the mappings
does not return J, but gives 共1 + ⌬t2兲J:

冉 1 ⌬t
冊 冉 冊冉
T
0 1 1 ⌬t
冊 z共t兲 = 冉 q0 + T⬘共p0兲t
p0
冊 = etDTz0 , 共3.14a兲
− ⌬t 1 −1 0 − ⌬t 1

= 冉 0
− 共1 + ⌬t 兲2
1 + ⌬t
0
2
冊 . 共3.7兲 z共t兲 = 冉 q0
p0 − V⬘共q0兲t

= etDVz0 . 共3.14b兲

As demonstrated by Cromer,15 a combination of explicit To construct the solution to Eq. 共3.12兲, we evolve the state zi
and implicit methods produces a symplectic method. If we by the second map, z⬘ = e⌬tDVzi, and then evolve z⬘ by the first
write p in the implicit form and q in the explicit form 共we map, and obtain
could interchange the explicit and implicit roles—see the zi+1 = e⌬tDTz⬘ = e⌬tDTe⌬tDVzi , 共3.15兲
adjoint symplectic Euler method in the following兲, we have
for any time-independent Hamiltonian H共q , p兲, which is the symplectic Euler method. It is easy to check that
Eq. 共3.15兲 gives Eq. 共3.10兲 for the harmonic oscillator.
⳵H共qi,pi+1兲 Equation 共2.9兲 shows that the exact solution to Hamilton’s
qi+1 = qi + ⌬t, 共3.8a兲
⳵p equations can be express in terms of the differential operator
DH. Because DH = DT + DV and the operators DV and DT do
not commute, we know that18
⳵H共qi,pi+1兲
pi+1 = pi − ⌬t. 共3.8b兲 etDH = et共DT+DV兲 = etDTetDV + O共t2兲. 共3.16兲
⳵q
For the harmonic oscillator, Eq. 共3.8兲 becomes Thus, the symplectic Euler method is a first-order method.
We can obtain a qualitative appreciation for the numerical
qi+1 = qi + pi+1⌬t, 共3.9a兲 behavior of the symplectic Euler method by examining it in
more detail. We note that the q and p integrations are not in
pi+1 = pi − qi⌬t. 共3.9b兲 phase. One consequence is that as q increases, the potential
energy peaks before the kinetic energy reaches its minimum,
Methods of this type are known as partitioned Euler and the computed energy is greater than the true energy. As q
methods.16 To verify the assertion of symplecticity, we re- decreases, the potential energy decreases before the compa-
write Eq. 共3.9兲 by substituting for pi+1 in Eq. 共3.9a兲 and rable increase in the kinetic energy, and the computed energy
obtain is less than the true energy. When the motion is away from

940 Am. J. Phys., Vol. 73, No. 10, October 2005 D. Donnelly and E. Rogers 940

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission
The excursion of the total computed energy is not sym-
metric about the true energy and depends on the initial con-
ditions. Further, the fact that the energy deviation of the nu-
merical solution has very nearly twice the frequency of the
oscillation suggests that there might exist a term in the com-
puted energy proportional to qp, because this term would
result in a product of sine and cosine terms providing the
observed frequency doubling. That this is the case follows
from the previous considerations, where it was observed that
the symplectic Euler method is the result of the product of
two simpler 共and symplectic兲 transformations e⌬tDV and
e⌬tDT.
If we use the Baker-Campbell-Hausdorf formula,4 a modi-
fied Hamiltonian function, H⬘, can be found so that
e⌬tDTe⌬tDV = e⌬tDH⬘. We write
H⬘共q,p兲 = H0 + ⌬tH1 + ⌬t2H2 + ¯ , 共3.17兲
and use the Baker-Campbell-Hausdorf formula to determine
Fig. 2. A phase plot of the potential versus the kinetic energy as given by the Hk. For the harmonic oscillator, we find for H0 and H1
numerical solution of the symplectic Euler method. The exact solution for
the specific initial conditions used here would produce a straight line be- 1
tween the points 共0.02,0兲 and 共0,0.02兲. The elongated oval form is typical, H0 = T + V = 共q2 + p2兲. 共3.18a兲
and the general shape does not depend on the initial conditions. 2

1 pq
H 1 = − T pV q = − . 共3.18b兲
the equilibrium position, there is excess energy; when the 2 2
motion is toward equilibrium, there is an energy deficit. We As higher-order terms in ⌬t are determined, we find that the
observe these effects in the phase plot in Fig. 2 and the expansion for H⬘ takes the form
energy plots in Fig. 3.
The energy phase diagram in Fig. 2 shows approximately H⬘共q,p兲 = ⍀1共H0共q,p兲 + H1⌬t兲, 共3.19兲
two orbits for each cycle. Ideally, the diagram should be a
where ⍀1 = 1 + ⌬t / 6 + ⌬t / 30+ ¯. An analytic form for ⍀1
2 4
straight line between points where the energy is all kinetic or
will be determined in the following. We see that to lowest
all potential. As the time step ⌬t is decreased, the phase
order H⬘共q , p兲 = H0共z兲 + H1共z兲⌬t, which shows that the error
difference decreases proportionally 共as does the amplitude of
the energy oscillation in Fig. 3兲, and the diagram more in the energy in the symplectic Euler method is O共⌬t兲.
closely approaches the true solution. If we let 共qn+1 , pn+1兲 = e⌬tDTe⌬tDV共qn , pn兲, it is easy to verify
Although the total energy is not conserved, the error has that
no secular increase, and the total energy remains near its true H⬘共qn+1,pn+1兲 = H⬘共qn,pn兲. 共3.20兲
value. The magnitude of the computed energy oscillates
asymmetrically at nearly twice the oscillator frequency about As Eq. 共3.20兲 suggests, the numerical solution is the exact
the true energy value with the amplitude of this oscillation solution to the associated “modified” Hamiltonian system
related to the time step, as can be seen from the analytic dz共t兲
description of the numerical solution given in the following. = DH⬘z共t兲. 共3.21兲
Although the local truncation error remains bounded, the dt
problem associated with the accumulation of round-off errors Because H⬘ is quadratic, this system is linear and can be
remains. solved exactly to yield the solutions

q⬘共t兲 = q0 cos ␻1t +


⍀1 ⌬t
␻1 2
冉 冊
p0 − q0 sin ␻1t,

共3.22兲
p⬘共t兲 = p0 cos ␻1t +
⍀1
␻1
⌬t

p0 − q0 sin ␻1t.
2

Here 共q0 , p0兲 is the initial condition and ␻1 = ⍀1冑1 − ⌬t2 / 4.
To determine ⍀ 1, note that 共q⬘共⌬t兲 , p⬘共⌬t兲兲
= e⌬tDTe⌬tDV共q⬘共0兲 , p⬘共0兲兲, which can be solved for ⍀1, yield-
ing
sin−1共⌬t冑1 − ⌬t2/4兲
⍀1 = , 共3.23兲
Fig. 3. The kinetic, potential, and total energy of the harmonic oscillator
⌬t冑1 − ⌬t2/4
calculated using the symplectic Euler method. The computed total energy is
the solid curve which oscillates about the analytic value of the total energy, so that the shift in frequency is ␻1 = 1 + O共⌬t2兲. We note that
for small ⌬t, ⍀1 is well approximated by 3 / 共4冑1 − ⌬t2 / 4
in this case a constant of magnitude 0.02 J. The kinetic energy 共solid兲 and
potential energy 共dotted兲 curves range from 0 to the approximate total
energy. − 1兲. The dependence on ⌬t of the difference between the

941 Am. J. Phys., Vol. 73, No. 10, October 2005 D. Donnelly and E. Rogers 941

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission
Fig. 4. The frequency shift as a function of the time step ⌬t.

shifted and the true frequency is shown in Fig. 4.


An analysis of the value of the energy of the numerical
trajectory reveals that the average value of this energy may
be greater or less than the true energy of the oscillator, de- Fig. 6. The phase diagram for the position and momentum, together with the
pending on the initial conditions as is readily seen from energy deviation from the true value 共with two oscillations per cycle兲 versus

冉 冊
position. The incomplete cycle permits us to follow the progress of the
1 1 ⌬t2 1 ⌬t curves during the course of a cycle. The fact that the q and p calculations are
具H典 = 共q20 + p20兲 1 + − q0 p0 . not in phase is the source of the small but visible asymmetry.
2 4 1 − ⌬t2/4 2 1 − ⌬t2/4
共3.24兲
The average computed energy and the true energy are equal ference in the q and p integrations mentioned previously is
for clearly visible in the asymmetry of the orbit; the qp term of
Eq. 共3.19兲 rotates the phase space ellipse. The corresponding
关2 ± 冑4 − ⌬t2兴q0 .
1 energy deviation also is shown. An incomplete cycle is pre-
p0 = 共3.25兲
⌬t sented so that the evolution of the two curves can be fol-
lowed.
The lines for which these two energies are equal, scaled for
There is a slight asymmetry in the phase diagram associ-
emphasis 共either multiplied or divided by ⌬t兲, separate what
ated with the symplectic Euler method 共Fig. 6兲. If we were to
we call modified quadrants 共see Fig. 5兲. The average value of
reflect this curve through the ordinate axis, the resulting
the computed energy is less than the true energy in quadrants
phase diagram would look equally physical and suggests that
one and three and is greater in quadrants two and four. As
there exists a similar but distinct algorithm that would yield
⌬t → 0, the modified quadrants approach the true quadrants,
essentially the same dynamic behavior, but with a phase dif-
and if we were to choose initial conditions at random, the
ference. This reflection corresponds to an interchange of ex-
likelihood that the average computed energy is greater or less
plicit and implicit roles for q and p in the algorithm. The
than the true energy would become the same.
resulting algorithm is the adjoint of the symplectic Euler
If we examine the initial conditions q0 ⫽ 0 and p0 = 0 in the
method and is described in the following.
position-momentum phase diagram in Fig. 6, the phase dif-
In Fig. 7 we show the kinetic, potential, and the total en-
ergy versus the position. The potential energy curve has the
parabolic shape we would expect. The kinetic energy is not
in phase with the position, and the kinetic energy oscillations
show a phase difference of 2␲ divided by the number of
iterations per cycle. If the abscissa were momentum instead
of position, the kinetic and potential energy curves would
interchange phase differences.
The symplectic Euler method is not the only first-order
symplectic method. Because we expect that DT+V = DV+T,
commuting the solution maps also should give an approxi-
mation to the exact solution map. The adjoint symplectic
Euler method is the product
zi+1 = e⌬tDVe⌬tDTzi , 共3.26兲
which for the harmonic oscillator gives

Fig. 5. The choice of the initial conditions determines whether the average
value of the computed energy is greater than or less than the true energy.
冉 冊冉
qi+1
pi+1
=
1 ⌬t
− ⌬t 1 − ⌬t2
冊冉 冊qi
pi
. 共3.27兲
The two lines shown in the figure represent the equality of the true and the
average computed energies and divide the plane into four modified quad-
The modified Hamiltonian of the adjoint method differs from
rants. The average computed energy is greater than the true energy in quad- Eq. 共3.19兲 in that the qp⌬t / 2 term is added rather than sub-
rants two and four, and is less in quadrants one and three. The slopes of the tracted. With this method we obtain a reflected phase dia-
two curves are scaled by factors of ⌬t and 1 / ⌬t. gram, analogous system behavior, and a similar curve for the

942 Am. J. Phys., Vol. 73, No. 10, October 2005 D. Donnelly and E. Rogers 942

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission
Fig. 8. Total energy curves, normalized by dividing by the analytic value of
the energy, for the harmonic oscillator as determined by the symplectic
Euler methods 关Eqs. 共3.9兲 and 共3.27兲兴 and the velocity Verlet method 关open
circles, Eq. 共4.2兲兴. The jagged curve follows the symplectic Euler method
for one-half step and then the adjoint method for a half-step.

a qualitative look at how the computation proceeds. The


open circles are the results of the calculation using the ve-
Fig. 7. The kinetic, potential, and total mechanical energy versus position. locity Verlet algorithm. In Fig. 8 the computed energy is
The lack of phase coherence between the position and momentum calcula-
tions, intrinsic to the first-order symplectic Euler method, is visible in the
normalized by dividing by the analytic value of the energy.
kinetic energy plot. If the abscissa had been the momentum, the phase dif- For a general Hamiltonian, the modified Hamiltonian for
ference would have appeared in the potential energy plot. Compare the the Verlet algorithm is4
H⬘共z兲 = H0共z兲 + ⌬t2共 12 兲
oscillations in the total energy with those in Fig. 3. In Fig. 9 we present only 1 1
the upper 1% of the energy range. H2p共z兲Hqq共z兲 − 24 Hq共z兲H pp共z兲
2

+ O共⌬t 兲. 4
共4.3兲

total energy except that it is out of phase with the energy As was the case for the first-order method, we can find an
exact form for the modified Hamiltonian:

冉 冉 冊 冊
curve obtained from the symplectic Euler method. Inspection
of these two energy curves suggests that if we were to com- 1 2 1 2 1 2 1 2 ⌬t4 2
bine the two first-order methods, the energy deviation would H⬘共q,p兲 = ⍀2 q + p + ⌬t2 p − q − q ,
2 2 12 24 48
be significantly reduced. A simple sum of the two total en-
ergy curves significantly reduces the energy variation to that 共4.4兲
of a second-order method. We will return to this point in from which exact solutions to the modified equations can be
Sec. IV. found by standard methods. The constant ⍀2 is found to
satisfy
IV. VELOCITY VERLET: A SECOND-ORDER sin−1共⌬t冑1 − ⌬t2/4兲 ⍀1
⍀2 = = . 共4.5兲
共1 + ⌬t2/6兲⌬t冑1 − ⌬t2/4
SYMPLECTIC METHOD
共1 + ⌬t2/6兲
The product of symplectic transformations also is sym-
plectic. We can exploit this fact by combining the two sym- From the exact solutions we calculate that the average total
plectic Euler methods sequentially as the energy curves sug- energy of the numerical solution is given by
gest. If we take two half-steps, using first one form and then
its adjoint, we can combine the two half-step expressions
into a single full-step expression. In terms of the exponential
1
具H典 = 共q20 + p20兲 +
4
p20 q2
− 0 1−
4共1 − ⌬t /4兲 4
2
⌬t2
4
. 冉 冊 共4.6兲

notation for the symplectic maps, this combination can be The frequency shift, ␻2 = ⍀1冑1 − ⌬t2 / 4 = ␻1, follows from the
expressed as fact that the Verlet algorithm is a product of the symplectic
共e共⌬t/2兲DVe共⌬t/2兲DT兲共e共⌬t/2兲DTe共⌬t/2兲DV兲 Euler method and its adjoint.
The phase diagram of the kinetic versus the potential en-
= e共⌬t/2兲DVe⌬tDTe共⌬t/2兲DV . 共4.1兲 ergy is a straight line with a slope of −0.996 in contrast to the
first-order result in Fig. 2. The fact that the slope is less than
For T共p兲 = 21 p2, the resulting second-order algorithm can be −1 indicates that the kinetic energy is always less than the
expressed as total energy.
1 ⳵V
qi+1 = qi + pi⌬t − 共qi兲⌬t2 ,
2 ⳵q V. FOURTH-ORDER METHODS
共4.2兲
pi+1 = pi − 冉
1 ⳵V
2 ⳵q
⳵V
共qi兲 + 共qi+1兲 ⌬t,
⳵q
冊 Higher-order methods tend to produce modified Hamilto-
nians that more closely approximate the original Hamil-
tonian. For example, for an nth-order symplectic method,18
which is the velocity form of the Verlet algorithm.22,23 H⬘共z兲 = H共z兲 + O共⌬tn兲. 共5.1兲
In Fig. 8 the solid curve represents the path taken by two
half-steps and shows the characteristic zig-zag of a split As an example, we consider the fourth-order method of
method; one half-step with the symplectic Euler method and Candy and Rozmus 共Fig. 9兲.24 For each step in the integra-
the next half-step with its adjoint. The zig-zag curve provides tion, we calculate four substeps. For example, to integrate

943 Am. J. Phys., Vol. 73, No. 10, October 2005 D. Donnelly and E. Rogers 943

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission
Table II. Comparison of energy ranges for first-, second-, and fourth-order
methods.

Method Emax − Emin


⌬t = 2␲ / 60 Emax

Symplectic Euler 7.213⫻ 10−2


Second-order velocity 2.742⫻ 10−3
Verlet
Fourth-order Candy and 9.223⫻ 10−6
Rozmus 共Ref. 24兲
Fourth-order optimal 共Ref. 26兲 1.123⫻ 10−7

ment over the second-order methods in reducing the energy


fluctuations.
McLachlan and Atela26 have constructed a fourth-order
Fig. 9. The normalized total energy and the kinetic energy as computed by integrator where the optimal coefficients bi , ci were deter-
the velocity Verlet method are shown as a function of the position. The zero mined to minimize the time step error 共see Table I兲. By using
point is suppressed. Similar figures are obtained with higher order methods. this integrator, the energy deviations as compared to those
With the fourth-order Candy-Rozmus method, the general shape is the same, using the Candy-Rozmus coefficients are further reduced by
but the energy variation is greatly reduced. Using optimal coefficients with almost two orders of magnitude.
the same algorithm, the energy variations are reduced still further, but the
A comparison of the energy deviations for the methods
curvature of the total energy curve is reversed.
discussed for one step size is shown in Table I. In Table II we
show a comparison of the energy deviation for the various
methods. The energy deviation 共Emax − Emin兲Emax is the same
from 共qn , pn兲 to 共qn+1 , pn+1兲 we iterate the following pair of as the deviation of the slope in the potential energy versus
equations as i goes from 1 to 4 kinetic energy phase diagram from the true value of −1. 共We
did not compute the slope for the Euler example as shown in
qi = qi−1 + ci pi⌬t,
Fig. 2.兲
共5.2兲
pi = pi−1 − biVq共qi−1兲⌬t⬘ , VI. COMMENTS
where 共q1 , p1兲 takes on the values of 共qn , pn兲 and the 共q4 , p4兲
Symplectic methods offer distinct advantages over tradi-
values are assigned to 共qn+1 , pn+1兲. The values for the fourth- tional Runge-Kutta methods in solving Hamilton’s equations
order constants are25 of motion because the symplectic structure of phase space is
b1 = b4 = 61 共2 + 21/3 + 2−1/3兲, preserved by these methods, a feature shared by the flow
map of the exact solution. Additionally, the trajectories pro-
duced by these algorithms remain on the surfaces of constant
b2 = b3 = 61 共1 − 21/3 − 2−1/3兲, 共5.3兲
energy of the associated Hamiltonian function, so the energy
of the system is closely approximated. Exactly solvable ex-
c1 = 0, c2 = c4 = 共2 − 21/3兲−1, c3 = 共1 − 22/3兲−1 . amples such as the harmonic oscillator reveal the structure of
If we write Si = ebi⌬tDTeci⌬tDV, the method of Candy and these algorithms, which can be developed from the symplec-
Rozmus24 can be realized as a product of elementary expo- tic structure inherent in phase space. The reader is invited to
nential maps:14 apply the symplectic Euler method to other Hamiltonian sys-
tems. The simple pendulum is treated by several authors
zn+1 = S4S3S2S1zn . 共5.4兲 共see, for example, Ref. 18兲. For a more challenging example,
When applied to the harmonic oscillator, this fourth-order the reader can investigate the central force problem with
method gives more than two orders of magnitude improve- H共r , pr , p␪兲 = 共1 / 2m兲共pr2 + p␪2 / r2兲 − k / r, which can be per-
turbed by a term such as −k2 / r3/2.

Table I. Two sets of coefficients for the fourth-order method discussed in the ACKNOWLEDGMENTS
text.
The authors would like to acknowledge the help of anony-
Order 4 Forest and Ruth 共Ref. 24兲 Optimal
mous reviewers, whose comments resulted in a greatly im-
proved version of this paper.
b1 1 / 6共2 + 21/3 + 2−1/3兲 0.515 352 837 431 122 936 4
b2 1 / 6共1 − 21/3 − 2−1/3兲 −0.085 782 019 412 973 646
a兲
b3 1 / 6共1 − 21/3 − 2−1/3兲 0.441 583 023 616 466 524 2 Electronic mail: donnelly@siena.edu
b兲
Electronic mail: rogers@siena.edu
b4 1 / 6共2 + 21/3 + 2−1/3兲 0.128 846 158 365 384 185 4 1
Rene de Vogelaere, “Methods of integration which preserve the contact
c1 0 0.134 496 199 277 431 089 2 transformation property of the Hamiltonian equations,” Report #4, De-
c2 共2 − 21/3兲−1 −0.224 819 803 079 420 805 8 partment of Mathematics, University of Notre Dame 共1956兲.
c3 共1 − 22/3兲−1 0.756 320 000 515 668 291 1 2
R. D. Ruth, “A canonical integration technique,” IEEE Trans. Nucl. Sci.
c4 共2 − 21/3兲−1 0.334 003 603 286 321 425 5 NS-30, 2669–2671 共1983兲.
3
S. Edvardsson, K. G. Karlsson, and M. Engholm, “Accurate spin axes

944 Am. J. Phys., Vol. 73, No. 10, October 2005 D. Donnelly and E. Rogers 944

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission
15
and solar system dynamics: Climatic variations for the Earth and Mars,” This method has been found more than once. See, for example, “Stable
Astron. Astrophys. 384, 689–701 共2002兲. solutions using the Euler approximation.” Alan Cromer, Am. J. Phys. 49,
4
H. Kinoshita, H. Yoshida, and H. Nakai, “Symplectic integrators and their 455–459 共1981兲.
application to dynamical astronomy,” Celest. Mech. 50, 59–71 共1991兲. 16
E. Harier, C. Lubich, and G. Wanner, Geometric Numerical Integration,
5
S. Mikkola and P. Wiegert, “Regularizing time transformations in sym- Structure-Preserving Algorithms for Ordinary Differential Equations
plectic and composite integration,” Celest. Mech. Dyn. Astron. 82, 375– 共Springer, New York, 2002兲.
390 共2002兲. 17
Haruo Yoshida, “Symplectic integrators for Hamiltonian systems: Basic
6
P. Saha and S. Tremaine, “Symplectic integrators for solar system dynam- theory,” in Chaos, Resonance, and Collective Dynamical Phenomena in
ics,” Astron. J. 104, 1633–1640 共1992兲. the Solar System, Proceedings of the 152nd Symposium of the Interna-
7
J. Wisdom and M. Holman, “Symplectic maps for the n-body problem,” tional Astronomical Union 共1991兲, p. 407.
Astron. J. 102, 1528–1538 共1991兲. 18
Haruo Yoshida, “Recent progress in the theory and application of sym-
8
J. Wisdom and M. Holman, “Symplectic maps for the n-body problem: plectic integrators,” Celest. Mech. Dyn. Astron. 56, 27–43 共1993兲.
Stability analysis,” Astron. J. 104, 2022–2029 共1992兲. 19
J. M. Sanz-Serna, “Symplectic integrators for Hamiltonian problems: An
9
Robert D. Skeel, Guihua Zhang, and Tamar Schlick, “A family of sym-
overview,” Acta Numerica 1, 243–286 共1992兲.
plectic integrators: Stability, accuracy, and molecular dynamics applica- 20
V. I. Arnold, Mathematical Methods of Classical Mechanics 共Springer-
tions,” SIAM J. Sci. Comput. 共USA兲 18, 203–222 共1997兲.
10 Verlag, New York, 1978兲.
Peter Nettesheim, Folkmar A. Bornemann, Burkhard Schmidt, and 21
B. A. Shadwick, Walter F. Buell, and John C. Bowman, “Structure pre-
Christof Schütte, “An explicit and symplectic integrator for quantum-
serving integration algorithms,” in Scientific Computing and Applications
classical molecular dynamics,” Chem. Phys. Lett. 256, 581–588 共1996兲.
11
Peter Nettesheim and Sebastian Reich, “Symplectic multiple-time- 共Nova Science, Commack, New York, 2001兲, Vol. 7, pp. 247–255.
22
stepping integrators for quantum-classical molecular dynamics,” in Com- Loup Verlet, “Computer ‘experiments’ on classical fluids. I. Thermody-
putational Molecular Dynamics: Challenges, Methods, Ideas, edited by P. namical properties of Lennard-Jones molecules,” Phys. Rev. 159, 98–103
Deuflhard, J. Hermans, B. Leimkuhler, A. E. Mark, S. Reich, and R. D. 共1967兲.
23
Skeel 共Springer, New York, 1998兲, pp. 412–420. See, for example, H. Gould and J. Tobochnik, An Introduction to Com-
12
Andreas Dullweber, Benedict Leimkuhlera, and Robert McLachlan, puter Simulation Methods, 2nd ed. 共Addison-Wesley, Reading, MA,
“Symplectic splitting methods for rigid body molecular dynamics,” J. 1996兲, p. 123.
24
Chem. Phys. 107, 5840–5851 共1997兲. J. Candy and W. Rozmus, “A symplectic integration algorithm for sepa-
13
F. Neri, “Lie algebras and canonical integration,” Technical Report, De- rable Hamiltonian functions,” J. Comput. Phys. 92, 230–256 共1991兲.
25
partment of Physics, University of Maryland, preprint 共1987兲, unpub- Franz J. Vesely, Computational Physics: An Introduction, 2nd ed. 共Klu-
lished. wer Academic, New York, 2001兲.
14 26
Haruo Yoshida, “Construction of higher order symplectic integrators,” R. I. McLachlan, “The accuracy of symplectic integrators,” Nonlinearity
Phys. Lett. A 150, 262–268 共1990兲. 5, 541–562 共1992兲.

945 Am. J. Phys., Vol. 73, No. 10, October 2005 D. Donnelly and E. Rogers 945

Downloaded 28 Sep 2012 to 136.159.235.223. Redistribution subject to AAPT license or copyright; see http://ajp.aapt.org/authors/copyright_permission

You might also like