The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing...

16
The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP Developers’ Group with support from the ESF k Network

description

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1 Some Elementary Checks  Has the run iterated to the ground state? Did it converge or run out of iterations? If problems, try a different minimizer.  Is the cohesive energy sensible? Should be close to experimental values from tables.  Total Energy should be extensive quantity. Do calculation of bulk energy in large cell and compare with unit.  Is surface energy reasonable?  Are forces close to zero for bulk solid ? N.B. perturb atoms away from special points as it may be maximum! -- will reveal input errors and program bugs.

Transcript of The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing...

Page 1: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

The Nuts and Bolts of First-Principles Simulation

Durham, 6th-13th December 2001

10: Testing Testing. Basic procedure to “validate” calculations

CASTEP Developers’ Groupwith support from the ESF k Network

Page 2: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Not a Black Box: the need to test. Are your input files correct? Many different convergence parameters and

tolerances. Always a tradeoff between degree of

convergence and accuracy. Full convergence is usually prohibitively expensive.

Electronic minimizers not foolproof. Some cases hard to converge, eg metal surfaces.

Schettino's Law. (All programs contain bugs!)

Page 3: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Some Elementary Checks Has the run iterated to the ground state? Did it

converge or run out of iterations? If problems, try a different minimizer.

Is the cohesive energy sensible? Should be close to experimental values from tables.

Total Energy should be extensive quantity. Do calculation of bulk energy in large cell and compare with unit.

Is surface energy reasonable? Are forces close to zero for bulk solid? N.B.

perturb atoms away from special points as it may be maximum!

-- will reveal input errors and program bugs.

Page 4: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Outline Not a black box: the need for testing Some elementary tests What number do you want?

Convergence parameters SCF Tolerance Plane-wave cutoff. Brillouin-Zone sampling

Page 5: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Convergence and Accuracy

How accurately do you need to know the energy to test your hypothesis?

Sensitivity of different tasks. SCF Tolerance Plane-wave cutoff, Gmax, Ecut and grid.

Finite basis-set correction. Density of BZ k-point sampling Error cancellation

Page 6: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

SCF Tolerance Parameter elec_energy_tol is convergence

criterion for exit from electronic minimizer. N.B. Ensure max_SCF_cycles not reached.

How accurate does it need to be? Case 1. Cohesive energy: same as accuracy of

result. Case 2. Geometry optimization: smaller

tolerance required to converge forces. Cost of higher tolerance is small; a few additional

SCF iterations since convergence is exponential.

Page 7: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Total energy is variational functional of density, but forces are not.E totH º n 2 But F Hº n

Page 8: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Plane-wave cutoff Cutoff determines highest representable spatial

fourier component of density. n(r) varies most rapidly near nucleus. Gmax depends only on types of atoms, not

number. Required cutoff is largest of any PSP in system.

E cut=2 / 2 mG max

2

Page 9: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Cutoff and Error Cancellation Detailed form of orbitals near nucleus has small

effect on bonding. Therefore energy differences converge much faster with cutoff than absolute energy.

Compute time varies as In practice, calculations are almost never fully

converged with cutoff energy. Strategy: test cutoff convergence on small, bulk

system, preferably with symmetry. Then very high cutoffs can be used at reasonable cost.

Warning: don't rely on uniform convergence behaviour. There are plateaus!

N pwHG max3 H E c

1.5

Page 10: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Error Cancellation Reaction energy. Energy diffs 500->4000eV MgO: 0.021eV H2O: 0.566eV Mg(OH)2: 0.562eV Reaction: 0.030eV

MgO s ƒ H 2 O g Ô Mg OH 2

Page 11: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Grid parameters Params grid_scale and fine_gmax set size of FFT

grid. FFT grid should be large enough to accommodate

all G-vectors of density, n(r), within cutoff: GRID_SCALE parameter sets this ratio, 1.75 by

default. Guaranteed to avoid "aliasing" errors with value 2,

but can get away with lower depending on XC functional.

Values as low as 1.5 have been used with LDA, but beware if using GGAs.

Finer grid may me necessary to represent augmentation charges with USPs for some elements. Set by FINE_GMAX parameter.

G „ 2G max

Page 12: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Finite basis-set corrections

Page 13: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Consistency of Energy and Stress

Page 14: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Brillouin-Zone Sampling Like cutoff, number of k-points used to sample

BZ is a convergence parameter. Unlike cutoff, inadequate sampling can give

either higher or lower energy. Also unlike cutoff, sampling required is a

function of simulation cell used. (Because it is specified in fractional k-space co-ordinates).

Therefore you can not rely on error cancellation between calculations using different cells.

Insulators typically require few k-points for large systems.

lim N kp ΠE =E tot

Page 15: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Metals In case of metals, kp-points must be

sufficient to model band occupancy as well as dispersion, ie represent the fermi surface.

In case of simple metals a smallish grid will do.

Pathalogical case such as hcp Zn may require 5000 or more k-points to represent fermi surface features. An 8X8x8 k-point grid gives wrong value for c/a!

Page 16: The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 10: Testing Testing. Basic procedure to “validate” calculations CASTEP.

Nuts and Bolts 2001 Lecture 10: Testing, testing. 1

Application to various tasks Cohesive energies Phase Stability Chemical Reaction Geometry optimization Unit cell optimization MD