12.07.2015 Views

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

COPYRIGHT 2008, PRINCETON UNIVERSITY PRESS

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

432 chapter 16Velocity-Verlet Algorithm: Another version of the Verlet algorithm, which we recommendbecause of its increased stability, uses a forward-difference approximationfor the derivative to advance both the position and velocity simultaneously:r i (t + h) ≃ r i (t)+hv i (t)+ h22 F i(t)+O(h 3 ), (16.19)v i (t + h) ≃ v i (t)+h a(t)+O(h 2 ) (16.20)[ ]Fi (t + h)+F i (t)≃ v i (t)+h+ O(h 2 ).2(16.21)Although this algorithm appears to be of lower order than (16.16), the use ofupdated positions when calculating velocities, and the subsequent use of thesevelocities, make both algorithms of similar precision.Of interest is that (16.21) approximates the average force during a time step as[F i (t + h)+F i (t)]/2. Updating the velocity is a little tricky because we need theforce at time t + h, which depends on the particle positions at t + h. Consequently,we must update all the particle positions and forces to t + h before we update anyvelocities, while saving the forces at the earlier time for use in (16.21). As soon asthe positions are updated, we impose periodic boundary conditions to ensure thatwe have not lost any particles, and then we calculate the forces.16.3 1-D Implementation and ExerciseC DOn the CD you will find a folder MDanimations that contains a number of 2-Danimations (movies) of solutions to the MD equations. Some frames from theseanimations are shown in Figure 16.3. We recommend that you look at them in orderto better visualize what the particles do during an MD simulation. In particular,these simulations use a potential and temperature that should lead to a solid orliquid system, and so you should see the particles binding together.✞☎// MD. java , Molecular Dyanmics via Lennard−Jones potential , velocity Verlet algorithmimport java . io .∗ ;import java . util .∗ ;public class MD {static int L , Natom = 8 , Nmax = 513; // Class variablesstatic double x[] = new double [Nmax] , f x [][] = new double [Nmax ][2];public static void main ( String [] argv ) throws IOException , FileNotFoundException {int t1 , t2 , i , Itemp , t , Nstep=5000, Nprint=100, Ndim=1 ;double h = 0.0004 , hover2 , PE, KE, T, Tinit = 10.0 , vx[] = new double [Nmax ] ;L = ( int ) Math .pow( 1 . ∗ Natom , 1./Ndim) ;Natom = ( int ) Math .pow( L , Ndim) ;System . out . println ("Natom = "+Natom+" L= "+L+"" );i = −1;for ( int ix = 0; ix

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!