Andreas Ernst


PIC PIC


The few-body problem and other selected topics in computational physics


PIC


.

Copyright © 2014 Andreas Ernst.

Alle Rechte vorbehalten, auch die des auszugsweisen Nachdrucks, der Speicherung in Datenverarbeitungsanlagen und der Übersetzung. Die Nutzung von Vorlesungsmaterial wurde mit Prof. Dr. phil. em. W. M. Tscharnuter arrangiert.

Veröffentlichungsdatum dieser Version: 1.12.2014
Erscheinungsdatum dieser Version: 1.12.2014

1. Auflage, Heidelberg, 2014

ISBN: 978-3-945825-00-6 (HTML)

Fraktalikum Druck & Verlag Dr. rer. nat. Andreas Ernst
http://www.fraktalikum.de

PIC

.

.

Es ist der Weisheit fromme Ehre,
Daß sie des Gottes Ruhm vermehre.
Da fragt ein Tor: “Wie werd’ ich weise?”
Es ruft im Chor: “Iß Götterspeise!”

It is the wisdom’s pious honor,
That it’s being god’s glory-donor.
A jerk talks big: “Being wise my wish is!”
It roars from heaven: “Eat klippfisk!”

A. Ernst

.

Inhaltsverzeichnis

Foreword
1 The few-body problem
 1.1 Introduction to the two-body problem
 1.2 Initial conditions for three- and four-body problems
 1.3 Few-body units
 1.4 Taylor integrators
 1.5 Leapfrog/Verlet integrators
  1.5.1 Standard Leapfrog methods
  1.5.2 Logarithmic Hamiltonian method (LogH)
  1.5.3 Time-transformed leapfrog (TTL)
  1.5.4 Higher-oder composition schemes
 1.6 Hermite integrators
  1.6.1 Standard Hermite method
  1.6.2 Iterated time-symmetric Hermite method
  1.6.3 Higher-order Hermite methods
  1.6.4 Adaptive time steps for the Hermite scheme
 1.7 Runge-Kutta integrators (RK)
 1.8 Tasks
2 Galactic dynamics
 2.1 Spherically symmetric models
  2.1.1 Mechanical foundations
  2.1.2 Kepler potential
  2.1.3 Power-law models
  2.1.4 Plummer model
  2.1.5 Dehnen models
  2.1.6 Logarithmic potential
 2.2 Multi component models
  2.2.1 The 3PLK Milky Way model
  2.2.2 JSH95 Milky Way model
  2.2.3 P90 Milky Way model
  2.2.4 Zotos’ barred spiral galaxy model
 2.3 Tasks
3 Linear stability analysis
 3.1 Introduction to linear stability analysis
 3.2 Logistic Map (1D)
 3.3 Hénon-Heiles system (2D)
 3.4 Lotka-Volterra system (2D)
 3.5 Lorenz attractor (3D)
 3.6 Rössler attractor (3D)
 3.7 Tasks
4 Integrating the stellar initial mass function
 4.1 Integral solving
  4.1.1 Solving a differential equation
  4.1.2 Using geometrical rules
  4.1.3 Monte-Carlo integration
 4.2 Tasks
5 Astrophysical Poisson equations
 5.1 Lane-Emden equation
  5.1.1 Chandrasekhar mass
  5.1.2 Isothermal case
 5.2 Tasks
   Afterword
   References
A Solutions and hints for some exercises
B TTL program
C Gnuplot examples
D Three-body animations

Foreword

The integration of differential equations and the numerical solution of integrals has gained much attention since the flowering of computer technology in the natural sciences. This book, which is called “Simply Integrate!’, contains descriptions of a collection of different integrators such as Taylor methods, Leapfrog methods, Hermite schemes, 2nd, 4th and 8th-order Runge-Kutta methods, or fancy ones, like a time-transformed 8th-order composition scheme where the highest accuracy is needed. An example are highly unstable periodic solutions of the three-body problem. In extreme cases one uses a “shooting method” from both sides to obtain closed orbits. A measure for the degree of instability is the dominant eigenvalue of the monodromy matrix in Floquet theory, which is not covered in this book, but for example in the book by Contopoulos (2002). The biggest part of the present book is concerned with “science that is hoary with age” (Platon, Timaios) but parts of it are also concerned with novel inventions and methods of modern physics and astrophysics.

The first main chapter of the present book is dedicated to the few-body problem. Starting with an introduction to the two-body problem, which is analytically solvable the author presents initial conditions for three- and four-body problems. These can be solved with the hereafter presented integration methods mentioned above. If heuristically means “concerning the inventions”, one may say: The chapter proceed heuristically, from simple to complex algorithms, from the two-body problem to the few-body problem.

The second main chapter of this book is about galactic dynamics and orbital mechanics in analytic gravitational potentials. At first spherically symmetric models of stellar systems are discussed and later multi compenent models of galaxies. The aim is to integrate orbits in these potentials with a self-written integrator, against the “ignava ratio”.

The third main chapter of this book is dedicated to linear stability analysis. The linear stability analysis is presented with many examples. Every example uses a general classification of equilibrium points, which is presented in the beginning. In this sense, the individual case is explained by summing it under a general classification or mathematical law. This is the paradigmatic method of the nomothetical sciences (Hempel1977Gadamer1990).

Further chapters are concerned with the stellar initial mass function and astrophysical Poisson equations.

The field of work of the author of this book is “experimental stellar dynamics”. The word “experimental” means in the context of astrophysics, that computer experiments are being used to study the dynamical evolution of stellar systems, where stars interact through gravity. Since the author’s N-body simulations require a huge amount of computer power, he has made use of Beowulf PC clusters as well as the largest supercomputers in Europe, field programmable gate arrays (FPGAs), graphics processing units (GPUs) and the grid technology. For the plots in this book, GNUPLOT, IDL, R, OMNIGRAFFLE and GIMP have been used. A website of this book with more material can be found at the internet address http://www.simplyintegrate.de. On the one hand, the readers of this book should get an impression what it means to do computational physics, on the other hand, they should see how much fun it is!

And the scientist and truth seeker, who has once read the book Burning Daylight by Jack London, knows well about the comparableness between the scientific research and the utterly exhausting search for gold nuggets at the Klondike River. It remains, to exclaim from time to time with Jack London’s hero: “Burning daylight!”

Heidelberg, im Mai 2014
Andreas Ernst

1 The few-body problem

1.1 Introduction to the two-body problem

We follow the lecture notes of Kühn & Spurzem (2005) first. A similar approach to the problem can be found in the book by Binney & Tremaine (2008). Newton’s equation of motion for the relative motion of two bodies under their mutual gravitational force is

    d2r    GM  r
¨r = dt2-= - -r2-r
(1.1)

where G is the gravitational constant, M = m1 + m2 is the total mass, r = (x2 - x1,y2 - y1,z2 - z1) the relative vector, r = |r| the relative distance and the two dots denote a second derivative with respect to time t in the notation of Newton. The bound solutions of Eqn. (1.1) are ellipses, the general solutions are conic sections. Kühn & Spurzem (2005) note that the Hamiltonian of the relative motion leads to μ¨r = -Gm1m2r∕r3 with the reduced mass μ = m1m2∕M and the above equation is that divided by μ. Therefore we can recover the sum M = 4π2a3(GT2) of the two masses, e. g. of a double star, using Kepler’s third law from the knowledge of the relative motion (semimajor axis a and orbital period T of the relative motion), provided that we can deproject the orbit and learn to know about its inclination with respect to the celestial sphere (see Figure 1, left-hand side). To obtain the individual masses, the knowledge of the ratio m1∕m2 is needed in addition. It can be obtained from the knowledge of the center of mass and that of the motion of the double star components around it (see Figure 1, right-hand side).

Numerical solution: For a numerical integration we need to replace Eqn. (1.1) by two coupled first-order differential equations,

 ˙r = v                                      (1.2)
      GM  r
v˙= - --2--.                                (1.3)
       r  r

Note that these cannot be solved independently. A dimensionless formulation can be introduced (e. g. Kühn & Spurzem2005). We define

-
r-= r∕R0                  ∘ -------                     (1.4)
v = v∕V0  mit ∕ with V0 =  GM  ∕R0                     (1.5)
                          ∘--3----
τ = t∕T0   mit ∕ with T0 =  R 0∕GM                      (1.6)

Using this we obtain

     dr
r′ = ---= v-                                 (1.7)
     dτ-    -
v′ = dv-= --r3.                               (1.8)
     dτ    r


PIC PIC

Abbildung 1: Left: Measuring the sum of masses M = m1 + m2 from the relative motion. Right: Measuring the mass ratio m1∕m2 = d2∕d1 from the motion of the double star components around their common center of mass. According to Green & Jones (2003). Graphics program: OMNIGRAFFLE.


where the prime denotes a derivative with respect to the scaled time τ in the notation of Lagrange.

The simplest Taylor integrator, the Euler integrator, can be written as

Euler-Methode / Euler method:

-    -   --       --   2
r1 = r0-+ v0Δt+ O (a0(Δt-))                           (1.9)
v1 = v0 + a0(r0)Δt + O(˙a0(Δt)2)                      (1.10)

where a = v= dv∕dτ is the dimensionless acceleration, Δt is the time step and the subscripts ‘0’ (and ‘1’) stand for the current (next) time step. The local error (in one time step) of the Euler method is of order a0t)2 in position and --
˙a0t)2 in velocity.

Although it is possible to implement the Euler scheme straightforwardly in the form of a computer program, the author recommends to begin the integration exercises with the initial conditions for three- and four-body problems given in the next section. The reason is that the computer program should be written generally enough, such that a few-body problem with N > 2 can be solved, where the variable N stands for the particle number.

Integrals of motion: We prove the temporal constancy of the integrals of the relative motion,

     1    GM
E =  -v2 -----,        (Energie ∕ energy)                            (1.11)
     2     r
L = r × v,             (Drehimpuls ∕ angular momentum )               (1.12)
 e = v×-L-- r,         (Runge - Lenz Vektor ∕ Runge - Lenz vector)   (1.13)
     GM     r

where r = |r| and v = |v|. We use the Graßmann identity

A × (B × C ) = B (A ⋅C )- C (A  ⋅B ).                     (1.14)

We use Eqn. (1.14) to calculate

L-×-r   (r-×-v)×-r-  v-  (v-⋅r)r  -d (r)
 r3  =     r3    =  r -   r3  = dt  r
(1.15)

and find

d-E = v⋅v˙- GM--r⋅v-= 0,                                     (1.16)
dt           r2  r
d-L = d-(r× v) = (v × v)+ (r× ˙v) = - GM-(r × r) = 0,          (1.17)
dt    dt(      )                    r3
-de = d-  v×-L-  - d-(r ) = - r×-L---d( r) = 0.              (1.18)
dt    dt  GM       dt r       r3    dt  r

Analytical solution: For an analytical solution of Eqn. (1.1) we consider the expression

         r-⋅(v-×-L)   (r×-v)⋅L-  -L2-
e⋅r + r =   GM     =   GM     = GM
(1.19)

This can be written as

ercos(ψ - ψ )+ r = -L2-  oder ∕ or                    (1.20)
      [   0    ]  GM
    ---L2∕(GM-)----
r = 1+ ecos(ψ- ψ0),                                 (1.21)

which is the well-known solution of a conic section with the orbital plane (e. g. Kühn & Spurzem2005) with the phase angle ψ = ψ(t).

Hamiltonian formulation: The conserved Hamiltonian is given by

H = T + V = H
             0
(1.22)

where T and V are kinetic and potential energy, respectively, and H0 a constant. With the dimensionless expressions for the relative motion of the two-body problem

T = 1v2,   V = - 1
    2            r
(1.23)

we obtain

      -
 r′ = dr-= ∇vH = ∇vT = v,                          (1.24)
     dτ-                 -
v-′ = dv-= ∇rH = ∇rV = - r-.                       (1.25)
     dτ                  r′3

where we have used the separability property of the Hamiltonian, according to which T = T(v) depends only on v and V = V (r) depends only on r. The notations of the gradient operators are r  =    --    --   -
(∂∕∂x,∂ ∕∂ y,∂ ∕∂z)  and v  =     -     -     -
(∂∕∂vx,∂∕∂vy,∂∕∂vz) , where denotes a placeholder for a scalar quantity. We recognize the equations of motion (1.2) and (1.3) of the two-body problem.

Lagrangian formulation: The Lagrange function is given by

            1-   1
L = T - V = -v2 +-
            2    r
(1.26)

in dimensionless phase space coordinates. The Euler-Lagrange equations of motion are given by

                  -    --
  -    d-- --    -r   dv-
∇ rL - dτ∇ vL = - r3 - dτ = 0
(1.27)

or

      -     -
-′′  d2r     r-
r = dτ2 = - r3.
(1.28)

We recognize the dimensionless formulation of Eqn. (1.1).

1.2 Initial conditions for three- and four-body problems

The initial conditions are given in the form m x y z vx vy vz.

Acht / Eight

1 0.9700436 -0.24308753 0 0.466203685 0.43236573 0  
1 -0.9700436 0.24308753 -0 0.466203685 0.43236573 0  
1 0 0 0 -0.93240737 -0.86473146 -0

Pytagoreisches Problem / Pythagorean problem

3 1 3 0 0 0 0  
4 -2 -1 0 0 0 0  
5 1 -1 0 0 0 0

Herz / Heart

1 -5.54504183347047 0 0 0 -0.414526370749686 0  
1 2.772520916735235 -1.678453738023547 0 0.3933483781289587 0.207263185374843 0  
1 2.772520916735235 1.678453738023547 0 -0.3933483781289587 0.207263185374843 0

Schwimmer / Swimmer

1 0 0 0 0 1.2050 0  
1 -1 0 0 0 -0.6025 0  
1 1 0 0 0 -0.6025 0

Ducati / Ducati

1 -1 0 0 0 -0.93932504689 0  
1 0.5 -0.647584 0 -0.505328085163 0.46962523449 0  
1 0.5 0.6475840 0 0.505328085163 0.46962523449 0

Stern / Star

1 1.0598738926379 1.7699901770118 0 -0.55391384867197 -0.39895079845794 0  
1 0 -0.80951135793043 0 1.0936551555351 0 0  
1 -1.0598738926379 1.7699901770118 0 -0.55391558212647 0.39895379682134 0  
1 0 -2.7304689960932 0 0.01417427526245 0 0

Special solutions of the three- or four-body problem are described in:

Szebehely & Peters (1976); Hénon (1976); Moore (1993); Simó (2000); Chencincer & Montgomery (2000); Broucke (2002); Vanderbei (2004); Martynova & Orlov (2009); Šuvakov & Dmitrašinović (2013); Ouyang & Xie (2013).

After a discussion of the unit scaling in the next section many different integration algorithms are described in following sections. The author recommends, after writing your own integration program according to one of these algorithms, to begin the integration exercises with the figure “eight”, since it is easy to integrate due to its stability and the fact, that close encounters do not occur at all. Afterwards, you may try to solve the Pythagorean problem. The Pythagorean problem is difficult to integrate. A very accurate integrator must be used which is able to cope with the numerous close encounters.

In addition to the initial conditions for the figure “heart” mentioned above we also state the initial conditions for two other choreographic solutions (Simó2000):

Choreographie 1 / choreography 1

0.3333333333333333 -0.39636722 0 0 0 -0.809132789 0  
0.3333333333333333 0.19818361 -0.12376832 0 0.673306125 0.404566394 0  
0.3333333333333333 0.19818361 0.12376832 0 -0.673306125 0.404566394 0

Choreographie 2 / choreography 2

0.3333333333333333 -1.56895624 0 0 0 -0.195438179 0  
0.3333333333333333 0.784478120 -0.10133157 0 0.631767478 0.097719082 0  
0.3333333333333333 0.784478120 0.10133157 0 -0.631767478 0.097719082 0

Particularly the second solution is highly unstable. A “shooting method” from both sides in combination with a highly accurate integrator is recommended to obtain a closed solution. For this purpose, the sign of the velocity vectors must be reversed. Then one integrates (“shoots”) from both sides, once with the standard initial conditions and once with the initial conditions with reversed signs of the velocity vectors. If the accuracy is high enough, one may hope that the solutions meet each other in the middle after half an orbital period. For further choreographies of the three-body problem we refer to the works of Carles Simó.

1.3 Few-body units

We follow the procedure from Sverre Aarseth’s direct N-body program NBODY6 (Aarseth19992003), but extend the method for the purpose of scaling to arbitrary units. We assume that the N-body system has units in which the gravitational constant has the value G the total mass has the value M and the total energy has the value E. We would like to scale to units in which these quantities have the values G, Mand E.

For example, we might be interested in scaling to standard N-body units according to Heggie & Mathieu (1986), which are defined by G= M= -4E= 1.

Or, for example, we might want to scale a double or triple star system to physical units, in which G= (222.3)-1 pc3M-1Myr-2, M= 1 M and E= 1 Mpc2Myr-2.

We must proceed as follows:

Calculation of the total mass: We calculate the total mass firstly,

    ∑N
M =    mi,
     i=1
(1.29)

where N is the number of particles.

Translation into the center of mass system: We calculate the center of mass and its velocity,

         N
x   = 1-∑  m  x ,                            (1.30)
 cm   M  i=1  i i
         N
vcm = 1-∑  mivi                              (1.31)
      M  i=1

If necessary (xcm = 0 or vcm = 0), we apply a translation to the center of mass frame,

m ′i = mi,                                   (1.32)
 x′= xi - xcm,                               (1.33)
  i′
 vi = vi - vcm,                              (1.34)

where the prime denotes the quantities in the center of mass frame.

Calculation of the energy: Now we calculate the total energy in the center of mass frame,

                  ⌊                    ⌋
            ∑N   ′⌈1 ′2   N∑    ---m′j---⌉
E = T + V =    m i 2vi -      G|x′i - x′j|
            i=1          j=i+1
(1.35)

where T and V are kinetic and potential energy. It can be seen that the positions and velocities are coupled through the masses, which enter quadratically in the potential energy, and the coupling constant G.

Scaling the masses, positions and velocities: We define three scaling factors

      ′            ′             ′
S1 = G ∕G,   S2 = M ∕M,    S3 = E ∕E.
(1.36)

We may set

S1 = G -1,  S2 = M - 1,  S3 = (- 4E )- 1
(1.37)

for standard N-body units (Heggie & Mathieu1986). Then we scale the individual masses, positions and velocities as follows:

m ′′i = m ′iS2                                 (1.38)
x ′′= x′S1S2∕S3                              (1.39)
  i′′   i′∘ -2---
v i = vi S3∕S2                              (1.40)

That’s it. The system has now units in which the gravitational constant has the value G, the total energy is Eand the total mass is M.

1.4 Taylor integrators


PIC

Abbildung 2: Top left: Numerical solution of Burrau’s problem (“The Pythagorean Three-Body Problem”). Top right: The figure “eight” solution. Bottom left: The “heart”. Bottom right: Strongly unstable choreographic solution. A “shooting method” from both sides was used to obtain closed orbits. Plotting language: IDL.


Taylor integrators are based on the evaluation of the Taylor series

                1      2  1      2   1  (2)   3    1  (3)    4    ( (4)    5)
x1 = x0 + v0Δt + 2a0(Δt) + 6a˙0(Δt) + 24a 0 (Δt ) + 120a0 (Δt) + O a0 (Δt)  (1.41)
                            1      2  1 (2)   2   1  (3)    3    ( (4)    4)
v1 =             v0 + a0Δt + 2˙a0(Δt) + 6a0 (Δt) + 24-a0 (Δt ) + O  a0 (Δt)  (1.42)

with Δt = (t-t0), where x1,v1, x0 and v1 are the positions and velocities at the next and current time. The simplest Taylor integrator is the Euler integrator which is first-order accurate.

The acceleration and its time derivatives for the Newtonian gravitational force are given by

       ∑N    xij
 ai = -   mj x3-                                                        (1.43)
       j=j⁄=1i    ij
        N    {                  }
 a˙ = -∑  m    vij- 3xij(xij ⋅vij)                                       (1.44)
  i    j=1  j  x3ij       x5ij
        j⁄=i
       ∑N    { a    6v  (x  ⋅v  )  3x  [ 5(x  ⋅v  )2                  ]}
a(2i) = -   mj   -i3j- --ij--ij5--ij-+ --i5j  --ij2-ij--- vij ⋅vij - xij ⋅aij   (1.45)
       j=1     xij       xij        xij      xij
        j⁄=i   {                       [                               ]
 (3)    ∑N      ˙aij  9aij(xij ⋅vij) vij                     45(xij ⋅vij)2
ai  = -   mj   x3ij -     x5ij     - x5ij 9vij ⋅vij + 9xij ⋅aij -  x2ij
       j=j⁄=1i
                   [
               - xij 3xij ⋅a˙ij + 9vij ⋅aij - 45(xij ⋅vij)(xij ⋅aij)
                x5ij                            x2ij
                                                3]}
               - 45(xij ⋅vij2)(vij ⋅vij)-+ 105(xij4⋅vij)                      (1.46)
                        xij               xij

where xij = xj - xi and xij = |xij| are the relative position of particles j and i and its modulus. Note that for ai(2) and ai(3) more than one summation have to be carried out which is numerically expensive.


PIC

Abbildung 3: Enlargement of the numerical solution of Burrau’s problem (“The Pythagorean Three-Body Problem”) from Figure 2. Historical facts about Burrau’s problem can be found in Burrau (1913), Szebehely & Peters (1976) and Peetre (1997). Plotting language: IDL.


1.5 Leapfrog/Verlet integrators

1.5.1 Standard Leapfrog methods

Hamiltonian flow: As a first “tool” we will introduce the Hamitonian flow. The Poisson brackets are given by

           [(    ) (   )   (    )(    )]
        ∑3    ∂X-   ∂Y-      ∂X-   ∂Y-
{X,Y } =      ∂xi   ∂vi  -   ∂vi   ∂xi
        i=1
(1.47)

where X = X(x,v,t) and Y = Y (x,v,t) are two “observables”, i.e. differentiable functions of the phase space coordinates x,v and time t (e. g. Kuypers1997). We define operators with a hat as

^X⋅ = {⋅,X}
(1.48)

where denotes a placeholder. Furthermore, we define the 6-component phase space vector as

            (   )
            | x1|
     (  )   || x2||
Q  =  x   = || x3||
      v     |( v1|)
              v2
              v3
(1.49)

We note that ^
H is the time evolution “operator”. The time evolution of each component of Q is governed by

˙    ^
Qi = HQi
(1.50)

The above equations (1.50) are called “flow equations” for the phase space coordinate Qi. They are equivalent to the Hamiltonian equations of motion, which are written in standard notation as

x˙= ∇vH,    v˙= - ∇xH
(1.51)

The solution of the flow equations (1.50) can be written formally as

          (   )
Qi(t) = exp tH^ Qi (0)
(1.52)

where exp(tH^) is called the “Hamiltonian flow”.

Baker-Campbell-Hausdorff identity: As a second “tool”, we introduce the Baker-Campbell-Hausdorff (BCH) identity: The product of the exponentials of any non-commutative operators X and Y can be expanded as

exp(X )exp(Y) = exp(Z )
(1.53)

with

             1           3  3   2     2
Z ≈ X  + Y + 2[X, Y]+ O (X  ,Y ,X  Y,XY  )
(1.54)

to second order. It we apply the BCH identity twice we can find

exp(X )exp (Y )exp(X) = exp(Z ′)
(1.55)

with

  ′               3  3  2     2
Z  ≈ 2X + Y + O(X ,Y  ,X  Y,XY  )
(1.56)

which is also second-order accurate.

Leapfrog schemes: The Leapfrog methods are based on the splitting of the Hamiltonian,

H = T(v)+ V (x)
(1.57)

where the kinetic energy T = T(v) depends only on the velocities and the potential energy V = V (x) depends only on positions. Let us call this property the “separability property”.

We can write

     (   )      ( (     ))      (  )    (  )
  exp t^H  = exp  t ^T + ^V   = exp t^T  exp t^V
     (    )    (  )    (    )
≈ exp  1t^T  exp t^V  exp  1tT^                               (1.58)
       2                 2

where the last approximate equality is valid because of the expansion (1.56).

The Hamiltonian equations of motion (1.50) can be written second-order accurate as

     (            )
Q˙i =   1^T + V^+ 1 ^T Qi
       2       2
(1.59)

or alternatively as

     (            )
˙Qi =  1V^+ T^+ 1V^  Qi.
      2        2
(1.60)

Switching to the standard notation we can obtain from (1.60)

       (                    )             (                    )
x˙= ∇v   1V(x)+ T (v )+ 1V (x ) ,   ˙v = - ∇x  1V (x) +T (v)+ 1V (x) .
         2             2                    2             2
(1.61)

Therefore the integration can be performed in three time-ordered steps. Here we need to consider the time-ordering of the operators with a hat which is dictated by the fact that they are non-commutative. Note that the time ordering can also be written formally by applying the Wick-Dyson time ordering operator T^. A typical non-commutative operation from every-day life is, for example, washing and drying clothes.


PIC
PIC

Abbildung 4: Flow charts showing the DKD leapfrog step (top) and the KDK leapfrog step (bottom). In difference to the DKD leapfrog step, which needs only one force evaluation, the KDK leapfrog step needs two force evaluations, which are computationally expensive. Graphics program: OMNIGRAFFLE.


Algorithms: The DKD (“Drift-Kick-Drift”) Leapfrog, also called “Position Verlet” is given by (e. g. Sutmann2006)

DKD Leapfrog:

1. “Drift”:

          v0-
x12 = x0 + 2 Δt                              (1.62)

2. “Kick”:

v1 = v0 + a(x12)Δt                            (1.63)
3. “Drift”:
x1 = x12 + v1Δt                              (1.64)
          2
Note that the “Drift” step is rather a half-drift.

The KDK (“Kick-Drift-Kick”) Leapfrog, also called “Velocity Verlet” is given by (e. g. Sutmann2006)

KDK Leapfrog:

1. “Kick”:

         a(x0)
v12 = v0 +--2--Δt                             (1.65)

2. “Drift”:

x1 = x0 + v 1Δt                             (1.66)
           2
3. “Kick”:
         a(x1)
v1 = v 12 + 2  Δt                             (1.67)
Note that the “Kick” step is rather a half-kick. We remark also that the KDK leapfrog requires, in comparison with the DKD leapfrog, twice as many force evaluations which are computationally expensive.

Properties of leapfrogs: The leapfrog methods have the following good properties (c. f. McLachlan & Quispel2001):

1.
Symplecticity: The leapfrog is symplectic, i.e. it respects the structure and properties of Hamiltonian systems. For example, it does not show any secular drift in energy error.
2.
Symmetry conservation: The leapfrog ist time-symmetric or symmetric under time reversal. Trajactories, which are integrated forwards or backwards in time, respectively, are exactly identical. This property also implies that there is no secular drift in the energy error.
3.
Volume conservation: The phase space volume is conserved. For example, a circular orbit stays circular or the amplitude of a rosette orbit as is shown in Figure 9 stays constant during a long-term integration.
4.
Integral conservation: The leapfrog conserves angular momentum exactly, as a simple calculation shows (noticed by Patrick Glaschke):

L1 = x(1 × v1    )                               (1.68)
   =  x1 + 1v1Δt  × v1                          (1.69)
       2   2
   = x1× v1                                     (1.70)
      2  (         )
   = x12 ×  v0 + a12Δt                            (1.71)
   = x1× v0                                     (1.72)
     (2         )
   =  x0 + 1v0Δt  × v0                          (1.73)
           2
   = x0 × v0 = L0                               (1.74)

We note that in practical computations every numerical scheme is prone to roundoff errors. For the connection to symplectic integration we refer to the work of Skeel (1999).

1.5.2 Logarithmic Hamiltonian method (LogH)

The LogH method, a leapfrog with adaptive time steps is in detail described in Preto & Tremaine (1999). It is based on a so-called “functional Hamiltonian” (cf. Mikkola & Tanikawa1999Preto & Tremaine1999Mikkola2008).

We introduce now a logarithmic Hamiltonian (LogH)

Γ = ϵ[log(T - P )- log(V)].
             0
(1.75)

where 0 < ϵ 1 is an accuracy parameter and P0 is an integral of motion which equals minus the initial energy. We remark that a different functional form for the Hamiltonian can be used as well. However, it should obey the separability property with respect to x and v.

In the special case of the relative motion of the two-body problem, which was treated in chapter 1, we have

T = 1 v2, V =  1
    2          r
(1.76)

with the dimensionless relative velocity v = |v| and the dimensionless distance r = |r|.

We obtain the equations of motion for the logarithmic Hamiltonian method,

-   dr           ∇vT-      2ϵv-
r′ = dτ-= ∇v-Γ = ϵT---P = v2 --2P                    (1.77)
    dv-           ∇-V0    ϵr   0
v′ =---= - ∇rΓ = ϵ-r--= - -2                         (1.78)
    dτ             V      r

where τ is a transformed time. The time step function is given by

 ′  dt     ∂Γ        ϵ        2ϵ
t = dτ-= ∂(- P0)-= T---P0 = v2 --2P
                                 0
(1.79)

Preto & Tremaine (1999) remark already the nice property that the Equations (1.77), (1.78) and (1.79) do not contain any square root operations which are computationally expensive.

The DKD (“Drift-Kick-Drift”) leapfrog algorithm can, according to Preto & Tremaine (1999) and Mikkola (2008) be written as follows with an accuracy constant ϵ and an integral of motion P0 which is equal to minus the initial energy:

LogH Methode / LogH method:

1. “Drift”:

          ϵv0Δt
r12 = r0 + v2+-2P--                            (1.80)
          0    0
t1=  t0 + -2ϵΔt----                            (1.81)
 2       v0 + 2P0

2. “Kick”:

         ϵr1Δt
v1 = v0 ---22---                             (1.82)
           r12
                                            (1.83)
3. “Drift”:
          ϵv1Δt
r1 = r12 + v2+-2P-                            (1.84)
          1    0
t1 = t1 +-2ϵΔt----                            (1.85)
     2   v1 + 2P0

Because of the Hamiltonian formulation the LogH method is going to preserve the two-body trajectory except for a phase error: If we integrate a two-body problem with the LogH method, the numerical solution will always stay on the corresponding conic section. The same holds for the TTL method which is discussed in the next section.

1.5.3 Time-transformed leapfrog (TTL)


PIC PIC

Abbildung 5: Exact integration of the Kepler problem with the time-transformed leapfrog except for a phase error. Left panel: circular orbit. Right panel: orbit with eccentricity e = 0.75. See also Figure 2.2 in Mikkola (2008). Plotting language: IDL.


The TTL method, also a leapfrog with adaptive time steps is in detail described in Mikkola & Aarseth (2002) and the Cambody lecture notes by Mikkola (2008).

The Hamiltonian equations of motion are given by

x˙= v                                    (1.86)
v˙= a(x)                                 (1.87)

where x, v and a are position, velocity and force on a unit mass and the dot denotes a derivative with respect to time. Note that these are coupled and cannot be solved independently of each other. A time transformation

dτ = Ω (x)dt
(1.88)

can be introduced, where Ω(x) > 0 can be the absolute value of the potential energy in the case of a few-body problem, or its square, or cube, or, for example,

       N   N
Ω(x) = ∑  ∑   ---1----.
       i=1j=i+1|xi - xj|
(1.89)

We introduce an auxiliary variable W = Ω. The equations of motion in the transformed time become

 ′
x = v∕W                                   (1.90)
t′ = 1∕W                                  (1.91)
v′ = a(x)∕Ω                               (1.92)

where the prime denotes a derivative with respect to the transformed time. The trick is to calculate W from the differential equation

W˙ = v⋅∇ Ω
(1.93)

With this trick the leapfrog scheme can be applied, since Ω = Ω(x) similar to a = a(x) and the separability property can be respected. Switching to the transformed time we obtain

W ′ = v⋅ 1∇ Ω = v⋅∇ lnΩ
        Ω
(1.94)

We obtain the differential equations

(    )   (      )   (           )
   x′      v∕W            0
||  t′ ||   || 1∕W  ||   ||     0     ||
(  v′) = (   0  ) + ( a (x)∕Ω(x) )
  W ′        0        v⋅∇ lnΩ(x)
(1.95)

These can be solved, for example with a DKD (“Drift-Kick-Drift”) leapfrog method. We note, however, that the separability property is not exactly realized in the equations (1.95).

The algorithm can be written as follows: TTL-Methode / TTL method:

1. “Drift”:

          v0Δt
x12 = x0 + 2W---                             (1.96)
          Δt 0
t12 = t0 +----                               (1.97)
         2W0

2. “Kick”:

          a(x1)Δt
 v1 = v0 +-Ω(2x-1)-                                 (1.98)
               2
W1  = W0 + v0 +-v1Δt ⋅∇ Ω(x1)                      (1.99)
           2Ω(x12)         2
3. “Drift”:
x1 = x1+  v1Δt-                             (1.100)
      2   2W1
t1 = t1+ -Δt-                               (1.101)
      2  2W1
1.5.4 Higher-oder composition schemes


PIC

Abbildung 6: Exact integration of the Kepler problem with an 8th-order time-transformed composition scheme except for a phase error for an orbit with eccentricity e = 0.99. Plotting language: IDL.







No. ValueNo.Value








w 1 1.35120719195965763404w6 w4
w2 w1w7 w1
w3 w1w8 w1
w4 -1.70241438391931526809w9 w1
w5 w4





Tabelle 1: Koeffizienten nach dem Theorem von Yoshida, Qin und Zhu für das Kompositionsverfahren 4. Ordnung. / Coefficients according to the theorem of Yoshida, Qin and Zhu for the 4th-order composition scheme.






No. ValueNo.Value








w 1 0.78451361047755726382w5 w3
w2 0.23557321335935813368w6 w2
w3 -1.17767998417887100695w7 w1
w4 1 - 2 i=13wi





Tabelle 2: Koeffizienten nach McLachlan (1995) für das Kompositionsverfahren 6. Ordnung. / Coefficients by McLachlan (1995) of the 6th-order composition scheme.






No. ValueNo.Value








w 1 0.74167036435061295345w9 w7
w2 -0.40910082580003159400w10 w6
w3 0.19075471029623837995w11 w5
w4 -0.57386247111608226666w12 w4
w5 0.29906418130365592384w13 w3
w6 0.33462491824529818378w14 w2
w7 0.31529309239676659663w15 w1
w8 1 - 2 i=17wi





Tabelle 3: Koeffizienten nach McLachlan (1995) für das Kompositionsverfahren 8. Ordnung. / Coefficients by McLachlan (1995) of the 8th-order composition scheme.

The composition schemes are higher-order leapfrog methods and in detail described in the review by Sutmann (2006). Valid is, for example, the

Theorem of Yoshida, Qin and Zhu: Let T^ i exp(    )
 hitH^i be a scheme of order 2n with the time step Δt. Then the time-ordered composition

 ∏     (      ) ∏     (           ) ∏     (     )
^T   exp γhit^Hi    exp  (1 - 2γ)hit^Hi    exp  γhitH^i  ,
  i              i                   i
(1.102)

with

   (           )
γ =  2- 21∕(2n+1) - 1
(1.103)

is a scheme of order 2n + 2 (Yoshida1990Qin & Zhu1992), where ^T is the Wick-Dyson time ordering operator. We refer to McLachlan & Quispel (2001) for the proof.

Many other composition possibilities exist. Mathematicians try to minimize the number of computationally expensive force evaluations for a given order of the integrator. For example using the coefficients given in Table 1, Table 2 or Table 3, 4th-order, 6th-order or 8th-order composition schemes can be written in a “Position Verlet” fashion as a loop over n = 9, n = 7 or n = 15 coefficients in n = 9, n = 7 or n = 15 steps,

FOR i=1, n DO BEGIN

             vi
xi+12 = xi + wi 2 Δt                             (1.104)
 vi+1 = vi + wia(xi+1)Δt                         (1.105)
                vi+21
 xi+1 = xi+12 + wi-2--Δt                          (1.106)
ENDFOR

1.6 Hermite integrators

1.6.1 Standard Hermite method


PIC

Abbildung 7: Flow chart for the standard 4th-order Hermite method. Graphics program: OMNIGRAFFLE.



PIC

Abbildung 8: Linear growth of the relative energy error for the standard 4th-order Hermite method for 1000 circular orbits. Plotting language: GNUPLOT.



1for (double t = 0; t < t_end; t += dt) { 
2 
3// Do the prediction 
4 
5    for (int i = 0; i < n; i++) { 
6      for (int k = 0; k < 3; k++) { 
7        old_r[i][k] = r[i][k]; 
8        old_v[i][k] = v[i][k]; 
9        old_a[i][k] = a[i][k]; 
10        old_j[i][k] = jk[i][k]; 
11        r[i][k] += v[i][k]*dt + a[i][k]*dt2/2 + jk[i][k]*dt3/6; 
12        v[i][k] += a[i][k]*dt + jk[i][k]*dt2/2; 
13      } 
14    } 
15 
16// Calc. acc. and jerk from predicted positions and velocities 
17 
18    acc_and_jerk(m, r, v, a, jk, n); 
19 
20// Do the interpolation and correction 
21 
22    for (int i = 0; i < n; i++) { 
23      for (int k = 0; k < 3; k++) { 
24        a2[i][k] = -6*(old_a[i][k]-a[i][k])/dt2 
25                 -  2*(2*old_j[i][k] + jk[i][k])/dt; 
26        a3[i][k] = 12*(old_a[i][k]-a[i][k])/dt3 
27                 +  6*(old_j[i][k]+jk[i][k])/dt2; 
28 
29        v[i][k] = v[i][k] + a2[i][k]*dt3/6 
30                + a3[i][k]*dt4/24; 
31        r[i][k] = r[i][k] + a2[i][k]*dt4/24 
32                + a3[i][k]*dt5/120; 
33      } 
34    } 
35 
36// Data output 
37 
38  ... 
39 
40}
Listing 1: Code fragment in C++ containing the integration loop of the standard Hermite integrator.


The standard 4th-order Hermite scheme (Makino1991Makino & Aarseth1992) is in detail described in Glaschke (2006, Section 4.4) or in Ernst (2009, Section 8.2.1). It is a predictor-corrector method, which is particularly used for direct N-body simulations with N 1, since it combines the advantages of being a fast integrator and a higher-order method. We cite the latter of the above descriptions in the following subsection:

Prediction step: “Positions and velocities of the ith particle are predicted according to

 p                 1       2  1       3
xi,1 = xi,0 + vi,0Δt + 2ai,0(Δt) + 6a˙i,0(Δt) ,                (1.107)
 p                 1       2
vi,1 = vi,0 + ai,0Δt + 2˙ai,0(Δt) ,                           (1.108)

where the superscript ‘p’ stands for ‘predicted’ and the subscripts ‘0’ and ‘1’ for the current time t0 and the following time t1, respectively. The acceleration ai,0 and jerk a˙i,0 have been calculated from positions xi,0 and velocities vi,0 at time t0 according to the analytical formulas

      ∑N      xji
ai(t) =   Gmj  r3-                                     (1.109)
      j=j⁄=1i      ji
       N      (                 )
˙a (t) = ∑ Gm     vji-- 3(vji ⋅xji)x                      (1.110)
 i    j=1    j  r3ji      r5ji    ji
       j⁄=i

where xji = xj - xi and vji = vj - vi are relative positions and velocities between the ith and jth particles, respectively. Acceleration ai,1p and jerk ˙ai,1p at time t1 can be calculated as well from the predicted positions (1.107) and velocities (1.108) using the analytical formulas (1.109) and (1.110).

Interpolation of higher derivatives: A second way to write down ai,1p and a˙i,1p approximately is by a Taylor series expansion which contains higher-order derivatives of acceleration:

ap  = ai,0 + ˙ai,0Δt + 1a(2)(Δt)2 + 1a(3)(Δt)3,               (1.111)
 i,1                2 i,0       6 i,0
˙ap  = ˙ai,0 + a(2)Δt + 1a(3)(Δt)2.                           (1.112)
 i,1         i,0     2 i,0

Since we know the quantities Δt, ai,0, a˙i,0, ai,1p and ˙ai,1p, we can solve the system of equations (1.111) – (1.112) to obtain the Hermite interpolation of the higher-order derivatives of acceleration:

1        ai,0 - ap   2a˙i,0 + ˙ap
-a(i2),0 = - 3-----2i,1- --------i,1,                     (1.113)
2          (Δt)p         Δtp
1a(3) = 2ai,0 --ai,1-+ ˙ai,0 +-˙ai,1.                      (1.114)
6 i,0      (Δt )3       (Δt )2

Correction step: With these quantities, positions and velocities from the prediction step can be corrected to higher orders,

xci,1 = xpi,1 + 1-a(2i,)0(Δt)4 +-1-a(i3,0)(Δt)5,                  (1.115)
            24          120
vci,1 = vpi,1 + 1a(2i,)0(Δt)3 +-1a(i3,0)(Δt)4,                    (1.116)
            6          24

where the superscript ‘c’ stands for ‘corrected’.” (Ernst2009, Section 8.2.1)

1.6.2 Iterated time-symmetric Hermite method


1for (double t = 0; t < t_end; t += dt) { 
2 
3// Do the prediction 
4 
5    for (int i = 0; i < n; i++) { 
6      for (int k = 0; k < 3; k++) { 
7        old_r[i][k] = r[i][k]; 
8        old_v[i][k] = v[i][k]; 
9        old_a[i][k] = a[i][k]; 
10        old_j[i][k] = jk[i][k]; 
11        r[i][k] += v[i][k]*dt + a[i][k]*dt2/2 + jk[i][k]*dt3/6; 
12        v[i][k] += a[i][k]*dt + jk[i][k]*dt2/2; 
13      } 
14    } 
15 
16// Do the iteration 
17 
18    for (int l = 0; l < 3; l++) { 
19 
20// Calc. acc. and jerk from predicted positions and velocities 
21 
22      acc_and_jerk(m, r, v, a, jk, n); 
23 
24// Do the correction 
25 
26      for (int i = 0; i < n; i++) { 
27        for (int k = 0; k < 3; k++) { 
28          v[i][k] = old_v[i][k] + (old_a[i][k] + a[i][k])*dt/2 
29                  + (old_j[i][k] - jk[i][k])*dt2/12; 
30          r[i][k] = old_r[i][k] + (old_v[i][k] + v[i][k])*dt/2 
31                  + (old_a[i][k] - a[i][k])*dt2/12; 
32        } 
33      } 
34    } 
35 
36// Data output 
37 
38  ... 
39 
40}
Listing 2: Code fragment in C++ containing the integration loop of the iterated time-symmetric Hermite integrator.


An extension is the iterated time-symmetric Hermite method (Kokubo, Yoshinaga & Makino1998)

Prediction step: The prediction is given by

 p              1      2  1      3
x  = x0 + v0Δt + 2a0(Δt) + 6a˙0(Δt)                    (1.117)
 p              1      2
v  = v0 + a0Δt + 2˙a0(Δt)                              (1.118)

Correction step: The corrector step is given by

vc = v0 + 1(ap + a0)Δt - -1(˙ap - a˙0)(Δt)2                 (1.119)
          2            12
xc = x0 + 1(vc + v0)Δt - -1(ap - a0)(Δt)2                 (1.120)
          2            12

where the Hermite interpolations in Eqns. (1.113) and (1.114) have been used implicitly.

Iteration: The iteration of the corrector is achieved by returning to Eqns. (1.109)–(1.110) with the predicted positions replaced by the more accurate values xc,vc (Glaschke2006, Abschnitt 4.5).

1.6.3 Higher-order Hermite methods

Hermite mothods of higher order are explicitely described by Nitadori & Makino (2008).

Prediction step: For example, the predictor for a 6th-order Hermite method is given by

 p                 1      2   1       3   1 (2)   4   1   (3)   5
xi,1 = xi,0 + vi,0Δt+ 2ai,0(Δt ) + 6˙ai,0(Δt) ,+ 24ai,0(Δt) + 120-ai,0(Δt )     (1.121)
 p                1       2   1 (2)    3   1 (3)   4
vi,1 = vi,0 + ai,0Δt+ 2 ˙ai,0(Δt ) + 6ai,0(Δt) + 24ai,0(Δt)                 (1.122)

Correction step: The corrector for the 6th-order Hermite method is given by

vc  = vi,0 + 1 (ai,1 + ai,0)Δt --1(˙ai,1 - a˙i,0)(Δt)2 +-1-(a(2)+ a(2))(Δt)3    (1.123)
 i,1        2               10                 120  i,1   i,0
xc  = xi,0 + 1 (vc + vi,0)Δt - -1(ai,1 - ai,0)(Δt)2 +-1-(˙ai,1 + a˙i,0)(Δt)3   (1.124)
 i,1        2   i,1          10                 120

An eighth-order method is also described in Nitadori & Makino (2008).

1.6.4 Adaptive time steps for the Hermite scheme

The standard 4th-order Hermite scheme is based on the Taylor expansions

xi,1 = xi,0 + vi,0Δt + 1ai,0(Δt)2 + 1 ˙ai,0(Δt )3 +-1a(2)(Δt)4 +-1 a(3)(Δt )5    (1.125)
     ◟------------2--◝◜------6-------◞   2◟4-i,0------◝1◜20--i,0---◞
             Vorhersage ∕ Prediction            Korrektur ∕ Correction
            ◜---------◞◟---------◝        ◜---------◞◟--------◝
 v   =      v  + a  Δt + 1˙a  (Δt)2     +  1a(2)(Δt)3 +-1 a(3)(Δt )4      (1.126)
  i,1         i,0   i,0     2 i,0             6 i,0       24  i,0

for the ith particle, where the subscripts ‘0’ and ‘1’ stand for the current time t0 and the following time t1, respectively. The idea of adaptive time steps is as follows: Depending on the order of the integrator, its local numerical error depends usually on some positive integer power of the step width. The local error should decrease monotonically with the step width. An adaptive time step criterion adjusts the time step in such a way, that the local error remains constant or, at least, has an upper bound during the integration. Time step criteria therefore involve an estimate of the local error.

Time step criteria: One may summarize a list of restrictions for the choice of an adaptive time step for the standard 4th-order Hermite integrator as follows:

1.
The time step must be a combination of dimensionless parameters and the quantities involved in (1.125) and (1.126),
2.
The time step must have the dimension of time and transform like a time under rescaling of units.
3.
The time step must be invariant under Galilei transformations of the N-body system.
4.
The time step must be well defined for special cases.

Aarseth criterion: It turns out that the Aarseth criterion

      ┌│ -------(2)--------
Δti = │∘ η-|ai||a-i-|+|˙ai|2-
         |˙ai||a(3i)|+ |a(i2)|2
(1.127)

fulfills all requirements, where η is a dimensionless accuracy parameter. This criterion is well defined for the special case ai = 0 at the Lagrangian points a tidal field or the “cold collapse” with ˙ai = ai(3) = 0, where all particles are initially at rest (Aarseth1985).

Hierarchical block time steps: Usually one quantizes the time steps for N 1 in powers of 12 such that blocks of particles with equal time steps can be integrated forwards simultaneously.

1.7 Runge-Kutta integrators (RK)

The Runge-Kutta method is in detail described in Press et al. (1986). As a standard numerical integrator, it “takes an initial condition and moves the objects in the direction specified by the differential equations”.

Suppose we have a system of N particles, which interact through gravity. Let mi be the mass of the ith particle and Qi,0 a 6-dimensional state vector, which contains position and velocity of the ith particle at time t0. We have then

      ( xi,0)             ( vi,0)
Qi,0 =  vi,0  ,     ˙Qi,0 =  ai,0  ,
(1.128)

where the dot denotes the time derivative. The acceleration ai,0 obeys the Newtonian law of gravitation,

      ∑N
ai,0 =   Gmj xj3i,0,
      j=1    rji,0
      j⁄=i
(1.129)

where xij,0 = xj,0 - xi,0,rij,0 = |xij,0| and the summation is over all those pairs of particles, where one of the particles is the ith particle. Of course, the ith particle does not interact with itself.

Since ai,0 depends on m1,...,mi-1,mi+1,...,mN and r1,0,...,rN,0, we have a system of ordinary differential equations

Q˙i,0 = F(m1, ...,mi-1,mi+1,...,mN ,Q1,0,...,Qi-1,0,Qi+1,0,...,QN,0),
(1.130)

where F is the known vector mapping. Given the masses mi and the vectors Qi,0, we want to find the vector Qi,1 at time t1 = t0 + Δt, where Δt is the time step.

For the pth-order Runge-Kutta mathod, we have to compute the following p 6-dimensional vectors:

       (                    )
                  j∑-1
ki,j = F |(Qi,0 + Δt ⋅  ajmki,m|)    for j = 1,...,p and i = 1,...,N
                  mj=>1m
(1.131)

with coefficients ajm given in tables 4, 5 and 6. In the above definition, F is the known vector mapping from (1.130). The integration step is then

                ∑p
Qi,1 = Qi,0 + Δt ⋅  bjki,j
                j=1
(1.132)

with coefficients bj given in tables 4, 5 and 6. The coefficients for the second- and fourth-order scheme are given in Press et al. (1986). It is not known to the present author who calculated the coefficients for the eighth-order method.





jaj1bj






1 0
21/2 1




Tabelle 4: Koeffizienten für das Runge-Kutta-Verfahren 2. Ordnung. / Coefficients for 2nd-order Runge-Kutta method.







jaj1aj2aj3 bj










1 1/6
21/2 1/3
3 01/2 1/3
4 0 0 11/6






Tabelle 5: Koeffizienten für das Runge-Kutta-Verfahren 4. Ordnung. / Coefficients for 4th-order Runge-Kutta method.











j aj1 aj2 aj3 aj4 aj5aj6aj7 bj


















1 7/1408
2 1/6 0
3 4/75 16/75 1125/2816
4 5/6 -8/3 5/2 9/32
5 -8/5144/25 -4 16/25 125/768
6361/320 -18/5407/128 -11/8055/128 0
7 -11/640 0 11/256-11/16011/256 0 5/66
8 93/640 -18/5803/256-11/16099/256 0 1 5/66










Tabelle 6: Koeffizienten für das Runge-Kutta-Verfahren 8. Ordnung. / Coefficients for 8th-order Runge-Kutta method.

1.8 Tasks

1.
How many summations have to be carried out for the calculation of a(2) and a(3) in Eqns. (1.45) and (1.46)?
2.
Scale the initial conditions of the Pythagorean problem to standard N-body units (Heggie & Mathieu, 1986).
3.
Integrate the initial conditions given in Section 1.2 with an integrator of your choice. Visualize the solution graphically, e. g. as shown in Appendix C, and/or animate it with the method described in Appendix D.
4.
Measure the growth behaviour of the relative energy error of an integrator of your choice and compare with that shown in Figure 8 for the standard Hermite method.
5.
Measure the time and distance of the closest encounter in the Pythagorean three-body problem before the binary forms and write down which particles are involved.
6.
Rotate the initial conditions for the Ducati orbit with an affine transformation by 45 degrees in the xy plane and integrate it.
7.
Think about the question, whether the 6th-order Hermite scheme described in Nitadori & Makino (2008) is getting time-symmetric or not after a few iterations of the corrector.
8.
Develop an adaptive time step criterion as in (1.127) for the 6th-order Hermite scheme described in Nitadori & Makino (2008).

2 Galactic dynamics

The aim of this chapter about orbital mechanics and galactic dynamics is to enable the reader to integrate orbits in different analytic gravitational potentials. It is left to the reader to write a program for the integration of orbits in these gravitational potentials. It may be useful to keep the program as general as possible to simplify the inclusion of new gravitational potentials without larger problems.

2.1 Spherically symmetric models

2.1.1 Mechanical foundations

Coordinates: A spherically symmetric self-consistent model of as stellar system, which is static in time and a solution of both the Poisson and the Boltzmann equation, is given by gravitational potential Φ(r), cumulative mass M(r), density ρ(r) and velocity dispersion σ(r). These scalar quantities depend only on radius r, which is defined as the distance from the center, not from time t or velocity v. We define

    (  )                                  (   )
    ( x)              ∘--2---2---2        ( vx)              ∘ -2---2----2
r =   y  ,    r = |r| = x + y + z ,   v =   vy  ,    v = |v| = vx + vy + vz.
      z                                     vz
(2.133)

Poisson Gleichung: The Poisson equation for a spherically symmetric system is given by

          1 ∂ (   ∂Φ(r))
∇2 Φ(r) =-2 --- r2-----  = 4πGρ(r)
         r  ∂r     ∂r
(2.134)

where 2 is the Laplacian operator and G is the gravitational constant.

Physical quantities: The force on a unit mass (the specific force or acceleration) is given by

                 ∂Φ(r)r      r
a(r) = - ∇ Φ(r) = ------ = f(r)-
                  ∂r  r      r
(2.135)

where is the gradient operator.

Starting from the gravitational potential, we have

∂Φ (r)   GM  (r)
--∂r- = --r2-- = - f (r)                         (2.136)
          1  ∂M (r)
  ρ(r) =---2 ------                             (2.137)
        4πr   ∂r

where we have used in the first step Newton’s second theorem (see Binney & Tremaine1987, p. 34f.) together with Newton’s law of gravitation.

Starting from the density, we have

       ∫             ∫
         r     ′       r  ′  ′2  ′
M (r) =  0 dM (r) = 4π 0 ρ(r)r dr                     (2.138)
          ∫ ∞ M (r′)  ′
Φ (r) = - G    --r′2-dr                                (2.139)
           r

where we assume limr→∞Φ(r) = 0 in the last step.

The circular velocity vc(r) and escape velocity ve(r) are given by

       ∂Φ (r)    ∂Φ (r)   GM  (r)
v2c(r) = ∂ln(r) = r-∂r- = ---r--                      (2.140)
 2
ve(r) = 2|Φ (r)|                                       (2.141)

The total potential energy W is given by the equivalent expressions

     4π ∫ ∞
W  = ---    ρ(r)Φ (r)r2dr                                     (2.142)
      2  0∫ ∞                ∫ ∞   2
   = - -1-    |f(r)|2r2dr = - G    M--(r)dr                   (2.143)
       2G  0∫               2  0∫   r2
            ∞                    ∞ M-(r)
   = - 4πG  0 ρ(r)M (r)rdr = - G 0    r  dM (r).              (2.144)

The derivation of the above integrals is discussed in chapter 2 of the book by Binney & Tremaine (1987). If the system is in virial equilibrium, the value of the potential energy W is connected to the values of total kinetic energy K = -W∕2 and the total energy E = -K = W∕2.

From Eqn. (2.144) follows the root mean squared escape speed,

               4W
⟨v2e⟩ = 2⟨|Φ|⟩ = ----,
               M
(2.145)

for a finite total mass M.

If the velocity dispersion tensor is isotropic, we can obtain the velocity dispersion σ(r) by integrating the Jeans equation of hydrostatic equilibrium,

 (     2  )
d-ρ(r)σ-(r)- = - ρ(r)dΦ(r).
     dr             dr
(2.146)

The velocity dispersion is given by the integral

            ∫ ∞   ′    ′
σ2(r) = -G--    ρ(r-)M′2-(r-)dr′.
        ρ(r)  r     r
(2.147)

Virial theorem: The kinetic energy due to random motion is given by the integral

    3    ∫ ∞                           ∞     ∫ ∞ d [        ]          W
Π = 2 ⋅4π    ρ(r)σ2(r)r2dr = 2πr3ρ(r)σ2(r)|0-- 2π    dr ρ(r)σ2(r) r3dr = C --2-,
          0                ◟     ◝C◜     ◞     0
(2.148)

where a an integration by parts has been carried out in the first step and the condition (2.146) of hydrostatic equilibrium has been plugged in in the second step. If Π is finite it follows that C = 0 and the virial theorem is fulfilled (Ernst2009).

Integrals of motion: Two integrals of motion in static spherically symmetric stellar systems are

     1 2
E  = 2v + Φ (x,y,z),                     (Energie ∕ energy)               (2.149)
     ( L )          ( yv  - zv )
 L = ( Lx) = r × v = ( zvz- xvy ) .     (Drehimpuls ∕ angular momentum )  (2.150)
       Ly             xvx - yvz
        z               y    x
2.1.2 Kepler potential

The Kepler potential is solution of the Poisson equation for a point mass in the origin of coordinates and given by

Φ (r) = - GM-
         r
(2.151)

Applications include, e. g., planetary dynamics or stellar orbits around a supermassive black hole. The acceleration is given by

(   )         (   )
  ax            x
( ay) = - GM3-( y ) .
  az       r    z
(2.152)

The jerk, which is of relevance for the Hermite integration scheme, is given by

(       )         ⌊                 (  )   (   ) ⌋
  dax∕dt      GM   3(xvx +yvy + zvz)   x      vx
( day∕dt) = - -r3-⌈-------r2------- ( y) - ( vy) ⌉            (2.153)
  daz∕dt                              z      vz

Integral of motion: An additional integral of motion in the Kepler potential is

e = v-×-L - r.         (Runge- Lenz Vektor ∕ Runge- Lenz vector)
     GM     r
(2.154)

2.1.3 Power-law models


PIC

Abbildung 9: Orbits of different eccentricities in a near-isothermal sphere, a power law model with Exponent α = 1.2. For each orbit the initial velocity is given in units of the circular velocity at the initial galactocentric radius. Top row: Rosette orbits without dynamical friction. Bottom row: With dynamical friction. From Ernst (2009). Integrator: INTEXT (Ernst2012). Plotting language: GNUPLOT.


The spherically symmetric power-law or scale-free models can be used to study the dynamics in the centers of galaxies. Note that power laws are connected to self-similarity, i.e. they are scale-invariant. In particular, the models discussed below are invariant under spatial magnification. They have a potential of the form

        (   )α- 1
Φ(r) = Φ0 r-     ,  α ⁄= 1,                        (2.155)
          r0

where r is the radius and r0 is a length unit. The acceleration has the form

(   )         (   )             (   )    (  )
( ax)     ∂Φ-1( x )          Φ0-  r- α-1 ( x)
  ay  = - ∂r r  y   = - (α - 1)r2 r0       y  .
  az            z                          z
(2.156)

The jerk is given by

( da ∕dt)     ({          (   )α-1⌊                      ( x)
( dax∕dt) = -   (α- 1)Φ0-  r-    ⌈ (α---3)(xvx-+-yvy +-zvz)( y)
  day∕dt      (       r2   r0                r2            z
    z                                 (   )⌋ )
                                        vx    }
                                    + ( vy )⌉ )                      (2.157)
                                        vz
2.1.4 Plummer model

The gravitational potential of a Plummer model is given by

          GM
Φ (r) = - √-2---2
          r + a
(2.158)

where a is the Plummer radius. The acceleration is then given by

( ax)          ( x)               ( x )
( ay) = - ∂Φ-1 ( y) = - ---GM-----( y ) .
  az      ∂r r   z      (r2 + a2)3∕2 z
(2.159)

The jerk, which is of relevance for the Hermite integration scheme, is given by

(       )              (                 (  )   (   ) )
  dax∕dt               {                   x      vx  }
( day∕dt) =  -2-GM2-3∕2  3(xvx +2yvy +2-zvz)( y) - ( vy)
  daz∕dt     (r + a )   (     (r + a )      z      vz  )
(2.160)

2.1.5 Dehnen models

The gravitational potential of a Dehnen model (Dehnen1993Tremaine1994) has, in contrast to that of the Plummer model, a “cusp” in the center. It is given by

                 [   (     )2-γ]
Φ(r) = - GM--1--- 1-   -r---
         a  2- γ       r+ a
(2.161)

where a is a scale radius. The acceleration is given by

(   )         (   )                   (   )
  ax      ∂Φ 1  x       GM  (  r  )3-γ  x
( ay) = - ∂r-r( y ) = - -r3-- r-+-a    ( y ) .
  az            z                       z
(2.162)

The jerk which is of relevance for the Hermite integration scheme, is given by

(       )   (                  ⌊                        (   )
  dax∕dt    {   GM   (   r ) -γ  (aγ + 3r)(xvx + yvy + zvz) x
( day∕dt) = ( (r+-a)3  r+-a-   ⌈ -------r2(r+-a)--------( y )
  daz∕dt                                                  z
                                ( vx)⌋ )}
                             -  ( vy)⌉                              (2.163)
                                  vz   )

Special cases are the Hernquist model with γ = 1 (Hernquist1990) and the Jaffe model with γ = 2 (Jaffe1983).

2.1.6 Logarithmic potential

A logarithmic gravitational potential, which is often used for dark matter halos of galaxies, is given by

        2  (     2)
Φ (r) = v0ln 1+ r-
       2        r20
(2.164)

The acceleration is given by

(   )          (  )             (  )
  ax      ∂ Φ1   x         v20     x
( ay)  = --∂rr ( y) = - (r2 +-r2)( y) .
  az             z            0   z
(2.165)

The jerk is given by

              ⌊                 (  )           (   ) ⌋
             2⌈                 ( x)     2   2 ( vx) ⌉
( dax∕dt)   v0  2(xvx + yvy + zvz) y - (r + r0)  vy
( day∕dt) = ----------------------z-2------------vz---
  daz∕dt                     (r2 + r20)
(2.166)

2.2 Multi component models

2.2.1 The 3PLK Milky Way model


PIC
PIC

Abbildung 10: Circular and near-circular orbit with a vertical oscillation (top) and a horizontal oscillation (bottom) at the solar radius in a 3-component Plummer-Kuzmin model of the Milky Way. Integrator: INTEXT (Ernst2012). Plotting language: GNUPLOT.



PIC

Abbildung 11: Halo orbit resembling a ball of wool for knitting socks and circular reference orbit at the solar radius in a 3-component Plummer-Kuzmin model of the Milky Way. Integrator: INTEXT (Ernst2012). Plotting language: GNUPLOT.



Tabelle 7: Die Liste der Milchstraßen-Komponenten-Parameter für das 3PLK-Modell der Milchstraße (Peter Berczik, Patrick Glaschke). / The list of galaxy component parameters for the 3PLK model of the Milky Way (Peter Berczik, Patrick Glaschke).





Component M [M] a [kpc]b [kpc]




Bulge 1.4 × 1010 0.0 0.3
Disk 9.0 × 1010 3.3 0.3
Halo 7.0 × 1011 0.0 25.0






Tabelle 8: Kreisbahngeschwindigkeiten bei z = 0 an verschiendenen Galaktozentrischen Radien für das 3PLK-Modell mit den Parametern aus Tabelle 7. Die astronomischen Konstanten sind Binney & Tremaine (2008, Anhang A) entnommen. / Circular velocities at different galactocentric radii (at z = 0) for the 3PLK model with the parameters of table 7. The astronomical constants are taken from Binney & Tremaine (2008, appendix A).





Rg [kpc] V cir [km s-1] Rg [kpc] V cir [km s-1]




0.5279.269858420500 10.5 231.472619038406
1.0 246.015548276821 11.0 231.416801583084
1.5 230.132164798490 11.5 231.499317939399
2.0 228.141259503200 12.0 231.704811326295
2.5 231.286020479153 12.5 232.017589382089
3.0 235.208140475138 13.0 232.422164626838
3.5 238.261145511816 13.5 232.903626883944
4.0 240.070687448505 14.0 233.447890039686
4.5 240.763498292986 14.5 234.041845222914
5.0 240.613878677284 15.0 234.673444774045
5.5 239.899715058196 15.5 235.331735556181
6.0 238.853489734555 16.0 236.006855744588
6.5 237.652904859520 16.5 236.690005856049
7.0 236.426154512127 17.0 237.373402187912
7.5 235.261261678691 17.5 238.050218839306
8.0 234.215362687272 18.0 238.714522944716
8.5 233.322594742001 18.5 239.361206558702
9.0 232.600357491854 19.0 239.985917711179
9.5 232.054117466732 19.5 240.584992445018
10.0 231.681026811365 20.0 241.155389105121





The parameters of the 3-component Plummer-Kuzmin model (Miyamoto & Nagai1975) of the Milky Way are given in table 7.1 The total gravitational potential is given by a a superposition of three potentials for bulge, disk and halo. The circular velocity as a function of galactocentric radius is given in table 8. The gravitational potential has the form

Φ(x,y,z) = ∘---------GM-----------.
            x2 + y2 + (a + √b2 +-z2)2
(2.167)

The acceleration for the Plummer-Kuzmin model is given by the expression

(    )     (      )                               (     x     )
( ax )     (dΦ ∕dx)    ----------- GM------------ (     y     )
  ay   = -   dΦ∕dy  =  [2    2      √ 2---2-2]3∕2 ⋅    a+√b2+z2
  az         dΦ∕dz     x  + y + (a+   b + z)        z ⋅ √b2+z2
(2.168)

The jerk is given by the lengthy expressions

          {   [             (         ) ]    [        (    √------)2]}
dax   GM---3x--xvx +-yvy +-zvz-√b2a+z2-+1----vx-x2 +-y2 +-a-+-b2 +-z2---
 dt =                    [        (    √------)2]5∕2
                          x2 + y2 + a + b2 + z2
(2.169)

          {   [             (         )]     [        (   √ ------) ]}
da    GM   3y  xvx + yvy + zvz √-2a-2-+1 - vy x2 + y2 + a + b2 + z2 2
--y = -------------------[-----b+z(----√------)-]5∕2-------------------
 dt                       x2 + y2 + a + b2 + z2 2
(2.170)

         {
daz          a+ √b2-+-z2[              (    a      ) ]
dt-= GM    3z--√-2---2-- xvx + yvy + zvz √-2---2-+1
         [      b + z            ]  [ (   b√-+-z--)               ]}
           2    2  (   ∘ -2---2)2     -a+--b2-+z2--   2----a-----
      - vz x + y +  a+   b + z    ×     √b2-+-z2   - z (b2 +z2)3∕2   /
     [                       ]5∕2
      x2 + y2 + (a +∘b2-+-z2)2                                         (2.171)

which also depend on the velocity components. A few orbits are plotted in Figures 10 and 11.

2.2.2 JSH95 Milky Way model

The gravitational potential of the JSH95 model of the Milky Way (see Johnston, Spergel & Hernquist1995Dinescu, Girard & van Altena1999) is given by

                                              (      )
        GMb--  ----------GMd------------   2       r2
Φ(r) = - r+ c - ∘-2---2-------∘--2---22-+ v0ln 1 + d2
                 x + y + (ad +  z + bd)
(2.172)

with Mb = 3.4 × 1010M, c = 0.7 kpc, Md = 1011M, ad = 6.5 kpc, bd = 0.26 kpc, v0 = 128 km s-1, d = 12.0 kpc. The bulge has a Hernquist profile, the disk is represented as a Plummer-Kuzmin model and the halo by a logarithmic potential.

The acceleration for the JSH95 model is given by the expression

(   )              (  )                                 (     x     )
( ax)     --GMb--- ( x)    -----------GMd-------------- (     y     )
  ay  = - r(r+ c)2 ⋅ y   - ( 2   2       ∘ -2---2 2)3∕2 ⋅    a+√b2+z2
  az                 z      x + y + (ad +  bd + z )       z ⋅ √b2+z2
            2          ( x)
        - 2v0----1--- ⋅( y)                                             (2.173)
           d21 + r2∕d2    z
2.2.3 P90 Milky Way model

The gravitational potential of the P90 model of the Milky Way (see Pacyński1990Dinescu, Girard & van Altena1999) is given by

                  GMb                         GMd
Φ(r) = - ∘-------------∘---------- ∘---------------∘--------
          x2 + y2 + (ab + z2 + b2b)2  x2 +y2 + (ad +   z2 + b2d)2
        GMh  [1   (   r2)   d       r]
      + --d-- 2 ln  1+ d2  - r arctan d                              (2.174)

with Mb = 1.12 × 1010M, ab = 0.0 kpc, bb = 0.277 kpc, Md = 8.0710M, ad = 3.7 kpc, bd = 0.20 kpc, Mh = 5 × 1010M, d = 6.0 kpc.

The acceleration for the P90 model is given by the expression

(   )                                  (      x     )
( ax)     -----------GMb-------------- |      y     |
  ay  = - ( 2   2       ∘ -2---2 2)3∕2 ⋅(   ab+√b2b+z2)
  az       x + y  +(ab +  bb + z )       z ⋅ √b2b+z2
                                       (      x     )
                     GMd               |      y     |
        - (-------------∘---------)3∕2-⋅(   ad+√b2d+z2)
           x2 + y2 +(ad + b2d + z2)2      z ⋅-√b2d+z2-
               (                      ) (   )
          GMh-- --d2 --r2-  -d      -r  ( x )
        -   d   r2(d2 + r2) - r3 arctand ⋅ y                     (2.175)
                                          z
2.2.4 Zotos’ barred spiral galaxy model


PIC

Abbildung 12: The effective potential of a barred spiral galaxy from Eqn. (2.176) in 2D. The contours are the isolines of constant effective potential. The positions of the Lagrangian equilibrium points L1 - L5 are marked with blue dots. Plotting language: IDL.



PIC

Abbildung 13: Forming spiral arms of a grand-design spiral in the effective potential in Eqn. (2.176). The density of points along one orbit is taken to be proportional to the velocity as described in Ernst & Peters (2014). Plotting language: GNUPLOT. Post-processed with GIMP.



PIC

Abbildung 14: Fully-fledged spiral arms in the effective potential in Eqn. (2.176). The density of points along one orbit is taken to be proportional to the velocity as described in Ernst & Peters (2014). Plotting language: GNUPLOT. Post-processed with GIMP.


The simple 2D effective potential of a barred spiral galaxy according to Zotos (2012), which is visualised in Figure 12, is given by the terms

                  Md              Mb
Φeff(x,y) = - ∘-2---2----2 - ∘-2---2-2---2
               x + y + α     2x  +b y + cb
           - ∘----Mn------+ v0ln(x2 +βy2 + c2)
               x2 + y2 + c2n 2               h
             1  2 2   2
           - 2Ω b(x  +y )                                    (2.176)

with the parameters α = 8, β = 1.3, b = 2, v0 = 15, Md = 9500, Mb = 3000, Mn = 400, cb = 1.5, cn = 0.25 and ch = 8.5. We have Ωb = 1.25. The model consists of a logarithmic halo, a disc, a Plummer nucleus (bulge) and a bar. The potential rotates clockwise at constant angular velocity Ωb. The effective potential in Eqn. (2.176) is the cut through the equatorial plane of a typical 3D potential of a barred spiral galaxy. We remark that for a axisymmetric halo the parameter β should be set to β = 1.

In Eqn. (2.176), the model units of length L0, velocity V 0, angular velocity Ω0, time T0 and mass M0 of the parameters, in which the gravitational constant G = 1, can be scaled to physical units of a realistic barred spiral galaxy as NGC 1300:

L0 = 1 kpc,        M0  ≈ 2.223× 107 M⊙,                  (2.177)
Ω0 = 10 km ∕s∕kpc,   V0 = 10 km∕s,                       (2.178)
    ∘ ---------
T0 =  L30∕(GM0 ) ≈ 100 Myr.                              (2.179)

The equations of motion in the rotating frame are given by

¨r = - ∇ Φ- 2 (Ωb × ˙r)- Ωb × (Ωb × r)
(2.180)

where r = (x,y,z) is the position vector, the dot denotes a derivative with respect to time and Φ is given by the first four terms in Eqn. (2.176). The Jacobi energy is an integral of motion and given by

eJ = 1˙r2 + Φeff
     2
(2.181)

A critical Jacobi energy is given by the value of the effective potential Φeff at the position of the two saddle points in Figure 12. Figures 13 and 14 illustrate fully-fledged spiral arms, which have been formed in the potential of Eqn. (2.176), as described in Ernst & Peters (2014). The spiral arms form out of escaping particles with overcritical Jacobi energies.

The density of points along one orbit in figures 13 and 14 is taken to be proportional to the velocity of a particle. This method can be called the “velocity-dependent plotting technique”. The spiral galaxies in this theory display spiral patterns which are persistent in time, in contrast to the transient spiral patterns in the old density wave theory (e.g. Pasha2004a,b). The winding problem in differentially rotating disks does not occur (“Weizsäcker’s cow”). Also, a large number of different galaxy morphologies can be reproduced in this theory.

2.3 Tasks

1.
Write an orbit integration program for the integration of orbits of a point mass in the gravitational potentials which have been presented in this chapter with one of the integrators which have been described in the previous chapter. The system of first-order differential equations to be integrated is given by

˙x = v
˙v = a

where x, v and a are position, velocity and acceleration of the point mass.

  • According to the interest of the reader, a composition scheme, a Hermite scheme or a Runge-Kutta scheme is recommended for this purpose.
  • Adaptive times steps may be implemented later after a corresponding modification of the program.
2.
Calculate analytical expressions for the physical quantities M(r)(r),vc(r)(r),... for some models..
3.
Calculate the rotation curve of the 3PLK model.
4.
Calculate the jerk for the JSH95 and the P90 model.
5.
Calculate spiral arms in the effective potential 2.176 according to the method described in Ernst & Peters (2014), i.e. by making use of the velocity-dependent plotting technique.

3 Linear stability analysis

3.1 Introduction to linear stability analysis

The linear stability analysis of equilibria is an important part of nonlinear dynamics. For this purpose one linearizes the dynamics around the equilibrium and considers the dynamics in this linearized theory, which is simpler than the full nonlinear theory. Methods of linear algebra are used. A German reference for linear algebra are the two books by Lorenz (1992a,b). In particular, the eigenvalue problem for the Jacobi matrix must be solved.

One-dimensional systems: Let

x    = f(x )
 n+1      n
(3.182)

be a one-dimensional (1D) map. The Jacobi matrix consists of only one element,

J = f′(xn) = ∂f-.
            ∂xn
(3.183)

If the modulus of the derivative, is smaller than one (larger than one) the corresponding fixed point is stable (unstable). If it is equal to one, we speak of a marginally stable fixed point.

Two-dimensional systems: Let, in a two-dimensional (2D) system,

x˙= f(x,y)                                (3.184)
 ˙y = g(x,y)                               (3.185)

                                          (3.186)

The Jacobi matrix is given by

    (            )
J =  ∂f ∕∂x ∂f ∕∂y
     ∂g∕∂x ∂g∕∂y
(3.187)

We can classify equilibrium points in two dimensions (2D) as follows (e. g. Izhikevich2007):

  • Node: Both eigenvalues are real and have the same sign. The node is stable (unstable) when all eigenvalues are negative (positive).
  • Saddle: Both eigenvalues are real and of opposite sign.
  • Focus (or “spiral point”): The two eigenvalues are complex-conjugate. The focus is stable (unstable) when the eigenvalues have negative (positive) real parts.

Three-dimensional systems: Let, in a three-dimensional (3D) system,

˙x = f(x,y,z)                              (3.188)
˙y = g(x,y,z)                              (3.189)
˙z = h(x,y,z)                              (3.190)

The Jacobi matrix is given by

   (                   )
     ∂f ∕∂x ∂f ∕∂y ∂f∕∂z
J = ( ∂g ∕∂x ∂g ∕∂y ∂g∕∂z )
     ∂h ∕∂x ∂h ∕∂y ∂h∕∂z
(3.191)

We can classify equilibrium points in three dimensions (3D) as follows (e. g. Izhikevich2007):

  • Node: All eigenvalues are real and have the same sign. The node is stable (unstable) when all eigenvalues are negative (positive).
  • Saddle: All eigenvalues are real and at least one differs in sign from the others.
  • Focus-Node: The point has one real eigenvalue and one pair of complex-conjugate eigenvalues, and all eigenvalues have real parts of the same sign. The equilibrium is stable (unstable) when the sign is negative (positive).
  • Saddle-Focus: The point has one real eigenvalue and one pair of complex-conjugate eigenvalues, and the real eigenvalue differs in sign from the real parts of the complex-conjugate ones.

3.2 Logistic Map (1D)


PIC

Abbildung 15: Feigenbaum diagram for the logistic map. Plotting language: GNUPLOT.



1//-------------------------------------------------------------- 
2// feigenbaum.C 
3// Code: Calculates Feigenbaum diagram for logistic map 
4// Author: Andreas Ernst 
5// Date: August 8, 2006 
6//-------------------------------------------------------------- 
7 
8#include  <iostream> 
9#include  <cmath> 
10#include  <cstdlib> 
11 
12using namespace std; 
13 
14int main() { 
15 
16  double h = 0.001, h0=0.001; 
17  double x; 
18  int niter = 1000; 
19 
20  for (double lambda=0.25; lambda<=3; lambda+=h) { 
21    for (double x0=h0; x0<=1; x0+=h0) { 
22      x = x0; 
23      for (int n=1; n<=niter; n++) { 
24        x = 4*lambda*x*(1-x); 
25        if (n==niter) cout << lambda << "␣␣␣" << x << endl; 
26      } 
27    } 
28  } 
29  return 0; 
30
31//--------------------------------------------------------------
Listing 3: C++ code feigenbaum.C for the Feigenbaum diagram


History: Historically, the non-linear logistic equation

    dn
n′ =---= 4λn(1- n),
    dτ
(3.192)

here with a free parameter λ, was introduced by Pierre-François Verhulst for studying population dynamics (Verhulst1838). The solutions for n(τ) < 1 are characteristic S-shaped curves, so-called sigmoid functions.

Logistische Abbildung: The associated discrete logistic map is given by

xn+1 = f(xn) = 4λxn (1 - xn)
(3.193)

with a free parameter λ. A plot of xn vs. λ for a large n yields the so-called Feigenbaum diagram shown in Figure 15. By increasing λ, it can be seen that at the period doubling bifurcations the fixed point(s) get(s) unstable. This is the “route into chaos”.

Linear stability analysis: The Jacobi matrix element is given by

J  = f′(x ) = 4λ(1 - 2x )
 00      n            n
(3.194)

For a fixed point we have the condition

xn+1 = xn = 4λxn(1- xn)
(3.195)

We obtain two solutions,

                   -1-
xn,1 = 0, xn,2 = 1- 4λ
(3.196)

We find

  • J00(xn,1) = 4λ. xn,1 is stable for 0 < λ < 0.25.
  • J00(xn,2) = 2 - 4λ. For 0.25 < λ < 0.75 xn,1 is unstable and xn,2 is stable.
  • For λ > 0.75 both xn,1 and xn,2 are unstable and we obtain a series which oscillates between two (and later more) fixed points xn,3 = f(xn,4) and xn,4 = f(xn,3) as can be seen in Figure 15. This is called a 2-periodic or period-2 orbit. For the period-2 orbit we have the condition xn+2 = xn in Eqn. (3.193).

3.3 Hénon-Heiles system (2D)


PIC

Abbildung 16: Equipotential lines for the Hénon-Heiles potential. The equilibrium points are marked with blue dots. Plotting language: GNUPLOT.



PIC PIC

Abbildung 17: Poincaré surfaces of section in the Hénon-Heiles potential with x = 0 and vx 0. Top panel: At E = 0.02. We see only periodic and quasiperiodic orbits. Bottom panel: At E = 0.125. We see a mixture of periodic, quasiperiodic and chaotic orbits. Plotting language: GNUPLOT.


History: Historically, the Hénon-Heiles system was the first system for which the existence of a so-called adelphic or non-classical integral of motion was demonstrated numerically. Figure 16 shows that the potential is not axisymmetric but has only a triangular symmetry according to the dihedral group D3 (Cushman2005). Hence the z-component of angular momentum is only approximately conserved. The energy is conserved exactly since the Hénon-Heiles system is a Hamiltonian system. The adelphic integral of the Henon-Heiles system can be represented as a power series, whose lowest order is the z-component of angular momentum (Finkler, Jones & Sowell1990).

The Hénon-Heiles potential (Hénon & Heiles1964) is given by

        1                1
Φ(x,y) =-(x2 +y2)+ x2y - -y3;
        2                3
(3.197)

Figure 16 shows the equipotential lines. The potential has a minimum H1 and three saddle points H2, H3 and H4.

Equations of motion: The equations of motion are

x˙= vx,                                      (3.198)
 ˙y = vy,                                     (3.199)
x¨= - x- 2xy,                                (3.200)
 ¨y = - y- x2 + y2.                           (3.201)

Figure 17 shows two Poincaré surfaces of section at two different energies. In the top panel of Figure 17 all orbits are quasiperiodic or periodic. In the bottom panel of Figure 17 there are large dotted chaotic regions in which smaller quasiperiodic islands are embedded.

Integrals of motion: The integrals of motion are

E =  1v2+ 1v2 + Φ(x,y),       (Energie ∕ energy)                          (3.202)
     2 x  2 y
I3 = xvy - yvx - x2vx + y2vx + 2xyvy - 2v3+ 2vxv2+ O (x4,y4,v4,v4,xyvxvy,...), (3.203)
                                   3 x      y           x y

where I3 is the adelphic integral to third order (Finkler, Jones & Sowell1990).

Linear stability analysis: Equilibrium points are determined via

(  )   (        )   [             ]   (  )
  ¨x  =   - ∂Φ ∕∂x =    - x2 (1 + 2y)  =  0
  ¨y      - ∂Φ ∕∂y    - x - y(1- y)     0
(3.204)

The solutions are

                               √ -                  √-
H1 = (0,0),  H2 = (0,1),  H3 = (-  3∕2,- 1∕2), H4 = (+ 3∕2,- 1∕2)
(3.205)

The central potential is Φ(H1) = 0. The potential at the saddle points is Ecrit = Φ(H2) = Φ(H3) = Φ(H4) = 16. For energies E > Ecrit particles can escape from the central region of the potential.

We proceed with a linear stability analysis. The Jacobi matrix is given by

      (                  )
           0      0    1 0
J   = ||    0      0    0 1||                        (3.206)
 mn   ( - 1 - 2y - 2x  0 0)
          - 2x - 1+ 2y 0 0

We consider the 2 × 2 submatrix of J,

     (               )
Jk′l =  - 1 - 2y - 2x                             (3.207)
         - 2x - 1+ 2y

The characteristic polynomial is given by

det(J′ - λ1) = λ2 + 2λ+ 1 - 4(x2 +y2) = 0
(3.208)

The general solutions are given by

            ∘ -------
λ1,2 = - 1± 2 x2 + y2
(3.209)

We find:

1.
The eigenvalue at H1 is λ1 = λ2 = -1. It is two-fold degenerate, real and negative. Therefore H1 is a stable equilibrium point.
2.
The eigenvalues at H2 are λ1 = -3 and λ2 = 1. Therefore H2 is a saddle point.
3.
The eigenvalues at H3 are λ1 = -3 and λ2 = 1. Therefore H3 is a saddle point.
4.
The eigenvalues at H4 are λ1 = -3 and λ2 = 1. Therefore H3 is a saddle point.

Computation of Poincaré surfaces of section:

The Poincaré surfaces of section, as shown in Figure 17, are 2D cuts through the 4D phase space. For example, for an y - vy surface of section we take an initial condition y = y0,vy = vy,0,x = x0 = 0 and calculate vx from vx = ∘ ------------------
  2E - v2y - 2Φ(x0,y0), where E is the total energy, Φ is the potential and vx is chosen to be always, say, the positive root. Then we integrate the initial condition forwards in time and plot a dot at each consequent (=“piercing point through the surface of section”) with x = 0 when vx 0.

Interpretation of Poincaré surfaces of section:

Dotted regions mark chaotic regions in the phase space, the “chaotic sea”. Embedded are usually regular islands of invariant curves, which are formed by quasiperiodic orbits. Quasiperiodic orbits respect, besides the energy, another integral of motion, for example the z-component of angular momentum or, as is the case for the Hénon-Heiles system, an adelphic integral of motion. In the center of each island lies a stable fixed point, which corresponds to a stable periodic orbit of period n. Between the islands one can sometimes find hyperbolic fixed points, which belong to unstable periodic orbits. As is well-known (Contopoulos2002), these are a source of chaotic dynamics. One may also read the famous mathematical paper by Li & Yorke (1975), Period three implies chaos.

Algorithm for finding periodic orbits on a Poincaré surface of section:

In this connection, we remark that the periodic orbits, shown as colored dots on the title page of this book, can be found with a self-written program as follows: Let r0 be the approximate phase space diameter of the Poincaré surface of section. We define an n-periodic orbit as a periodic orbit of period n.

1.
Calculate for an n-periodic orbit the nth consequent (“= piercing point through the surface of section”) of an orbit for an initial condition in the quasiperiodic island on the Poincaré surface of section close to the periodic orbit and measure the distance Δr0∕r0 of the nth consequent from the initial condition.
2.
Calculate the nth consequents of four neighbouring orbits in the directions north, south, east, west, which are located at a distance 0 < Δr∕r0 1 away from the original orbit and measure for an n-periodic orbit the distances Δri∕r0, i = 1,...,4, of the nth consequents with the corresponding initial condition.
3.
Go one step of size 0 < Δr∕r0 1 in the direction, which belongs to the smallest of the four distances if minri∕r0) < Δr0∕r0. If the latter condition is not fulfilled the periodic orbit has be found to an accuracy of order Or∕r0).
4.
Decrease Δr∕r0 by a suitable factor.
5.
Repeat the procedure from 1. until the n-periodic orbit has been found to a reasonable accuracy.

3.4 Lotka-Volterra system (2D)

Population dynamics: Assume a system, in which two species interact, the predator and the prey populations. In the field of astrophysics at the university, the predator species might be the astrophysicists and the prey “species” the public funds (not: third-party funds). The theory of such a system is well-known and can near the fixed points be described by a system of coupled differential equations, the Lotka-Volterra equations,

 ˙
N1 = N1(γ - αN2)                             (3.210)
N˙2 = N2(βN1 - δ)                             (3.211)

where the variables are defined as follows:

  • N1: the number of astrophysicists,
  • N2: the amount of public money for astrophysics,
  • α > 0: the constant decreasing rate of the number of astrophysicists per unit of public money,
  • β > 0: the constant growth rate of the amount of public money per astrophysicist,
  • γ > 0: the constant growth rate of the number of astrophysicists in the limit N2 = 0,
  • δ > 0: the reduction rate of the amount of public money in the limit that N1 = 0,


PIC
PIC

Abbildung 18: Top panel: Phase portrait for Eqns. (3.215) and (3.216) for λ = 0.5. A marginally stable fixed point at (n1,n2) = (1,1) can be seen. n1 and n2 have upper and lower limits. Bottom panel: Phase portrait for Eqns. (3.215) and (3.216) for λ = -0.5. The fixed point at (n1,n2) = (1,1) is unstable and n1 and/or n2 die out or grow infinitely in number. The position of the fixed point is marked with a blue dot in both panels. Plotting language: GNUPLOT.



PIC

Abbildung 19: Example of a solution of the system of Eqns. (3.215) and (3.216) for λ = n1(0) = n2(0) = 0.5. Plotting language: GNUPLOT.


Dimensionless formulation: We may introduce scaled variables (e. g. Kühn & Spurzem2005),

n1 = (β∕δ)N1,  n2 = (α∕γ)N2,   τ = γt,   λ = δ∕γ              (3.212)

to arrive at the dimensionless formulation

dn1
-dτ = n1(1- n2),                             (3.213)
dn2
-dτ = λn2(n1 - 1)                            (3.214)

with only one free parameter λ. In logarithmic notation, Eqns. (3.213) and (3.214) can be written more concisely as

d-lnn1-= 1 - n ,                              (3.215)
  dτ         2
d-lnn2-= λ(n  - 1)                            (3.216)
  dτ       1

Solutions: Figure (18) shows phase portraits for the Eqns. (3.213) - (3.214). These are similar to the Poincaré surfaces of section except for the fact that the solutions of the Eqns. (3.213) - (3.214) are all regular (non-chaotic), such that the phase can be identified easily. One solution is shown in Figure 19 for λ = 0.5.

Linear stability analysis: For stationary solutions we set the left-hand sides of Eqns. (3.213) and (3.214) to zero,

 n1(1 - n2) = 0                             (3.217)
λn2(n1 - 1) = 0                              (3.218)

The solutions for arbitrary λ are

E0 = (0,0), E1 = (1,1)
(3.219)

For λ = 0 other solutions exist.

We proceed with a linear stability analysis. For that purpose we consider the Jacobi matrix

      [1 - n   - n   ]
Jmn =   λn  2λ(n -11)
           2    1
(3.220)

with m = 1,2 and n = 1,2. The eigenvalues are given by the zeros of the characteristic polynomial, i.e.

              2
det(J - λ1) = λ - λ[λ(n1 - 1)- (n2 - 1)]+λ (n1 + n2 - 1) = 0
(3.221)

The general solutions are given by

                             ∘ ------------------2---------------
λ1,2 = - 1[λ(n1 - 1)- (n2 - 1)]± [λ-(n1---1)--(n2---1)]-- λ(n1 + n2 - 1)
       2                                4
(3.222)

The stability of the fixed point E1 can be seen as follows:

At E1 the solutions are

          √ ---    √ --
λ1,2(E1 ) = ± - λ = ±i λ.
(3.223)

We have Re[λ1,2(E1)] = 0 for λ > 0 and and therefore E1 is a marginally stable fixed point for this parameter range. The normalized eigenvector basis at E1 is given by

                      (  )                          (  )
                        0                            1
^e1 = J1n(E1)∕|J1n(E1)| = 1  ,  ^e2 = J2n(E1 )∕|J2n(E1)| = 0
(3.224)

The top panel of Figure 18 shows that for λ = 0.5 these eigenvectors point indeed in the right direction at E1, i.e. that they are parallel to the n1 and n2 axes, respectively.

3.5 Lorenz attractor (3D)


PIC PIC

Abbildung 20: Top panel: The Lorenz attractor for σ = 10,b = 83,r = 28. Bottom panel: The Rössler attractor for a = 0.15,b = 0.20,c = 10. Plotting language: R.


History: Edward N. Lorenz was a meteorologist working on the theory of the weather. “He reduced the Navier-Stokes equations in the Boussinesq approximation for a plane, from below heated fluid model [...] to a system of three ordinary nonlinear differential equations, which governs the temporal evolution of three fundamental modes, a velocity and two temperature distributions” (Argyris, Faust & Haase1995).

Equations of motion: The system of equations of motion for the Lorenz attractor (Lorenz1963) are given by

x˙= - σ(x - y)                               (3.225)
y˙= rx- y - xz                              (3.226)
z˙= xy - bz                                 (3.227)

Solution: They describe a so-called “strange attractor” (Ruelle & Takens1971), which is shown in the upper panel of Figure 20. A possible choice of the parameters is σ = 10, b = 83, r = 28.

Linear stability analysis: The Jacobi matrix is given by

      (            )
         - σ  σ  0
Jmn = ( r - z - 1 - x)                          (3.228)
          y   x - b

The fixed points are for b = 0 given by

                    (  ∘-------  ∘ -------     )
L1 = (0,0,0),  L2∕3 = ±  b(r- 1),±  b(r- 1),r- 1
(3.229)

The Jacobi matrix at L1 is given by (cf. Argyris, Faust & Haase1995)

      (          )
        - σ σ  0
JLm1n = (  r - 1 0 )                             (3.230)
         0  0 - b

The eigenvalues of JL1 are given by

       σ-+-1  ∘ ------2----------
λ1∕2 = -  2  ±   (σ+ 1) + 4σ(r- 1),  λ3 = - b
(3.231)

We find that

  • For 0 < r < 1 all three eigenvalues are negative. L1 is a stable node.
  • For r = 1 we find λ1 = 02 = -(σ + 1) < 03 = -b < 0. L1 is a marginally stable node.
  • For r > 1 we find λ1 > 02 < 03 < 0. L1 is a saddle point.

3.6 Rössler attractor (3D)

History: Otto E. Rössler searched for a simpler “strange Attractor” than the Lorenz attractor. He found one. Equations of motion: The system of equations of motion for the Rössler attractor (Rössler1976) are given by

x˙= - (y + z)                               (3.232)

y˙= x +ay                                   (3.233)
z˙= b+ z(x- c)                              (3.234)

Solution: The lower panel of Figure 20 shows the Rössler attractor. A possible choice of the parameters is a = 0.15, b = 0.20, c = 10.

Linear stability analysis: The Jacobi matrix is given by

      (          )
      ( 0 - 1 - 1 )
Jmn =   1 a   0                                (3.235)
        z 0  x- c

The fixed points are for a = 0 given by

                   (   c  c)
R1 = (0,0,0),  R2 =  c,- a, a-
(3.236)

The Jacobi matrix at R1 is given by

      ( 0 - 1 - 1)
JR1 = ( 1 a  0 )                              (3.237)
 mn     0 0  - c

The characteristic polynomial at R1 is given by

    R1          2
det(J   - λ1) = (λ - aλ + 1)(- c- λ) = 0
(3.238)

The eigenvalues of JR1 are given by

         ∘ ------
      a     a2
λ1∕2 = 2-±   4-- 1,  λ3 = - c
(3.239)

We find that

  • For 0 < a < 2 λ1 and λ2 are complex-conjugate with Re(λ1) = Re(λ2) > 0 and λ3 = -c < 0 is real. R1 is an unstable spiral point in the e1∕e2 plane and stable in the direction of e3, where ei is the eigenvector corresponding to λi. Such a point is called a “saddle-focus”.
  • For a = 2 we find λ1 = λ2 = a∕2 > 03 = -c < 0. R1 is unstable in the e1∕e2 direction and stable in the e3 direction.
  • For a > 2 we find λ1 < 02 < 03 < 0. R1 is a stable node.

3.7 Tasks

1.
Calculate the solutions for the condition xn+2 = xn in Eqn. (3.193) for the period-2 orbit.
2.
Calculate the time derivative of I3 in Eqn. (3.203).
3.
Calculate a few Poincaré surfaces of section at different energies for the Hénon-Heiles system.
4.
Calculate a movie out of 400-1500 Poincaré surfaces of section at different energies, where the energy is continuously changed.
5.
Solve the equations of motion for the Lorenz attractor (3.225) - (3.227) and the Rössler attractor (3.232) - (3.234) numerically.
6.
Investigate their properties (Jacobi matrix, fixed points, their stability etc.).
7.
Is this possible? Find your own equations of motion which admit an attractor solution like the Lorenz or Rössler attractor.

4 Integrating the stellar initial mass function


PIC

Abbildung 21: The Kroupa (2002) initial mass function, a segmented power law. Plotting language: GNUPLOT.


More information can be found in the book “An introduction to the Theory of Stellar Structure and Evolution” by D. Prialnik (Prialnik2000). According to Salpeter (1955), the initial mass function ξ(m) (IMF) is defined as the number of stars per unit logarithmic mass interval, or, equivalently, as “the amount of mass in stars with masses in the interval [m,m + dm] formed at a given time in a given volume of space”,

         dN     mdN
ξ(m ) =------ ∝ -----∝ m Γ
       dlogm     dm
(4.240)

where m = M∕M is the mass in solar mass units and the IMF is assumed to be a simple power law. Salpeter found a single power law index of

     dlog ξ
Γ = ------ = - 1.35
    d logm
(4.241)

for stars in the solar neighborhood. However, the lower and upper bounds of stellar masses dictated by the laws of stellar structure and evolution imply that the Salpeter IMF is not scale free as the power law (4.240) with the exponent (4.241) suggests.

One may as well define a function ϕ(m), which is sometimes called the “stellar birth function”, as the number of stars per unit mass interval, or, equivalently, the number of stars with masses in the range [m,m + dm] formed at a given time in a given volume of space,

       dN    1
ϕ(m ) =--- = --ξ(m ) ∝ m Γ -1
       dm    m
(4.242)

Kroupa, Tout & Gilmore (1993) found the following double-logarithmic slopes of the IMF (4.240):

    (
    { - 0.3   0.08 ≤ m < 0.5
Γ = ( - 1.2    0.5 ≤ m < 1.0
      - 1.7    1.0 ≤ m < ∞
(4.243)

where the most drastic change in the power law index at 0.5 M may indicate the existence of a characteristic mass scale in the star formation process, as Kroupa et al. notice. However, the IMF given by (4.243) is a relation which has been found empirically for stars in the solar neighborhood. The slope for the higher-mass stars (above one solar mass including the whole upper main sequence), is slightly higher than the Salpeter slope (4.241).

In Kroupa (2002), the IMF is extended to the very low mass regime:

       (| 2.01587m -0.3 = ϕ    0.01 ≤ m < 0.08
       |{ 0.16127m -1.3 = ϕ 1  0.08 ≤ m < 0.5
ϕ(m) = | 0.08063m -2.3 = ϕ 2  0.5 ≤ m < 1.0
       |( 0.08063m -2.7 = ϕ 3  1.0 ≤ m < 120.0
                        4
(4.244)

The 4 constants in (4.244) are obtained by solving the system of 4 linear equations,

    ∫
      120.0
N =  0.01  dm ϕ(m ) = 1,                                        (4.245)

ϕ1(0.08) = ϕ2(0.08),  ϕ2(0.5) = ϕ3(0.5),    ϕ3(1.0) = ϕ4(1.0).        (4.246)

4.1 Integral solving

To obtain the result in Eqn. (4.245) we need to evaluate the corresponding integral. This can be done analytically for the case of the Kroupa (2002) IMF in Eqn. (4.244) or numerically. For the numerical computation, there are three main approaches:

4.1.1 Solving a differential equation

We may solve the corresponding differential equation (see e. g. Press et al.1986),

-dy
dm  = ϕ(m)
(4.247)

for N = y(120.0) with the boundary condition y(0.01) = 0. For this purpose, we may use an appropriate integrator, e. g. a Runge-Kutta method.

4.1.2 Using geometrical rules

We may use geometrical rules such as the trapezoidal rule (see e. g. Press et al.1986):

    120.0∕h
     ∑                     h-
N ≈      [ϕ(m) +ϕ (m + h)]× 2
    0.01∕h
(4.248)

with the step size 0 < h 1. Higher-order geometrical rules are the Simpson’s rule, Simpsons 38 rule or Bode’s rule (see e. g. Press et al.1986).

4.1.3 Monte-Carlo integration

We need a suitable majorizing function Φ(m) of the function ϕ(m) with ϕ(m) < Φ(m) in the whole integration interval, whose integral is known. Now we “sprinkle” the area in the integration range below the majorizing function with random points. The knowledge of the ratio of the number of points below the function ϕ(m) and the number of points below the majorizing function Φ(m) allows the determination of the integral. We note that majorizing integrability is connected to the mathematical possibility to exchange integration and limiting procedure.

4.2 Tasks

1.
Find out whether the coefficients (0.035, 0.019 and 0.019) in Equation (13) of Kroupa, Tout & Gilmore (1993) are correct.
2.
Find the mean stellar mass for the Kroupa (2002) IMF numerically and compare with the analytical result.
3.
Derive the local error for the trapezoidal rule in Eqn. (4.248).
4.
Derive the 1σ,2σ and 3σ confidence levels by numerical integration over a normal (Gaussian) distribution using the trapezoidal rule.

5 Astrophysical Poisson equations

This chapter is based on lectures and exercises by Prof. W. M. Tscharnuter at the University of Heidelberg. The theory of the Lane-Emden equation can be found in the book “Galactic dynamics” of J. Binney and S. Tremaine (Binney & Tremaine19872008).

5.1 Lane-Emden equation


PIC

Abbildung 22: Solutions of the Lane-Emden equation. Plotting language: GNUPLOT.


The polytropic equation of state is

       1+1∕n
P = K ρ
(5.249)

where K is the polytropic constant, n is the polytropic index and P and ρ are pressure and density, respectively. An integration of the equation of hydrostatic equilibrium

dP-     dΦ-
dr = - ρdr
(5.250)

where Φ is the gravitational potential, leads to

   [     Φ    ]n
ρ = - (n-+1)K-
(5.251)

The Poisson equation reads then

     (     )       [         ]
-1-d   2dΦ-          ----Φ--- n
r2dr  r dr   = 4πG  -(n + 1)K    .
(5.252)

Introducing dimensionless quantities s and ψ(s),

ψ(s) =-Φ-,                                     (5.253)
      Φc
   s = (- Φc )(n-1)∕2Ar,                         (5.254)
          4πG
 A2 = [(n+-1)K-]n-,                             (5.255)

we obtain the Lane-Emden equation

1 d (   dψ(s))
s2ds  s2-ds-- = - ψn(s)
(5.256)

which has analytical solutions for n = 0,n = 1 and n = 5. For other values of n, it must be solved numerically using the boundary conditions ψ(z = 0) = 1, which means that the central potential is finite and dψ∕ds|s=0 = 0, which corresponds to a flat core of the stellar polytrope.

To integrate it, we replace it into a system of two first-order differential equations,

 χ = s2dψ,                                (5.257)
       ds
dχ-= - s2ψn.                              (5.258)
ds

The solutions are shown in Figure 22.

5.1.1 Chandrasekhar mass

From (5.251) follows a relation between central potential Φc and central density ρc,

      (      )1∕n
- Φc =  4πGρ2c-    ,
         A
(5.259)

and we have

          1-n  -1∕n
r = (4πG ρc) 2n A   s.
(5.260)

On the other hand, from (5.251) and (5.259) follows

ρ = ρcψn (s)
(5.261)

Solving (5.260) for ρc yields

     [        ]-n-
ρ  =  --4πG--- 1-n ( r)12n-n .
 c    (n+ 1)K       s
(5.262)

We now have for the cumulative mass

       ∫
M  = 4π  R r2ρdr                                              (5.263)
        0
              3-23nn  -3∕n   ∫ s1 2 n
   = 4π(4πG ρc)    A    ρc  0 s ψ (s)ds                        (5.264)
          3-n                   3∕2∫ s1  (     )
   = - 4π ρ2cn-(4πG)3-23nn[(n+-1)K]--    d-  s2dψ- ds            (5.265)
                       (4πG)3∕(2n)  0  ds    ds
          3-n-[(n+ 1)K ]3∕2[  dψ]
   = - 4π ρ2cn --------     s2---  .                           (5.266)
                4πG       ◟--d◝s◜-s1◞
                            -Mn

|In addition to the dimensionless constant Mn = -[s2dψ∕ds]s1, we set another dimensionless constant Rn = s1. These constants can be found by numerically integrating the Lane-Emden equation (5.256). s1 is just the first zero of the Lane-Emden equation, i.e. it corresponds to the stellar radius.

Plugging in (5.262) in (5.266), we obtain after some tedious calculation the important relation

(     )n-1(    )3-n            n
  GM--      -R-     = [(n-+-1)K-]-
  Mn        Rn           4πG
(5.267)

between the polytropic constant K, the radius R and the cumulative mass M. Solving for the polytropic constant K and plugging it in the polytropic equation of state (5.249), we find

            (     )n-1 (   ) 3-n-
    (4πG)1∕n  GM--  n   -R-  n   n+n1
P =   n+ 1    Mn        Rn      ρ   .
(5.268)

For the case n = 3 (relativistic degenerate electron gas), we find for the central pressure

        1∕3G ( M  )2∕3 4∕3
Pc = (4π) -4  M--    ρc
                3
(5.269)

where G is the gravitational constant and the numerical constant M3 2.01824. On the other hand, quantum statistics of a relativistic degenerate electron gas tells us that

        (  )1∕3(     )4∕3
Pc = hc  3-     --ρc-    ,
      8  π      mp μe
(5.270)

where h,c,mp are the Planck constant, the speed of light and the proton mass, respectively, and μe = 2. Equating these two and solving for the mass gives the famous Chandrasekhar mass

    (    )   √ -
      hc- 3∕2--3-M3--
M =   2G     2π m2pμ2e ≈ 1.43M ⊙.
(5.271)

5.1.2 Isothermal case


PIC

Abbildung 23: Regular and singular solutions of the isothermal Lane-Emden equation and Taylor expansion which covers the core of the regular solution. Plotting language: GNUPLOT.



PIC

Abbildung 24: Gravitational potential of the isothermal sphere and limiting cases. Plotting language: GNUPLOT.



PIC

Abbildung 25: Existence of the Jeans mass of an isothermal sphere. The maximum is at θ 14. Plotting language: GNUPLOT.



PIC

Abbildung 26: UV-diagram (“isothermal curl”). Note the similarity with the proboscis of a butterfly which is flying over the meadows in springtime. Plotting language: GNUPLOT.


The corresponding equation for the isothermal sphere is given by

     (       )
12-d  s2dψ(s)  = exp(- ψ).
s ds     ds
(5.272)

Their corresponding system of first-oder differential equations is given by

       dψ
 χ = s2ds,                                  (5.273)
dχ
ds-= s2exp(- ψ).                            (5.274)

Illustrations of the solutions are shown in Figures 23, 24, 25 and 26.

5.2 Tasks

1.
Solve the Lane-Emden equation analytically for the cases n = 0,n = 1 und n = 5.
2.
Solve the Lane-Emden equation numerically for the case n = 72 and plot density, cumulative mass and potential as functions of radius.
3.
Derive Eqn. (5.267).
4.
Calculate the constant M3.

Afterword

The author would like to thank Dr. Thomas Peters for helping out with calculations and Dr. Patrick Glaschke for teaching him the “high art” of theoretical physics. Furthermore, the author would like to thank Prof. Dr. Rainer Spurzem and Prof. Dr. Andreas Just. For the method of writing bilingual scripts the author is grateful to Prof. Dr. em. Franz Wegner at the University of Heidelberg. Last, the author would like to thank Prof. Dr. em. Werner M. Tscharnuter for interesting lectures on celestial mechanics in the winter term 2006/2007 at the University of Heidelberg from which some of the material presented here stems.

The present book would not be without the existence of the stellar dynamics working group at the Astronomisches Rechen-Institut in Heidelberg, Germany, led by Prof. Dr. Rainer Spurzem and Prof. Dr. Andreas Just, their vivid exchange of knowledge with Dr. Sverre Aarseth at the Institute of Astronomy in Cambridge, UK (you may also read the book by Aarseth2003), and the possibility of being involved for years in this interesting field of research, which is beyond the mainstream topics of modern physics. The author hopes, that the tradition of doing N-body calculations at the Astronomisches Rechen-Institut, which once started with Dr. Sebastian von Hoerner (you may also read the article by von Hoerner2001) continues to be pursued in the future.

And your life, dear reader, and mine, how shall they be pursued? I dreamed: ... La vie, la route des routes ... On my balcony grows a tiny beech tree in a blue plastic bucket. Did a bird deposit a beechnut in the bucket for hard times? Or is it going to be a blackberry bush? How is it possible to comprehend this sprouting, growing, blossoming, maturing, reproducing, prospering and lastly dying life in its entirety? I think of Hanna’s words to the Homo Faber: »You do not treat life as a living shape, but as a mere addition, therefore no relation to time, because no relation to death. Life is living shape in time.«

    References

   Aarseth S. J., 1985, in: Brackbill J. U. and Cohen B. I., eds., 1985, Multiple Time Steps, Academic Press, New York, p. 377.

   Aarseth S. J. 1999, PASP, 111, 1333

   Aarseth S. J. 2003, Gravitational N-body simulations – Tools and Algorithms, Cambridge University Press, Cambridge, UK

   Argyris J., Faust G., Haase M., 1995, Die Erforschung des Chaos, Vieweg Verlag, Deutschland

   Binney S., Tremaine S., 1987, Galactic dynamics, Princeton University Press, Princeton, USA

   Binney S., Tremaine S., 2008, Galactic dynamics, second edition, Princeton University Press, Princeton, USA

   Blanchet L., 2006, Living Rev. Relativity, 9, 4

   Broucke C., 2002, AIAA 2002, 4544

   Burrau C., 1913, Numerische Berechnung eines Spezialfalles des Dreikörperproblems, Astron. Nachr. 195, 113

   Chencincer A., Montgomery R., 2000, Annals of Mathematics, 151, 881

   Contopoulos G., 2002, Order and Chaos in Dynamical Astronomy, Springer, Berlin, Heidelberg, Deutschland

   Cushman R., 2005, No Polar Coordinates. Lectures by Richard Cushman., in: Efstathiou K., Sadovskií D., eds., Geometric Mechanics and Symmetry: the Peyresq Lectures, London Mathematical Society Lecture Note Series, No. 306, Cambridge University Press, Cambridge, UK, p. 211

   Dehnen W., 1993, MNRAS, 265, 250

   Dinescu D. I., Girard T. M., van Altena W. F., 1999, AJ, 117, 1792

   Ernst A., 2009, Dissertation, University of Heidelberg, Deutschland, http://www.ub.uni- heidelberg.de/archiv/9375

   Ernst A., 2012, NBODY6TID manual, http://www.simplyintegrate.de

   Ernst A., Peters T., 2014, MNRAS, 443, 2579

   Finkler P., Jones E. C., Sowell G. A., 1990, Phys. Rev. A, 42, 1931

   Gadamer H.-G., 1990, Wahrheit und Methode. Grundzüge einer philosophischen Hermeneutik., 6. Auflage, J. C. B. Mohr (Paul Siebeck), Tübingen, Deutschland

   Gasiorowicz S., 1996, Quantum Physics, second edition, Wiley & Sons

   Glaschke P., 2006, Dissertation, University of Heidelberg, Deutschland, http://www.ub.uni-heidelberg.de/archiv/6553

   Green S. F., Jones M. H., eds., 2003, 2004, An introduction to the sun and stars, The Open University, Cambridge University Press, Cambridge, UK

   Heggie D. C., Mathieu R. D., 1986, in Hut P., McMillan S., eds., LNP 267, The Use of Supercomputers in Stellar Dynamics Standardised Units and Time Scales, Springer Verlag, Berlin, p. 233

   Hempel C. G., 1977, Aspekte wissenschaftlicher Erklärung, de Gruyter, Berlin, New York

   Hénon M., Heiles C., 1964, Astron. J., 69, 73

   Hénon M. 1976, Cel. Mech. Dyn. Astron., 13, 267

   Hernquist L., 1990, Ap. J. 356, 359

   v. Hoerner S., 2001, How it All Started, in: Deiters S., Fuchs B., Just A., Spurzem R., Wielen R., eds., Dynamics of Star Clusters and the Milky Way, ASP Conference Series, Vol. 228

   Eugene M. Izhikevich (2007), Scholarpedia, 2(10):2014 with small changes by the present author

   Jaffe W., 1983, MNRAS, 202, 995

   Johnston K. V., Spergel D. N., Hernquist L., 1995, Ap. J., 451, 598

   Just A., Peñarrubia J. 2005, A&A, 431, 861

   Just A., Khan F. M., Berczik P., Ernst A., Spurzem R., 2011, MNRAS 411, 653

   Kokubo E., Yoshinaga K., Makino J., 1998, MNRAS 297, 1067

   Kühn R., Spurzem R., 2005, Introduction to Computational Physics, Vorlesungsskript, Universität Heidelberg, Deutschland

   Kroupa P., Tout C. A., Gilmore G., 1993, MNRAS, 262, 545

   Kroupa P., 2002,. Science, 295, 82

   Kuypers F., 1997, Klassische Mechanik, 5. Auflage, Wiley-VCH, Weinheim, Deutschland

   Li, T.-Y., Yorke, J. A.,1975, The American Mathematical Monthly, 82, p. 985

   Lorenz E. N., 1963, J. of the athmospheric sciences, 20, 130

   Lorenz F., 1992, Lineare Algebra I, B.I. Wissenschaftsverlag, Mannheim, Leipzig, Wien, Zürich

   Lorenz F., 1992, Lineare Algebra II, B.I. Wissenschaftsverlag, Mannheim, Leipzig, Wien, Zürich

   McLachlan R., 1995, SIAM J. Sci. Comp., 16, 151

   McLachlan R., Quispel R., 2001, Six Lectures on the Geometric Integration of ODEs, in: DeVore R., Iserles A., Süli E., eds., Foundations of Computational Mathematics, Cambridge University Press, Cambridge, UK, p. 155

   Makino J., 1991, Ap. J., 369, 200

   Makino J., Aarseth S. J., 1992, PASJ, 44, 141

   Martynova, A. I., Orlov V. V., 2009, Astron. Lett., 35, 572

   McLachlan R., 1995, SIAM J. Sci. Comp., 16, 151

   Moore C., 1993, Phys. Rev. Lett., 70, 3675

   Mikkola S., Tanikawa K., 1999a, MNRAS, 310, 745 50

   Mikkola S., Tanikawa K., 1999b, Cel. Mech. Dyn. Astron., 74, 287

   Mikkola S., Aarseth S. J., 2002, Cel. Mech. Dyn. Astron., 84, 343

   Mikkola S., 2008, in: Aarseth S., Tout, C., Mardling R., eds., The Cambridge N-body lectures, Lecture Notes in Physics, Volume 760, Springer Verlag, Berlin, Heidelberg, Deutschland

   Miyamoto M., Nagai R., 1975, PASJ, 27, 533

   Nitadori K., Makino J., 2008, New Astronomy, 13, 498

   Ouyang T., Xie Z., arXiv:1306.0119v2

   Paćynski B., 1990, Ap. J., 348, 485

   Pasha I. I., arXiv:arXiv:astro-ph/0406142

   Pasha I. I., arXiv:astro-ph/0406143

   Peetre J., 1997, Ernst Meissel and the Pythagorean problem - the Drei-Körper-Problem in the Nachlass Meissel

   Plummer H. C., 1911, MNRAS 71, 460

   Ruelle D., Takens F., 1971, Commun. Math. Phys., 20, 167

   Press W. H., Flannery B. P., Teukolsky S. A., Vetterling W. T., 1986, Numerical Recipes - The Art of Scientific Computing, Cambridge University Press, Cambridge, UK

   Preto M., Tremaine S. 1999, AJ, 118, 2532

   Prialnik D., 2000, An Introduction to the Theory of Stellar Structure and Evolution, Cambridge University Press, Cambridge, UK

   Qin M., Zhu W. J., 1992, Computing, 27, 309

   Regenbogen A., Meyer U., Hrsg., 2013, Wörterbuch der philosophischen Begriffe, Felix Meiner Verlag, Hamburg, Deutschland

   Rössler O., 1974, Phys. Lett., 57A, 397

   Salpeter E. E., Ap. J., 121, 161

   Simó C., 2000, Dynamical properties of the figure eight solution of the three-body problem, Proceedings of thr ECM, Barcelona, http://www.maia.ub.es

   Skeel R. D., 1999, Appl. Num. Math., 29, 3

   Spurzem R., 1999, J. Comp. Appl. Maths, 109, 407

   Sundman K. F., 1912, Acta Math., 36, 105

   Sutmann G., 2006, Molecular dynamics - Vision and Reality, in: Grotendorst J., Blügel S., Marx D., eds., Computational Nanoscience - Do it yourself!, Lecture Notes, NIC Series Volume 31, Forschungszentrum Jülich, Deutschland

   Šuvakov M., Dmitrašinović V., 2013, arXiv:1303.0181v1

   Szebehely V., Peters C.F., 1976, Astron. J., 72, 876

   Tremaine S. et al., 1994, AJ, 107, 634

   Vanderbei R. J., 2004, Ann. of the New York Academy of Sciences, 1017, 422, arXiv:astro-ph/0303153

   Verhulst P. F., 1838, Notice sur la loi que la population poursuit dans son accroissement., Corresp. Math. Phys.. 10, 113-121

   Verlet L., 1967a, Phys. Rev. 159, 98

   Verlet L., 1967b, Phys. Rev. 165, 201

   Yoshida H., 1990, Phys. Lett. A, 150, 262

   Zotos E. E., 2012, Research in Astron. Astrophys., 12, 500

Wikipedia, the English-German dictionary of the LEO GmbH (http://dict.leo.org) as well as the Wörterbuch der philosophischen Begriffe of the Meiner Edition (Regenbogen & Meyer2013) have been used as further sources of information.

A Solutions and hints for some exercises


PIC

Abbildung 27: Time evolution of the relative energy error for the iterated time-symmetric Hermite method for 1000 circular orbits in dependence of the number of iterations. Plotting language: GNUPLOT.


Chapter 1

1.
For the calculation of both expressions ai(2) und ai(3) for the i-particle in Eqns. (1.45) and (1.46) two summations over all j-particles have to be carried out.
2.
The scaled initial conditions read in standard N-body units (Heggie & Mathieu1986)

Skaliertes Pythagoreisches Problem / Scaled Pythagorean Problem

0.25 0.3560185185185185 1.068055555555556 0 0 0 0  
0.3333333333333333 -0.712037037037037 -0.3560185185185185 0 0 0 0  
0.4166666666666666 0.3560185185185185 -0.3560185185185185 0 0 0 0

3.
The reader must solve this task.
4.
We demonstrate the growth of the relative energy error of the time-symmetric iterated Hermite method in dependence of the number of iterations in Figure 27. With no iteration, the relative energy error grows linearly. The first iteration increases the accuracy already by almost two orders of magnitude. Then the behavior changes qualitatively. After two or three iterations a secular drift can no longer be seen in the relative energy error.
5.
We must first choose units. According to Szebehely & Peters (1976) we have for the Pythagorean problem G = 1,M = 3 + 4 + 5 = 12,E = -76960 ≈-12.8166666666666667. With this scaling we find that the closest encounter happens at time t = 126.64 between the particles with masses m = 4 and m = 5. The closest distance is 4.1 × 10-4.
6.
We must rotate the Ducati initial conditions for both positions and velocities with a rotation matrix by an angle of α = 45 degrees in the xy plane. The result can be seen in Figure 28. The affine transformations are given by
( x′)   (  cos(α ) sin(α) 0) ( x)
( y′) = ( - sin(α) cos(α) 0) ( y)
  z′         0      0   1    z
(A.275)

(  ′)   (                ) (   )
( vx′)   (  cos(α)  sin(α) 0 ) (vx )
  vy′  =   - sin(α) cos(α) 0   vy
  vz         0      0  1     vz
(A.276)

Zeit-transformiertes Kompositionsverfahren / Time-transformed composition scheme:

FOR i=1, n DO BEGIN

            v0Δt
 x12 = x0 + wi2W0-                                  (A.277)
            Δt
 t12 = t0 +wi 2W--                                   (A.278)
              0
 v1 = v0 + wia(x12)Δt                               (A.279)
             Ω(x 12)
             v0 +-v1
W1  = W0 + wi2Ω(x1)Δt ⋅∇ Ω(x12)                     (A.280)
                 2
 x1 = x12 + wiv1Δt                                  (A.281)
             2W1
 t1 = t1 + wi-Δt-                                   (A.282)
      2     2W1
ENDFOR

unter Verwendung von / using

Ω(x) = - Φ(x)
(A.283)

und wi aus den Tabellen 1, 2 oder 3. / and wi from Tables 1, 2 or 3.

Chapter 2

1.
The reader may implement the time-transformed composition scheme given in the box above, for example with the coefficients from Table 3. This method does not make use of the time derivative of acceleration.
2.
See Ernst (2009) for a discussion of quantites in the Plummer and scale free models, Jaffe (1983), Hernquist (1990), Dehnen (1993) and Tremaine (1994) for a discussion of quantites in the Jaffe, Hernquist and Dehnen models or Miyamoto & Nagai (1975) for a discussion of the Plummer-Kuzmin model.
3.
The rotation curve of the 3PLK model is shown in Figure 31.
4.
For example, the expressions for the Dehnen and Plummer-Kuzmin models are given in Eqns. (2.163) and (2.169)-(2.171).

Chapter 3

1.
The condition xn+2 = xn leads to the cubic equation
- 1-xn - xn + x3n = --1-+--13
  4λ               4λ   64λ
(A.284)

This equation must be solved for xn. The obtained solution must be plugged into f(xn). The stable range can then be determined.

2.
The time derivative of the expression in Eqn. (3.203) gives a quantity which is fourth order in the coordinates and velocities (Finkler, Jones & Sowell1990).
3.
Further Poincaré surfaces of section are shown in Figure 29.
4.
A movie can be downloaded at http://www.simplyintegrate.de.
5.
The solutions for the parameter sets σ = 10,b = 83,r = 28 (Lorenz attractor) and a = 0.15,b = 0.20,c = 10 (Rössler attractor) are shown in Figure 20.
6.
The reader must solve this task.
7.
The reader must solve this task.


PICPIC

Abbildung 28: Ducati orbits according to Martynova & Orlov (2009) and rotated Ducati orbits. Plotting language: GNUPLOT.



Tabelle 9: Konfidenzlevel der Normalverteilung.





w -+ exp  [  2    2]
  - x ∕(2σ )(              √ ---
                2πσ)dx w -+ exp                                        [   2   2 ]
                                         - x∕(2σ )(                                                     √---
                                                      2πσ)dx




0.5 0.38292492254802620727 4.5 0.99999320465375053987
1.0 0.68268949213708589717 5.0 0.99999942669685624161
1.5 0.86638559746228386799 5.5 0.99999996202087506822
2.0 0.95449973610364158559 6.0 0.99999999802682470992
2.5 0.98758066934844772966 6.5 0.99999999991967998832
3.0 0.99730020393673981094 7.0 0.99999999999744037491
3.5 0.99953474184192894992 7.5 0.99999999999993618216
4.0 0.99993665751633376015 8.0 0.99999999999999875580





Chapter 4

1.
The mass function according to Kroupa, Tout & Gilmore (1993) is given by
       (
       { C1m -1.3 = ϕ1    0.08 ≤ m < 0.5
ϕ (m ) = ( C2m -2.3 = ϕ2   0.5 ≤ m < 1.0
         C3m -2.7 = ϕ3    1.0 ≤ m < ∞
(A.285)

The 3 constants in (A.285) are obtained analytically by solving the system of 3 linear equations,

    ∫ ∞
N =     dm  ϕ(m) = 1,   ϕ1(0.5) = ϕ2(0.5),   ϕ2(1.0) = ϕ3(1.0).     (A.286)
     0.08

But how is it possible to integrate up to numerically? This question must be solved by the reader.

2.
For the mean stellar mass of the mass function according to Kroupa (2002), one obtains
     ∫ 120.0
⟨m ⟩ =      dmm ϕ (m ) ≈ 0.29143
      0.01
(A.287)

solar masses.

3.
The local error of the trapezoidal rule is of order O(h3f′′), where f′′ is the value of the second derivative of the function somewhere in the interval of integration (Press et al.1986).
4.
The confidence levels of the normal distribution are given in Table 9 to an accuracy of 20 digits after the comma.

Chapter 5

1.
The reader must solve this task.
2.
The solutions for normalized density ρ∕ρc, cumulative mass M∕M72 and potential ψ∕ψc are shown in Figure 30 as functions of scaled radius r∕rK, where rK =   ----------
∘ 9σ2K ∕(4πρc) and units where used in which G = σK = ρc∕ρ(ψc) = 1.
3.
The reader must solve this task.
4.
We find for the numerical constant M3 2.01824.


PIC PIC

Abbildung 29: Further Poincaré surfaces of section in the Hénon-Heiles potential with y = 0 and vy 0. Top panel: At E = 0.02. We see only periodic and quasiperiodic orbits. Bottom panel: At E = 0.125. We see a mixture of periodic, quasiperiodic and chaotic orbits. Plotting language: GNUPLOT.



PIC

Abbildung 30: Solution of the Lane-Emden equation for a n = 72 polytrope. Top panel: potential. Middle panel: cumulative mass. Bottom panel: density. Plotting language: GNUPLOT.



PIC

Abbildung 31: Rotation curve of the 3PLK model and its components. The solar radius is marked by the vertical line at 8 kpc. Plotting language: GNUPLOT.


B     TTL program


1//------------------------------------------------------- 
2// ttl.C 
3// Code: Time-transformed leapfrog integrator 
4// Ref: S. Mikkola, S. Aarseth, 
5//      A Time-Transformed Leapfrog Scheme, Cel. Mech. 
6//      Dyn. Astron., 84 (4), 343-354 (2002) 
7// Author: Andreas Ernst 
8// Date: Jan 13, 2005 
9//------------------------------------------------------- 
10 
11#include  <iostream> 
12#include  <cmath> 
13#include  <cstdlib> 
14 
15using namespace std; 
16 
17// Calculate accelerations and gradient of Omega function 
18 
19void acc_and_gradomega(double m[], double r[][3], double a[][3], 
20                       double grom[][3], int n) { 
21  int i, j, k; 
22  double (* my_a)[3] = new double[n][3]; 
23  double (* my_grado)[3] = new double[n][3]; 
24 
25  for (i=0; i<n; i++) for (k=0; k<3; k++) { 
26    my_a[i][k] = 0; 
27    my_grado[i][k] = 0; 
28  } 
29 
30  for (i = 0; i < n; i++) { 
31    for (j = i+1; j < n; j++) { 
32      double rji[3]; 
33      for (k = 0; k < 3; k++) { 
34        rji[k] = r[j][k] - r[i][k]; 
35      } 
36      double r2 = 0; 
37      for (int k = 0; k < 3; k++) r2 += rji[k] * rji[k]; 
38        double r3 = r2 * sqrt(r2); 
39        for (int k = 0; k < 3; k++) {
Listing 4: C++ code ttl.C of the time-transformed leapfrog



40          my_a[i][k] += m[j] * rji[k] / r3; 
41          my_grado[i][k] += rji[k] / r3; 
42          my_a[j][k] -= m[i] * rji[k] / r3; 
43          my_grado[j][k] -= rji[k] / r3; 
44       } 
45     } 
46  } 
47 
48  for (i=0; i<n ; i++) for (k=0; k<3; k++) { 
49     a[i][k] = my_a[i][k]; 
50     grom[i][k] = my_grado[i][k]; 
51   } 
52 
53   delete my_a; 
54   delete my_grado; 
55
56 
57// Calculate energy 
58 
59double energy(double m[], double r[][3], double v[][3], int n) { 
60  double ekin = 0, epot = 0; 
61  for (int i = 0; i < n; i++) { 
62    for (int j = i+1; j < n; j++){ 
63      double rji[3]; 
64      for (int k = 0; k < 3; k++) rji[k] = r[j][k] - r[i][k]; 
65      double r2 = 0; 
66      for (int k = 0; k < 3; k++) r2 += rji[k] * rji[k]; 
67      epot -= m[i]*m[j]/sqrt(r2); 
68    } 
69    for (int k = 0; k < 3; k++) 
70      ekin += 0.5 * m[i] * v[i][k] * v[i][k]; 
71  } 
72  return ekin + epot; 
73
74 
75// Calculate Omega function 
76 
77double omega(double m[], double r[][3], int n) { 
78  double om = 0; 
79  for (int i = 0; i < n; i++) { 
80    for (int j = i+1; j < n; j++){ 
81      double rji[3]; 
82      for (int k = 0; k < 3; k++) rji[k] = r[j][k] - r[i][k]; 
83      double r2 = 0; 
84      for (int k = 0; k < 3; k++) r2 += rji[k] * rji[k]; 
85      om += 1/sqrt(r2); 
86    } 
87  } 
88  return om; 
89}
Listing 5: C++ code ttl.C of the time-transformed leapfrog



90int main(int argc, char *argv[]) { 
91 
92// Read initial conditions from stdin, declaration of variables 
93 
94  int i, j, k; 
95 
96  if (argc < 3 ) { 
97    cout << "Usage:␣ttl␣<dt>␣<t_end>␣<dt_opt>" << endl; 
98    return 0; 
99  } 
100 
101  double dt = atof(argv[1]); // time step 
102  double t_end = atof(argv[2]); 
103  double dt_opt = atof(argv[3]); 
104  double t_opt = 0.0; 
105 
106  int n; 
107  cin >> n; 
108 
109  double t; 
110  cin >> t; 
111 
112  double * m = new double[n]; 
113  double (* r)[3] = new double[n][3]; 
114  double (* v)[3] = new double[n][3]; 
115  double (* a)[3] = new double[n][3]; 
116  double (* grado)[3] = new double[n][3]; 
117  double (* old_v)[3] = new double[n][3]; 
118 
119  for (int i = 0; i < n ; i++){ 
120    cin >> m[i]; 
121    for (int k = 0; k < 3; k++) cin >> r[i][k]; 
122    for (int k = 0; k < 3; k++) cin >> v[i][k]; 
123  } 
124 
125// Calculate initial total energy 
126 
127  double e_in = energy(m, r, v, n); 
128  cerr << "Initial␣total␣energy␣E_in␣=␣" << e_in << endl; 
129 
130  double dt_out = 0.001; 
131  double t_out = dt_out; 
132 
133// Initialize variables 
134 
135   double W0 = omega(m,r,n); 
136   double W = W0, O = 0; 
137   t = 0; 
138 
139// Integration loop
Listing 6: C++ code ttl.C of the time-transformed leapfrog



140  while (t < t_end) { 
141 
142// First step x_{n+1/2} 
143 
144    for (i=0; i<n; i++) for (k=0; k<3; k++) { 
145      r[i][k] += dt*v[i][k]/(2*W); 
146    } 
147    t += dt/(2*W); 
148 
149// Second step v_{n+1} 
150 
151    acc_and_gradomega(m, r, a, grado, n); 
152 
153    O = omega(m,r,n); 
154 
155    for (i=0; i<n; i++) for (k=0; k<3; k++) { 
156 
157      old_v[i][k] = v[i][k]; 
158 
159      v[i][k] += dt*a[i][k]/O; 
160 
161      W += dt*(old_v[i][k]+v[i][k])*grado[i][k]/(2*O); 
162    } 
163 
164// Third step r_{n+1} 
165 
166    for (i=0; i<n; i++) for (k=0; k<3; k++) { 
167      r[i][k] += dt*v[i][k]/(2*W); 
168    } 
169    t += dt/(2*W); 
170 
171// Data output 
172 
173    if (t >= t_out) { 
174      cout << "DATA:␣"; 
175      cout << n << "␣"; 
176      cout << t << "␣"; 
177      for (int i = 0; i < n; i++) { 
178        cout << m[i] << "␣"; 
179        for (int k = 0; k < 3; k++) cout << r[i][k] << "␣"; 
180        for (int k = 0; k < 3; k++) cout << v[i][k] << "␣"; 
181      } 
182      cout << endl; 
183      t_out += dt_out; 
184    } 
185// Energy output 
186 
187   if (t >= t_opt) { 
188     double e_cur = energy(m, r, v, n); 
189     cerr << "TIME:␣" << t << "␣ENERGY:␣" << e_cur
Listing 7: C++ code ttl.C of the time-transformed leapfrog



190           << "␣DEE:␣" << (e_cur - e_in)/e_in << endl; 
191       t_opt += dt_opt; 
192     } 
193 
194  } 
195 
196  double e_out = energy(m, r, v, n); 
197  cerr << "Initial␣total␣energy␣E_in␣=␣" << e_in << endl; 
198  cerr << "Final␣total␣energy␣E_out␣=␣" << e_out << endl; 
199  cerr << "absolute␣energy␣error:␣E_out␣-␣E_in␣=␣" 
200         << e_out - e_in << endl; 
201  cerr << "relative␣energy␣error:␣(E_out␣-␣E_in)␣/␣E_in␣=␣" 
202       << (e_out - e_in) / e_in << endl; 
203 
204  delete m; 
205  delete r; 
206  delete v; 
207  delete a; 
208  delete grado; 
209  delete old_v; 
210 
211  return 0; 
212
213//---------------------------------------------------------
Listing 8: C++ code ttl.C of the time-transformed leapfrog


C     Gnuplot examples    

Plot data file:

plot "out" u 2:8 lt 1 lw 4 ps 5 w l  
replot "out" u 2:10 lt 2 pt 7 ps 5

Plotting styles:

Symbol type: pt, symbol color: lt, line width: lw, point size: ps

Global point size:

set pointsize 10  
set pointsize 0.1

3D Plot:

set view 45,45  
splot "out" u 4:5:6

Palette Plot, color bar for 5th column:

set view map  
set palette rgbformulae 22,13,-31  
splot "out" u 2:4:5 pal

Plot function:

f(x)=x**2  
plot [0.0001:1000] f(x) lt 2 pt 7 lw 4

Logarithmic plots:

set logscale x  
set logscale y  
set logscale xy  
unset logscale x  
unset logscale y  
unset logscale xy

Set plot range:

set xrange [-2:2]  
set yrange [-2:2]

Plot to Postscript file:

set terminal postscript enhanced color  
set output "out.ps"  
set terminal x11  
set output

Axis Labels and Plot Titles:

set xlabel "{/Symbol r}/{/Symbol r}_0"  
set ylabel "dE/E_{in}"  
set title "Kepler problem"

Parametric Plots (e. g. Lissajous figures):

set parametric  
plot [0:10*pi] sin(t),cos(t)  
plot [0:10*pi] sin(t),cos(3*t)  
plot [0:10*pi] sin(t),cos(4*t)  
plot [0:10*pi] sin(t),cos(3*t+pi/4)

Plot vertical line with inlined data:

plot "-" w l lt 1 notitle  
5 0  
5 1  
e

Plot different functions in different ranges:

plot (x<=0.08)||(x>=0.5)?1/0:f(x) lt 1 notitle,\  
(x<=0.5)||(x>=1.0)?1/0:g(x) lt 2 notitle,\  
(x<=1.0)?1/0:h(x) lt 3 notitle

Grid points:

set grid

Label, Arrows:

set label "(0,0) first" at first 0, first 0  
set label "(0,0) graph" at graph 0, graph 0  
set label "(0,0) screen" at screen 0, screen 0  
 
set arrow from 0,0 to 1,1  
set arrow from 0,0 to 1,2  
set arrow from 0,0 to 1,3  
 
set noarrow 2  
set arrow 3 to 1,5

Fitting with Gnuplot:

f(x) = (1+x**2/a**2)**-2.5  
FIT_LIMIT = 1e-10  
a = 1.154  
fit [0.1:4] f(x) "out3" u 2:4 via a  
plot f(x) lt 1 title "Plummer a = 1.154 r_0",\  
"out3" u 2:4 w l lt 2 title "King W_0=3"

Multiple Plots:

set multiplot  
set size square 0.3, 0.5  
 
set origin 0.0, 0.5  
set title "V_0 = 0.5 v_{cir}"  
plot "out11" u 4:5 w l notitle  
 
set origin 0.0, 0.0  
set title "V_0 = 0.5 v_{cir}"  
plot "out21" u 4:5 w l notitle  
 
...  
 
unset multiplot

D     Three-body animations    

You need two GNUPLOT scripts, anim.gnu und loop.gnu, with the following commands:

anim.gnu:

set nokey  
set pointsize 3  
set xrange [-3:3]  
set yrange [-3:3]  
n=1  
c=0.001  
load ’loop.gnu’

loop.gnu:

plot ’out’ ev ::n::n u 5:6 pt 7,\  
     ’out’ ev ::n::n u 12:13 pt 7,\  
     ’out’ ev ::n::n u 19:20 pt 7  
print "Step ",n+1  
pause c  
n=n+1;  
reread

The file out is the output generated by the integrator with (x,y) in the (5-th, 6-th), (12-th, 13-th) und (19-th, 20-th) column for the particles 1, 2 und 3.

.