36
Benasque 2004 Numerical methods 1 Numerical methods (I & II) Introduction : from equations to computer programs Algorithms for minimization/self-consistency • Pseudopotentials/Planewaves The ABINIT software Warning : here we focus on the time-independent problems (needed before going to TD considerations)

Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 1

Numerical methods (I & II)

• Introduction : from equations to computerprograms

• Algorithms for minimization/self-consistency• Pseudopotentials/Planewaves• The ABINIT software

Warning : here we focus on the time-independent problems(needed before going to TD considerations)

Page 2: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 2

The Kohn-Sham orbitals and eigenvaluesNon-interacting electrons in the Kohn-Sham potential :

external pot. Hartree pot. Exchange-correlation pot.

Density

To be solved self-consistently !

Alternative formulations ...

-12

— 2 + vKS(r r )È

Î Í ˘

˚ ˙ y i(r r ) = ei y i(

r r )

n(r r ) = y i*(r r ).y i(

r r )i=1

N

Â

vKS(r r ) = vext (r r ) +

n(r r ' )r r ' -r r Ú dr r '+

dExc n[ ]dn(r r )

vKS(r r )

y i(r r )

n(r r )

Page 3: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 3

Variational (minimum) principle for theeigenfunctions/eigenvalues

ˆ H y i = ei y iOr, using Dirac notations :

Lowest eigenfunction can be found by a minimum principlefor the expectation value of the eigenenergy

min y0T ˆ H y0

T = e0T

under constraint

y0T y0

T =1

Lowest eigenvectors can be found by a minimum principlefor the expectation value of the sum of eigenenergies

min y iT ˆ H y i

T

i

N

 = eiT

i

N

 under constraints

y iT y j

T = dij

-12

— 2 + vKS(r r )È

Î Í ˘

˚ ˙ y i(r r ) = ei y i(

r r )

(T stands for "trial")

Page 4: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 4

Variational (minimum) principlefor the electronic energy

the self-consistent solution of the Kohn-Sham system of equations is equivalent to the minimisation of

under constraints of orthonormalization

for the occupied orbitals. Also, the self-consistency for thepotential can be dissociated from the solution of the Schrödinger equation. The Kohn-Sham potential is then the one that minimizes

Building upon the variational principle for the wavefunctions,

Eel vKST[ ] = ENSC vKS

T[ ] + vext (r r ) - vKS

T (r r )( )n vKST[ ](r r )Ú dr r + EHxc n vKS

T[ ][ ]†

y iT y j

T = dij

Eel y iT[ ] = y i

T

i

N

 -12

— 2 y iT + vext (

r r )nT (r r )Ú dr r + 12

nT (r r )nT (r r ' )r r - r r 'Ú dr r dr r '+Exc nT[ ]

Page 5: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 5

Finding the nuclei configuration

Within the Born-Oppenheimer approximation (BO), one determines for each possible nuclei configuration , the energy of the electrons in their ground state (or in an excited state), then one adds the interaction energy of nuclei, to get the "Born-Oppenheimer" energy

Fk ,a = -∂EBO

∂Rk ,a r R k{ }

EBOr R k{ }

r R k{ }

Classically, thanks to the principle of virtual works,

For the nuclei configuration minimizing the Born-Oppenheimer,the classical forces vanish.

Page 6: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 6

From equations to computer programs1) Choice of equations => allowed algorithms

How accurate must be the answer ? 2) Representation of equations in the computer : finite memory e.g. a discretisation of the continuous real space is needed, for

n(r r ),y i(r r ), vext (

r r ) ...

Periodic systems : the space has also infinite extension

Target accuracy : should not spoil the capabilities ofpresent-days XC functionals ! Meaning : algorithmsand representations that will introduce errors much lessthan 1-2% error for optimized geometries (bond lengths, bond angles ...). On the other hand,e.g. 1.0e-6 relative accuracy is overkilling. Typically, one tries to reach 0.1-0.3%.

Page 7: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 7

Algorithms for optimizationand self-consistency

Page 8: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 8

Algorithmics : problems to be solved

(1) Kohn - Sham equationRepresentation of v and yi : real space , planewaves , localised functions ?

Size of the system [2 atoms… 600 atoms…] + vacuum ?Dimension of the vectors 300… 100 000… (if planewaves)# of (occupied) eigenvectors 4… 1200…

(2) Self-consistency

(3) Geometry optimizationFind the positions of ions such that the forces vanish

[ = Minimization of energy ]

Current practice : iterative approaches

-12

— 2 + vKS(r r )È

Î Í ˘

˚ ˙ y i(r r ) = ei y i(

r r )

r r j{ }

r G j{ }

A x i = li x i

x i

vKS(r r )

y i(r r )

n(r r )

r R k{ }

r F k{ }

Page 9: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 9

Force calculations (I)

Response to a perturbation of the system

=> What is the energy change ?small parameter

In case of a single electronic eigenenergy ...

Perturbation theory : Hellmann - Feynman theorem

Application to a nuclear displacement :

is not needed !

Rk ,a{ } Æ Rk ,a + l dRk ,a{ }

Fk ,a = -∂en

∂Rk ,a r R k{ }

= - yn∂ ˆ H

∂Rk ,ayn

Fk ,a = -∂EBO

∂Rk ,a r R k{ }

en(1) = yn

(0) ˆ H (1) yn(0)

yn(1)

ˆ H = ˆ T + ˆ v ext

r R k{ } fi

∂ ˆ H ∂Rk ,a

=∂ˆ v ext

∂Rk ,a

Page 10: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 10

Force calculations (II)

n(r')

( can be generalized to the case of pseudopotentials)

Change of potential due to change of nuclear position

= 0 thanks to the variational principle [ The effect of constraint is not explicited here ]!

∂vext (r r )

∂Rk ,a= -

Zkr r -

r R k

3 . ra - Rk ,a( )

The Hellmann-Feynman can be generalized to Density-Functional Theory :

Warning : for finite basis sets that depend on nuclei positions (e.g. most localised basis),supplementary terms (Pulay corrections) must be added to Hellman-Feynman expression.

Easy !

vext (r r ) = -

Zk 'r r -

r R k 'k '

Â

∂Eel

∂Rk ,a r R k{ }

= n(r r ' )Ú ∂vext (r r ' )

∂Rk ,adr r '= - n(r r ' )Ú Zk

r r -r R k

3 . ra - Rk ,a( )dr r '

∂Eel

∂Rk ,a r R k{ }

=∂Eel

∂y i(r r )

∂y i(r r )

∂vext (r r ' )

dr r Ê

Ë Á

ˆ

¯ ˜ Ú

i +

∂Eel

∂vext (r r ' )

È

Î Í Í

˘

˚ ˙ ˙

Ú ∂vext (r r ' )

∂Rk ,adr r '

Page 11: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 11

Energy and forces close to the equilibrium geometry

Analysis of forces close to the equilibrium geometry, at which forces vanish,thanks to a Taylor expansion :

Moreover,

Vector and matrix notation

Let us denote the equilibrium geometry as

Rk ,a*

Rk ,a* Æ R*

Rk ,a Æ R

Fk ,a Æ F

∂ 2EBO

∂Rk ,a∂Rk ',a ' Rk ,a*{ }

Æ H†

∂Fk ',a '

∂Rk ,a= -

∂ 2EBO

∂Rk ,a∂Rk ',a '

Fk ,a = -∂EBO

∂Rk ,a

(the Hessian)

Fk ,a (Rk ',a ' ) = Fk ,a (Rk ',a '* ) +

∂Fk ,a

∂Rk ',a 'k ',a 'Â

R*{ }Rk ',a ' - Rk ',a '

*( )+ O Rk ',a ' - Rk ',a '*( )

2

Page 12: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 12

The ‘steepest-descent’ algorithm (I)

=> Iterative algorithm. Choose a starting geometry, then a parameter , and iterately update thegeometry, following the forces :

Forces are gradients of the energy : moving the atomsalong gradients is the steepest descent of the energy surface.

l

Analysis of this algorithm, in the linear regime :

Equivalent to the simple mixing algorithm of SCF (see later)

Rk ,a(n +1) = Rk ,a

(n) + lFk ,a(n)

F(R) = F(R*) - H R - R*( )+ O R - R*( )2

R(n +1) = R(n) + lF(n)

R(n +1) - R*( ) = R(n) - R*( )- lH R(n) - R*( )

R(n +1) - R*( ) = 1- lH( ) R(n) - R*( )

Page 13: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 13

The ‘steepest-descent’ algorithm (II)

Need to understand the action of the matrix (or operator)

For convergence of the iterative procedure, the"distance" between the trial geometry and the equilibriumgeometry must decrease. 1) Can we predict conditions for convergence ?2) Can we make convergence faster ?

R(n +1) - R*( ) = 1- lH( ) R(n) - R*( )

1- lH

Page 14: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 14

The ‘steepest-descent’ algorithm (III)What are the eigenvectors and eigenvalues of ?

Yes ! If l positive, sufficiently small ...

symmetric, positive definite matrix

The coefficient of is multiplied by 1- l hi

positive definite => all hi are positiveIs it possible to have |1- l hi| < 1 , for all eigenvalues ?

H

H

=∂ 2EBO

∂Rk ,a∂Rk ',a ' Rk ,a*{ }

Ê

Ë

Á Á

ˆ

¯

˜ ˜

H f i = hi f i

where f i{ } form a complete, orthonormal, basis set

Thus the discrepancy can be decomposed as

R(n) - R*( ) = ci(n)

i f i

R(n +1) - R*( ) = 1- lH( ) ci(n)

i f i = ci

(n)

i 1- lhi( )f i

H

and

f i

Iteratively :

R(n) - R*( ) = ci(0)

i 1- lhi( )(n) f i

The size of the discrepancy decreases if |1- l hi| < 1

Page 15: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 15

The ‘steepest-descent’ algorithm (IV)

The maximum of all |1- l hi| should be as small as possible.At the optimal value of l, what will be the convergence rate m ? ( = by which factor is reduced the worst component of ? )

How to determine the optimal value of l ?

As an exercise : suppose h1 = 0.2h2 = 1.0h3 = 5.0

=> what is the best value of l ?

+ what is the convergence rate m ?

R(n) - R*( ) = ci(0)

i 1- lhi( )(n) f i

R(n) - R*( )

Hint : draw the three functions |1- l hi| as a function of l. Then, findthe location of l where the largest of the three curves is the smallest. Find the coordinates of this point.

Page 16: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 16

The ‘steepest-descent’ algorithm (V)Minimise the maximum of |1- l hi|

h1 = 0.2 |1- l .0.2| optimum => l = 5h2 = 1.0 |1- l . 1 | optimum => l = 1h3 = 5.0 |1- l . 5 | optimum => l = 0.2

?

0.2 1

1

h3h2

h1

l

optimum m = |1- l 0.2| = |1- l 5|

1- l. 0.2 = -( 1- l .5)

2 - l (0.2+5)=0 => l = 2/5.2

m = 1 - 2. (0.2 / 5.2)

positive negative

Only ~ 8% decrease of the error, per iteration ! Hundreds of iterations will beneeded to reach a reduction of the error by 1000 or more.

Note : the second eigenvalue does not play any role.The convergence is limited by the extremal eigenvalues : if the parameter is toolarge, the smallest eigenvalue will cause divergence, but for that smallparameter, the largest eigenvalue lead to slow decrease of the error...

Page 17: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 17

The condition numberIn general, lopt = 2 / (hmin + hmax)

mopt = 2 / [1+ (hmax/hmin)] - 1 = [(hmax/hmin) -1] / [(hmax/hmin) +1]

Perfect if hmax = hmin . Bad if hmax >> hmin .hmax/hmin called the "condition" number. A problem is "ill-conditioned" if thecondition number is large. It does not depend on the intermediate eigenvalues.

Suppose we start from a configuration with forces on the order of 1 Ha/Bohr, andwe want to reach the target 1e-4 Ha/Bohr. The mixing parameter is optimal.How many iterations are needed ?Let us work this out for a generic decrease factor D , with "n" the number of iterations.

F(n ) ªhmax hmin -1hmax hmin +1

Ê

Ë Á

ˆ

¯ ˜

n

F(0)

D ªhmax hmin -1hmax hmin +1

Ê

Ë Á

ˆ

¯ ˜

n

n ª ln hmax hmin +1hmax hmin -1

Ê

Ë Á

ˆ

¯ ˜

È

Î Í

˘

˚ ˙

-1

ln D ª 0.5 hmax hmin( )ln 1D

(The latter approximate equality suppose a large condition number)

Page 18: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 18

Analysis of self-consistency

Natural iterative methodology (KS : in => out) :

Which quantity plays the role of a force, that should vanish at the solution ?The difference (generic name : a "residual")

Simple mixing algorithm ( ≈ steepest - descent )

Analysis ...

Like the steepest-descent algorithm, this leads to the requirement tominimize |1- l hi| where hi are eigenvalues of

(actually, the dielectric matrix)

vKS(r r )

y i(r r )

n(r r )

vin (r r ) Æy i(r r ) Æ n(r r ) Æ vout (

r r )

vout (r r ) - vin (r r )

vin(n +1) = vin

(n) + l vout(n) - vin

(n)( )

vout v in[ ] = vout v*[ ] + dvout

dvin

v in - v*( )

H

dvout

dvin

Page 19: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 19

Finding eigenfunctions of H

2) Iterative techniques : better adapted to electronic structure !

• Might focus only on the lowest eigenstates (= # bands Nbd)• TCPU a Nbd * T ( )

In particular, for plane waves, or a discretized representationon a grid, the CPU time needed to apply the Hamiltonian to a wavefunction

does not scale like a matrix-vector product Nbasis x Nbasis, but like Nbasis or Nbasis log Nbasis

H j

Label the lowest energy state as i=0, then states with increasing energy, i = 1, i = 2, i = 3 …

1) Direct methods : in a finite basis (planewaves, mesh points, localized orbitals ...)an Hamiltonian is nothing else than a matrix, that can be treated bydirect methods developed by numericians (e.g. Choleski-Householder)

• H matrix Nbasis x Nbasis• TCPU a N3

basis• Deliver all eigenvalues and eigenvectors i = 0 … (Nbasis -1)

ˆ H y i = ei y i

Page 20: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 20

The component with the largest increases the most rapidly.

After renormalisation,

Only the component with maximal eigenvalue will survive !

ei

The power method

ˆ H y i = ei y i

Suppose we want to find the eigenvector associated with the largesteigenvalue of

We start from a trial vector

yT , and apply iteratively the operator. At the end (or during the procedure, to avoid divergence), we renormalize the vector.

Analysis :

yT = ci(0)

i y i

y (1) = ˆ H yT = ci(0)ei

i y i

y (2) = ˆ H 2 yT = ci(0)ei

2

i y i

...

n Æ•lim y (n ) = ci

(0) ein

emaxn

i y i

Page 21: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 21

It is possible to optimize the convergence rate by shifting the Hamiltonian

The power and shift method

By this operation, all the eigenvalues of the Hamiltonian are shifted,while the eigenvectors are unaffected. One tries to minimize the largest absolute ratio between the wanted extremal eigenvalue and all the other eigenvalues. The condition number is now the ratio between the rangeof the smallest and largest eigenvalues, and the one of eigenvalues in which the one that is wanted is excluded.

~ ‘simple mixing’ or ‘steepest descent’

ˆ H '= ˆ H + l ˆ 1

e'= e + l ˆ 1

Other interior eigenvector/eigenvalues might be found afterwards,iteratively determining them by repeated application of the operator,coupled with orthogonalization with the already-found eigenvectors.

Page 22: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 22

How to do a better job ?

The residual vector is the nul vector at convergence in all three case.

Simple mixingSteepest descent very primitive algorithmsPuissance + schift

The information about previous iterations is completely ignoredWe already know several vector/residual pairs We should try to use them !

1) Taking advantage of the history

2) Decreasing the condition number

v(n) Æ v(n +1)

v(n), r(n )( )

R Æ F

vin Æ vout - vin

yT Æe = yT ˆ H yT

R = ˆ H - e( ) yT

Ï Ì Ô

Ó Ô

Page 23: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 23

Minimisation of the residual (I)

An excellent strategy is select the sp such as to minimize the norm of the residual (RMM =residual minimisation method - Pulay). Then one mixes part ofthe predicted residual to the predicted vector.

Suppose we know that

We try to find the best v that can be obtained by combining the latestone with its differences with other v(p) . This is equivalent to considering

What is the residual associated with v , if we make a linear approximation ?

fi The new residual is a linear combination of the old ones, with the same coefficients as those of the potential.

gives for p=1, 2 ... n

with†

v(p)

r(p)

v = sp v(p)

p=1

n

Â

1 = spp=1

n

 (like a normalisation)

r = H v - v*( ) = H sp v(p)

p=1

n

 - spp=1

n

ÂÊ

Ë Á Á

ˆ

¯ ˜ ˜ v

Ë

Á Á

ˆ

¯

˜ ˜

= sp v(p) - v*( )p=1

n

ÂÊ

Ë Á Á

ˆ

¯ ˜ ˜ = sp H v(p) - v*( )

p=1

n

 = spr(p)

p=1

n

Â

Page 24: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 24

Minimisation of the residual (II)

Characteristics of the RMM method :(1) it takes advantage of the whole history(2) it makes a linear hypothesis(3) one needs to store all previous vectors and residuals(4) it does not modify the condition number

Point (3) : memory problem if all wavefunctions are concerned, and the basis set is large (plane waves, or discretized grids). Might sometimes also be a problem for potential-residual pairs, represented on grids, especially for a large number of iterations. No problem of memory for geometries and forces.

Simplified RMM method : Anderson's method, where onlytwo previous pairs are kept.

(D.G. Anderson, J. Assoc. Comput. Mach. 12, 547 (1964))

Page 25: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 25

Modifying the condition number (I)

Back to the optimization of geometry, with the linearizedrelation between forces, hessian and nuclei configuration :

F(R) = -H R - R*( )Steepest-descent :

giving

Now, suppose an approximate inverse Hessian

H-1( )approx

Then, applying

H-1( )approxon the forces, and moving the nuclei

along these modified forces gives

R(n +1) = R(n) + l H-1( )approxF(n)

The difference between trial configuration and equilibrium configuration,in the linear approximation, behaves like

R(n +1) - R*( ) = 1 - l H-1( )approxHÊ

Ë Á

ˆ ¯ ˜ R(n) - R*( )

R(n +1) = R(n) + lF(n)

R(n +1) - R*( ) = 1- lH( ) R(n) - R*( )

Page 26: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 26

Modifying the condition number (II)

F(R) = -H R - R*( )†

R(n +1) = R(n) + l H-1( )approxF(n)

R(n +1) - R*( ) = 1 - l H-1( )approxHÊ

Ë Á

ˆ ¯ ˜ R(n) - R*( )

Notes : 1) If the approximate inverse Hessian is perfect, the optimalgeometry is reached in one step, with l =1. Thus the steepest-descent is NOT the best direction in general.

2) Non-linear effects are not taken into account. For geometryoptimization, they might be quite large. Even with theperfect hessian, one needs 5-6 steps to optimize a water molecule.3) Approximating the inverse hessian by a multipleof the unit matrix is equivalent to changing the l value.4) Eigenvalues and eigenvectors ofwill govern the convergence : the condition number can be changed. is often called a "pre-conditioner".5) Generalisation to other optimization problems is trivial. (The Hessianis referred to as the Jacobian if it is not symmetric.)

H-1( )approxH

H-1( )approx

Page 27: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 27

Modifying the condition number (III)The approximate Hessian can be generated on a case-by-case basis.

1) Geometry optimization :

The bare Hessian, the so-called interatomic force constant matrix,can be very ill-conditioned,with some nuclear displacements generating large energy changes,and other collective displacements (rotations or torsion of groups)leading to tiny energy changes.

There are excellent preconditioners: approximate force fields ! Models of the energy using 2-body [bond lengths], 3-body

[bond angles], 4-body [torsion] terms, empirically determined.

Page 28: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 28

Modifying the condition number (IV)

2) Selfconsistent determination of the Kohn-Sham potential :

The jacobian is the dielectric matrix. Lowest eigenvalue close to 1 usually. Largest eigenvalue for small close-shell molecules, and small unit cell solids, is 1.5 ... 2.5 . (Simple mixing will sometimes converge with parameter set to 1 !) For larger close-shell molecules and large unit cell insulators, the largest eigenvalue is on the order of the macroscopic dielectric constant (e.g. 12 for silicon). For large-unit cell metals, or open-shell molecules, the largest eigenvalue might diverge !

Model dielectric matrices are known for rather homogeneous systems. With knowledge of the approximate macroscopic dielectric constant,preconditioners can be made very efficient. Work is still in progressfor inhomogeneous systems (e.g. metals/vacuum systems).

Page 29: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 29

Modifying the condition number (V)

3) Preconditioning the Schrödinger equation.

The hamiltonian matrix depends strongly on the basis set.Each basis set must be examined case-by-case ...

An important case : planewaves, where the kinetic energyof short-wavelength planewaves will dominate most of the Hessian. An approximate inverse kinetic energy is easilygenerated in this case.

The approximate Hessian can be further improved by using thehistory. Large class of methods : Broyden (quasi-Newton-type), Davidson, conjugate gradients, Lanczos ... (although the three latter methods are not often presented in this way !).

Page 30: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 30

The Broyden method (in brief)

R(n +1) = R(n) - J -1( )(n)

F(n)

One starts with an approximate Jacobian (=Hessian).The inverse jacobian is updated at each step,in such a way that the new inverse jacobian is able toreproduce the result of the iteration just completed, i.e.

Iterative application of

R(n +1) - R(n) = J -1( )(n +1)

F(n +1)- F(n)( )

This provides M equations for the M*M components of the inverse jacobian. Other conditions : the change in theJacobian matrix is minimized from one step to the other.

As such : huge memory requirements (store J). However,one can reformulate the technique, and store only the history.

Page 31: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 31

The conjugategradient method(idea)

Page 32: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 32

Conjugate gradient

Minimizing a quadratic formAssociated gradient fieldIt is possible to generate a set of conjugate directions as follows.Choose a starting point, with corresponding gradientMinimize the function along the gradient direction,Compute the new gradientThe direction of the new gradient is not conjugate to the old searchdirection, but the following direction is conjugate to it :

Moreover, a set of conjugate directions might be generated by iterativelyminimizing along new search directions given by

E(X) = X.H.X /2

—E(X) = G X( ) = H.X

X(0) G(0) = G X(0)( )

X(1) = X(0) + lG(0)

G(1) = G X(1)( )

F(1) = G(1) +g (1)G(0)

g (1) = G(1).G(1)( ) G(0).G(0)( )

F(n) = G(n) +g (n )F(n -1)

g (n ) = G(n).G(n)( ) G(n -1).G(n -1)( )

Page 33: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 33

Finding the ground-state fromdamped (or viscous) dynamics.

In brief ...The variables on which the minimization is to be performed,may be made dynamical variables, with an associated kineticenergy (depending on the derivative with time). Removingkinetic energy (by viscosity or sudden stop of variables)leads to systematic convergence towards the minimum.The time is then discretized => an iterative method !

Advantages : quite stable, non-linear effects properly dealt with ; pre-conditioning is also possible ; convergence rate might be as good CG, for optimal choice of parameters

However, to be really efficient, need to combine all three iterative stages (in the Car-Parrinello spirit), and have optimal parameters. Might diverge is the time step is too large.Problems with metals.

Page 34: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 34

Convergence rate

Number of iterations needed for simple mixing, steepest descent, first-order damped dynamics, ...

n ª 0.5 hmax /hmin( )ln 1D

Number of iterations needed for conjugate gradients, RMM,Broyden, second-order damped dynamics, ...

n ª hmax hmin ln 1D

Differences in the memory needs, the stability (non-linear effects) ...

Page 35: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 35

Iterative algorithms

Ubiquitous in present-days electronic structure programs :1) determination of eigenfunctions2) self-consistency3) geometry optimization

Optimal method must : -take advantage of the history-rely on pre-conditioners

Most of cases are satisfactorily dealt with.Exception : highly inhomogeneous systems, with somemetallic response (charge sloshing problem).Might still be possible improvements, though ...

Page 36: Numerical methods (I & II) - TDDFT.org · 2019. 10. 2. · Benasque 2004 Numerical methods 5 Finding the nuclei configuration Within the Born-Oppenheimer approximation (BO), one determines

Benasque 2004 Numerical methods 36

Some referencesR.M. Martin "Electronic structure" Cambridge U. Press 2004, particularly Chapter 9 "Solving Kohn-Sham equations" ; Appendix L "Numerical Methods" ; Appendix M "Iterative methods in electronic structure". See also the many references mentioned in these chapters and appendices.

P.H. Dederichs & R. Zeller "Self-consistency iterations in electronic-structure calculations"Phys. Rev. B28, 5462 (1983)

D.D. Johnson "Modified Broyden's method for accelerating convergence in self-consistentcalculations" Phys. Rev. B28, 12807 (1988)

M.P. Teter, M.C. Payne, D.C. Allan "Solution of Schrödinger's equation for large systems",Phys. Rev. B40, 12255 (1989)

X. Gonze "Towards a potential-based conjugate gradient algorithm for order-N self-consistent total energy calculations", Phys. Rev. B54, 4383 (1996)

F. Tassone, F. Mauri and R. Car "Acceleration schemes for ab initio molecular-dynamics simulations and electronic-structure calculations". Phys. Rev. B50, 10561 (1994).