algorithms for total energy and forces in condensed-matter dft codes

26
Algorithms for Total Energy and Forces in Condensed-Matter DFT codes IPAM workshop “Density-Functional Theory Calculations for Modeling Materials and Bio-Molecular Properties and Functions” Oct. 31 – Nov. 5, 2005 P. Kratzer Fritz-Haber-Institut der MPG D-14195 Berlin-Dahlem, Germany

Upload: harper-morton

Post on 03-Jan-2016

17 views

Category:

Documents


2 download

DESCRIPTION

Algorithms for Total Energy and Forces in Condensed-Matter DFT codes. IPAM workshop “Density-Functional Theory Calculations for Modeling Materials and Bio-Molecular Properties and Functions” Oct. 31 – Nov. 5, 2005 P. Kratzer Fritz-Haber-Institut der MPG D-14195 Berlin-Dahlem, Germany. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

IPAM workshop “Density-Functional Theory Calculations for Modeling Materials and Bio-Molecular Properties and Functions”

Oct. 31 – Nov. 5, 2005

P. KratzerFritz-Haber-Institut der MPG

D-14195 Berlin-Dahlem, Germany

Page 2: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

DFT basics

Kohn & Sham (1966)

[ –2/2m + v0(r) + Veff[] (r) ]j,k(r) = j,k j,k(r)

(r) = j,k | j,k( r) |2 in daily practice:Veff[] (r) Veff((r)) (LDA) Veff[] (r) Veff((r), (r) ) (GGA)

Kohn & Hohenberg (1965)For ground state properties, knowledge of the electronic density (r) is sufficient. For any given external potential v0(r), the ground state energy is the stationary point of a uniquely defined functional

)()(][][ 00rvrdrEv F

Page 3: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Outline

• flow chart of a typical DFT code• basis sets used to solve the Kohn-Sham equations• algorithms for calculating the KS wavefunctions and KS

band energies• algorithms for charge self-consistency• algorithms for forces, structural optimization and

molecular dynamics

Page 4: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

for all k determine wavefunctions spanning the occupied space

initialize charge density

initialize wavefunctions

forces converged ?

forces small ?

construct new charge density

determine occupancies of states

energy converged ?

move ions STOP

STOPyesstatic run

yesrelaxation run or molecular dynamicsno

no

yes

yes

no

Page 5: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

DFT methods for Condensed-Matter Systems

• All-electron methods

• Pseudopotential / plane wave method: only valence electrons (which are involved in chemical bonding) are treated explicitly

1) ‘frozen core’ approximation

2) fixed ‘pseudo-wavefunction’ approximation

projector-augmented wave (PAW) method

Page 6: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Pseudopotentials and -wavefunctions

• idea: construct ‘pseudo-atom’ which has the valence states as its lowest electronic states

• preserves scattering properties and total energy differences

• removal of orbital nodes makes plane-wave expansion feasible

• limitations: Can the pseudo-atomcorrectly describe the bonding in different environments ? → transferability

Page 7: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

1. All-electron: atomic orbitals + plane waves in interstitial region (matching condition)

2. All-electron: LMTO (atomic orbitals + spherical Bessel function tails, orthogonalized to neighboring atomic centers)

3. PAW: plane waves plus projectors on radial grid at atom centers (additive augmentation)

4. All-electron or pseudopotential: Gaussian orbitals5. All-electron or pseudopotential: numerical atom-centered

orbitals6. pseudopotentials: plane waves

Basis sets used to represent wavefuntions

LCAOsLCAOs

LCAOsLCAOs

PWs

Page 8: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Implementations, basis set sizes

implementation(examples)

bulk compound

surface,oligo-peptide

1 WIEN2K ~200 ~20,000

2 TB-LMTO ~50 ~1000

3 CP-PAW, VASP, abinit 100..200 5x103…5x105

4 Gaussian,Quickstep, …

50-500 103…104

5 Dmol3 ~50 ~1000

6 CPMD, abinit, sfhingx, FHImd

100..500 104…106

Page 9: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Eigenvalue problem: pre-conditioning

• spectral range of H: [Emin, Emax]in methods using plane-wave basis functions dominated by

kinetic energy; • reducing the spectral range of H: pre-conditioning

H → H’ = (L†)-1(H-E1)L-1 or H → H’’ = (L†L)-1(H-E1)

C:= L†L ~ H-E1• diagonal pre-conditioner (Teter et al.)

;2718128

27181281623

234

xxx

xxxxC cutETx /ˆ

)2(~ 22max ecutcut mkEE

Page 10: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Eigenvalue problem: ‘direct’ methods

• suitable for bulk systems or methods with atom-centered orbitals only

• full diagonalization of the Hamiltonian matrix• Householder tri-diagonalization followed by

– QL algorithm or– bracketing of selected eigenvalues by Sturmian sequence

→ all eigenvalues j,k and eigenvectors j,k • practical up to a Hamiltonian matrix size of ~10,000

basis functions

Page 11: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Eigenvalue problem: iterative methods

• Residual vector • Davidson / block Davidson methods

(WIEN2k option runlapw -it)– iterative subspace (Krylov space)– e.g., spanned by joining the set of occupied states {j,k} with

pre-conditioned sets of residues {C―1(H-E1) j,k}– lowest eigenvectors obtained by diagonalization in the

subspace defines new set {j,k}

mmmR )( SH

Page 12: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Eigenvalue problem: variational approach

• Diagonalization problem can be presented as a minimization problem for a quadratic form (the total energy)

(1)

(2)• typically applied in the context of very large basis sets (PP-PW)• molecules / insulators: only occupied subspace is required

→ Tr[H ] from eq. (1)• metals:

→ minimization of single residua required

ionionHartreeHartreej

jtot

ionionj

jxcHartreeionjtot

EEEE

EVVVTE

kk

kkk

.,

.,, ||

kk ,, iif 1,, 1)/exp( Tkf Bii k

Page 13: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Algorithms based on the variational principle for the total energy

• Single-eigenvector methods: residuum minimization, e.g. by Pulay’s method

• Methods propagating an eigenvector system {m}:(pre-conditioned) residuum is added to each m– Preserving the occupied subspace

(= orthogonalization of residuum to all occupied states):• conjugate-gradient minimization• ‘line minimization’ of total energy

Additional diagonalization / unitary rotation in the occupied subspace is needed ( for metals ) !

– Not preserving the occupied subspace: • Williams-Soler algorithm• Damped Joannopoulos algorithm

Page 14: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Conjugate-Gradient Method

• It’s not always best to follow straight the gradient→ modified (conjugate) gradient

• one-dimensional mimi-mization of the total energy (parameter j )

)1()1(

)()(

|

|

mm

mm

mRR

RR

)1()()( mm

mm dRd

)()()1( sincos ijj

ijj

ij d

Page 15: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Charge self-consistency

• separate loop in the hierarchy (WIEN2K, VASP, ..)• combined with iterative diagonalization loop (CASTEP,

FHImd, …)‘charge sloshing’

lines of fixed

Two possible strategies:

Page 16: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Two algorithms for self-consistency

construct new charge density and potential

|| (i) –(i-1) ||= ?

(-< ?

iterative diagonalization step of for fixed

construct new charge density and potential

|| (i) –(i-1) ||= ?

|| (i) –(i-1) ||< ?

{(i-1)}→ {(i)}

STOPSTOP

YesYes

No

No

No

No

Page 17: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Achieving charge self-consistency

• Residuum:• Pratt (single-step) mixing:• Multi-step mixing schemes:

– Broyden mixing schemes: iterative update of Jacobian J

idea: find approximation to during runtimeWIEN2K: mixer

– Pulay’s residuum minimization

inj

jjin fR 2

,,,][

kkk

][ )()()1( iin

iin

iin R

i

Nij

jinj

iin

iin R ][ )()()1(

;

,

1

1

kllk

llj

j A

A ][|][ )()( l

inkinlk RRA

);(][ scR J ]);[][(1 XCHartree VVJ

Page 18: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Total-Energy derivatives

• first derivatives– Pressure – stress– forces

Formulas for direct implementation available !• second derivatives

– force constant matrix, phonons

Extra computational and/or implementation work needed !

)()()( 2nOnEnnE SCFSCF

VEp

ijij E

REF

Page 19: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Hellmann-Feynman theorem

• Pulay forces vanish if the calculation has reached self-consistency and if basis set orthonormality persists independent of the atomic positions

1st + 3rd term =

• FIBS=0 holds for pure plane-wave basis sets (methods 3,6), not for 1,2,3,5.

k

kkkkk

k HH

H,

,,,,,

, ||||||j

jjjjj

j

dR

d

dR

d

dR

ddR

dEF

kkk

k ,,,

, | jjj

j

IBS

dRdF

Page 20: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Forces in LAPW

FACTIBScoreHF FFFFFF

R

E

R

VF ionion

jj

effj

HF

k

kk,

,, ||

dSTdSTFMTr

jjj MTr

jjT

kk

kkk ,,

,,,

ˆˆ

rrr dVnF effcorecore )()(

0FACF

Page 21: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Combining DFT with Molecular Dynamics

• Born-Oppenheimer MD • Car-Parrinello MD

construct new charge density and potential

|| (i) –(i-1) ||=0 ?

|| (i) –(i-1) ||=0 ?

{(i-1)}→ {(i)}

move ions

Forces converged?

construct new charge density and potential

|| (i) –(i-1) ||=0 ?

|| (i) –(i-1) ||=0 ?

{(i-1)}→ {(i)}

move ions

Forces converged?

Page 22: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Car-Parrinello Molecular Dynamics• treat nuclear and atomic coordinates on the same footing:

generalized Lagrangian

• equations of motion for the wavefunctions and coordinates

• conserved quantity• in practical application: coupling to thermostat(s)

kkk ,,,, nn

njjj H

RE jtotjjj

,,,,,

kkkk

REL jtotjjj

,,,,,

kkkk

FRM

Page 23: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Schemes for damped wavefunction dynamics

• Second-order with damping

numerical solution: integrate diagonal part (in the occupied subspace) analytically, remainder by finite-time step integration scheme (damped Joannopoulos), orthogonalize after advancing all wavefunctions

• Dynamics modified to first order (Williams-Soler)

kkkk ,,,, )( jjjj H

kkk ,,, )( jjj H

)(,

)(,,

)1(, )ˆ()]ˆ(exp[ i

javgijjavg

ij VVVT kkkk

Page 24: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Comparison of Algorithms (pure plane-waves)

bulk semi-metal (MnAs), SFHIngx code

Page 25: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Summary

• Algorithms for eigensystem calculations: preferred choice depends on basis set size.

• Eigenvalue problem is coupled to charge-consistency problem, hence algorithms inspired by physics considerations.

• Forces (in general: first derivatives) are most easily calculated in a plane-wave basis; other basis sets require the calculations of Pulay corrections.

Page 26: Algorithms for Total Energy and Forces in Condensed-Matter DFT codes

Literature

• G.K.H. Madsen et al., Phys. Rev. B 64, 195134 (2001) [WIEN2K].• W. E. Pickett, Comput. Phys. Rep. 9, 117(1989) [pseudopotential

approach].• G. Kresse and J. Furthmüller, Phys. Rev. B 54, 11169 (1996)

[comparison of algorithms].• M. Payne et al., Rev. Mod. Phys. 64, 1045 (1992) [iterative

minimization].• R. Yu, D. Singh, and H. Krakauer, Phys. Rev. B 43, 6411 (1991)

[forces in LAPW]. • D. Singh, Phys. Rev. B 40, 5428(1989) [Davidson in LAPW].