N-body simulations Phys 750 Lecture 10
N-body simulations Forward integration in time of strongly coupled classical particles or (rigid-body composite objects) dissipation Brownian motion Very general class of second-order ODE: r = r apple r apple r 5 + ë (2) (r, r )+ <, ë Referred to as N-body simulation or molecular dynamics in various scientific communities arbitrary forces (3) (r, r, r )+5
Broad applicability Useful in many contexts and over vastly different scales galaxy formation virus classical water
N-body simulations Classical systems of many particles, dissipationless and interacting via central forces, have a Hamiltonian of the form = 2 2 + < ( ) Momentum variables are conjugate to the position variables ( 2DN dimensional phase space) r i p i = m i v i Interactions determined by the pair potential U(r)
N-body simulations The set of second-order differential equations maps to a set of coupled first-order equations: Ür i = )H )p i = p i m i = v i Üp i = )H )r i = jëi )U(r ij ) )r i = jëi U (r ij )Çr ij net force exerted by the other N 1 particles
N-body simulations Special considerations: For long-range forces all particle pairs interact strongly with one another at best, N(N 1) 2 scaling Repulsive interactions require a container (via walls or periodic boundary conditions) Time step must be adjusted such that the length scale v t can resolve the spatial structure of U(r)
Finite simulation cell Typical setup: finite L L L periodic cell serves as a representative sample of space How to judge distance for the L purpose of computing long range forces? L L
Finite simulation cell Periodicity is equivalent to tiling all space with copies of the same cell Forces arise from interactions with each of an infinite number of image particles
Finite simulation cell Approximating the infinite summation in 1D: F e (r) = 1X n= 1 F (r + nl) = + F (r L)+F (r)+f(r + L)+ F (min{ r,l r }) closest-image distance intra-cell separation L<r<L r
Finite simulation cell Summation has an F e (r) exact form for EMlike and gravity-like interactions F (r) = 1 r 2 F (min{ r,l r }) F (r) F e (r) =F (chord(r)) r sin( r/l) /L chord length
Finite simulation cell F (chord(r)) closest-image F e (r) approximation increasingly good as interactions become short-ranged; e.g., F (min{ r,l r }) F (r) F (r) = 1 r 7
Finite simulation cell r i =(x i,y i,z i ) Example distance measure r j =(x j,y j,z j ) in a 3D orthogonal cell d i, j = min{ Dx,L Dx } 2 +min{ Dy,L Dy } 2 j L +min{ Dz,L Dz } 2 1/2 i Dx = x i Dy = y i x j y j L L Dz = z i z j
Lennard-Jones Potential 2 1.5 U(r) Model of Van der Waal s 1 0.5 0 0.5 r 0 =2 1/6 attraction between neutral atoms plus an inner core repulsion 1 1 1.2 1.4 1.6 1.8 2 U(r) =4 r 12 6 r Equilibrium point U (r 0 )=0 separates the attractive and repulsive regions
Choice of Time Step 2 1.5 U(r) 1 two particles at rest at separation distance 1.7 0.5 0 0.5 1 1 1.2 1.4 1.6 1.8 2
Choice of Time Step 2 1.5 U(r) artificial energy gain 1 0.5 0 particle penetrated well beyond the classical turning point! 0.5 1 1 1.2 1.4 1.6 1.8 2
Adaptive Time Step t/3 t/3 Allow time step to vary dynamically within the simulation t/3 t Check convergence by comparing evolution of two otherwise identical copies of the system
Range Truncation If interactions are finite-range, there are only a small number of forces acting on each particle (unless the particles have coalesced) Algorithm now scales as 1 2 N i=1 N (i) nearby N(N 1) 2 Can we impose a cutoff?
Range Truncation E.g., Lennard-Jones tail is very weak beyond r c 2 3 10 8 U(r) U (r) 6 4 2 0 2 1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6
Range Truncation Care must be taken not to introduce unphysical forces 10 8 U(r)θ(r c r) U (r)θ(r c r) + U(r)δ(r c r) 6 4 2 0 2 discontinuous, 1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6 impulsive force
Range Truncation Ũ(r) U(r) U(r c )+(r r c )U (r c ) (r c r) F (r) = Ũ (r) = U (r)+u (r c) (r c r) 10 8 ~ U(r) ~ U (r) 6 4 2 0 2 1 1.2 1.4 1.6 1.8 2 2.2 2.4 2.6
Ewald summation Naive truncation is not possible in the case of truly longranged interactions Ewald summation is a useful Fourier space trick E.g., consider non-self electrostatic interactions between particles in all image cells: U Coulomb = 1 2 X i,j X X q i q j (1 ri rj,nl) r i r j + nl n2z 3 0 q i q j 1 2 i,j,n r i,j,n
Ewald summation Exact rewriting in terms of a background constant, a direct space sum, and a dual space sum: U 0 = U 1 = 1 2 1 X p i q 2 i 0 X erfc(r i,j,n / 0 ) 0q i q j i,j,n U 2 = 1 2 L 3 X i,j q i q j r i,j,n X m2z 3 m6=0 exponentially real lattice decaying envelope exp ( m ) 2 +2 im (r i r j ) m 2 reciprocal lattice
Ewald summation Safe to truncate the sum in U 1 at separations above 0 Order sum over particle indices in can be N 2 evaluated as two order U 2 = 1 2 L 3 X m6=0 N exp sums: U 2 ( m ) 2 m 2 S(m) 2 S(m) = X j q j exp(2 im r j ) structure factor
Barnes-Hut tree dynamic data structure: recursive subdivision of space into quads containing at most one particle The centre-of-mass position is calculated at each tree level and passed up the linked-list hierarchy
Barnes-Hut tree Assume that a particle cluster sufficiently far away can be represented by a single representative particle at the centreof-mass (neglects tidal forces) d l Distance judged by the size of the opening angle l/d < c Scales as N log N
Parallel Computation Simulate on many CPUs simultaneously Each machine updates the 9 1 2 particles in a sub-region of the full space 8 3 Position information passed as messages 7 6 5 4 passed around the ring
Parallel Computation Because of message-passing overhead, the algorithm scales somewhat worse than N(N : Each CPU is numbered cyclically n =0, 1,...,N CPU 1 Loop for each time step: Node n computes forces exerted by its own particles Repeat n 1 times: 1)/2N CPU Node n sends positions to node n + 1 and receives positions from node n 1 Uses received positions to compute forces on its own particles Each node updates its own positions and velocities
Neutral territory methods R R R R traditional half-shell neutral territory message passing overhead 1 2 R2 +2R 2R