Docsity

Molecular Dynamics-Computational Physics-Lecture Slides, Slides of Computational Physics

Partial preview of the text

Download Molecular Dynamics-Computational Physics-Lecture Slides and more Slides Computational Physics in PDF only on Docsity!

Molecular Dynamics:

  • What to choose in an integrator
  • The Verlet algorithm
  • Boundary Conditions in Space and time
  • Neighbor tables
  • Long ranged interactions
  • Thermostats
  • Constraints

Criteria for an Integrator

  • simplicity (How long does it take to write and debug?)
  • efficiency (How fast to advance a given system?)
  • stability (what is the long-term energy conservation?)
  • reliability (Can it handle a variety of temperatures,

densities, potentials?)

  • compare statistical errors (going as h-1/2^ ) with time

step errors which go as hp^ where p=2,3...?

The Verlet Algorithm

The nearly universal choice for an integrator is the Verlet (leapfrog) algorithm

r(t+h) = r(t) + v(t) h + 1/2 a(t) h^2 + b(t) h^3 + O(h^4 ) Taylor expand

r(t-h) = r(t) - v(t) h + 1/2 a(t) h^2 - b(t) h^3 + O(h^4 ) Reverse time

r(t+h) = 2 r(t) - r(t-h) + a(t) h^2 + O(h^4 ) Add

v(t) = (r(t+h) - r(t-h))/(2h) + O(h^2 ) estimate velocities

Time reversal invariance is built in  the energy does not drift.

How to set the time step

  • Adjust to get energy conservation to 1% of kinetic energy.
  • Even if errors are large, you are close to the exact trajectory of a nearby physical system with a different potential.
  • Since we don’t really know the potential surface that accurately, this is satisfactory.
  • Leapfrog algorithm has a problem with round-off error.
  • Use the equivalent velocity Verlet instead:

r (t+h) = r (t) +h [ v (t) +(h/2) a (t)] v (t+h/2) = v (t)+(h/2) a (t) v (t+h)= v (t+h/2) + (h/2) a (t+h)

Spatial Boundary Conditions

Important because spatial scales are limited. What can we choose?

  • No boundaries; e.g. droplet, protein in vacuum. If droplet has 1 million atoms and surface layer is 5 atoms thick 25% of atoms are on the surface.
  • Periodic Boundaries: most popular choice because there are no surfaces (see next slide) but there can still be problems.
  • Simulations on a sphere
  • External potentials
  • Mixed boundaries (e.g. infinite in z, periodic in x and y)

Periodic Boundary Conditions

Is the system periodic or just an infinite array of images?

How do you calculate distances in a periodic system?

Complexity of Force Calculations

  • Complexity is defined as how a computer algorithm scales with the number of degrees of freedom (particles)
  • Number of terms in pair potential is N(N-1)/2  O(N^2 )
  • For short range potential you can use neighbor tables to reduce it to O(N) - (Verlet) neighbor list for systems that move slowly - bin sort list (map system onto a mesh and find neighbors from the mesh table)
  • Long range potentials with Ewald sums are O(N3/2) but Fast Multipole Algorithms are O(N) for very large N.

! Loop over all pairs of atoms. do i=2,natoms do j=1,i- !Compute distance between i and j. r2 = 0 do k=1,ndim dx(k) = r(k,i) - r(k,j) !Periodic boundary conditions. if(dx(k).gt. ell2(k)) dx(k) = dx(k)- ell(k) if(dx(k).lt.-ell2(k)) dx(k) = dx(k)+ell(k) r2 = r2 + dx(k)*dx(k) enddo

!Only compute for pairs inside radial cutoff. if(r2.lt.rcut2) then r2i=sigma2/r r6i=r2ir2ir2i !Shifted Lennard-Jones potential. pot = pot+eps4ri6(ri6-1)- potcut !Radial force. rforce = eps24r6ir2i(2r6i-1) do k = 1 , ndim force(k,i)=force(k,i) + rforcedx(k) force(k,j)=force(k,j) - rforcedx(k) enddo endif enddo enddo

LJ Force Computation

Constant Pressure

  • To generalize MD, follow similar procedure as for the thermostat for constant pressure. The size of the box is coupled to the internal pressure

TPN

  • Volume is coupled to

virial pressure

  • Unit cell shape can also

change.

P 2 ,

d i j dr i j

K r^ 

Parrinello-Rahman simulation

  • 500 KCl ions at 300K
  • First P=
  • Then P=44kB
  • System spontaneously

changes from rocksalt to

CsCl structure

Constraints in MD

  • Some problems require constraints:
    • fixed bond length (water molecule). We would like to get rid of high frequency motion (not interesting)
    • In LDA-MD we need to keep wavefunctions orthogonal.
    • Putting constraints in “by hand” is difficult (for example, working in polar coordinates)
  • WARNING: constraints change the ensemble.
  • SHAKE algorithm lets dynamics move forward without constraint; then forces it back to satisfy the constraint.
  • Let equation for constraint be:  (R) =
  • Bond constraint is  (R) =|r (^) i -r (^) j|^2 - a^2