Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is...

48
Convergence – how to get a good answer! Matt Probert Condensed Matter Dynamics Group Department of Physics, University of York, U.K. http://www-users.york.ac.uk/~mijp1

Transcript of Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is...

Page 1: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Convergence – how to get a good answer!

Matt Probert Condensed Matter Dynamics Group Department of Physics, University of York, U.K. http://www-users.york.ac.uk/~mijp1

Page 2: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Research results

n  First-principles methods may be used for subtle, elegant and accurate computer experiments and insight into the structure and behaviour of matter.

Results of First-Principles Simulations

• Results of First-Principles

Simulations

• Synopsis

Convergence

Structural Calculations

Surfaces

Defect calculations

Summary

Convergence - CASTEP Workshop: Oxford 2015 2 / 29

First-principles methods may be used for

subtle, elegant and accurate computer ex-

periments and insight into the structure

and behaviour of matter.

Structure of phase III of solid hydrogen

Chris J. Pickard and Richard J. Needs Na-

ture Physics 3, 473 - 476 (2007)

Structure of phase III of solid hydrogen Chris J. Pickard and Richard J. Needs Nature Physics 3, 473 - 476 (2007)

Page 3: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Research results

n  First-principles methods may be used for subtle, elegant and accurate computer experiments and insight into the structure and behaviour of matter.

Results of First-Principles Simulations

• Results of First-Principles

Simulations

• Synopsis

Convergence

Structural Calculations

Surfaces

Defect calculations

Summary

Convergence - CASTEP Workshop: Oxford 2015 2 / 29

First principles results may be worthless nonsense

… or worthless nonsense!

Page 4: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Overview of lecture

n  Approximations and convergence

n  CASTEP details

n  Examples

Page 5: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Approximations and convergence

Page 6: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Approximations

n  Distinguish physical approximations n  Born-Oppenheimer Approximation n  Level of Theory and XC functional

n  and convergable, numerical approximations n  basis-set size n  Integral evaluation cutoffs n  numerical approximations - FFT grid n  Iterative schemes: number of iterations and

exit criteria (tolerances) n  system size

Page 7: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Approximations

n  Scientific integrity and reproducibility: n  All methods should agree answer to (for

example) “What is lattice constant of silicon in LDA approximation” if sufficiently well-converged.

n  No ab-initio calculation is ever fully-converged! n  Need to appreciate how to acceptable level of

convergence for given level of theory

Page 8: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Basis set size

n  Basis set is fundamental approximation to get correct shape of wavefunction.

n  How accurate does it need to be? n  Variational principle guarantees we get an

upper bound on true ground state E0

n  With energy error n  With plane waves can increase size and

accuracy by adding waves with higher G n  Much harder with Gaussian basis – need to

add ad hoc ‘diffuse’ or ‘polarization’ functions

n

=(x

n

� xn�1)

T (rf (xn

)�rf (xn�1))

(rf (xn

)�rf (xn�1))

T (rf (xn

)�rf (xn�1))

E

cut

=~22m

|Gmax

|2

GG

0 =�⇢ (G)

�⇢ (G0)

GG

0 ' ↵ |G|2 �GG

0

|G|2 +G

2o

E (V ) = E0 +9V0B0

16

8<

:

"✓V0

V

◆ 23

� 1

#3

B

00 +

"✓V0

V

◆ 23

� 1

#2 "6� 4

✓V0

V

◆ 23

#9=

;

B0 = �V

@P

@V

����P=0

V0 B

00 =

@B

@P

����P=0

E = E0 +1

2k (x� x0)

2

E = E0 +L

2k�

2

� =

0

@�

xx

xy

xz

yx

yy

yx

zx

zy

zz

1

A

�E ⇠ |� |2

2

Page 9: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Properties

n  Fortunately well converged properties may frequently be computed using an incomplete basis.

n  Size of planewave basis set governed by single parameter: n cut_off_energy (in energy units) or basis_precision=COARSE/MEDIUM/FINE in CASTEP .param file

n  NB Though E is monotonic in Ecut it is not necessarily regular.

Page 10: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Error cancellation

n  Consider energetics of simple chemical reaction: MgO(s) + H2O(g) → Mg(OH)2,(s)

n  Reaction energy computed as

n  What if compute at Ecut=500 & 4000 eV? n  Change in energy of each component: ΔE(MgO)

= -0.021 eV, ΔE(H2O) = -0.566 eV, ΔE(Mg(OH)2) = -0.562 eV, error in ΔE = -0.030 eV

n  i.e. errors cancel in final result if same Ecut etc n  Energy differences converge faster than E

�n =(xn � xn�1)

T (rf (xn)�rf (xn�1))

(rf (xn)�rf (xn�1))T (rf (xn)�rf (xn�1))

Ecut =~22m

|Gmax|2

�GG0 =�⇢ (G)

�⇢ (G0)

�GG0 ' ↵ |G|2 �GG0

|G|2 +G

2o

E (V ) = E0 +9V0B0

16

8<

:

"✓V0

V

◆ 23

� 1

#3

B

00 +

"✓V0

V

◆ 23

� 1

#2 "6� 4

✓V0

V

◆ 23

#9=

;

B0 = �V

@P

@V

����P=0

V0 B

00 =

@B

@P

����P=0

E = E0 +1

2k (x� x0)

2

E = E0 +L

2k�

2

� =

0

@�xx �xy �xz

�yx �yy �yx

�zx �zy �zz

1

A

�E ⇠ |� |2

4E = Eproduct �X

Ereactants = EMg(OH)2 � E (EMgO + EH2O)

2

Page 11: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Planewave convergence

n  Properties of a plane-wave basis. n  Cutoff determines highest representable

spatial Fourier component of density. n  Energy differences converge faster than total

energies. Electron density varies most rapidly near nuclei, where min. effect on bonding

n  Ecut (and Gmax) depend on each element n  Simulation cutoff is max of all elements in calc

n  Required cutoff is system-independent but not property-independent.

Page 12: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Pseudopotentials

n  With efficient pseudopotentials rate of convergence with cutoff is not always smooth. n  Can get plateaus, etc n  Sometimes cause is over-optimization of the

pseudopotential at too low a desired cutoff. n  In which case choose criterion for convergence

energy to be plateau values. n  Absolute energy convergence is rarely

desirable. Force and stress convergence is much more useful criterion.

Page 13: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

FFT grid

n  FFT grid should be large enough to handle all G-vectors of density ρ(r), within cutoff: n  |G| ≤ 2|Gmax| n  Guaranteed to avoid ”aliasing” errors in

case of LDA and pseudopotentials without additional core-charge density.

n  LDA can often use 1.5Gmax or 1.75Gmax with little error penalty – faster and less RAM

n  GGA functionals have higher Fourier components, and so use 1.75Gmax - 2Gmax

Page 14: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

FFT grid and ultrasoft n  CASTEP can use ultrasoft pseudopotentials

n  See next week for more – faster and less RAM n  Finer grid needed for USP augmentation

charges or core-charge densities. n  CASTEP has a second, finer grid for core/

augmentation charges n  Set by parameter fine_grid_scale

(multiplier of Gmax ) or fine_gmax (inverse length Gfine) – keep Gmax for orbitals.

n  fine_gmax is transferable to other systems but fine_grid_scale is not.

Page 15: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Force convergence

n  CASTEP can do MD or geom opt with forces

Force and Stress

• Results of First-Principles

Simulations

• Synopsis

Convergence

• Approximations and

Convergence

• Convergence with basis

set

• Error Cancellation

• Plane-wave cutoff

convergence/testing

• Pseudopotentials and

cutoff behaviour

• FFT Grid parameters

• Force and Stress

• Iterative Tolerances

• K-point convergence

• Strategies for

convergence testing

• Automation of

convergence testing

• Golden rules of

convergence testing

Structural Calculations

Surfaces

Defect calculations

Summary

Convergence - CASTEP Workshop: Oxford 2015 11 / 29

Frequently need to find crystal structure at mechanical equilibrium.

• Given guessed or exptl. initial structure, seek local minimum of

Born-Oppenheimer energy surface generated by K-S functional.

• Energy minimum implies forces are zero but not vice versa.

• CASTEP provides for “geometry op-

timization” using quasi-newton meth-

ods.

• Need to worry about accuracy of

forces.

• Forces usually converge at lower cut-

off than total energy because density

in region of nucleus unimportant.400 500 600 700 800 900

Ecut (eV)-0.1

-0.08-0.06-0.04-0.02

00.020.040.060.08

0.1

Conv

erge

nce

erro

r∆E (eV)∆F (eV/A)∆P/1000 (GPa)∆P/100 (inc FSBC)

Cut-off convergence testcubic ZrO2

• different physical quantities converge at different rates.

• Always test convergence specifically of quantities of importance to your

planned calculation

n  Forces usually converge at lower Ecut than total energy as nuclear region unimportant

n  Pressure/stress different again

n  Test the convergence of each property!!!

Page 16: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Iterative solvers

n  Parameter elec_energy_tol specifies when SCF energy converged. n  Optimizer also exits if max_SCF_cycles

reached n  i.e. you must always check that it really did

find the ground state!

n  How accurate does SCF convergence need to be?

Page 17: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Solver tolerances

n  Energetics: same accuracy of result. n  Geometry/MD: need much smaller (tighter) elec_energy_tol to converge forces. n  Cost of higher tolerance is only a few

additional SCF iterations. n  Or use elec_force_tol to exit SCF only

when force convergence criterion satisfied. n  Inaccurate forces are common cause of

geometry optimization failure.

Page 18: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

SCF convergence

n  Example: E is converged in 5-6 SCF cycles n  Force is converged in 12 SCF cycles …

Iterative Tolerances

• Results of First-Principles

Simulations

• Synopsis

Convergence

• Approximations and

Convergence

• Convergence with basis

set

• Error Cancellation

• Plane-wave cutoff

convergence/testing

• Pseudopotentials and

cutoff behaviour

• FFT Grid parameters

• Force and Stress

• Iterative Tolerances

• K-point convergence

• Strategies for

convergence testing

• Automation of

convergence testing

• Golden rules of

convergence testing

Structural Calculations

Surfaces

Defect calculations

Summary

Convergence - CASTEP Workshop: Oxford 2015 12 / 29

• How to control the iterative solvers?

• Parameter elec energy tol specifies

when SCF energy converged.

• Optimizer also exits if max cycles reached –

always check that it really did converge.

• How accurate does SCF convergence need

to be?

• Energetics: same accuracy of result.

• Geometry/MD: much smaller energy toler-

ance needed to converge forces.

• Cost of higher tolerance is only a few addi-

tional SCF iterations.

• Or use elec force tol to exit SCF only

when force convergence criterion satisfied.

• Inaccurate forces are common cause of geometry optimization failure.

Iterative Tolerances

• Results of First-Principles

Simulations

• Synopsis

Convergence

• Approximations and

Convergence

• Convergence with basis

set

• Error Cancellation

• Plane-wave cutoff

convergence/testing

• Pseudopotentials and

cutoff behaviour

• FFT Grid parameters

• Force and Stress

• Iterative Tolerances

• K-point convergence

• Strategies for

convergence testing

• Automation of

convergence testing

• Golden rules of

convergence testing

Structural Calculations

Surfaces

Defect calculations

Summary

Convergence - CASTEP Workshop: Oxford 2015 12 / 29

• How to control the iterative solvers?

• Parameter elec energy tol specifies

when SCF energy converged.

• Optimizer also exits if max cycles reached –

always check that it really did converge.

• How accurate does SCF convergence need

to be?

• Energetics: same accuracy of result.

• Geometry/MD: much smaller energy toler-

ance needed to converge forces.

• Cost of higher tolerance is only a few addi-

tional SCF iterations.

• Or use elec force tol to exit SCF only

when force convergence criterion satisfied.

• Inaccurate forces are common cause of geometry optimization failure.

Page 19: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Quality of Forces/Stresses

n  Can only find a good structure if have reliable forces/stresses

n  Stresses converge more slowly than energies as increase number of plane waves n  CONVERGENCE!

n  Should also check degree of SCF convergence elec_energy_tol (fine quality ≤ 10-6 eV/atom)

can also set elec_force_tol – useful with DM Stresses converge slower than forces!

Page 20: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when
Page 21: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when
Page 22: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

K-point convergence

n  Brillouin Zone sampling is very important n  Usually set in <seed>.cell with keyword kpoint_mp_grid p q r or kpoint_mp_spacing X with optional offset kpoint_mp_offset. n  Convergence is not variational and

frequently oscillates. n  Finite-temperature smearing can accelerate

convergence, but must extrapolate result back to T=0K

Page 23: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

K-point convergence of Al

n  Even simple metals like Al require dense k-point meshes in primitive cell

n  Metals require more k-points than insulators due to occupancy discontinuity at E=EF

n  Can get some error cancellation with insulators but only if identical cells

K-point convergence

• Results of First-Principles

Simulations

• Synopsis

Convergence

• Approximations and

Convergence

• Convergence with basis

set

• Error Cancellation

• Plane-wave cutoff

convergence/testing

• Pseudopotentials and

cutoff behaviour

• FFT Grid parameters

• Force and Stress

• Iterative Tolerances

• K-point convergence

• Strategies for

convergence testing

• Automation of

convergence testing

• Golden rules of

convergence testing

Structural Calculations

Surfaces

Defect calculations

Summary

Convergence - CASTEP Workshop: Oxford 2015 13 / 29

Brillouin Zone sampling is another important convergence issue. Usually set in

<seed>.cell with keyword kpoint mp grid p q r with optional offset

kpoint mp offset.

• Convergence is not variational and fre-

quently oscillates.

• Even simple metals like Alneed dense

meshes for primitive cell.

• Finite-temperature smearing can acceler-

ate convergence, but must extrapolate the

result back to 0K.

• In case of insulators some k-point error

cancellation occurs but only between iden-

tical simulation cells.

Consequently comparative phase stabil-

ity energetics and surface energetics fre-

quently demand high degree of k-point

convergence.0 5 10 15 20 25 30

Monkhorst-Pack q-56.42

-56.41

-56.4

-56.39

-56.38

-56.37

-56.36

Ener

gy (e

V)

-56.42

-56.41

-56.4

-56.39

-56.38

-56.37

-56.36

Ener

gy (e

V)

Al k-point convergence testSmear=0.08, a0=4.04975, PBE, Ec=160eV

Page 24: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Strategies for convergence testing

Page 25: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Strategies for testing convergence

n  Tests should be simple and fast n  Make use of transferability of cut_off_energy

and grid_scale and kpoint_mp_spacing or use length scaling for k-point grids convergence

n  Test on representative small systems n  Test Ecut with coarse k-point grid n  Test k-point grids with coarse Ecut

n  Work with fixed geometry as optimization depends on details of convergence

n  Accuracy of forces a good proxy for phonon convergence

Page 26: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Automation of convergence tests

n  Recently added castepconv to the standard set of CASTEP tools n  A suite of Python programs to automate

convergence testing n  Can do cutoff energy, k-point grid and

fine_gmax n  And graph the results

Page 27: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Golden rules of convergence test

n  Change one parameter at a time n  Do not use too high an Ecut – are you

converging augmentation charges? Check fine_gmax instead

n  Use forces & stresses as proxies for other more expensive properties (e.g. phonons)

n  Write your convergence criteria in paper n  Convergence is when parameter of interest

stops changing, NOT when run out of resources or when agree with experiment!

Page 28: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Structural calculations

Page 29: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Modelling molecules

n  CASTEP has 3D periodic boundary conditions n  Surround molecule by vacuum space n  Periodic array …

Solids, molecules and surfaces

• Results of First-Principles

Simulations

• Synopsis

Convergence

Structural Calculations

• Solids, molecules and

surfaces

• Variable Volume

Calculations

• Variable Volume

Calculations -II

Surfaces

Defect calculations

Summary

Convergence - CASTEP Workshop: Oxford 2015 18 / 29

Sometimes we need to compute a non-periodic system with a PBC code.

• Surround molecule by vacuum space to model using periodic code.

• Similar trick used to construct slab for surfaces.

Page 30: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Modelling surfaces

n  Ditto – add vacuum to separate surfaces

n  But how much vacuum? Must converge it! n  And for slab, need enough layers to get to

bulk-like environment n  Another convergence parameter!

So

lid

s,

mo

lec

ule

sa

nd

su

rfa

ce

s

•R

esu

ltsofF

irst

-Pri

nci

ple

s

Sim

ula

tions

•S

ynopsi

s

Conve

rgence

Str

uct

ura

lCalc

ula

tions

•S

olid

s,m

ole

cule

sand

surf

ace

s

•V

ari

able

Volu

me

Calc

ula

tions

•V

ari

able

Volu

me

Calc

ula

tions

-II

Surf

ace

s

Defe

ctca

lcula

tions

Sum

mary

Conve

rgence

-C

AS

TE

PW

ork

shop:

Oxf

ord

2015

18

/29

So

me

time

sw

en

ee

dto

com

pu

tea

no

n-p

eri

od

icsy

ste

mw

itha

PB

Cco

de.

•S

urr

ou

nd

mo

lecu

leby

vacu

um

spa

ceto

mo

de

lusi

ng

pe

rio

dic

cod

e.

•S

imila

rtr

ick

use

dto

con

stru

ctsl

ab

for

surf

ace

s.

•M

ust

incl

ude

enough

vacu

um

space

thatperi

odic

images

do

not

inte

ract

.

So

lid

s,

mo

lec

ule

sa

nd

su

rfa

ce

s

•R

esu

ltsofF

irst

-Pri

nci

ple

s

Sim

ula

tions

•S

ynopsi

s

Conve

rgence

Str

uct

ura

lCalc

ula

tions

•S

olid

s,m

ole

cule

sand

surf

ace

s

•V

ari

able

Volu

me

Calc

ula

tions

•V

ari

able

Volu

me

Calc

ula

tions

-II

Surf

ace

s

Defe

ctca

lcula

tions

Sum

mary

Conve

rgence

-C

AS

TE

PW

ork

shop:

Oxf

ord

2015

18

/29

So

me

time

sw

en

ee

dto

com

pu

tea

no

n-p

eri

od

icsy

ste

mw

itha

PB

Cco

de.

•S

urr

ou

nd

mo

lecu

leby

vacu

um

spa

ceto

mo

de

lusi

ng

pe

rio

dic

cod

e.

•S

imila

rtr

ick

use

dto

con

stru

ctsl

ab

for

surf

ace

s.

•M

ust

incl

ude

enough

vacu

um

space

thatperi

odic

images

do

not

inte

ract

.

Page 31: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Dipolar surfaces

n  Beware polar materials and dipole surfaces n  Surface energy does not converge with slab

thickness! n  Use same cell for bulk and slab where possible

to get k-point error cancellation n  If not possible then must use absolute

converged k-point set as no error cancellation n  Can use dipole_correction=static/self-consistent with dipole_dir=x/y/z/all to correct electrostatics

Page 32: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Variable cell calculations

n  Can get equilibrium lattice parameter from min E with vol or from where stress=0 n  Stress is automated with geom opt but

converges less well than min E with Ecut

Structural Calculations 17 / 29

Solids, molecules and surfaces

Sometimes we need to compute a non-periodic system with a PBC code.

• Surround molecule by vacuum space to model using periodic code.

• Similar trick used to construct slab for surfaces.

• Must include enough vacuum space that periodic images do not interact.

• To model surface, slab should be thick enough that centre is “bulk-like”.

• Beware of dipolar surfaces. Surface energy does not converge with slab thickness.

• When calculating surface energy, try to use same cell for bulk and slab to maximise error cancellation of k-point set.

• Sometimes need to compare dissimilar cells – must use absolutely converged k-point set as no error cancellation.

Convergence - CASTEP Workshop: Oxford 2015 18 / 29

Variable Volume Calculations

• Two ways to evaluate equilibrium lattice parameter - minimum of energy or zero of stress.

• Stress converges less well than energy minimum with cutoff.

• Incomplete basis error in stress approximated by Pulay stress correction.

• “Jagged” E vs V curve due to discreteness of NPW. Can be corrected using Francis-Payne method (J. Phys. Conden. Matt 2, 4395

(1990))

• Finite-size basis corrections for energy and stress automatically computed by CASTEP.

Convergence - CASTEP Workshop: Oxford 2015 19 / 29

9

Page 33: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Finite Basis Correction

n  “Jagged” E vs V curve due to change in number of plane waves when change volume n  Gmin changes with real-space cell size n  Correct using Francis-Payne method (J. Phys.

Conden. Matt 2, 4395 (1990)) n  Use finite_basis_corr=MANUAL/AUTO

with additional finite_basis_npoints at finite_basis_spacing values of Ecut

n  Or specify basis_dE_dlogE instead.

Page 34: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Number of plane waves

n  Two possibilities when changing cell size: n  fixed basis size (fixed_NPW=true)

n Number of plane-waves NPW is constant n Cell expansion lowers Gmax and K.E. of each

plane wave, and therefore lowers effective Ecut. n Easy to code but easy to get erroneous results. n Need very well-converged cutoff for success.

n  fixed cutoff => physically correct n  reset basis every time change cell parameters n  vary NPW so as to keep Gmax and Ecut fixed

Page 35: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Surface modelling

n  Surfaces can be modelled as a slab cleaved from bulk crystal. Can calculate n  Surface energy or free energy n  Surface reconstructions n  Energies of steps n  Adsorption energies and structures of

adsorbates n  Surface chemical reaction energies.

Page 36: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Choice of surface

n  Choice of slab: usually need to make both surfaces identical.

n  Surfaces related by symmetry operation are more easily geometry optimised.

n  Simulation cell should not be optimised. (use fix_all_cell=T in .cell file ). n  In-plane cell parameters usually fixed at

values from relaxed bulk crystal. n  Perpendicular direction has extra vacuum

Page 37: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Surface convergence

n  Esurf is very sensitive to convergence of total energies. n  Sometime get k-point error

cancellation of slab vs bulk if use non-primitive bulk cell with same in-plane vectors as slab. (not CaCO3 shown).

n  Only 1 k-point in perp to slab. n  Must converge slab thickness

and vacuum gap

Surface Energy calculations

• Surface free energy defined as

Esurf = (Eslab − Ebulk)/A

A is total area of both surfaces.

• Esurf is sensitive quantity requiring well-converged total energies.

• Can sometimes gain some k-point error cancellation between slab and bulk

calcs by using non-primitive bulk cell with same in-plane vectors as slab. (not

CaCO3 101̄4 shown).

• Sometimes need to compare dissimilar cells – must use absolutely converged

k-point set as no error cancellation.

• Need only 1 k-point in direction perpendicular to slab. Any dispersion in bands

is error due to insufficient vacuum gap - no point in calculating accurately!

• Need to test convergence with both slab thickness and vacuum gap

Convergence - CASTEP Workshop: Oxford 2015 24 / 29

12

101_

4

Page 38: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Polarization in slabs

n  Electric dipoles perpendicular to surface raise theoretical difficulties n  Energy does not converge with slab thickness n  Three types of polar surface:

Polarization in slabs

• Electric dipoles perpendicular to surface raise theoretical difficulties

• Energy does not converge with slab thickness.

• P.W. Tasker (Surf. Sci 87, 315 (1979) described 3 classes of surface.

• In classical charge model, Type III unstable and must always reconstruct.

• In ab initio calculation, surfaces can instead become metallic.

• Polar molecules on surface also raise dipole-dipole problems.

• Can sometimes use double surface with inversion symmetry.

Convergence - CASTEP Workshop: Oxford 2015 25 / 29

Defect calculations 26 / 29

Defect models

Point- and extended- defects may be modelled using supercell approach. Several tricky convergence issues with supercells, to converge

defect-defect interaction to zero. See M. I. J. Probert and M. C. Payne Phys. Rev. B67 075204 (2003).

• Only need to converge energy to a few meV, but still need accuracy in forces to correctly describe strain relaxation.

• Strain relaxation. Local strain around defect decreases as 1/R.

Can model long-range strain relaxation using classical models if suitable potential exists.

• Charged defects can be modelled using periodic interaction correction terms (M. Leslie and M. Gillan, J. Phys. Cond. Mat. 18, 973

(1985))

• Corrections for higher multipoles also available G. Makov and M. C. Payne Phys. Rev. B51, 4104 (1995), L. N. Kantorovich Phys.

Rev. B60, 15476 (1999)).

Convergence - CASTEP Workshop: Oxford 2015 27 / 29

13

Page 39: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Polarization in slabs

n  In classical charge model, Type III unstable and must always reconstruct.

n  In ab initio calculation, surfaces can instead become metallic.

n  Polar molecules on surface also raise dipole-dipole problems. n  Use CASTEP dipole correction scheme

n  Can sometimes use double surface with inversion symmetry n  Dipoles cancel.

Page 40: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Defect calculations

n  Can model defects by supercell approach: n  Some tricky convergence issues to get defect-

defect interaction to zero. n  Only need to converge energy to a few meV,

but need accurate forces to get relaxation OK. n  Local strain around defect decays as 1/R. Can

use classical models if know suitable pot n  Charged defects can be modelled using

periodic interaction correction terms. Also correction terms for higher order multipoles.

Page 41: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Example: Si(100) Surface Reconstruction

Page 42: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Si(100) supercell with vacuum gap

… with added hydrogen passivation

9 layers of Silicon and 7 Ǻ vacuum

Page 43: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Convergence Tests

n  Converge cut-off energy → 370 eV n  Converge k-point sampling → 9 k-points n  Converge number of bulk layers → 9 layers n  Converge vacuum gap → 9 Å n  only then see asymmetric dimerisation:

()=best lit. value

Page 44: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Si(100) – The Movie

Page 45: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Si(100) – BFGS Progress

n  Initial slow decrease in energy due to surface layer compression. n  Then small barrier to dimer formation overcome around iteration 14. n  Then rapid energy drop due to dimerisation. n  Final barrier to asymmetric dimerisation overcome around iteration 24.

Page 46: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Summary

Page 47: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

Summary n  First principles materials modelling can give

highly accurate property values. n  Need to know how convergence error

depends on basis set, kpoints, grid, etc. n  Degree of convergence required depends on

scientific question asked … n  An over-converged calculation is costly. n  An under-converged calculation is useless. n Be systematic: use automated scripts

such as castepconv

Page 48: Convergence – how to get a good answer!mijp1/teaching/grad_FPMM/...Cost of higher tolerance is only a few additional SCF iterations. ! Or use elec_force_tol to exit SCF only when

References n  Anne E Mattson et al, “Designing meaningful density

functional theory calculation in materials science - a primer” Model. Sim. Mater. Sci Eng. 13 R1-R31 (2005)

n  M Leslie and M Gillan, “The energy and elastic dipole tensor of defects in ionic crystals calculated by the supercell method”, J. Phys. Cond. Mat. 18, 973 (1985)

n  G Makov and MC Payne, “Periodic boundary conditions in ab initio calculations”, Phys. Rev. B 51, 4014 (1995)

n  MIJ Probert and MC Payne, “Improving the convergence of defect calculations in supercells: An ab initio study of the neutral silicon vacancy”, Phys. Rev. B 67 075204 (2003)