DFT in practice - th.fhi-berlin.mpg.de

91
DFT in practice Sergey V. Levchenko Fritz-Haber-Institut der MPG, Berlin, DE

Transcript of DFT in practice - th.fhi-berlin.mpg.de

Page 1: DFT in practice - th.fhi-berlin.mpg.de

DFT in practice

Sergey V. Levchenko

Fritz-Haber-Institutder MPG, Berlin, DE

Page 2: DFT in practice - th.fhi-berlin.mpg.de

Outline

• From fundamental theory to practical solutions

• General concepts:

- basis sets - integrals and grids, electrostatics, molecules and clusters versus periodic systems- scalar relativity- solution of the eigenvalue problem

Page 3: DFT in practice - th.fhi-berlin.mpg.de

Equations to be solved

Hohenberg-Kohn theorems

� � → �� → Ψ ��,��,…,��; {�} → �[�],…Electron density

� � = ��Ψ∗ �,��,…,��; {�} Ψ �,��,…,��; {�} ���� …����

�� �� � − � �� � ��� − � = 0 → � � ,�,�…

Variational principle:

� � −?

Page 4: DFT in practice - th.fhi-berlin.mpg.de

� = Ψ �� Ψ = −�

�∫Ψ∗ ��,��,… ∑

��

����

���� Ψ ��,��,… � � −

−∫Ψ∗ ��,��,… ∑��

������,� Ψ ��,��,… � � +

+∫Ψ∗ ��,��,… ∑�

������,� Ψ ��,��,… � � =

= −�

�∫

���� �,��

���������

��� − ∫� � ∑��

����� ��� + ∫

� �,��

����������′

Equations to be solved

with one- and two-particle density matrices:

�� �,�� = �Ψ∗ �,��,… Ψ �′,��,… ���� …����

� �,�� = �Ψ∗ �,�′,�� … Ψ �,�′,��,… ���� …����

Problem: kinetic energy and electron-electron interaction energy as a functional of �(�) -- ?

Page 5: DFT in practice - th.fhi-berlin.mpg.de

Equations to be solved

Kohn-Sham approach:

�������� + ���� = −�

�∑ �� ∫��

∗ � ���� � ���� +

∫� � �(��)

����������� + ���[�]

where functions �� represent the density: � � = ∑ �� �� � ��

�� �� � − � ∫� � ��� − � = 0 →

���∗ �

� � − ∑ �� �� �� − 1� = 0 →

(Generalized) Kohn-Sham equations:

−��

�+ ���� � + ∫

� ��

�������� �� � + ∫���,�[{�}] �,�� �� �� ���� =

= ���� �

Page 6: DFT in practice - th.fhi-berlin.mpg.de

Solving Kohn-Sham equations

−��

�+ ���� � + ∫

� ��

�������� �� � + ∫���,�[{�}] �,�� �� �� ���� =

= ���� �

Page 7: DFT in practice - th.fhi-berlin.mpg.de

Initial guess: e.g. density

Calculate potential

Construct Hamiltonian

Obtain new eigenvalues, eigenvectors, and density

Converged?Update density / density matrix

(mixer, preconditioner)

Update potential

Yes

No

n0

V0

n j

nj+1= nj+f(Δn)

V j+1

Self-consistent field method

Page 8: DFT in practice - th.fhi-berlin.mpg.de

When is the calculation finished?• Answer: When „property“ does not change

Convergence

Convergence threshold Very strictVery loose

Typical „properties“ to converge:

Change of the density n

Change of the sum of eigenvalues

Change of the total energy

Options differ between codes

Page 9: DFT in practice - th.fhi-berlin.mpg.de

Initial guess: e.g. density

Calculate potential

Construct Hamiltonian

Obtain new eigenvalues, eigenvectors, and density

Converged?Update density / density matrix

(mixer, preconditioner)

Update potential

Yes

No

n0

V0

n j

nj+1= nj+f(Δn)

V j+1

Self-consistent field method (SCF)

Page 10: DFT in practice - th.fhi-berlin.mpg.de

Importance of the initial guessElectronic structure exhibits multiple minima

• Qualitatively different behavior depending on guess

• Common issue for magnetic solids

1O2

3O2

Initial guess

Page 11: DFT in practice - th.fhi-berlin.mpg.de

Importance of the initial guessElectronic structure exhibits multiple minima

• Qualitatively different behavior depending on guess

• Common issue for magnetic solids

1O2

3O2

How do we find „the right“ initial guess?

Initial guess

Page 12: DFT in practice - th.fhi-berlin.mpg.de

Random initialization• Traditional approach (for bandstructure

codes)

Initial guess

Page 13: DFT in practice - th.fhi-berlin.mpg.de

Superposition of spheric atomicdensities

• Most common (for bandstructure codes)

Initial guess

Page 14: DFT in practice - th.fhi-berlin.mpg.de

Extended Hückel Model [1]

Semi-empirical method:

- Linear combination of atomic orbitals

- Hamiltonian parameterized:

- Density from orbitals:

Initial guess

[1] R. Hoffmann, J Chem. Phys (1963), 1397; [2] R. S. Mulliken, J. Chem. Phys. (1946) 497; [3] M. Wolfsberg and L. Helmholtz, J. Chem. Phys (1952), 837

Page 15: DFT in practice - th.fhi-berlin.mpg.de

Initial guess: e.g. density

Calculate potential

Construct Hamiltonian

Obtain new eigenvalues, eigenvectors, and density

Converged?Update density / density matrix

(mixer, preconditioner)

Update potential

Yes

No

n0

V0

n j

nj+1= nj+f(Δn)

V j+1

Self-consistent field method (SCF)

Page 16: DFT in practice - th.fhi-berlin.mpg.de

Calculate new density from Kohn-Sham orbitals

Replace old density by new density

nnn jj =1

Example: H2, d=1.5Å, projected in 1 dimension

Density Update

Naive Mixing

Page 17: DFT in practice - th.fhi-berlin.mpg.de

Calculate new density from Kohn-Sham orbitals

Replace old density by new density

nnn jj =1

Example: H2, d=1.5Å, projected in 1 dimension

Density Update

Naive Mixing

Typically does not work

- Best case: Osciallating, non-converging results- Worst case: Bistable, apparently converged

solution

Page 18: DFT in practice - th.fhi-berlin.mpg.de

Calculate new density from Kohn-Sham orbitals

Replace old density by new density

Example: H2, d=1.5Å, projected in 1 dimension

Density Update

Linear Mixing

nnn jj = a1

Page 19: DFT in practice - th.fhi-berlin.mpg.de

Calculate new density from Kohn-Sham orbitals

Replace old density by new density

Example: H2, d=1.5Å, projected in 1 dimension

Density Update

Linear Mixing

nnn jj = a1

Page 20: DFT in practice - th.fhi-berlin.mpg.de

Calculate new density from Kohn-Sham orbitals

Replace old density by new density

Example: H2, d=1.5Å, projected in 1 dimension

Density Update

Linear Mixing

nnn jj = a1

Page 21: DFT in practice - th.fhi-berlin.mpg.de

Calculate new density from Kohn-Sham orbitals

Replace old density by new density

Example: H2, d=1.5Å, projected in 1 dimension

Density Update

Linear Mixing

nnn jj = a1

system dependent

No clear recipe to choose ideal α

Guaranteed convergence

Page 22: DFT in practice - th.fhi-berlin.mpg.de

[1] P. Pulay, Chem. Phys. Lett. 73 , 393 (1980).

Density Update

Define residual:

Change between input and output density

Predict residual of next step from previous steps

Idea: obtain b minimizing norm ∫���� � � ����

Pitfall: Only use limited number of previous steps

Pulay Mixing [1](Direct Inversion of Iterative Subspace)

Page 23: DFT in practice - th.fhi-berlin.mpg.de

[1] P. Pulay, Chem. Phys. Lett. 73 , 393 (1980).

Density Update

Construct „optimal density“ minimizing residual norm, form new density

Learning from previous steps

Ideal case: convergence independent of a

Rules of thumb:

- a = 0.2 .. 0.6 for insulators

- a = 0.05 for metals

Pulay Mixing [1](Direct Inversion of Iterative Subspace)

Page 24: DFT in practice - th.fhi-berlin.mpg.de

[1] P. Pulay, Chem. Phys. Lett. 73 , 393 (1980).

Density Update

Construct „optimal density“ minimizing residual norm, form new density

Learning from previous steps

Ideal case: convergence independent of a

Rules of thumb:

- a = 0.2 .. 0.6 for insulators

- a = 0.05 for metals

Pulay Mixing [1](Direct Inversion of Iterative Subspace)

Much faster than linear mixing

No guarantee for congerence

Page 25: DFT in practice - th.fhi-berlin.mpg.de

Kerker (charge) preconditioning

Problem: Charge Sloshing

Charge „bounces“ back and forth

(Lack of) balance between long-range and short-range charge re-distribution

Typical for metals

Often encountered in „defective“ systems Localized defects (vacancies, interstitials)

Surfaces, Slabs, Thin Films

Density Update

Page 26: DFT in practice - th.fhi-berlin.mpg.de

Charge preconditioning

Solution: Make α depend on ��(�)

Concept:

Treat density change in Fourier space:

Damp long-range oscillations:

Density Update

���� � = �� � + �Δ� � → ����� � = ��� � + �Δ�� �

�� � =1

�� � ��������

q0: Screening parameter

q >> q0: G ≈ a

Normal mixing

q << q0: G ≈ aq2/q02

Damping

� = ���

�� + ���

Page 27: DFT in practice - th.fhi-berlin.mpg.de

Charge preconditioning

Density Update

8 layer Al slab, PBE calculation

no a priori known ideal choice for q0

Reasonable guess fromThomas-Fermi:

q0: Screening parameter� = ���

�� + ���

Page 28: DFT in practice - th.fhi-berlin.mpg.de

A special problem: Metallic systems

Density Update

http://www.phys.ufl.edu/fermisurface/periodic_table.html

Metallic properties determined by Fermi surface

Fermi-surface: Collection of k-points at which e = eFermi

At eFermi occupation changes from 1 to 0

Problem: Frequent „level switching“ during SCF

Page 29: DFT in practice - th.fhi-berlin.mpg.de

A special problem: Metallic systems

Density Update

Solution: Replace step function by a more smooth function

Methfessel-Paxton [3]

[1] N. Mermin, Phys. Rev.137 , A1441 (1965).[2] C.-L. Fu, K.-H. Ho, Phys. Rev. B 28 , 5480 (1983). [3] M. Methfessel, A. Paxton, Phys. Rev. B 40 , 3616 (1989).

Gaussian [2]

Fermi [1]

Page 30: DFT in practice - th.fhi-berlin.mpg.de

A special problem: Metallic systems

Density Update

Physical implications:

• States become fractionally occupied

• In DFT, well defined as ensemble average

• Broadening is not electron temperature (except: Fermi)

Numerical Implications

• Level switching is damped

• Much faster convergence

• Total energy now dependson σ, no longer variational

• Back-extrapolation possible

Cu (111), 5 layer slab, Gaussiansmearing, PBE calculation, 12x12x1 k-points

Pitfall: Adsorption of molecules

Page 31: DFT in practice - th.fhi-berlin.mpg.de

Summary SCF

Ground state electron density determined iteratively

Initial guess needs initial thought, can change results qualiatively

Density update by– Linear mixing (slow)

– Pulay mixing

Convergence acceleration by – Preconditioner

– Broadening of states

Page 32: DFT in practice - th.fhi-berlin.mpg.de

Representing KS states: Basis sets

Page 33: DFT in practice - th.fhi-berlin.mpg.de

The tool for this workshop: FHI-aims (NAOs)

Page 34: DFT in practice - th.fhi-berlin.mpg.de

Our choice: Numeric atom-centered basis functions

Page 35: DFT in practice - th.fhi-berlin.mpg.de

Our choice: Numeric atom-centered basis functions

Page 36: DFT in practice - th.fhi-berlin.mpg.de

Constructing a basis-set library

Page 37: DFT in practice - th.fhi-berlin.mpg.de

Iterative selection of NAO basis functions

Page 38: DFT in practice - th.fhi-berlin.mpg.de

Result: Hierarchical basis set library for all elements

Page 39: DFT in practice - th.fhi-berlin.mpg.de

Accuracy: (H2O)2 hydrogen bond energy

Page 40: DFT in practice - th.fhi-berlin.mpg.de

Basis-set superposition error (BSSE)

By construction, our NAO basis sets are close to completeness for very small BSSE for atomic dimers

Page 41: DFT in practice - th.fhi-berlin.mpg.de

Basis-set superposition error (BSSE)

Page 42: DFT in practice - th.fhi-berlin.mpg.de

Using numeric atom-centered basis functions

Page 43: DFT in practice - th.fhi-berlin.mpg.de

Numeric atom-centered basis functions: Integration

Page 44: DFT in practice - th.fhi-berlin.mpg.de

Overlapping atom-centered grids: “Partitioning of unity”

Page 45: DFT in practice - th.fhi-berlin.mpg.de

Integration in practice: Large systems - small errors!

Page 46: DFT in practice - th.fhi-berlin.mpg.de

Hartree potential (electrostatics): Overlapping multipoles

Page 47: DFT in practice - th.fhi-berlin.mpg.de

Electrostatics: convergence with ����

Page 48: DFT in practice - th.fhi-berlin.mpg.de

Periodic systems

Page 49: DFT in practice - th.fhi-berlin.mpg.de

Structure optimization

Page 50: DFT in practice - th.fhi-berlin.mpg.de

Global structure search

Born-Oppenheimer energy surface can contain several minima– Constitution isomery

– Configuration isomery

– Conformation isomery

– Polymorphism

50

• System in equilibrium is given by ensemble average over all minima

• Often dominated by global minimum (but watch out for tautomers)

Page 51: DFT in practice - th.fhi-berlin.mpg.de

Global structure search

Methods to find the global minimum:

o Basin Hopping

o Molecular dynamics: o Simulated annealing

o Minima Hopping

o Metadynamics

o Cluster expansion

o Genetic algorithm

o Diffusion methods

Page 52: DFT in practice - th.fhi-berlin.mpg.de

Local structure optimization

Once we have a reasonable guess, find closest minimum

Different approaches possible:– Mapping of the potential energy surface

• Requires a lot of calculations

• Typically only for dynamics

52

dCC

aCCO

Page 53: DFT in practice - th.fhi-berlin.mpg.de

Local structure optimization

Once we have a reasonable guess, find closest minimum

Different approaches possible:– Mapping of the whole potential energy surface

– Gradient free method: e.g., simplex

– Gradient-based methods

• Calculate gradient (a.k.a. „forces“)

� = −��

��

Page 54: DFT in practice - th.fhi-berlin.mpg.de

Total energy gradient

Search for minimum by following the gradient

��

��= �

���

��� +

���

���� � + � ��

���

��

������������������

= �� ∑�� �����

������� + �� ∫

� � ����

���� � ���

��=

��

��

��+

��

��

��• First term vanishes

• Second term survives foratom-centered basis functions Pulay forces

(vanish when basis set approaches completeness)

Page 55: DFT in practice - th.fhi-berlin.mpg.de

Total energy gradient

Search for minimum by following the gradient

Additional contributions from atom-centeredapproximations– Multipole expansion

– Relativistic corrections

– (Integration grids)

All straightforward but lengthy

Once we have the Force, how do we find the minimum?

��

��= �

���

��� +

���

���� � + � ��

���

��

Page 56: DFT in practice - th.fhi-berlin.mpg.de

Geometry update – Steepest descent

Follow negative gradient to find minimum

Step-length α variable

Guaranteed but slow convergence

Oscillates near minimum

Not suitable for saddle points

Improved versions exists– Line minimization

(optimal step length)

– Conjugated gradient [1]

[1] M. Hestenes, E. Stiefel (1952). "Methods of Conjugate Gradients for Solving Linear Systems"

Page 57: DFT in practice - th.fhi-berlin.mpg.de

Geometry update – (Quasi)Newton Methods

Approximate PES by quadratic function

Find minimum:

Newton: calculate exact HExpensive! Cheaper method needed

... Hessian

[1] J. Nocedal and S. J. Wright, “Numerical optimization” (Springer, 2006)

� Δ� ≈ � �� +��

�������

Δ� +�

�∑

���

�����������

������

−� ��

Page 58: DFT in practice - th.fhi-berlin.mpg.de

Geometry update – (Quasi)Newton Methods

Approximate PES by quadratic function

Find minimum:– Newton: calculate exact H

– Quasi-Newton: approximate H

• Update as search progresses [1]

[1] J. Nocedal and S. J. Wright, “Numerical optimization” (Springer, 2006)

... Hessian

� Δ� ≈ � �� +��

�������

Δ� +�

�∑

���

�����������

������

−� ��

Page 59: DFT in practice - th.fhi-berlin.mpg.de

Geometry update – (Quasi)Newton Methods

Guess initial Hessian

Simple choice: Scaled unit matrix

Chemically motivated choice (e.g.: Lindh [1])

[1] R. Lindh et al. , Chem. Phys. Lett. 241 , 423 (1995).

streching

bending

torsion

k parameterized [1]

Update as search progresses [2]

[2] J. Nocedal and S. J. Wright, “Numerical optimization” (Springer, 2006)

Page 60: DFT in practice - th.fhi-berlin.mpg.de

Geometry update – (Quasi)Newton Methods

Initial Hessian is critical for performance

May even influence result

(combination with convergence thresholds)

Courtesy of Elisabeth Wruss

Diagonal Hessian Model Hessian (Fischer)

Lower in energy

Page 61: DFT in practice - th.fhi-berlin.mpg.de

Challenges of Quasi-Newton Methods

Soft degrees of freedom can cause large ΔR

Step control needed:– Line search method: If new point is worse than old, interpolate

– Trust radius method

• Enforce upper limit for ΔR

• Evaluate quality of quadratic model

• Adjust ΔRmax based on q

Page 62: DFT in practice - th.fhi-berlin.mpg.de

Conclusions

(Global optimization: PES feature-rich, methods to find global minima exist)

Local geometry optimization: Follow gradient– Hellman-Feynman from moving potentials

– Pulay from moving basis functions

– + additional terms

Quasi-Newton method de-facto standard– Requires approximation and update of Hessian

– Step control by line search or trust radius method

Page 63: DFT in practice - th.fhi-berlin.mpg.de

Vibrations in the harmonic approximation

Page 64: DFT in practice - th.fhi-berlin.mpg.de

Why calculating vibrations?

Vibrations give important information about the system:– Classification of stationary points (minimum / saddle point)

– If saddle-point: Provides search direction

– Thermodynamic data

• Zero-point energy

• Partition sum

• Finite-temperature effects

– Connection to experiment:

• Infrared intensities: derivative of dipole moment

• Raman intensities: derivative of polarizabilty

Page 65: DFT in practice - th.fhi-berlin.mpg.de

How good is the harmonic approximatino?

Morse-potential:

Morse:

Harmonic oscillator:

Harmonic osc.

Page 66: DFT in practice - th.fhi-berlin.mpg.de

How good is the harmonic approximation?

Morse-potential:

Morse:

Harmonic oscillator:

Harmonic osc.

Morse:

Harmonic osc.

Reasonable modelfor small displacements(~10% of bond length)

Maximum displacement:

About 0.1Å at roomtemperature

Page 67: DFT in practice - th.fhi-berlin.mpg.de

Vibrations

Expand Energy in Taylor series:

Hessian H

Page 68: DFT in practice - th.fhi-berlin.mpg.de

Interpretation of results:

• Single negative ω: Transition state

Calculating Vibrations

Solve Newton‘s equations of motion:– Exponential ansatz:

– Leads to generalized eigenvalue problem:

�~���/���

Page 69: DFT in practice - th.fhi-berlin.mpg.de

From vibrations to thermodynamics

Partition function

Free energy for finite temperature

Hessian from geometry optimization is not sufficent– Analytic second derivative using perturbation theory [1]

– Numerical differentiation

• Computationally very expensive

• Contains parameter (displacement), needs to be checked carefully

• Often single displacement is not sensible to sample all vibrations

[1] S. Baroni et al. , Rev. Mod. Phys. 73 , 515 (2001).

Page 70: DFT in practice - th.fhi-berlin.mpg.de

Conclusions

Often calculated in harmonic approximation

Yield information about stability of geometry

Required for temperature effects

Anharmonic effects via molecular dynamics

Page 71: DFT in practice - th.fhi-berlin.mpg.de

Relativity

Page 72: DFT in practice - th.fhi-berlin.mpg.de

Simple approximation to scalar relativity

Page 73: DFT in practice - th.fhi-berlin.mpg.de

Simple approximation to scalar relativity

Page 74: DFT in practice - th.fhi-berlin.mpg.de

Fixing ZORA

Page 75: DFT in practice - th.fhi-berlin.mpg.de

Atomic ZORA and scaled ZORA in practice

Page 76: DFT in practice - th.fhi-berlin.mpg.de

Computational scaling: two subproblems

Page 77: DFT in practice - th.fhi-berlin.mpg.de

CPU time versus system size

Page 78: DFT in practice - th.fhi-berlin.mpg.de

CPU time versus system size

Page 79: DFT in practice - th.fhi-berlin.mpg.de

Parallel eigenvalue solvers - the problem

Page 80: DFT in practice - th.fhi-berlin.mpg.de

Parallel eigenvalue solvers - the problem

Page 81: DFT in practice - th.fhi-berlin.mpg.de

A massively-parallel dense eigensolver: ELPA

Page 82: DFT in practice - th.fhi-berlin.mpg.de

The key improvement: two-step trigonalization

Page 83: DFT in practice - th.fhi-berlin.mpg.de

The key improvement: Two-step trigonalization

Page 84: DFT in practice - th.fhi-berlin.mpg.de

ELPA: Performance

Page 85: DFT in practice - th.fhi-berlin.mpg.de

ELPA: Performance (Cray XC30, 2013)

Page 86: DFT in practice - th.fhi-berlin.mpg.de

Generalized Kohn-Sham DFT: Exact exchange

Page 87: DFT in practice - th.fhi-berlin.mpg.de

Resolution of identity (RI)

Page 88: DFT in practice - th.fhi-berlin.mpg.de

Hybrid functionals -- scaling with system size

Periodic GaAs, HSE06 hybrid functional

Page 89: DFT in practice - th.fhi-berlin.mpg.de

Hybrid functionals -- CPU scaling

Periodic GaAs, HSE06 hybrid functional

Page 90: DFT in practice - th.fhi-berlin.mpg.de

Summary

Page 91: DFT in practice - th.fhi-berlin.mpg.de

Our approach to all-electron simulations: FHI-aims

Volker Blum(Duke Univ.)

Igor Ying Zhang (FHI)

Karsten Reuter (TU Munich)

Patrick Rinke (Aalto Univ., Finland)

Ville Havu (Aalto Univ., Finland)