Presentation on theme: "(a short) CPMD tutorial"— Presentation transcript:
1(a short) CPMD tutorial F.L. GervasioETH Zurich c/o USI campus,Via Buffi 13, 6900 Lugano, CHAcknowledgments:This tutorial is partially based on that initially put together with Carme Rovira, Roger Rousseau, Axel Kohlmeyer and Alessandro Laio presented at Centre for Research in Theoretical Chemistry of the Parc Cientific de Barcelona in 2004.Prof. Nicola Marzari (MIT) for useful discussions
2Why Ab-initio Molecular Dynamics? Classical molecular dynamics using predefined potentials is well established as a powerful tool to investigate many-body condensed matter systems. Despite overwhelming success a fixed model potential implies serious drawbacks:1 Many different atom or molecule types give rise to a myriad of different inter-atomic interactions that have to be parameterized.2 The electronic structure/bonding pattern changes qualitatively in the course of the simulation.3 Systems at very high temperatures/pressures for which no experimental data is available.
3Why Ab-initio Molecular Dynamics? Publication and citation analysis.Squares: number of publications which appeared up to the year n that contain the keyword “ab initio molecular dynamics" or synonyma in title, abstract or keyword list.Circles: number of publications which appeared up to the year n that cite the 1985 paper by Car and Parrinello[R. Car and M. Parrinello, Phys. Rev. Lett. 55, 2471 (1985).]
4What is CPMD?The CPMD code is a plane wave/pseudopotential implementation of DFT for ab-initio molecular dynamics.First version by Jurg Hutter at IBM Zurich Research Lab.Many people contributed to the development: Michele Parrinello, Jurg Hutter, D. Marx, P. Focher, M. Tuckerman, W. Andreoni, A. Curioni, E. Fois, U. Roetlisberger, P. Giannozzi, T. Deutsch, A. Alavi, D.Sebastiani, A. Laio, J. VandeVondele, A. Seitsonen, S. Billeter and others.
5What is CPMD?The current version, , is copyrighted jointly by IBM Corp and by Max Planck Institute, Stuttgart.It is distributed free of charge to non-profit organizations (http://www.cpmd.org/)CPMD runs on many different computer architectures and it is well parallelized (MPI and Mixed MPI/SMP).
6CPMD characteristicsLDA, LSD and many gradient correction schemes (BLYP,HTCH,PBE,etc)Norm conserving or ultrasoft pseudopotentialsFree energy density functional implementationIsolated systems, periodic boundary conditions, k-pointsMolecular and crystal symmetry
7CPMD capabilitiesWavefunction optimization: direct minimization and diagonalizationGeometry optimization: local optimization and simulated annealingMolecular dynamics: NVE, NVT, NPTPath integral MDResponse functionsExcited statesTime-dependent DFT (excitations, MD in excited states)Coarse-grained non-Markovian metadynamicsWannier, EPR, Vibrational analysisQM/MMSee on-line manual at:
8Theory: Infos and Literature Car-Parrinello molecular dynamics (CP-MD) simulations bring together methods from classical molecular dynamics (MD), solid state physics and quantum chemistry, so some knowledge in all of these areas is needed.Reviews:D.K. Remler and P.A. Madden, Mol. Phys. 70, 921ff. (1990) M.C. Payne, M.P. Teter, D.C. Allen, T.A. Arias and J.D. Joannopoulos, Rev. Mod. Phys. 64, (1992) D. Marx and J. Hutter, Forschungszentrum Jülich, NIC Series, Vol. 1 (2000),J. Kohanoff and N. Gidopoulos, Handbook of Molecular Physics and Quantum Chemistry, ed. Stephen Wilson. Volume 2, Part 5, Chapter 26, pp (Wiley, Chichester, 2003)J. Kohanoff: “Electronic Structure Calculations for Solids and Molecules” Cambridge university Press Webpages:
9Molecular Dynamics Initial geometry, velocities Potential U(R) Evolve the trajectory on thePhase space usingNewton’s second law.The potential depends only on the positionsThe total energy is conserved
10Initial structure? The Initial geometry can be obtained from: Experiment: PDB database, Cambridge database, etc.Drawing it from scratchIt is better that you pre-optimize it by using a MM force field,If the initial geometry is completely wrong the wavefunctionOptimization will take an extremely long time or even fail(see WF optimization).
11Potentials from electronic structure theory • Born-Oppenheimer approximation• Solution to the electronic time-independent Schroedinger eq.• For a given electronic state we get
12Car-Parrinello MD BOMD DFT CPMD Ficticious electronic mass Electronic velocitiesorthonormalizationkinetic energy of the electrons
13Necessary condition for CP-MD Car-Parrinello MDNecessary condition for CP-MDEThe electrons have to adiabatically follow the nucleiIf there is an energy transfer from the nuclei to the elctronsThe electronic temperature increasesThe system leaves the BO surface
15wnuclear welectronic w Why the CP method works? increase Car-Parrinello MDWhy the CP method works?Nuclear and electronic subsystems decoupledNo superposition of their power spectraE.g.:diatomic moleculedecrease mincrease mnuclearwnuclearwelectronicwTo control the adiabaticdecouplingincreaseBetter adiabaticitydecreasing mBest compromisedecrease Dtmax
16Comparison of CP and BOMD forces (Si crystal ) Car-Parrinello MDComparison of CP and BOMD forces (Si crystal )(Pastore, Smargiassi and Buda, Phys. Rev. A 44, 6334, 1991)CP: continous line BO: pointsThe difference is small and oscillatory
17Tnuclei >> Telectrons Telectrons = constant Etotal = constant Car-Parrinello MDIn generalEgap ~ 1 eV= a.u.Dt = a.u. = fsAttention to metals (Egap= 0)NO adiabatic separationBOMD or CPMD free energy DFTCheck the following propertiesTnuclei >> TelectronsTelectrons = constantEtotal = constant
19Latest results on the effect of m Car-Parrinello MDLatest results on the effect of m
20Latest results on the effect of m Car-Parrinello MDLatest results on the effect of m(i)[ …] great care is required in the choice of an appropriate fictitious electron mass. Values of m of 800 au (for H2O) or 1100 au (for D2O) are inappropriate for simulations longer than a few picoseconds. A value of 400 au should be used.(ii) Simulations in the microcanonical ensemble for small systems near a phase transition can lead to problematic (nonergodic) behavior that gives reproducibility problems. The same applies to empirical water models.(iii) BOMD simulations suffer from the same problems regarding reproducibility as CPMD simulations.An advantage of the CPMD approach using a Lagrangian including the fictitious electronic degrees of freedom is that it allows us to conserve the total energy extremely well, better than BOMD.(iv) Overall, simulations in the canonical ensemble offer distinct advantages: instabilities and sensitivity to initial conditions of microcanonical simulations are avoided and the use of larger fictitious electron masses is permissible in CPMD simulations (massive thermostats).The computational benefits of CPMD sampling over Born-Oppenheimer sampling for structural and thermodynamic properties are appreciable for liquid water and arise from the substantial reduction in computer time per step (by about a factor of 20) that is only partially compensated by the requirement for a smaller time step (by about a factor of 5).The simulations presented here show that classical trajectories for 64-molecule systems using the BLYP-TM and BLYP-GTH descriptions of water (at T = 315 K and F ) 1.0 g/cm3) yield an overstructured liquid (gOO max too high by about 0.2 units), an underestimated heat capacity, and an underestimated self diffusion constant. However better than PBE functional (gOO max too high by about 0.8 units).Using massive thermostats on the ions and electrons givesreliable results even with relatively large mThe error on the Functional is much larger than any effect of m
21Density Functional Theory with PW BO-Approximation:Hohenberg and Kohn: proof that the density uniquely determines the energy of the system. Physical Review 136 B864 (1964).Kohn and Sham: that the variational search for the density which provides the lowest energy may be preformed using single particle wavefunctions. Physical Review 140, A1133 (1965).Density is sum of square of orbitals.Electronic energy in terms of electronic densityOne can treat this as an eigenvalue problem:
22Plane WavesThe KS orbitals in a periodic system may be expanded in a basis set of G vectorsWith this basis set the KS equations take on the form:Where the first term is the kinetic energy operator, Te, and it is diagonal in a basisof G vectors and we only need to solve an NelecXNplanewaves problem.Note Te is defined also for non-reciprical lattice vectors k. These vectorsform the Brillouin Zone or k-space and are usually sampled on a gridof k-points.
23Evaluating Kohn Sham Equations: Planewave expansionsFor a periodic 3D potential the kinetic energy operator has eigenfucntions of planewaves with reciprocal vector G and eigenvalues |G|2.Since EαG2 then we can define the number of basis functions by the cutoffenergy Ecut. For historical reasons specified in rydberg (Ry)=0.5 a. u.Estimating the number of plane waves for a cell with a G-space volume Ω we get:To construct the electronic density in terms of G vectors we have to useA doubly large set.Note: density expansion depends only on the box size and linear in Nelec-not the number of atoms
24When will this be a good basis set: The pseudopotential.Plane waves are a good basis set if the functions we want to describe aresmooth-i.e. the eigenfunctions of a smoother potential.However, atomic wavefunctions are not so nice for core orbitals andto radial nodes of valence orbitals in the core region.Solution replace core orbitals by pseudopotential and remove radial nodes.Steep potential=badflat potential=good
25The choice of pseudopotentials CPMD works with several types of pseudopotentials (Norm conserving, Ultra soft)The most commonly used for non-metallic atoms areMartin Troullier [Phys. Rev. B, 43, 1993 (1991)].MT are the preferred norm-conserving potentials.Work well for light main group elements: C, N, O, S, P etcThey have EXC built in: if you change functional you must change pseudo.They are subject to “ghost states” from KB seperation.They are not really flexible enough to obtain transferable potentials for transition metals.Typical cut-off: 70RyWith transition metals you need to use Goedecker-Hutter or Vanderbilt ultra soft.GH require high cutoff, cover most elementsVanderbilt: low cut-off~40Ry, more calculations required, in CPMD many features not implemented.On under /contributed you will find a pseudopotential library.When you use a new pseudopotential always check it against known properties:geometry, vibrational properties, lattice constants, bulk modulus (better all-electron).
26Evaluating Kohn Sham Equations: OverviewInput: Structure, box, EcutG-vectors and Real space GridInitail GuessConstruct: VKSDiagonalize KS equationsSCFCalculate EKSCalculate SCF criteriumOK,Write RestartEXIT
27Comparing to Gaussians The Good:Has a better scaling than Gaussian based methods-without loss of accuracy.Planewaves are easy to program-fast math libraries. No Pulay Forces.Can do solids, polymers and molecules all in same framework.No BSSE (Mad Gaussian Disease).Other properties, not discussed here, are easy to calculate with PW.The Bad:Care must be taken with real space grid and EcutRipple noise makes it hard to converge structures.To do isolated molecules requires a lot of work: screening of images.Need lots of planewaves.Chemists have to learn Solid state physics lingo-culture gap.The Ugly:Exact Exchange is non-trivial and very expensive to include in this formalism.Pseudopotentials!
28CPMD basicsTo run this examples you need the compiled executable, the input and the pseudopotentialsCompiling CPMD is simple on most architectures1. Make sure that you have the necessary libraries (MPI, BLAS)2. Untar your package3. Run ./mkconfig.sh (PC-IFC-P4) > MakefileSome hints to compile a scalar version on linux can be found on.html.To run (a scalar version of) cpmd you just call the executable followed by the input filename
29Wavefunction optimization Every CPMD run starts by optimizing the wavefunction or from a RESTART.In this example we will optimize the hydrogen electronic structureThe input is organized in sections that begin with &NAME and end with &ENDAll commands MUST be in UPPER case otherwise ignoredA minimal input should have the sections &CPMD, &SYSTEM &ATOMS(see the online manual)
31Wavefunction optimization Starting from the initial guess based on atomic wavefunctions the wavefunction for the total system is now calculated with an optimization procedure. You can follow the progress of the optimization in the output file.NFI: Step numberGEMAX: largest off−diagonal componentCNORM:average of the off−diagonal comp.ETOT: total energyDETOT: change in total energy from previous stepTCPU: (CPU) time for this step.
32Wavefunction optimization The calculation stops after the convergence criterion of 1.0d−7 has been reached for the GEMAX value.Although the calculation startedwith the experimental H−H bond length there are still some forces in the direction of the molecular axis.Note, that regardless of the input units, coordinates in the CPMD output are always in atomic units.Other important OUTPUT files:RESTART.1, LATEST contain all the information on the final state of the systemGEOMETRY.xyz contains the coordinates of the atoms
33Wavefunction optimization There are several ways to optimize the wavefunction in CPMDThe default uses Direct Inversion of the Iterative Subspace (DIIS)[P. Pulay, Chem. Phys. Lett. 73, 393 (1980). ] which is usually the faster.Any optimization that takes more than 100 steps should be considered slow. If the ODIIS converger gets stuck (more than one reset) stop the run and restart usingthe conjugate gradient minimizer with line search is much more robust.Starting a CPMD from a random wavefunction with all atom positions fixed, a comparatively high electron mass and using ANNEALING ELECTRONS is another alternative to get to a reasonably converged wavefunction.Wavefunction optimizations for geometries that are far from equilibrium are often difficult. You can relax the convergence criteria to or and do some geometry steps. After that optimization will be easier.PCGMINIMIZETIMESTEP 20
34Geometry optimization A geometry optimization is not much else than repeated single point calculations, where the positions of theatoms are updated according to the forces acting on them.We replaced WAVEFUNCTION with GEOMETRY and added the sub-option XYZ to have CPMD write a 'trajectory' of the optimization in a file name GEO_OPT.xyz .We also specify the convergence parameter for the geometry.Please notice:In the case of large systems this way of optimizing the geometry is very inefficient.It is much better to perform a Car-Parrinello dynamics with ANNEALING IONS.
35Geometry optimization This run will take a little longer, than the previous.Here we have to do multiple wavefunction optimizations.In the output you can see, that after printing the positions and forces of the atoms there is a small report block.The numbers for GNMAX, GNORM, and CNSTR stand for the largest absolute component of the force on any atom, average force on the atoms, and the largest component of a constraint force on the atoms respectively.
36Car-Parrinello MDRestarting from previous coordinates and optimized wavefunctions, we can now perform a CPMDThe keyword MOLECULAR DYNAMICS CP defines the job type.We tell the program to pick up the previously calculated wavefunction and coordinates from the latest restart file (which is named RESTART.1 by default)The temperature of the system will be initialized to 50K. The time step is set to 4 atomic units (~0.1 femtoseconds). MAXSTEP limits the MD to 200 steps.
37Car-Parrinello MDNFI: Step number (number of finite iterations) EKINC: (fictitious) kinetic energy of the electronic (sub−)system TEMPP: Temperature (= kinetic energy / degrees of freedom) for atoms (ions) EKS: Kohn−Sham Energy, equivalent to the potential energy in classical MD ECLASSIC: Equivalent to the total energy in a classical MD (ECLASSIC = EHAM − EKINC) EHAM: total energy, should be conserved DIS: mean squared displacement of the atoms from the initial coordinates. TCPU: (CPU) time needed for this step.In the CPMD code atoms are sometimes referred to as ions. This is due to the pseudopotential approach, where you integrate the core electrons into the (pseudo)atom which then could be also described as an ion.
38Car-Parrinello MDThe plot shows the evolution of the various energies. Little energy from the ionic system is transferred to the fictitious electron dynamics (the temperature is always less than the initial). The difference between the orange (EHAM) and the blue (ECLASSIC) graphs is EKINC, and the difference to the potential energy (EKS) is kinetic energy in the ionic system.
39Other Job TypesThere are several further types of calculations possible with CPMD, those above are an example. Please check out the CPMD manual, the CPMD mailing list archives for more information on how to perform them.A great source of useful examples is the CPMD test suite (on
40Water Molecule Now we will study a more ambitious molecule: water. Since water has a dipole moment, you have to keep in mind, that we are calculating a system with periodic boundary conditions, so the water molecule 'sees' its images and interacts with them.*&CPMDOPTIMIZE GEOMETRY XYZHESSIAN UNITYCONVERGENCE ORBITALS 1.0d-7CONVERGENCE GEOMETRY 3.0d-4ODIIS 5MAXSTEP 100MAXCPUTIME 1500STRUCTURE BONDS ANGLES&END*There are methods implemented in CPMD to compensate for this effect In &SYSTEMuse SYMMETRY 0 and set POISSON SOLVER HOCKNEY or TUCKERMAN
41Water Molecule &DFT FUNCTIONAL BLYP GC-CUTOFF 1.0d-06 &END&SYSTEMSYMMETRY 1CELLCUTOFF 70.0&ATOMS*O_MT_BLYP.psp KLEINMAN-BYLANDERLMAX=P1*H_CVB_BLYP.pspLMAX=SThis time we will use a gradient corrected functional (BLYP) instead of the LDA.Also note that in the &ATOMS section the LMAX for the oxygen is set to P (instead of S for hydrogen) and that the keyword KLEINMAN−BYLANDER is required for for the calculation of the nonlocal parts of the pseudopotential.
42Water Molecule&CPMDPROPERTIESRESTART WAVEFUNCTION COORDINATESWANNIER WFNOUT ALLWANNIER REFERENCE&END&PROPLOCALIZEPROJECT WAVEFUNCTIONDIPOLE MOMENTCHARGES&DFTFUNCTIONAL BLYPGC-CUTOFF 1.0d-06&SYSTEM …&ATOMS …We can now do a properties calculation using the RESTART from the previous run
43Concluding Remarks This has been only a short Introduction to CPMD and PW-DFT.Mixed basis Gaussian/PW codes can combineadvantages of both.These methods can be made linear in scalability.Currently the community is shifting towardthese approaches (cp2k