5 Texts in Computational Science and Engineering Editors TimothyJ.Barth MichaelGriebel DavidE.Keyes RistoM.Nieminen DirkRoose TamarSchlick Michael Griebel Stephan Knapek Gerhard Zumbusch Numerical Simulation in Molecular Dynamics Numerics, Algorithms, Parallelization, Applications With180Figures,43inColor,and63Tables 123 MichaelGriebel StephanKnapek InstitutfürNumerischeSimulation e-mail:[email protected] UniversitätBonn Wegelerstr.6 53115Bonn,Germany e-mail:[email protected] GerhardZumbusch InstitutfürAngewandteMathematik Friedrich-Schiller-UniversitätJena Ernst-Abbe-Platz2 07743Jena,Germany e-mail:[email protected] LibraryofCongressControlNumber:2007928345 Mathematics Subject Classification (2000): 68U20, 70F10, 70H05, 83C10, 65P10, 31C20, 65N06,65T40,65Y05,68W10,65Y20 ISSN 1611-0994 ISBN 978-3-540-68094-9 SpringerBerlinHeidelbergNewYork Thisworkissubjecttocopyright.Allrightsarereserved,whetherthewholeorpartofthematerialis concerned,specificallytherightsoftranslation,reprinting,reuseofillustrations,recitation,broad- casting,reproductiononmicrofilmorinanyotherway,andstorageindatabanks.Duplicationof thispublicationorpartsthereofispermittedonlyundertheprovisionsoftheGermanCopyrightLaw ofSeptember9,1965,initscurrentversion,andpermissionforusemustalwaysbeobtainedfrom Springer.ViolationsareliableforprosecutionundertheGermanCopyrightLaw. SpringerisapartofSpringerScience+BusinessMedia springer.com ©Springer-VerlagBerlinHeidelberg2007 Theuseofgeneraldescriptivenames,registerednames,trademarks,etc.inthispublicationdoes notimply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfromtherelevant protectivelawsandregulationsandthereforefreeforgeneraluse. Typesetting:bytheauthorsusingaSpringerTEXmacropackage Coverdesign:WMXDesignGmbH,Heidelberg Production:LE-TEXJelonek,Schmidt&VöcklerGbR,Leipzig Printedonacid-freepaper 46/3180/YL-543210 Preface The rapid development of parallel computing systems made it possible to recreate and predict physical processes on computers. Nowadays, computer simulations complement and even substitute experiments. Moreover, simu- lations allow to study processes that cannot be analyzed directly through experiments. This accelerates the development of new products since costly physical experiments can be avoided. Additionally, the quality of products canbeimprovedbytheinvestigationofphenomenanotpreviouslyaccessible. Hence, computer simulation plays a decisive role especially in the develop- ment of new substances in the material sciences as well as in biotechnology and nanotechnology. Many interesting processes cannot be described nor understood in their entirety in a continuum model, but have to be studied with molecular or atomic models. The numerical simulationofmodels onthis lengthscale usu- ally relies on particle methods and other methods of molecular dynamics. Areas of application range from physics, biology, and chemistry to modern material sciences. The fundamental mathematical model here is Newton’s second law. It is asystemofordinarydifferentialequationsofsecondorder.Thelawdescribes therelationshipbetweentheforceactingonaparticleandtheresultingaccel- erationoftheparticle.Theforceoneachparticleiscausedbytheinteraction of that particle with all other particles. The resulting system of differential equations has to be numerically approximated in an efficient way. After an appropriatetimediscretization,forcesonallparticleshavetobecomputedin each time step. Different fast and memory-efficient numerical methods exist which are tailored to the short-range or long-range force fields and poten- tials thatare used.Here,especiallythe linkedcellmethod, theparticle mesh method, the P3M method and its variants, as well as several tree methods suchas the Barnes-Hutmethod or the fast multipole method are to be men- tioned. The execution times of these methods can be substantially reduced by a parallel implementation on modern supercomputers. Such an approach is also of fundamental importance to reach the very large numbers of parti- cles and long simulation times necessary for some problems. The numerical methods mentioned are already used with great success in many different implementations by physicists, chemists, and material scientists. However, VI Preface without a deeper understanding of the particular numerical method applied it is hard to make changes or modifications, or to parallelize or otherwise optimize the available programs. The aim of this book is to present the necessary numerical techniques of molecular dynamics in a compact form, to enable the reader to write a molecular dynamics programin the programming language C, to implement thisprogramwithMPIonaparallelcomputerwithdistributedmemory,and to motivate the reader to set up his own experiments. For this purpose we present in all chapters a precise description of the algorithms used, we give additional hints for the implementation on modern computers and present numerical experiments in which these algorithms are employed. Further in- formation and some programs can also be found on the internet. They are available on the web page http://www.ins.uni-bonn.de/info/md. Afterashortintroductiontonumericalsimulationinchapter1,wederive in chapter 2 the classical molecular dynamics of particle systems from the principlesofquantummechanics.Inchapter3weintroducethebasicmodules of molecular dynamics methods for short-range potentials and force fields (linkedcellimplementation,Verlettimeintegration).Additionally,wepresent afirstsetofexamplesoftheiruse.Here,thetemperatureistakenintoaccount usingstatisticalmechanicsinthesettingofanNVTensemble.TheParrinello- Rahman method for the NPT ensemble is also reviewed. Subsequently we discuss in detail the parallel implementation of the linked cell method in chapter 4 and give a set of further examples. In chapter 5 we extend our methodstomolecularsystemsandmorecomplexpotentials.Furthermore,in chapter 6 we give an overview of methods for time integration. Different numerical methods for the efficient computation of long-range forcefields arediscussedinthe followingchapters7 and8.The P3Mmethod approximates long-rangepotentials on an auxiliary grid. Using this method, further examples can be studied that involve in particular Coulomb forces or, on a different length scale, also gravitational forces. We review both the sequential and the parallel implementation of the SPME technique, which is a variant of the P3M method. In chapter 8 we introduce and discuss tree methods. Here, the emphasis is on the Barnes-Hut method, its extension to higher order, and on a method from the family of fast multipole methods. Both sequential and parallel implementations using space filling curves are presented. In chapter 9 we give examples from biochemistry that require a combination of the methods introduced before. We thank the SFB 611 (Collaborative ResearchCenter sponsored by the DFG- the GermanResearchAssociation)“SingularPhenomenaandScaling in Mathematical Models” at the University of Bonnfor its support, Barbara Hellriegel and Sebastian Reich for valuable hints and references, our col- Preface VII leagues and coworkers Marcel Arndt, Attila Caglar, Thomas Gerstner, Jan Hamaekers, Lukas Jager, Marc Alexander Schweitzer and Ralf Wildenhues for numerous discussions, their support in the implementation of the algo- rithms as well as for the programming and computation for various model problems andapplications.Inparticular we thank Attila andalso Alex,Jan, Lukas, Marcel, Ralf and Thomas for their active help. We also thank Bern- hard Hientzsch for the efforts he put in translating the German version1 of this book. Bonn, Michael Griebel April 2007 Stephan Knapek Gerhard Zumbusch 1 Numerische Simulation in der Moleku¨ldynamik, Numerik, Algorithmen, Paral- lelisierung, Anwendungen, SpringerVerlag, Heidelberg, 2004. Table of Contents 1 Computer Simulation – a Key Technology ................ 1 2 From the Schro¨dinger Equation to Molecular Dynamics .. 17 2.1 The Schro¨dinger Equation ............................... 17 2.2 A Derivation of Classical Molecular Dynamics.............. 21 2.2.1 TDSCF Approach and Ehrenfest Molecular Dynamics. 21 2.2.2 Expansion in the Adiabatic Basis................... 24 2.2.3 Restriction to the Ground State.................... 26 2.2.4 Approximation of the Potential Energy Hypersurface . 26 2.3 An Outlook on Methods of Ab Initio Molecular Dynamics ... 30 3 The Linked Cell Method for Short-Range Potentials...... 37 3.1 Time Discretization – the Sto¨rmer-Verlet Method........... 40 3.2 Implementation of the Basic Algorithm.................... 46 3.3 The Cutoff Radius...................................... 53 3.4 The Linked Cell Method ................................ 56 3.5 Implementation of the Linked Cell Method ................ 58 3.6 First Application Examples and Extensions................ 64 3.6.1 Collision of Two Bodies I.......................... 66 3.6.2 Collision of Two Bodies II ......................... 68 3.6.3 Density Gradient................................. 72 3.6.4 Rayleigh-TaylorInstability ........................ 73 3.6.5 Rayleigh-B´enardConvection ....................... 79 3.6.6 Surface Waves in Granular Materials................ 82 3.7 Thermostats, Ensembles, and Applications................. 86 3.7.1 Thermostats and Equilibration..................... 87 3.7.2 Statistical Mechanics and Thermodynamic Quantities. 93 3.7.3 Phase Transition of Argon in the NVT Ensemble ..... 96 3.7.4 The Parrinello-RahmanMethod.................... 104 3.7.5 Phase Transition of Argon in the NPT Ensemble ..... 107 4 Parallelization ............................................ 113 4.1 ParallelComputers and ParallelizationStrategies........... 113 4.2 Domain Decomposition for the Linked Cell Method ......... 122 4.3 Implementation ........................................ 128 X Table of Contents 4.4 Performance Measurements and Benchmarks............... 139 4.5 Application Examples................................... 146 4.5.1 Collision of Two Bodies ........................... 146 4.5.2 Rayleigh-TaylorInstability ........................ 148 5 Extensions to More Complex Potentials and Molecules ... 151 5.1 Many-Body Potentials .................................. 151 5.1.1 Cracks in Metals – Finnis-Sinclair Potential.......... 152 5.1.2 Phase Transition in Metals – EAM Potential......... 160 5.1.3 Fullerenes and Nanotubes – Brenner Potential ....... 167 5.2 Potentials with Fixed Bond Structures .................... 181 5.2.1 Membranes and Minimal Surfaces .................. 181 5.2.2 Systems of Linear Molecules ....................... 186 5.2.3 Outlook to More Complex Molecules................ 202 6 Time Integration Methods................................ 211 6.1 Errors of the Time Integration ........................... 212 6.2 Symplectic Methods .................................... 221 6.3 Multiple Time Step Methods – the Impulse Method......... 226 6.4 Constraints – the RATTLE Algorithm .................... 230 7 Mesh-Based Methods for Long-Range Potentials.......... 239 7.1 Solution of the Potential Equation........................ 243 7.1.1 Boundary Conditions ............................. 243 7.1.2 Potential Equation and Potential Decomposition ..... 244 7.1.3 Decomposition of the Potential Energy and of the Forces .......................................... 248 7.2 Short-Range and Long-Range Energy and Force Terms...... 250 7.2.1 Short-Range Terms – Linked Cell Method ........... 250 7.2.2 Long-Range Terms – Fast Poisson Solvers ........... 252 7.2.3 Some Variants ................................... 258 7.3 Smooth Particle-MeshEwald Method (SPME) ............. 260 7.3.1 Short-Range Terms ............................... 261 7.3.2 Long-Range Terms ............................... 263 7.3.3 Implementation of the SPME method............... 273 7.4 Application Examples and Extensions..................... 281 7.4.1 Rayleigh-TaylorInstability with Coulomb Potential... 281 7.4.2 Phase Transition in Ionic Microcrystals ............. 284 7.4.3 Water as a Molecular System ...................... 287 7.5 Parallelization ......................................... 294 7.5.1 Parallelizationof the SPME Method................ 294 7.5.2 Implementation .................................. 299 7.5.3 PerformanceMeasurements and Benchmarks......... 302 7.6 Example Application: Structure of the Universe ............ 306 Table of Contents XI 8 Tree Algorithms for Long-Range Potentials............... 313 8.1 Series Expansion of the Potential......................... 314 8.2 Tree Structures for the Decomposition of the Far Field ...... 320 8.3 Particle-Cluster Interactions and the Barnes-Hut Method.... 325 8.3.1 Method ......................................... 326 8.3.2 Implementation .................................. 328 8.3.3 Applications from Astrophysics .................... 339 8.4 ParallelTree Methods................................... 341 8.4.1 An Implementation with Keys ..................... 343 8.4.2 Dynamical Load Balancing ........................ 357 8.4.3 Data Distribution with Space-Filling Curves ......... 359 8.4.4 Applications ..................................... 366 8.5 Methods of Higher Order................................ 370 8.5.1 Implementation .................................. 371 8.5.2 Parallelization ................................... 376 8.6 Cluster-Cluster Interactions and the Fast Multipole Method . 377 8.6.1 Method ......................................... 377 8.6.2 Implementation .................................. 382 8.6.3 Error Estimate................................... 385 8.6.4 Parallelization ................................... 386 8.7 Comparisons and Outlook ............................... 387 9 Applications from Biochemistry and Biophysics........... 391 9.1 Bovine Pancreatic Trypsin Inhibitor ...................... 392 9.2 Membranes ............................................ 394 9.3 Peptides and Proteins................................... 398 9.4 Protein-LigandComplex and Bonding..................... 408 10 Prospects................................................. 413 A Appendix................................................. 417 A.1 Newton’s, Hamilton’s, and Euler-Lagrange’sEquations ...... 417 A.2 Suggestions for Coding and Visualization.................. 418 A.3 Parallelizationby MPI .................................. 421 A.4 Maxwell-Boltzmann Distribution ......................... 425 A.5 Parameters ............................................ 428 References.................................................... 431 Index......................................................... 467