5636 - Parallel Numerical Algorithms Mike Peardon — Hilary Term 2016

advertisement
5636 - Parallel Numerical Algorithms
Mike Peardon — mjp@maths.tcd.ie
http://www.maths.tcd.ie/~mjp/5636
School of Mathematics
Trinity College Dublin
Hilary Term 2016
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
1 / 13
Numerical solutions to
hamiltonian dynamics
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
2 / 13
Molecular dynamics
Consider a system of n particles, interacting via pairwise
potentials. Examples:
Atomistic simulation of large molecules, polymers, proteins
etc.
N-body simulation of star clusters.
Hybrid Monte Carlo
Forces can usually be categorised as either short- or
long-ranged. Examples:
Short-ranged
Long-ranged
Chemical bonds (L-J) Electrostatic
Van der Waals
Gravitational
Short-ranged forces easier to parallelise, long-range presents
much more of a challenge. Simplest implementations have
O(n2 ) complexity and O(n2 ) parallel communication costs.
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
3 / 13
Solving Hamiltonian dynamics
Many standard integrators (Euler, Runge-Kutta) are unstable
when used to evolve equations of motion:
ẋ = p,
ṗ = f (x, t)
Example: Euler applied to simple harmonic oscillator; update
is linear operator on phase space {x, p}
xk+1
1 h
xk
=
pk+1
−h 1
pk
k xk
1 h
x0
so
=
pk
−h 1
p0
and an analytic form for xk can be constructed.
Eigenvalues are λ± = 1 ± ih, so |λ| > 1 when h > 0.
Amplitude of oscillations grows exponentially, in proportion
to e µt with µ = ln 1 + h2
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
4 / 13
Symplectic integrators and leap-frog
A class of integrators for hamiltonian evolution can be
constructed with better properties - the symplectic
integrators
Simplest (reversible) example - leap-frog
The leap-frog integrator
1
2
3
xk+1/2 = xk + h2 pk
pk+1 = pk + hf (xk+1/2 , t + h/2)
xk+1 = xk+1/2 + h2 pk+1
This scheme is reversible: {xk , pk } → {xk+1 , pk+1 } means
{xk+1 , −pk+1 } → {xk , −pk }
Because of reversibility, leap-frog is a second-order scheme
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
5 / 13
Leap-frog (2)
From the recursion, x is updated twice consecutively, so
xk+3/2 = xk+1/2 + hpk+1
Now see where the method gets its name!
x0
x 1/2
p0
x 5/2
x 3/2
p1
p2
x3
p3
The leap-frog integrator
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
6 / 13
Leap-frog (3)
Once again, one leap-frog step for the SHO is a linear
operator on {x, p}:
1 0
xk
xk+1
1 h2
1 h2
=
−h 1
pk
pk+1
0 1
0 1
2
3
xk
1 − h2 h − h4
=
2
pk
−h
1 − h2
Again, x k ∀k constructed from x k = M k x 0
Eigenvalues of M are
√
h2 ih 4 − h2
λ± = 1 −
±
2
2
Now for h ≤ 2, have |λ| = 1. For h > 2 at least one eigenvalue
has modulus greater than unity
Integrator stable (solution bounded) for h < 2 for SHO
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
7 / 13
Leap-frog (4)
2
Euler, h=0.1
Leap-frog, h=0.1
x(t)
1
0
-1
-2
0
2
4
6
8
10
12
14
16
18
20
t
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
8 / 13
Barnes-Hut Tree
If region has more than one
star, sub-divide into four
quadrants.
Continue recursively until all
quadrants contain at most
one star
Tree then consists of
“external” nodes,
representing one star and
“internal” nodes,
representing a cluster.
For all nodes, store total
mass, and centre-of-mass
location.
2
4
0
7
1
6
8
9
3
5
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
9 / 13
Barnes-Hut Tree
2
4
0
7
4
1
6
8
9
3
5
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
10 / 13
Barnes-Hut Tree
2
4
0
7
4
7
6
3
5
9
1
6
8
9
3
5
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
11 / 13
Barnes-Hut Tree
2
4
0
7
4
7
6
3
5
9
1
2
0
1
8
6
8
9
3
5
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
12 / 13
Barnes-Hut force evaluation
Set some accuracy threshold, θ. To evaluate the force on star x:
Start at top of tree, and evaluate d,
the distance from x to the
centre-of-mass of the cell (with
side-length s).
If node is external (1 star) evaluate
force directly.
d
If s/d < θ, the cell is far enough to
be
treated as a point.
s
else go down the tree and examine
the four sub-quadrants.
Example shows force on star 9 being evaluated with θ = 1/2. NW
cell is far enough to be treated as point, NE contains only one star
(4) SW and SE too close
2
4
0
7
1
6
8
9
3
5
Mike Peardon — mjp@maths.tcd.ie (TCD)
5636
Hilary Term 2016
13 / 13
Download