Lecture 15: Structural Calculations and Pressure

of 36/36
The Nuts and Bolts of First-Principles Simulation Durham, 6th-13th December 2001 Lecture 15: Structural Calculations and Pressure CASTEP Developers’ Group with support from the ESF ψ k Network
  • date post

    02-Oct-2021
  • Category

    Documents

  • view

    1
  • download

    0

Embed Size (px)

Transcript of Lecture 15: Structural Calculations and Pressure

lecture15.PDFFirst-Principles Simulation
CASTEP Developers’ Group
with support from the ESF ψk Network
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 2
Overview of Lecture
r Why bother?
r How does it work?
r Damped MD in CASTEP
r BFGS in CASTEP
r Conclusions
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 3
Why bother?
r Want to find ground state of system l Need to minimise energy of electronic structure at fixed ionic
positions and then optimise the ionic positions and/or the unit cell shape and size (particularly if external pressure applied)
l Theoretical minimum depends on choice of pseudopotential, plane-wave cut-off energy, choice of XC functional, etc.
l Often not exactly the same as experiment! Fully converged calculation should get agreement to better than 1%
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 4
What Can It Tell You?
r Equilibrium bond lengths and angles
r Equilibrium cell parameters
r Elastic constants
r Surface reconstructions
r Starting point for many advanced investigations …
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 5
How Does It Work?
r Electrons adjust instantly to position of ions so have a multi-dimensional potential energy surface and want to find global minimum l Treat as an optimisation problem
l Simplest approach is steepest descents
l More physical approach is damped MD
l More sophisticated approaches are conjugate gradients or BFGS
l Could use simulated annealing to avoid getting stuck in local minima
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 6
Steepest Descents (I)
r Simplest minimiser
l Step downhill in direction of local steepest gradient using trial step length
l Line minimisation to find the optimal step length
l Repeat to convergence
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 7
Steepest Descents (II)
Enlargement of a single step showing the line
minimisation in action – the step continues until the local energy starts to rise again whereupon a new direction is selected which is orthogonal to
the previous one
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 8
Steepest Descents (III)
l Reliable – will always get to the minima eventually
r Disadvantages
l Can get stuck in local minima
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 9
Damped MD (I)
r Improved Steepest Descents
l Move ions using velocities as well as forces e second-order equation of motion e more efficient than steepest descents
l Need to add damping term ‘-γv’ to forces
l Initially v=0
l Use physical insight to get ‘optimal damping’ factor and to
adjust the time step s.t. get rapid convergence
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 10
Damped MD (II)
x
t
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 11
Damped MD (III)
r Advantages l Easy to code, robust, much more efficient than either steepest
descents or simulated annealing
l Can do with Car-Parrinello or conjugate gradient minimisation of electrons.
l If not CP then can accelerate the ab initio part of the calculation using wavefunction extrapolation
r Disadvantages l Convergence rate depends on damping factor
l Can get stuck in local minima
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 12
Conjugate Gradients (I)
r Improved Steepest Descents
l Moves ions according to the gradient with a line minimisation to find the best step length
l But not just the locally steepest gradient – constructs a direction which is conjugate to all previous directions so it does
not undo earlier minimizations at later times e big improvement in rate of convergence
l See previous talks on electronic minimisation strategies for details
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 13
Conjugate Gradients (II)
The initial search direction is given by steepest
descents. Subsequent search directions are constructed to be orthogonal to the previous and all prior search directions.
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 14
Conjugate Gradients (III)
r Advantages
l Rapid rate of convergence – in a quadratic energy landscape, each iteration should converge one degree of freedom
l Low storage requirements
l More complex to code and cannot use with CP
l No knowledge of the Hessian explicitly generated
l Can get stuck in local minima
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 15
BFGS (I) r Basic idea:
l Energy surface around a minima is quadratic in small displacements and so is totally determined by the Hessian matrix A (the matrix of second derivatives of the energy):
l so if we knew A then could move from any nearby point to the minimum in 1 step!
( ) ( )minmin
2
1
2
1
2
11
2
2
δ
O
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 16
BFGS (II)
l We do not know A a priori
l Therefore we build up a progressively improving approximation to A (actually H=A-1) as we move the ions
according to the BFGS (Broyden-Fletcher-Goldfarb-Shanno)
algorithm.
l Also known as a quasi-Newton or variable metric method.
r Positions updated according to:
iii
iii
FHX
XXX
= +=+ λ1
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 17
BFGS (III)
r In a perfectly quadratic system then λ=1 is the optimal step length. In a real system need a line minimization to
find the optimal λ:
start
trial
best
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 18
BFGS (IV)
l Mathematically equivalent to BFGS
l Less tolerant of round-off error or inexact line minimisation
r Direct Hessian Method l Calculates A rather than H
l Uses Cholesky decomposition to keep similar speed but should guarantee that A remains non-singular. Very rare problem in practice.
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 19
BFGS (V)
( ) ( ) ( ) ( )
UUFFHFFHH
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 20
BFGS (VI)
r Advantages
l Extra physical information generated from Hessian
r Disadvantages
l Complex to code and cannot use with CP
l Storage of Hessian ~ (number d.o.f.)^2 which is prohibitive for electronic problem but OK for ionic
l Can get stuck in local minima
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 21
Simulated Annealing (I)
r Stochastic method
l Always accept steps that go downhill in energy
l Sometimes accept uphill steps depending on Boltzman factor combining energy change with current temperature of system
l Progressively reduce temperature and iterate to ground state



− −
< =
− −

EE
EE
p
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 22
Simulated Annealing (II)
U(x)
x
start
stop
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 23
Simulated Annealing (III)
l Reasonably immune to local minima
r Disadvantages
l Exceedingly slow to converge
l Need to be careful in cooling rate so as not to quench and trap in local minimum if too fast, and not to waste too much time if too slow.
l Cannot guarantee will find exact global minimum
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 24
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 25
Damped MD in CASTEP (I)
r Need to calculate damping γ that corresponds to critical damping
l For simple harmonic oscillator, this can be found from the characteristic
frequency ω0
l For a system with a dominant natural mode then this can be found and
used to set γ l As convergence is approached, the mode with largest ω will be converged
first whereupon γ can be re-evaluated to accelerate the convergence of the slower modes
l In the same way, the time step of the MD can be linked to the dominant
mode ω and therefore progressively increased as convergence is approached.
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 26
Damped MD in CASTEP (II)
r CASTEP has several different algorithms for calculating the optimal γ and time step
r Whilst it is to be expected that BFGS will be superior, experience has shown that the old CASTEP BFGS can sometimes be beaten l Although DMD will require more iterations than BFGS, each one will be
cheaper because of wavefunction extrapolation
l Sometimes it is more stable and succeeds in finding a minimum where old CASTEP BFGS fails
r A useful fall-back but not so necessary with new CASTEP and the improved BFGS algorithm? Need more experience to tell!
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 27
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 28
BFGS in old CASTEP (I)
r Simultaneous optimisation of ions and positions e seeks to minimise the enthalpy H=E+p
r Works in space of cell parameters (a,b,c,α,β,γ) and ionic positions with optional external pressure
r Convergence criteria l Simultaneous convergence in enthalpy, RMS force, RMS stress
component, RMS displacement of ions but has ‘escape route’ if everything except stress is converged
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 29
BFGS in old CASTEP (II)
r Problems
l Uses DFP not BFGS update
l Uses heuristic for step length rather than rigorous line minimisation
l Starts with initial H = I (unit matrix)
l Periodically resets H to I to reduce error accumulation whether strictly necessary or not
l Does not guarantee that a step will go down in enthalpy
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 30
BFGS in new CASTEP (I) r Also seeks to minimise the enthalpy H=E+p r Works in space of fractional ionic positions and strains with optional
external pressure l Unified approach allows better strain/coordinate coupling
r Does rigorous line minimisation to find optimal step length l Only recalculate ground-state at the new structure if sufficiently different to the trial
structure
l Also quadratic step if necessary
r Builds up H using BFGS update
r Only reset H if run out of search directions
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 31
BFGS in new CASTEP (II)
r Starts with more complex initial guess at H l Block diagonal using input/default guess at bulk modulus (B) for cell part
and input / default guess at the characteristic frequency (ω0) for the ionic part
l Guaranteed to preserve symmetry if so desired
r Analyse H to get updated estimates for B and ω0
r Only allows ‘uphill’ steps if all else has failed (including resetting H)
r Stringent convergence criteria l Simultaneous convergence in enthalpy, max. modulus of force on any ion,
max. component of stress tensor, max. displacement of any ion
l Over a ‘window’ of successive iterations
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 32
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 33
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 34
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 35
Future Directions
r Redundant Internal Coordinates
l Transform to normal coordinates and then only optimise the non-redundant degrees of freedom
l Recent theoretical breakthrough in application to crystals/extended systems
l Need to see how it compares to the new BFGS
r Variable cell damped MD
Nuts and Bolts 2001 Lecture 15: Structural Calculations and Pressure 36
Conclusions
r Two independent algorithms have been implemented within new CASTEP for structural optimisation
r Damped MD l Can be very efficient depending on γ l Only works with fixed cell parameters (so far!)
r BFGS l Can do either/or/both ionic positions and cell parameter
optimisation