このページは http://www.slideshare.net/KeigoNitadori/talk-40311323 の内容を掲載しています。

掲載を希望されないスライド著者の方は、こちらよりご連絡下さい。

約2年前 (2014/10/15)にアップロードin学び

Presentation at

’Stellar N-body Dynamics’, Sep. 2014,

http://www.sexten-cfa.eu/conferences/2014/d...

Presentation at

’Stellar N-body Dynamics’, Sep. 2014,

http://www.sexten-cfa.eu/conferences/2014/details/42-stellar-n-body-dynamics

- A block-step version

of KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

A block-step version of KS regularization

Summary

at Steller N-body Dynamics, Sexten

Keigo Nitadori

Co-Design Team, Exascale Computing Project

RIKEN Advanced Institute for Computational Sciencd

September 10, 2014 - A block-step version

of KS regularization

Acknowledgement

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

My sincerest thanks go to Sverre Aarseth and IoA for inviting

me 7 times, 07, 08, 09, 10, 11, 12, and 13, in which the most

important and creative collaboration on the development of

NBODY6/GPU was done. - A block-step version

of KS regularization

Abstract

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

I talk about a new future implemented in NBODY6/GPU:

Summary

A block-step version of KS regularized binary.

To eliminate serial bottleneck

Very accurate with fully conservational Hermite integrator

Amazingly, it is already working!

Public code is available as nbody6b and nbody7b - A block-step version

of KS regularization

Topics

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

1. Brief introduction of Kustaanheimo–Stiefel (KS)

regularization (with Hamilton’s quaternion numbers)

2. A very accurate variant of Hermite integrator for harmonic

oscillators (and regularized binaries)

3. Block stepping in real time ∆t - A block-step version

of KS regularization

3 steps of regularization

Keigo Nitadori

KS regularization

1. Time transformation. dt = r dτ, (hereafter, ˙

[ ] = d [ ],

Hermite integrator

dt

KS block-step

and [ ] = d

dτ [ ] =

r ˙

[ ])

Summary

r(τ) is already a harmonic oscillator (+bias ).

But equation of motion r = f (r, r ) is numerically

dangerous.

2. Write the equation of motion in conserved quantities.

ex. r = f (E, e, r) in Sparing–Burdeet–Heggie

regularization.

Perturbation to E and e are integrated independently.

3. Coordinate transformation from r to u. Finally, it becomes

a harmonic oscillator, u = 1 hu.

2

h is an energy integral and available as h(u, u ), but should

be integrated independently. - A block-step version

of KS regularization

Levi-Civita transformation in a complex plane

Keigo Nitadori

KS regularization

Hermite integrator

Ellipse of harmonic oscillator:

KS block-step

1.5

harmonic

u = A cos θ + iB sin θ

(1) Summary

Kepler

1

F1

F2

Ellipse of Kepler motion:

0.5

r =u2

0

=A2 − B2 + A2 + B2 cos 2θ + i2AB sin 2θ

2

2

-0.5

=a(e + cos φ) + ia 1 − e2 sin φ

-1

with

-1.5

φ = 2θ, a = A2 + B2 , e = A2 − B2

-1.5

-1

-0.5

0

0.5

1

1.5

2

A2 + B2

(2) - A block-step version

of KS regularization

Hamilton’s quaternion

Keigo Nitadori

KS regularization

Hermite integrator

The complex numbers algebra can be applied to the

KS block-step

two-dimensional geometry

Summary

We can add, subtract, multiply, and divide 2D vectors

What about on 3D vectors?

According to a letter Hamilton wrote later to his son

Archibald:

Every morning in the early part of October 1843, on my coming

down to breakfast, your brother William Edward and yourself

used to ask me: "Well, Papa, can you multiply triples?" Whereto

I was always obliged to reply, with a sad shake of the head, "No,

I can only add and subtract them."

Finally, he discovered that quadruple numbers can be applied to

the arithmetics of 3D vectors - A block-step version

of KS regularization

cont.

Keigo Nitadori

KS regularization

Hermite integrator

Introduce a new imaginary unit j that anti-commutes with i,

KS block-step

e.g. ij = −ji, and let k = ij. Then,

Summary

i2 = j2 = k2 = ijk = −1

or

ij = −ji = k, jk = −kj = i, ki = −ik = j

defines the (non-commutative) quaternion algebra.

A quaternion is

H

q = s + ix + jy + kz

(s, x, y, z ∈ R)

s is referred to as scalar and ix + jy + kz vector. - Broom Bridge
- A block-step version

of KS regularization

Usage of quaternion

Keigo Nitadori

KS regularization

Hermite integrator

A unit quaternion rotates a vector.

KS block-step

rrot = αr ¯α,

(3)

Summary

with a unit quaternion α and a vector r = ix + jy + kz.

Example:

ekφ/2(ix + jy + kz)e−kφ/2 =ekφ (ix + jy) + kz

=ekφ(x + ky)i + kz

(4)

ie−kφ/2 = ekφ/2i,

je−kφ/2 = ekφ/2j,

ke−kφ/2 = e−kφ/2k

α =

φ

φ

ekφ/2 = cos

+ k sin

rotated a vector about the z-axis

2

2

by an angle φ. - A block-step version

of KS regularization

Let’s rotate the orbit

Keigo Nitadori

KS regularization

Let Kepler orbit on the xy-plane

Hermite integrator

x + iy = u2,

(5)

KS block-step

Summary

with LC coordinate u = u0 + iu1. By multiplying j from right,

we move the orbit on the yz-plane,

(x + iy)j = jx + ky = u2j = uj¯u.

(6)

With arbitrary rotational quaternions α and β,

α(jx + ky) ¯α = α(uj¯u) ¯α = (αu ¯β)( βj ¯β)( β¯u ¯α)

(7)

Now we can write

r = qκ ¯q,

(8)

with a three-dimensional orbit r, a quaternion q = αu ¯

β, and

a unit vector κ = βj ¯

β (is either i, j, or k). - A block-step version

of KS regularization

Comparison of LC and KS

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

LC

KS

Summary

algebra

complex, C

quaternion, H

phys. coord.

r = x + iy

r = ix + jy + kz

reg. coord.

u = u0 + iu1

u = u0 + iu1 + ju2 + ku3

transformation

r = u2

r = uκ ¯u

eq. of motion

u = 1 hu + 1 |u|2fu

u = 1 hu − 1 u 2fuκ

2

2

2

2

f is a perturbation vector

Original 2 × 2 real matrix formulation is possible for LC

Original 4 × 4 real matrix or 2 × 2 complex matrix (Pauli

matrices) formulation is possible for KS - A block-step version

of KS regularization

A very accurate Hermite integrator

Keigo Nitadori

KS regularization

(Accidentally) it turn out that the following symmetric

Hermite integrator

corrector form

KS block-step

∆τ

∆τ2

Summary

ucorr =uold +

(u

+ u ) −

(u

− u

),

2

corr

old

12

new

old

∆τ

∆τ2

u

=

+

+

−

corr

u

(u

u

) −

(u

u

),

(9)

old

2

new

old

12

new

old

after P(EC)n convergence 5 of 6 orbital elements (except for the

phase) conserve in machine accuracy.

If you use another form for the position

∆τ

∆τ2

∆τ3

ucorr =uold +

(u

+ u ) −

(u

− u

) +

(u

+ u ),

2

corr

old

10

new

old

120

new

old

(10)

this property is lost. - A block-step version

of KS regularization

Why it works

Keigo Nitadori

KS regularization

Consider a harmonic oscillator ¨x = −ωx, and let vi = ˙xi and

Hermite integrator

fi = ¨xi.

KS block-step

An analytical solution for one step ∆t writes,

Summary

ωx

ω

1

=

cos ω ∆t

sin ω ∆t

x0 .

(11)

v1

− sin ω ∆t

cos ω ∆t

v0

It is equivalent to

v

∆

1 − v0

= tan(ω∆t/2)

t

f1 + f0 .

(12)

x1 − x0

ω ∆t/2

2

v1 + v0

A second order integrator approximates this as

v

∆

1 − v0

= t f1 + f0 .

(13)

x1 − x0

2

v1 + v0

The difference is only a small factor on the stepsize ∆t. - A block-step version

of KS regularization

Fourth- and sixth-order version

Keigo Nitadori

KS regularization

The 4th-order Hermite integrator is equivalent to

Hermite integrator

KS block-step

v

∆

1 − v0

=

1

t

f1 + f0 ,

(14)

Summary

x

2

1 − x0

2

v

1 − 1 ω∆t

1 + v0

3

2

and a 6th-order one

ω∆t 2

v

1 − 1

∆

1 − v0

=

15

2

t

f1 + f0 .

(15)

x

2

1 − x0

2

v

1 − 2 ω∆t

1 + v0

5

2

tan(ω ∆t/2)

The factor to ∆t is approaching to

ω ∆

, of exact

t/2

solution.

Phase error shared among 4 waves of KS

⇒ 5 of 6 orbital elements conserve - A block-step version

of KS regularization

Phase correction

Keigo Nitadori

If one likes to conserve also the phase, emphasize the step-size

KS regularization

∆t.

Hermite integrator

KS block-step

∆t

x1 =x0 + c2

(v1 + v0),

Summary

2

∆t

∆t2

x1 =x0 + c4

(v1 + v0) −

(f1 − f0),

2

12

∆t

∆t2

∆t3

x1 =x0 + c6

(v1 + v0) −

(f1 − f0) + c6

(˙f1 + ˙f0),

(16)

2

10

120

(so on the velocity), with

1

1 − 2 φ2

c

,

φ2 ,

5

,

2 = tan φ

φ

c4 = tan φ

φ

1 −

c6 = tan φ

(17)

3

φ 1 − 1 φ2

15

and φ = ω ∆t/2. Now the results agree with the analitic

trigonometric functions in machine accuracy. - A block-step version

of KS regularization

Block stepping

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Usually, fixed ∆τ, ∼ 30 step/orbit is enough for weakly

perturbed binary.

τ+∆τ

τ

dt

+∆τ

Then, real step ∆t =

r dτ,

τ

dτ dτ =

τ

becomes a varying real (non-quantized) number.

This prevents parallelization, we hope ∆t restricted to

2n (n ∈ Z) (McMillan, 1986; Makino 1992). - A block-step version

of KS regularization

Truncation procedure

Keigo Nitadori

From given natural step ∆τnat, we compute a truncated step

KS regularization

∆τbs(< ∆τnat) for which the corresponding step ∆tbs = 2n obeys

Hermite integrator

the block-step criterion.

KS block-step

Summary

∆τ

∆

∆

∆τ

nat −

−−−−−→

tnat −−−−−→ tbs −−−→

bs

(18)

integrate

truncate

solve

We integrate

6

∆

t n ( ∆τnat)n

t

,

nat =

t n = dn t .

(19)

n!

dτn

n=1

After truncation ∆tnat → ∆tbs, we solve ∆τbs from

6

t n ( ∆τbs)n

− ∆tbs +

= 0,

(20)

n!

n=1

by using of Newton–Raphson iterations (unique solution

exists). - A block-step version

of KS regularization

Derivatives of physical time t

Keigo Nitadori

KS regularization

After a 4th-order Hermite integration, up to 3rd derivative

Hermite integrator

of force (5th derivative of coordinate) is available

KS block-step

Up to 6th derivative of time is available

Summary

t =u · u,

t =2(u · u ),

t

=2(u · u + u · u ),

t 4 =2(u · u ) + 6(u · u ),

t 5 =2(u · u 4 ) + 8(u · u ) + 6(u · u ),

t 6 =2(u · u 5 ) + 10(u · u 4 ) + 20(u · u ).

(21)

tnext is explicitly available at the end of this step

Predictor only, no corrector is applied for t - A block-step version

of KS regularization

Summary

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

The block-step version of KS is working in Sverre’s code

Some Hermite integrators turned out to integrate harmonic

oscillators very accurately with P(EC)n iterations

Regularization is not acrobatics, nor a black magic

(at least for two-body).