Quantum-ESPRESSO: The SCF Loop and Some Relevant Input Parameters Sandro Scandolo ICTP (most slides courtesy of Shobhana Narasimhan) www.quantum-espresso.org 2 ASESMA-2010 Quantum-ESPRESSO: the project • Quantum ESPRESSO stands for opEn Source Package for Research in Electronic Structure, Simulation, and Optimization. It is freely available to researchers around the world under the terms of the GNU General Public License. • Quantum ESPRESSO is an initiative of the DEMOCRITOS National Simulation Center (Trieste) and SISSA (Trieste), in collaboration with the CINECA National Supercomputing Center in Bologna, the Ecole Polytechnique Fédérale de Lausanne, Princeton University, the Massachusetts Institute of Technology, and Oxford University. Courses on modern electronic-structure theory with hands-on tutorials on the Quantum ESPRESSO codes are offered on a regular basis in developed as well as developing countries, in collaboration with the Abdus Salam International Centre for Theoretical Physics in Trieste. 3 ASESMA-2010 What can QE do (I) • # Ground-state calculations: • • • • • • • • * Self-consistent total energies, forces, stresses; * Electronic minimization with iterative diagonalization techniques, damped-dynamics, conjugate-gradients; * Kohn-Sham orbitals; * Gamma-point and k-point sampling, and a variety of broadening schemes (Fermi-Dirac, Gaussian, Methfessel-Paxton, and Marzari-Vanderbilt); * Separable norm-conserving and ultrasoft (Vanderbilt) pseudo-potentials, PAW (Projector Augmented Waves); * Several exchange-correlation functionals: from LDA to generalized-gradient corrections (PW91, PBE, B88-P86, BLYP) to meta-GGA, exact exchange (HF) and hybrid functionals (PBE0, B3LYP, HSE); * Hubbard U (LDA+U); * Berry's phase polarization; * Spin-orbit coupling and noncollinear magnetism; * Maximally-localized Wannier functions using WANNIER90 code. • # Structural Optimization: • • • • • • • • • • • • • • • • * GDIIS with quasi-Newton BFGS preconditioning; * Damped dynamics; * Ionic conjugate-gradients minimization; * Projected velocity Verlet; * Transition states and minimum energy paths: o Born-Oppenheimer nudged elastic band; o Born-Oppenheimer string dynamics; # Ab-initio molecular dynamics * Car-Parrinello Molecular Dynamics; o Microcanonical (Verlet) dynamics; o Isothermal (canonical) dynamics - Nosé-Hoover thermostats and chains; o Isoenthalpic, variable cell dynamics (Parrinello-Rahman); o Constrained dynamics; 4 ASESMA-2010 What can QE do (II) • • • • • • * Born-Oppenheimer Molecular Dynamics; o Microcanonical (Verlet) dynamics; o Isothermal (canonical) dynamics - Anderson, Berendsen thermostats; o Isoenthalpic, variable cell dynamics (Parrinello-Rahman); o Constrained dynamics; o Ensemble-DFT dynamics (for metals/fractional occupations); • # Response properties (density-functional perturbation theory): • • • • • • • • • * Phonon frequencies and eigenvectors at any wavevector; * Full phonon dispersions; inter-atomic force constants in real space; * Translational and rotational acoustic sum rules; * Effective charges and dielectric tensors; * Electron-phonon interactions; * Third-order anharmonic phonon lifetimes; * Infrared and (non-resonant) Raman cross-sections; * EPR and NMR chemical shifts using the GIPAW method; # Spectroscopic properties: • * K- and L1-edge X-ray Absorption Spectra (XAS) • * Electronic excitations with Many-Body Perturbation Theory using YAMBO code. • # Quantum Transport: • * Ballistic Transport using PWCOND module. • * Coherent Transport from Maximally Localized Wannier Functions using WanT code. 5 ASESMA-2010 QE platforms Platforms: Runs on almost every conceivable current architecture from large parallel machines (IBM SP and BlueGene, Cray XT, Altix, Nec SX) to workstations (HP, IBM, SUN, Intel, AMD) and single PCs running Linux, Windows, Mac OS-X, including clusters of 32-bit or 64-bit Intel or AMD processors with various connectivity (gigabit ethernet, myrinet, infiniband...). Fully exploits math libraries such as MKL for Intel CPUs, ACML for AMD CPUs, ESSL for IBM machines. 6 ASESMA-2010 How to thank the authors 7 ASESMA-2010 Useful information about input variables 8 ASESMA-2010 INPUT_PW.html 9 ASESMA-2010 The Kohn-Sham problem Want to solve the Kohn-Sham equations: 1 2 V ( r ) V [ n ( r )] V [ n ( r )] nuc H XC 2 i (r) i i (r) H Note that self-consistent solution necessary, as H depends on solution: { i } n(r ) H Convention: e me 1 10 ASESMA-2010 Self-consistent Iterative Solution Vnuc known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vnuc(r) + VH (r) + VXC (r) How to solve the Kohn-Sham eqns. for a set of fixed nuclear (ionic) positions. Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 11 ASESMA-2010 Plane Waves & Periodic Systems • For a periodic system: where G = reciprocal 1 (r) c e lattice vector • The plane waves that appear in this expansion can i ( k G )r k k ,G G be represented as a grid in k-space: ky • Only true for periodic systems that grid is discrete. • In principle, still need kx infinite number of plane waves. 12 ASESMA-2010 Truncating the Plane Wave Expansion • In practice, the contribution from higher Fourier • • components (large |k+G|) is small. So truncate the expansion at some value of |k+G|. Traditional to express this cut-off in energy units: ky |k G | Ecut 2m 2 2 E=Ecut kx Input parameter ecutwfc 13 ASESMA-2010 Step 0: Defining the (periodic) system Namelist ‘SYSTEM’ How to Specify the System • All periodic systems can be specified by a Bravais Lattice and an atomic basis. + = 15 ASESMA-2010 How to Specify the Bravais Lattice / Unit Cell Input parameter ibrav - Gives the type of Bravais lattice (SC, BCC, Hex, etc.) Input parameters {celldm(i)} - Give the lengths [& directions, if necessary] of the lattice vectors a1, a2, a3 a2 a1 • Note that one can choose a non-primitive unit cell (e.g., 4 atom SC cell for FCC structure). 16 ASESMA-2010 Atoms Within Unit Cell – How many, where? Input parameter nat - Number of atoms in the unit cell Input parameter ntyp - Number of types of atoms FIELD ATOMIC_POSITIONS - Initial positions of atoms (may vary when “relax” done). -Can choose to give in units of lattice vectors (“crystal”) or in Cartesian units (“alat” or “bohr” or “angstrom”) 17 ASESMA-2010 Step 1: Obtaining Vnuc Vnuc known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vnuc(r) + VH (r) + VXC (r) Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 18 ASESMA-2010 Nuclear Potential • Electrons experience a Coulomb potential due to the nuclei. • This has a known and simple form: Vnuc Z r • But this leads to computational problems! 19 ASESMA-2010 Problem for Plane-Wave Basis Core wavefunctions: sharply peaked near nucleus. Valence wavefunctions: lots of wiggles near nucleus. High Fourier components present i.e., need large Ecut 20 ASESMA-2010 Solutions for Plane-Wave Basis Core wavefunctions: sharply peaked near nucleus. Valence wavefunctions: lots of wiggles near nucleus. High Fourier components present i.e., need large Ecut Don’t solve for the core electrons! Remove wiggles from valence electrons. 21 ASESMA-2010 Pseudopotentials for Quantum Espresso - 1 • Go to http://www.quantum-espresso.org; Click on “PSEUDO” 22 ASESMA-2010 Pseudopotentials for Quantum Espresso - 2 • Click on element for which pseudopotential wanted. 23 ASESMA-2010 Pseudopotentials for Quantum Espresso - 3 Pseudopotential’s name gives information about : • type of exchangecorrelation functional • type of pseudopotential • e.g.: 24 ASESMA-2010 Element & Vion info for Quantum Espresso ATOMIC_SPECIES Ba 137.327 Ba.pbe-nsp-van.UPF Ti 47.867 Ti.pbe-sp-van_ak.UPF O 15.999 O.pbe-van_ak.UPF NOTE • Should have same exchange-correlation functional for all pseudopentials. • ecutwfc, ecutrho depend on type of pseudopotentials used (should test for system & property of interest). 25 ASESMA-2010 Step 2: Initial Guess for n(r) Vion known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vion(r) + VH (r) + VXC (r) Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 26 ASESMA-2010 Initial Choice of n(r) Various possible choices, e.g.,: Superpositions of atomic densities. Converged n(r) from a closely related calculation (e.g., one where ionic positions slightly different). Approximate n(r) , e.g., from solving problem in a smaller/different basis. Random numbers. Input parameter startingwfc 27 ASESMA-2010 Initial Choice of n(r) 28 ASESMA-2010 Step 3: VH & VXC Vion known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vion(r) + VH (r) + VXC (r) Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 29 ASESMA-2010 Exchange-Correlation Potential • VXC dEXC/dn contains all the many-body information. • Known [numerically, from Quantum Monte Carlo ; various analytical approximations] for homogeneous electron gas. • Local Density Approximation: Exc[n] = n(r) VxcHOM[n(r)] dr -surprisingly successful! pz (in name of pseudopotential) Replace • Generalized Gradient Approximation(s): Include terms involving gradients of n(r) pw91, pbe (in name of pseudopotential) 30 ASESMA-2010 Step 4: Potential & Hamiltonian Vion known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vion(r) + VH (r) + VXC (r) Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 31 ASESMA-2010 Kohn-Sham equations in plane wave basis • Eigenvalue equation is now: • Matrix elements are: • Ionic potential given by: 32 ASESMA-2010 Step 5: Diagonalization Vion known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vion(r) + VH (r) + VXC (r) Expensive! Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 33 ASESMA-2010 Exact Diagonalization is Expensive! Have to diagonalize (find eigenvalues & eigenfunctions of) H k+G,k+G’ Typically, NPW > 100 x number of atoms in unit cell. Expensive to store H matrix: NPW2 elements to be stored. Expensive (CPU time) to diagonalize matrix exactly, ~ NPW3 operations required. Note, NPW >> Nb = number of bands required = Ne/2 or a little more (for metals). So ok to determine just lowest few eigenvalues. 34 ASESMA-2010 Iterative Diagonalization • • • Can recast diagonalization as a minimization problem. Then use well-established techniques for iterative minimization by searching in the space of solutions, e.g., Conjugate Gradient. Another popular iterative diagonalization technique is the Davidson algorithm. Input parameter diagonalization -which algorithm used for iterative diagonalization Input parameter nbnd -how many eigenvalues computed 35 ASESMA-2010 Step 6: New Charge Density Vion known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vion(r) + VH (r) + VXC (r) Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 36 ASESMA-2010 Brillouin Zone Sums 0 Many quantities (e.g., n, Etot) involve sums over k. In principle, need infinite number of k’s. In practice, sum over a finite number: BZ “Sampling”. Number needed depends on band structure. Typically need more k’s for metals. Need to test convergence wrt k-point sampling. F 1 P Nk P(k)w kBZ k k 37 ASESMA-2010 Types of k-point meshes 0 Special Points: [Chadi & Cohen] Points designed to give quick convergence for particular crystal structures. Monkhorst-Pack: Equally spaced mesh in reciprocal space. May be centred on origin [‘non-shifted’] or not [‘shifted’] 1st BZ b2 K_POINTS { tpiba | automatic | crystal | gamma } If ‘automatic’, use M-P mesh: nk1, nk2, nk3, k1, k2, k3 b1 shift nk1=nk2=4 38 ASESMA-2010 Step 7: Test for Convergence Vion known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vion(r) + VH (r) + VXC (r) Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 39 ASESMA-2010 How To Decide If Converged? • • • • Check for self-consistency. Could compare: New and old wavefunctions / charge densities. New and old total energies. Compare with energy estimated using Harris-Foulkes functional. Input parameter conv_thr -Typically OK to use 1.e-08 Input parameter electron_maxstep -Maximum number of scf steps performed 40 ASESMA-2010 Step 8: Mixing Can take a long time to reach self-consistency! Vion known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vion(r) + VH (r) + VXC (r) Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 41 ASESMA-2010 Mixing - 1 Iterations n of self-consistent cycle: Successive approximations to density: nin(n) nout(n) nin(n+1). nout(n) fed directly as nin(n+1) ?? No, usually doesn’t converge. Need to mix, take some combination of input and output densities (may include information from several previous iterations). Goal is to achieve self consistency (nout = nin ) in as few iterations as possible. 42 ASESMA-2010 Mixing - 2 Simplest prescription = linear mixing: nin(n+1) = b nout(n) + (1-b) nin(n). There exist more sophisticated prescriptions (Broyden mixing, modified Broyden mixing of various kinds…) Input parameter mixing_mode Input parameter mixing_beta -Typically use value between 0.1 & 0.7 (depends on type of system) 43 ASESMA-2010 Mixing - 3 44 ASESMA-2010 Output Quantities Vion known/constructed Initial guess n(r) Calculate VH[n] & VXC[n] Generate new n(r) Veff(r)= Vion(r) + VH (r) + VXC (r) Hi(r) = [-1/22 + Veff(r)] i(r) = i i(r) Calculate new n(r) = i|i(r)|2 No Self-consistent? Yes Problem solved! Can now calculate energy, forces, etc. 45 ASESMA-2010 Output Quantities (Converged) Diagonalization i, i Strictly speaking, only n(r) & Etot are “correct”. * n To get Etot: Sum over eigenvalues, correct for doublecounting of Hartree & XC terms, add ion-ion interactions. Very useful quantity! Can use to get structures, heats of formation, adsorption energies, diffusion barriers, activation energies, elastic moduli, vibrational frequencies,… 46 ASESMA-2010 Geometry Optimization Using Etot Simplest case: only have to vary one degree of freedom - e.g., structure of diatomic molecule - e.g., lattice constant of a cubic (SC, BCC, FCC) crystal Can just look for minimum in binding curve: 47 ASESMA-2010 Forces Need for geometry optimization and molecular dynamics. Could get as finite differences of total energy - too expensive! Use force (Hellmann-Feynman) theorem: - Want to calculate the force on ion I: - Get three terms: When is an eigenstate, -Substitute this... 48 ASESMA-2010 Forces (contd.) 0 • The force is now given by 0 • Note that we can now calculate the force from a • • calculation at ONE configuration alone – huge savings in time. If the basis depends upon ionic positions (not true for plane waves), would have extra terms = Pulay forces. should be exact eigenstate, i.e., scf well-converged! Input parameter tprnfor 49 ASESMA-2010 An Outer Loop: Ionic Relaxation Inner SCF loop for electronic iterations Move ions Outer loop for ionic iterations Forces =0? Structure Optimized! 50 ASESMA-2010 Geometry Optimization With Forces 0 • Especially useful for optimizing internal degrees of freedom, surface relaxation, etc. calculation = ‘relax’ • Choice of algorithms for ionic relaxation, e.g., steepest descent, BFGS. NAMELIST &IONS Input parameter ion_dynamics 51 ASESMA-2010 Structure of the input file 52 ASESMA-2010 Input file: namelists 53 ASESMA-2010 Input file: namelists 54 ASESMA-2010 Input file: input_cards 55 ASESMA-2010 Input file: input_cards 56 ASESMA-2010 Input file: a simple example 57 ASESMA-2010