Scientific Computing II Molecular Dynamics Numerics Michael Bader SCCS Technical University of Munich Summer 018
Recall: Molecular Dynamics System of ODEs resulting force acting on a molecule: F i = j i acceleration of a molecule (Newton s nd law): F r i = i j i F ij = m i m i or, with acceleration a i := 1 m i Fi : r i = a i, = F ij U( r i, r j ) j i r ij m i where F i and a i depend on all positions r i transfer to dn coupled ordinary differential equations of 1st order: m i r i = p i or r i = v i p i = F i vi = F i /m i = a i Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018
Euler Time Stepping for MD Explicit Euler Method: Taylor series expansion of the positions in time: (ṙ, r, r (i) : derivatives) r(t + t) = r(t) + t r(t) + 1 t r(t) + t i i! r (i) (t) +... (1) neglecting terms of higher order of t, and analogous formulation of v(t) := r(t) with a(t) := v(t) = r(t) = F (t) m leads to the explicit Euler method: v(t + t). = v(t) + t a(t) r(t + t). = r(t) + t v(t) Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 3
Euler Time Stepping for MD (cont.) explicit Euler method: v(t + t). = v(t) + t a(t) r(t + t). = r(t) + t v(t) (a) (b) similar for implicit Euler method derivatives at the time step end: v(t + t). = v(t) + t a(t + t) r(t + t). = r(t) + t v(t + t) (3a) (3b) disadvantage for both schemes: do not conserve critical properties; lead to wrong long-term solutions (compare tutorial on circular motion); plus: low accuracy Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 4
Classical Störmer Verlet Method the Taylor series expansion in (1) can also be performed for t: r(t t) = r(t) t r(t) + 1 t r(t) + ( t)i r (i) (t) +... (4) i! from (1) and (4) the classical Verlet algorithm can be derived: r(t + t) = r(t) r(t t) + t r(t) + O( t 4 ) r(t) r(t t) + t a(t) (5) note: direct calculation of r(t + t) from r(t) and F(t) velocity can be estimated via v(t) = r(t). = r(t + t) r(t t) t disadvantage: needs to store two previous time steps (6) Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 5
Crank Nicolson Method explicit approximation (7a) for half step [t, t + t ] inserted into implicit approximation (7b) for half step [t + t, t + t] v(t + t t ) = v(t) + a(t) (7a) v(t + t) = v(t + t ) + t a(t + t) (7b) leads to Crank-Nicolson scheme for v: v(t + t) = v(t) + t ( a(t) + a(t + t) ) (8) key disadvantage: implicit scheme, as a(t + t) depends on r(t + t); needs to solve non-linear system of equations Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 6
Velocity Störmer Verlet Method The Velocity Störmer Verlet method is a composition of a Taylor series expansion of nd order for the positions, as in Eq. (1) and a Crank Nicolson method for the velocities, as in Eq. (8) r(t + t) = r(t) + t v(t) + t a(t) (9a) ( v(t + t) = v(t) + t a(t) + a(t + t) ) (9b) Forward Euler r Force calculation Crank-Nicolson v r v F t- t t t+ t t- t t t+ t t- t t t+ t t- t t t+ t Memory requirement: (3 + 1) 3N (3+1 vector fields) update of v(t + t) requires v(t), r(t + t) and F (t + t), but also F (t) Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 7
Velocity Störmer Verlet Implementation reformulate equation for positions r: r(t + t) = r(t) + t v(t) + t a(t) ( = r(t) + t v(t) + t ) a(t) contains half an Euler time step for v similar for the velocities v: v(t + t) = v(t) + t ( a(t) + a(t + t) ) ( = v(t) + t ) a(t) + t a(t + t) reuses the result of the half Euler time step for v Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 8
Velocity Störmer Verlet Implementation () 1. compute half an Euler time step for v v(t + t ) = v(t) t + a(t). update positions r: r(t + t) = r(t) + t v(t + t ) 3. calculate forces a(t + t) from positions r(t + t) 4. update the velocities v: v(t + t) = v(t + t ) + t a(t + t) Note: memory requirements: 3 3N (3 vector fields) vectors v and r, as well as forces/accelerations a may be updated in-place in each time step Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 9
Leapfrog Method combine steps 4 (from previous time step) and 1 to a single step velocity calculation thus shifted by a half time step: v(t + t ) = v(t t ) + t a(t) (10a) r(t + t) = r(t) + t v(t + t ) (10b) r v F t- t/ t+ t/ t- t/ t+ t/ t- t/ t+ t/ t- t/ t+ t/ t- t t t+ t t- t t t+ t t- t t t+ t t- t t t+ t exact arithmetic: Störmer Verlet, Velocity Störmer Verlet and Leapfrog Scheme are equivalent the latter two are more robust w.r.t. roundoff errors Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 10
Dimensionless Velocity Störmer Verlet remember dimensionless formulation: ( r := σ r, v := σ v t, t := σ m ɛ t, r = 1 m F := 1 ɛ m σ F ) insert into Velocity Störmer Verlet Method to get:. r (t + t) = r (t) + v (t) + v (t + t) = v (t) + t t F (t) + F (t) t F (t + t) (11a) (11b) Forward Euler r ½ Forward Euler v Force calculation ½ Backward Euler v r v F t- t t t+ t t- t t t+ t t- t t t+ t t- t t t+ t t- t t t+ t Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 11
Dimensionless Velocity Störmer Verlet () Forward Euler r ½ Forward Euler v Force calculation ½ Backward Euler v r v F t- t t t+ t t- t t t+ t t- t t t+ t t- t t t+ t t- t t t+ t Procedure: 1. calculate new positions (11a), partial velocity update: + t F (t) in (11b). calculate new forces, accelerations (computationally intensive!) 3. calculate new velocities: + t F (t + t) in (11b) memory requirements: 3 3N Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 1
Outlook: Leapfrog Method with Thermostat Leapfrog method: v(t + t ) = v(t t ) + t a(t) r(t + t) = r(t) + t v(t + t ) r v F Thermostat t- t t+ t t+ t t- t t+ t t- t t t+ t t- t t t+ t t- t t t+ t t- t t t+ t t- t t t+ t intermediate ( step may be introduced for the thermostat v(t) := 1 v(t + t ) + v(t t )) to synchronize velocity: v act (t) = v(t t ) + t a(t) (13a) v(t + t ) = (β 1) v act(t) + t a(t) (13b) Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 13
Evaluation of Time Integration Methods Evaluation criteria: accuracy (often not of great importance for exact particle positions) stability conservation of phase space density (symplectic) of energy of momentum (especially with PBC Periodic Boundary Conditions) reversibility of time use of resources: computational effort (number of force evaluations) maximum time step size memory usage Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 14
Reversibility of Time time reversal for a closed system means a turnaround of the velocities and also momentums; positions at the inversion point stay constant traverse of a trajectory back in the direction of the origin demand for symmetry for time integration methods + satisfied by Verlet method, e.g. not satisfied by, e.g., Euler method, Predictor Corrector methods (also not by standard Runge-Kutta methods) contradiction with the H-theorem (increase of entropy, irreversible processes)? (Loschmidt s paradox) the second theorem of thermodynamics? reversibility in theory only for a very short time Lyapunov instability Kolmogorov entropy Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 15
Lyapunov Instability Basic question: how does a model behave with slightly disturbed initial condition? Example of a simple system: stable case: jumping ball on a plane with slightly disturbed initial horizontal velocity linear increase of the disturbance instable case: jumping ball on a sphere with slightly disturbed initial horizontal velocity exponential increase of the disturbance (Lyapunov exponent) for the instable case, small disturbances result in large changes: chaotic behaviour (butterfly leading to a hurricane?) non-linear differential equations are often dynamically instable Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 16
Lyapunov Instability: A Numerical Experiment setup of 4000 fcc atoms for a second setup, the position of a single atom was displaced by 0.001 this atom is traced in both setups tracing a Molecule (with initial displacement) Molecule 5, run1 Molecule 5, run 4.1 4 3.9 3.8 3.7 3.6 3.5 colours indicate velocity.5 3 3.5 4 4.5 5 7.7 7.6 7.5 7.4 7.3 7. 5.5 7.1 Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 17
Lyapunov Instability: A Numerical Experiment Calculation of the trajectories badly conditioned problem: a small change of the initial position of a molecule may result in a distance to the comparable original position, after some time, in the magnitude of the whole domain! Thus: do not target at simulation of individual trajectories numerical simulation of the behaviour of the system is wanted! tracing a Molecule (with initial displacement) Molecule 5, run1 Molecule 5, run 0.5 0.45 Molecule deviation (with initial displacement) 0.4 4.1 0.35 4 3.9 0.3 3.8 3.7 0.5 3.6 3.5 0..5 3 3.5 4 4.5 5 7.7 7.6 7.5 7.4 7.3 7. 5.5 7.1 0.15 0.1 0.05 0.5 3 3.5 4 4.5 5 5.5 Michael Bader SCCS Scientific Computing II Molecular Dynamics Numerics Summer 018 18