A block-step version of KS regularization

  • View
    264

  • Download
    1

  • Category

    Science

Preview:

DESCRIPTION

Presentation at 'Stellar N-body Dynamics', Sep. 2014, http://www.sexten-cfa.eu/conferences/2014/details/42-stellar-n-body-dynamics

Citation preview

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

A block-step version of KS regularizationat Steller N-body Dynamics, Sexten

Keigo Nitadori

Co-Design Team, Exascale Computing ProjectRIKEN Advanced Institute for Computational Sciencd

September 10, 2014

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Acknowledgement

My sincerest thanks go to Sverre Aarseth and IoA for invitingme 7 times, 07, 08, 09, 10, 11, 12, and 13, in which the mostimportant and creative collaboration on the development ofNBODY6/GPU was done.

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Abstract

I talk about a new future implemented in NBODY6/GPU:A block-step version of KS regularized binary.I To eliminate serial bottleneckI Very accurate with fully conservational Hermite integrator

Amazingly, it is already working!

Public code is available as nbody6b and nbody7b

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Topics

1. Brief introduction of Kustaanheimo–Stiefel (KS)regularization (with Hamilton’s quaternion numbers)

2. A very accurate variant of Hermite integrator for harmonicoscillators (and regularized binaries)

3. Block stepping in real time ∆t

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

3 steps of regularization

1. Time transformation. dt = ‖r‖dτ, (hereafter, [ ] = ddt [ ],

and [ ]′ = ddτ [ ] = ‖r‖ [ ])

I r(τ) is already a harmonic oscillator (+bias ).I 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–Heggieregularization.I Perturbation to E and e are integrated independently.

3. Coordinate transformation from r to u. Finally, it becomesa harmonic oscillator, u′′ = 1

2 hu.I h is an energy integral and available as h(u,u′), but should

be integrated independently.

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Levi-Civita transformation in a complex plane

-1.5

-1

-0.5

0

0.5

1

1.5

-1.5 -1 -0.5 0 0.5 1 1.5

harmonicKepler

F1F2

Ellipse of harmonic oscillator:

u = A cos θ + iB sin θ (1)

Ellipse of Kepler motion:

r =u2

=A2 − B2

2+

A2 + B2

2cos 2θ + i2AB sin 2θ

=a(e + cos φ) + ia√

1 − e2 sin φ

with

φ = 2θ, a =A2 + B2

2, e =

A2 − B2

A2 + B2(2)

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Hamilton’s quaternion

I The complex numbers algebra can be applied to thetwo-dimensional geometry

I We can add, subtract, multiply, and divide 2D vectorsI What about on 3D vectors?I According to a letter Hamilton wrote later to his son

Archibald:Every morning in the early part of October 1843, on my comingdown to breakfast, your brother William Edward and yourselfused to ask me: "Well, Papa, can you multiply triples?" WheretoI was always obliged to reply, with a sad shake of the head, "No,I can only add and subtract them."

I Finally, he discovered that quadruple numbers can be applied tothe arithmetics of 3D vectors

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

cont.

Introduce a new imaginary unit j that anti-commutes with i,e.g. ij = −ji, and let k = ij. Then,

i2 = j2 = k2 = ijk = −1

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

defines the (non-commutative) quaternion algebra.A quaternion is

H 3 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 versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Usage of quaternion

A unit quaternion rotates a vector.

rrot = αrα, (3)

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 φ2 + k sin φ

2

)rotated a vector about the z-axis

by an angle φ.

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Let’s rotate the orbit

Let Kepler orbit on the xy-plane

x + iy = u2, (5)

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 = uju. (6)

With arbitrary rotational quaternions α and β,

α(jx + ky)α = α(uju)α = (αu β)(βj β)(βuα) (7)

Now we can writer = qκq, (8)

with a three-dimensional orbit r, a quaternion q = αu β, anda unit vector κ = βj β (is either i, j, or k).

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Comparison of LC and KS

LC KSalgebra complex, C quaternion, Hphys. coord. r = x + iy r = ix + jy + kzreg. coord. u = u0 + iu1 u = u0 + iu1 + ju2 + ku3transformation r = u2 r = uκueq. of motion u′′ = 1

2 hu + 12 |u|

2fu u′′ = 12 hu − 1

2 ‖u‖2fuκ

I f is a perturbation vectorI Original 2 × 2 real matrix formulation is possible for LCI Original 4 × 4 real matrix or 2 × 2 complex matrix (Pauli

matrices) formulation is possible for KS

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

A very accurate Hermite integrator

(Accidentally) it turn out that the following symmetriccorrector form

ucorr =uold +∆τ

2(u′corr + u′old) −

∆τ2

12(u′′new − u′′old),

u′corr =u′old +∆τ

2(u′′new + u′′old) −

∆τ2

12(u′′′new − u′′′old), (9)

after P(EC)n convergence 5 of 6 orbital elements (except for thephase) conserve in machine accuracy.If you use another form for the position

ucorr =uold +∆τ

2(u′corr + u′old) −

∆τ2

10(u′′new − u′′old) +

∆τ3

120(u′′′new + u′′′old),

(10)

this property is lost.

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Why it works

Consider a harmonic oscillator x = −ωx, and let vi = xi andfi = xi.An analytical solution for one step ∆t writes,(

ωx1v1

)=

(cosω∆t sinω∆t− sinω∆t cosω∆t

) (ωx0v0

). (11)

It is equivalent to(v1 − v0x1 − x0

)=

(tan(ω∆t/2)ω∆t/2

)∆t2

(f1 + f0v1 + v0

). (12)

A second order integrator approximates this as(v1 − v0x1 − x0

)=∆t2

(f1 + f0v1 + v0

). (13)

The difference is only a small factor on the stepsize ∆t.

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Fourth- and sixth-order version

The 4th-order Hermite integrator is equivalent to(v1 − v0x1 − x0

)=*..,

1

1 − 13

(ω∆t

2

)2

+//-

∆t2

(f1 + f0v1 + v0

), (14)

and a 6th-order one(v1 − v0x1 − x0

)=*..,

1 − 115

(ω∆t

2

)2

1 − 25

(ω∆t

2

)2

+//-

∆t2

(f1 + f0v1 + v0

). (15)

The factor to ∆t is approaching to(

tan(ω∆t/2)ω∆t/2

), of exact

solution.Phase error shared among 4 waves of KS⇒ 5 of 6 orbital elements conserve

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Phase correction

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

x1 =x0 +c2∆t

2(v1 + v0),

x1 =x0 +c4∆t

2(v1 + v0) −

∆t2

12(f1 − f0),

x1 =x0 +c6∆t

2(v1 + v0) −

∆t2

10(f1 − f0) +

c6∆t3

120(f1 + f0), (16)

(so on the velocity), with

c2 =tan φφ

, c4 =tan φφ

(1 −

13φ2

), c6 =

tan φφ

1 − 25φ

2

1 − 115φ

2, (17)

and φ = ω∆t/2. Now the results agree with the analitictrigonometric functions in machine accuracy.

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Block stepping

I Usually, fixed ∆τ, ∼ 30 step/orbit is enough for weaklyperturbed binary.

I Then, real step ∆t =

∫ τ+∆τ

τ

dtdτ

dτ =

∫ τ+∆τ

τ‖r‖dτ,

becomes a varying real (non-quantized) number.I This prevents parallelization, we hope ∆t restricted to

2n (n ∈ Z) (McMillan, 1986; Makino 1992).

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Truncation procedure

From given natural step ∆τnat, we compute a truncated step∆τbs(< ∆τnat) for which the corresponding step ∆tbs = 2n obeysthe block-step criterion.

∆τnat −−−−−−→integrate

∆tnat −−−−−−→truncate

∆tbs −−−−→solve

∆τbs (18)

We integrate

∆tnat =

6∑n=1

t〈n〉(∆τnat)n

n!,

(t〈n〉 =

dn

dτn t). (19)

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

−∆tbs +

6∑n=1

t〈n〉(∆τbs)n

n!= 0, (20)

by using of Newton–Raphson iterations (unique solutionexists).

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Derivatives of physical time t

I After a 4th-order Hermite integration, up to 3rd derivativeof force (5th derivative of coordinate) is available

I Up to 6th derivative of time is available

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)

I tnext is explicitly available at the end of this stepI Predictor only, no corrector is applied for t

A block-step versionof KS regularization

Keigo Nitadori

KS regularization

Hermite integrator

KS block-step

Summary

Summary

I The block-step version of KS is working in Sverre’s codeI Some Hermite integrators turned out to integrate harmonic

oscillators very accurately with P(EC)n iterationsI Regularization is not acrobatics, nor a black magic

(at least for two-body).

Recommended