Making Electronic Structure Theory work...2009/06/24 · Broyden-Fletcher-Goldfarb-Shannon (BFGS)...
Transcript of Making Electronic Structure Theory work...2009/06/24 · Broyden-Fletcher-Goldfarb-Shannon (BFGS)...
Making Electronic Structure Theory work
Ralf Gehrke
Fritz-Haber-Institut der Max-Planck-GesellschaftBerlin, 23th June 2009
Hands-on Tutorial on Ab Initio Molecular Simulations:Toward a First-Principles Understanding of Materials Properties and Functions
� Achieving Self-ConsistencyDensity Mixing� Linear Mixing, Pulay Mixer, Broyden Mixer
Electronic Smearing� Fermi-Dirac, Gaussian, Methfessel-Paxton
PreconditioningDirect Minimization
� Spin Polarization� Energy Derivatives� Local Atomic Structure Optimization� Outlook on Global Structure Optimization
Outline
� Achieving Self-Consistency� Spin Polarization
Fixed Spin vs. Unconstrained Spin Calculation� Energy Derivatives� Local Atomic Structure Optimization� Outlook on Global Structure Optimization
Outline
Outline� Achieving Self-Consistency� Spin Polarization� Energy Derivatives
Atomic ForcesNumeric vs. Analytic Second DerivativeVibrational Frequencies
� Local Atomic Structure Optimization� Outlook on Global Structure Optimization
Outline� Achieving Self-Consistency� Spin Polarization� Energy Derivatives� Local Atomic Structure Optimization
Steepest DescentConjugate GradientBroyden-Fletcher-Goldfarb-Shannon (BFGS)Cartesian vs. Internal Coordinates
� Outlook on Global Structure Optimization
Outline� Achieving Self-Consistency� Spin Polarization� Energy Derivatives� Local Atomic Structure Optimization� Outlook on Global Structure Optimization
Achieving Self-Consistency
Density Mixing
�hKS���2
2�V eff � n in
��� ,r �
�hKS �l ���l �l �
R nin����nout
� ��n in��� ,r ��n in
���r��� n �r �
� n ���� n�2 d3r � � ?
finished !
n in�0�
yes
no
nout���r���
l�l
2 �r �
Achieving Self-Consistency
Density Mixing
charge sloshing !
N2 = 1.1 Å PBE
nin��1 ��nout
��
�hKS���2
2�V eff � n in
��� ,r �
�hKS �l ���l �l �
R nin����nout
� ��n in��� ,r ��n in
���r��� n �r �
� n ���� n�2 d3r � � ?
nin��1 ��� nout
����1���nin��
finished !
n in�0�
yes
no
nout���r���
l�l
2 �r �
Achieving Self-Consistency
Density Mixing
Let's try some damping...
Achieving Self-Consistency
Density Mixing
�=0.5
N2 = 1.1 Å PBE
nin��1 ��� nout
����1���nin��
seems to work !
�hKS���2
2�V eff � n in
��� ,r �
�hKS �l ���l �l �
R nin����nout
� ��n in��� ,r ��n in
���r��� n �r �
� n ���� n�2 d3r � � ?
nin��1 �� f �nin
�� ,n in��1� ,n in
��2 �,�,nout�� ,nout
��1 �,nout� j�2 � ,��
finished !
n in�0�
yes
no
nout���r���
l�l
2 �r �
Achieving Self-Consistency
Density Mixingbut we can still do better...
�hKS���2
2�V eff � n in
��� ,r �
�hKS �l ���l �l �
R nin����nout
� ��n in��� ,r ��n in
���r��� n �r �
� n ���� n�2 d3r � � ?
nin��1 �� f �nin
�� ,n in��1� ,n in
��2 �,�,nout�� ,nout
��1 �,nout� j�2 � ,��
finished !
n in�0�
yes
no
nout���r���
l�l
2 �r �
Achieving Self-Consistency
Density Mixing
?
but we can still do better...
Achieving Self-Consistency
Density Mixing
N2 = 1.1 Å PBE
Achieving Self-Consistency
The Pulay Mixer
ninopt��
�n in
� � ���1
� take more previous densities into account under the constraint of norm conservation
P. Pulay, Chem. Phys. Lett. 73 (1980), 393
Achieving Self-Consistency
The Pulay Mixer
ninopt��
�n in
� � ���1
R ninopt ��R� �n in
� ���� �R n in���
� take more previous densities into account under the constraint of norm conservation
� main assumption: the charge density residual is linear w.r.t. to the density
P. Pulay, Chem. Phys. Lett. 73 (1980), 393
Achieving Self-Consistency
The Pulay Mixer
ninopt��
�n in
� � ���1
R ninopt ��R� �n in
� ���� �R n in���
�
��l��R nin
opt � R n inopt �����
���0
� take more previous densities into account under the constraint of norm conservation
� main assumption: the charge density residual is linear w.r.t. to the density
� coefficients � are determined by minimizing the residual
system of equations for �
P. Pulay, Chem. Phys. Lett. 73 (1980), 393
Achieving Self-Consistency
The Pulay Mixer
nin�1 � nin
�2� nnin
opt
�R R�R1�R n in
�1 ��R2�R nin
�2 � �
�R n inopt � R n in
opt � ���� R1��1���R2�2
� illustration in one dimension with two densities
P. Pulay, Chem. Phys. Lett. 73 (1980), 393
Achieving Self-Consistency
The Pulay Mixer
nin�1 � nin
�2� nnin
opt
�R R�R1�R n in
�1 ��R2�R nin
�2 � �
�R n inopt � R n in
opt � ���� R1��1���R2�2
nin��1 ��n in
opt�� R n inopt �nin
�1 �
nin�2�
ninopt
n true
xnin�3�
� illustration in one dimension with two densities
� to prevent trapping in subspace, add fraction of residual
P. Pulay, Chem. Phys. Lett. 73 (1980), 393
Achieving Self-Consistency
The Pulay Mixer
nin��1 ��n in
opt� �GR ninopt � �G�A k2
k2�k 02
preconditioning matrix:
� additional preconditioner might accelerate convergence
P. Pulay, Chem. Phys. Lett. 73 (1980), 393
long-range components of density changes are stronger damped than short-range
G. Kerker, Phys. Rev. B 23 (1981), 3082
Achieving Self-Consistency
The Pulay Mixer
n� � r ��n�� r� n� � r ��n�� r�
nin��1 ��n in
opt� �GR ninopt � �G�A k2
k2�k 02
preconditioning matrix:
�R n� ,n� � R n� ,n� � ����� d r �� n� �
2�r � � n� �r��nout
� �n in� � , �r ���n in
� �r�
� additional preconditioner might accelerate convergence
long-range components of density changes are stronger damped than short-range
� two spin channels are to be mixed in the case of spin polarization
charge density: spin density:
combine both channels to one matrix !
stable convergenceP. Pulay, Chem. Phys. Lett. 73 (1980), 393
G. Kerker, Phys. Rev. B 23 (1981), 3082
Achieving Self-Consistency
The Broyden Mixer
f �xn�� f �x n�1� f ' �x n��xn�xn�1�
f �xn�1��! 0
xn�1�x n�1f ' �xn�
f �x n�xn�1xn
xn�1
f �xn�
f �xn�1�
secant method
Achieving Self-Consistency
The Broyden Mixer
f �xn�� f �x n�1� f ' �x n��xn�xn�1�
f �xn�1��! 0
xn�1�x n�1f ' �xn�
f �x n�
n in��1 ��n in
���G�� Rn in� ��
� nin���G���Rn in
� ���0
xn�1xnxn�1
f �xn�
f �xn�1�
secant method
approximate Jacobian:
D.D. Johnson, Phys. Rev. B 38 (1988), 12807
Achieving Self-Consistency
The Broyden Mixer
f �xn�� f �x n�1� f ' �x n��xn�xn�1�
f �xn�1��! 0
xn�1�x n�1f ' �xn�
f �x n�
n in��1 ��n in
���G�� Rn in� ��
� nin���G���Rn in
� ���0�
�Gij!G��1 ��G� �!�0
G��1��G� ��� �n ����G�� �R�� � � ��R��
xn�1xnxn�1
f �xn�
f �xn�1�
secant method
approximate Jacobian:
under-determined
“as little change as possible”
D.D. Johnson, Phys. Rev. B 38 (1988), 12807
Achieving Self-Consistency
The Broyden Mixer
f �xn�� f �x n�1� f ' �x n��xn�xn�1�
f �xn�1��! 0
xn�1�x n�1f ' �xn�
f �x n�
n in��1 ��n in
���G�� Rn in� ��
� nin���G���Rn in
� ���0�
�Gij!G��1 ��G� �!�0
G��1��G� ��� �n ����G�� �R�� � � ��R��
E�w0!G��1��G��!
2��
iwi!� n
�i ��G��1��R�i �!2
xn�1xnxn�1
f �xn�
f �xn�1�
secant method
approximate Jacobian:
under-determined
“as little change as possible”
modified Broyden: minimize
D.D. Johnson, Phys. Rev. B 38 (1988), 12807
Achieving Self-Consistency
Electronic Smearing� level crossing may lead to charge sloshing
EF
�i
��
�i �i
��1� ��2 � .......
EF n�r���l
N occ
�l2 �r �
Achieving Self-Consistency
Electronic Smearing� level crossing may lead to charge sloshing
EF
�i
��
�i �i
��1� ��2 � .......
EF
EF
�i �i �i
EF
f l f l f l1 1 1
� electronic smearing softens the change of electronic density
n�r���l
N occ
�l2 �r �
n�r���lf l�l
2�r�
Achieving Self-Consistency
Electronic Smearing
f � ��E F� �� 1
exp ����E F�"���1Fermi-Dirac1:
f � ��E F� ��1
2 �1�erf ��EF� ��Gaussian2:
f 0�x ��12�1�erf �x ��
f N �x �� f 0� x���m�1
N
Am H2m�1�x �ex2
Methfessel-Paxton3:
N#$%�x �
x���EF�
1 N. Mermin, Phys. Rev. 137 (1965), A14412 C.-L. Fu, K.-H. Ho, Phys. Rev. B 28 (1983), 54803 M. Methfessel, A. Paxton, Phys. Rev. B 40 (1989), 3616
Achieving Self-Consistency
Electronic Smearing
&E { c}, { f }�&E { c}� � &E� f i n0
'0
� Kohn-Sham functional not a variational quantity anymore
Achieving Self-Consistency
Electronic Smearing� Kohn-Sham functional not a variational quantity anymore
� electronic free energy F is variational
&E { c},{ f }�&E { c}� � &E� f i n0
'0
F�E�� S �� ,{ f n}�
entropy term
� F� f i n0
�0
Achieving Self-Consistency
Electronic Smearing
� F� f i n0
�0F�E�� S �� ,{ f n}�
F ����E��0�( O��
2�
O�� 2�N �E��0 (
12�F ����E ����
1N�2
��N�1�F ����E ����
� Kohn-Sham functional not a variational quantity anymore
� electronic free energy F is variational
� systems with continuous density of states at the Fermi edge:
Fermi-Dirac / Gaussian
Methfessel-Paxton
desired total energy E for zero smearing can be backextrapolated
entropy term
&E { c},{ f }�&E { c}� � &E� f i n0
'0
M. Methfessel, A. Paxton, Phys. Rev. B 40 (1989), 3616 M. Gillan, J. Phys.: Condens. Matter 1 (1989), 689
F. Wagner, T. Laloyaux, M. Scheffler, Phys. Rev. B 57 (1998), 2102
Achieving Self-Consistency
Alternative: Direct Minimization
� &E� �)l
� gl �� f l � �hKS��l � )l �
)l��1� �� )l����� gl �
&E�EKS��l�l ��)l )l��1 ��EF ��l f l�N �
EKS
()l *
Etot
gl �
� constrained minimum of Kohn-Sham functional:
� gradient:
� steepest-descent:
Spin Polarization
Fixed Spin vs. Unconstrained Spin
EF�
EF� EF
N��i �
f i� � �i��EF
w �N ���i
f i� � �i
��EF�
w � N ���i
f i�� �i
��EF�
w �M��
i� f i
�� fi� �M�N ��N �
total spin is relaxedtotal multiplicity kept fixed
�12�2�V eff
� �r ��)i���i� )i� V XC� �r ��
� EXC
� n� �r�
Spin Polarization
Co3 PBE
obtained with unconstrained spin
fixed spin
obtained multiplicity the lowest one
Fixed Spin vs. Unconstrained Spin
Energy Derivatives
Atomic Forces
E tot�min(c* �E
KS��i��i� ��)i � )i� ��1��� &E (c0 (R�**, (� (R�**, (R�*�
� total energy of the system is the total minimum of the Kohn-Sham-functional under the normalization constraint:
� &E� (c* c�c
0
�0� &E� (�* c�c
0
�0
Energy Derivatives
Atomic Forces
E tot�min(c* �E
KS��i��i� ��)i � )i� ��1��� &E (c0 (R�**, (� (R�**, (R�*�
� total energy of the system is the total minimum of the Kohn-Sham-functional under the normalization constraint:
� since the Kohn-Sham-functional is variational, only the partial derivative remains:
F� ��d E tot
dR��
=� �&E
�R���(c
0*
� &E� (c0*+
=0
�(c0*
� R���
(�*
� &E�(�*+
=0
� (�*
�R�
=� �&E
�R���
�EKS
�R�� �
�R��i��i� � �)i� )i� ��1�
� &E� (c* c�c
0
�0� &E� (�* c�c
0
�0
Energy Derivatives
The Individual Force Contributions
FHF ,��Z ��,'�
Z,R���R,
R��R, 3�Z��d r n �r � R��r
R��r 3
FPulay ,���2�l� � ��l��R� �hKS��l� �l��
FMP ,���� d r �n � r ��nMP� r���V H n
MP ��R��
FGGA ,����d r n �r�� �XC
� � n 2
� � n 2
�R�
� classical Coulomb interaction:
� Pulay-correction due to incomplete or nuclear-dependent basis set:
“moving basis functions”
� Multipole-correction due to “incomplete” Hartree-potential:
“moving multipole components”
� gradient-dependency of exchange-correlation energy in case of a GGA functional:
Energy Derivatives
The Convergence of the Forces� total energy is variational error in the density enters total energy to second order
� atomic forces are not variational error in the density enters total energy to first order
convergence of atomic forces more expensive than total energy
� &E� (c* c�c
0
�0
�F�� (c* c�c
0
��2 &E
�R� � (c* c�c0'0N-N (d=1.0 Å)
total energyforces
Energy Derivatives
Forces and Electronic Smearing
&E { c},{� }, {R }, { f } ,EF�� &E� f i n0
'0
F���d E tot
dR��
=� �&E
�R���
( f *
� &E�( f *+'0
� ( f *�R�
�� &E� EF+
= 0
�EF�R�
'�� &E�R�
� F� f i n0
�0 F���� F�R�
� Kohn-Sham functional not variational w.r.t. the occupation numbers
atomic forces are not consistent with the total energy of the system !
atomic forces are consistent with the electronic free energy
M. Weinert and J.W. Davenport, Phys. Rev. B 45 (1992), 13709 R.M. Wentzcovitch, J.L. Martin and P.B. Allen, Phys. Rev. B 45 (1992), 11372
Energy Derivatives
The Second Derivative and Vibrations
F� ��� &E�R��
� first derivative was simple
analytical
Energy Derivatives
The Second Derivative and Vibrations
F� ��� &E�R��
� first derivative was simple
� second derivative more nasty
analytical
e.g. A. Komornicki and G. Fitzgerald, J. Chem. Phys. 98 (2), 1398 (1993)
H� ,�d2 E tot
dR� dR,��d F�dR,
��2 &E
�R� �R,��
(c*
� 2 &E�R� � (c *
�(c0*
�R,
Energy Derivatives
The Second Derivative and Vibrations
F� ��� &E�R��
H� ,�d2 E tot
dR� dR,��d F�dR,
��2 &E
�R� �R,��
(c*
� 2 &E�R� � (c *
�(c0*
�R,
�(c*
�2 E� (c*2
� (c0*
�R���
�2 E�R� �(c *
� first derivative was simple
� second derivative more nasty
� set of coupled equations needs to be solved
analytical
e.g. A. Komornicki and G. Fitzgerald, J. Chem. Phys. 98 (2), 1398 (1993)
Energy Derivatives
The Second Derivative and Vibrationsnumerical
d F�d R,
F� �R , , 0����F��R, , 0���
2�R, ,0
M � -R���ddR�
E �(R*� E �(R*��E �(R0*��12��,
d2 Ed R�d R, (R 0*
u�u, u��R��R� , 0
u� �t ��u� ei. t det �H�,�.2M� ��! 0
vibrations
talk by Gert von Helden, Friday, 26th June, 11:30, “Fingerprinting molecules: Vibrational Spectroscopy, Experiment and Theory”
Local Atomic Structure OptimizationPotential Energy Surface (PES)
E tot � (R�*�
Local Atomic Structure OptimizationPotential Energy Surface (PES)
E tot � (R�*�
Local Atomic Structure Optimization
R� , i�1�R� ,i��i F�� (R� , i*�
Steepest Descent
Local Atomic Structure Optimization
R� , i�1�R� ,i��i F�� (R� , i*�
Steepest Descent
(R�*
too small �too large �
Local Atomic Structure Optimization
R� , i�1�R� ,i��i F�� (R� , i*�
Steepest Descent
(R�*
too small �too large �
ill-conditioned PES might lead to zig-zag behaviour
Local Atomic Structure Optimization
R� , i�1�R� ,i��i F�� (R� , i*�
R� , i�1�R� ,i��iG� ,i �(R� , i*� G
� ,i�F� ,i�,iG� ,i�1 ,iFletcher-Reeves�
F� , i/ F� ,i
F� , i�1/ F� ,i�1
Steepest Descent
Conjugate Gradient(R�*
too small �too large �
� take information of previous search directions into account
ill-conditioned PES might lead to zig-zag behaviour
,iPolak-Ribiere�
F� , i/ �F� , i�F� ,i�1�F� , i�1/ F� ,i�1
0
� constructions of search directions based upon the assumption that PES is perfectly harmonic
line minimization
Local Atomic Structure Optimization
The Broyden-Fletcher-Goldfarb-Shanno Method
(R�*
f �x �� f �x i���x�xi�/� f �xi��12�x�xi�/A/�x�x i���
� f �x��� f �xi��A/�x�x i���
� f �x��! 0 x�xi��A��1/� f �x i�
Newton-Method:� additional to the atomic forces, the Hessian is taken into account:
W. H. Press et al., Numerical Recipes, 3rd Edition, Cambridge University Press
Local Atomic Structure Optimization
The Broyden-Fletcher-Goldfarb-Shanno Method
R� , i�1�R� ,i��iG� ,i �(R� , i*�
(R�*
f �x �� f �x i���x�xi�/� f �xi��12�x�xi�/A/�x�x i���
� f �x��� f �xi��A/�x�x i���
� f �x��! 0 x�xi��A�1/� f �x i�
Newton-Method:
� “Quasi”-Newton-Scheme: inverse Hessian is approximated iteratively
G� ,i�HiF� , i
H0�1 R� , i�1�R� ,i�Hi�1 /�F� , i�F� ,i�1� Hi�1� Hi��
� additional to the atomic forces, the Hessian is taken into account:
� 1 1 perfectly harmonic PES is assumed� line minimization
W. H. Press et al., Numerical Recipes, 3rd Edition, Cambridge University Press
Local Atomic Structure Optimization
Cartesian vs. Internal Coordinates
d1
d2
2
(R1 ,R2 ,R3 *# (q1 , q2 , q3* q1�d1 q2�d 2 q3�2
q�B �R�R0 �
P. Pulay, G. Fogarasi, F. Pang, J.E. Boggs, J. Am. Chem. Soc. 101, 2550 (1979)
(3N-6) x (3N) 3 not invertable !R�R �q � difficult!
Local Atomic Structure Optimization
Cartesian vs. Internal Coordinates
d1
d2
2
(R1 ,R2 ,R3 *# (q1 , q2 , q3* q1�d1 q2�d 2 q3�2
E�E0��i)i qi�
12�ijFij qi q j�
16�ijkFijk qi q j qk��
q�B �R�R0 �
P. Pulay, G. Fogarasi, F. Pang, J.E. Boggs, J. Am. Chem. Soc. 101, 2550 (1979)
)i���E�qi
Fijk�� �3E� qi� q j� qk
(3N-6) x (3N) 3 not invertable !R�R �q � difficult!
as “simple” as possible
faster convergence of the local geometry optimizer
Local Atomic Structure Optimization
Inverse-Distance Coordinates
J. Baker, P. Pulay, J. Chem. Phys. 105 (24), 11100 (1996)
P.E. Maslen, J. Chem. Phys. 122, 014104 (2005)
� appropriate for weekly bound systems
R
Local Atomic Structure Optimization
Inverse-Distance Coordinates
J. Baker, P. Pulay, J. Chem. Phys. 105 (24), 11100 (1996)
P.E. Maslen, J. Chem. Phys. 122, 014104 (2005)
� appropriate for weekly bound systems
R
q� 1R
�E� q��
� E�R/R2
�2E� q2
��2 E� R2
/R4�2 �E� R/R3
Local Atomic Structure Optimization
Inverse-Distance Coordinates
J. Baker, P. Pulay, J. Chem. Phys. 105 (24), 11100 (1996)
P.E. Maslen, J. Chem. Phys. 122, 014104 (2005)
� appropriate for weekly bound systems
R
q� 1R
�E� q��
� E�R/R2
�2E� q2
��2 E� R2
/R4�2 �E� R/R3
R� , i�1�R� ,i��iG� ,i �(R� , i*�
displacements are accelerated for large interatomic distances
Global Structure OptimizationPotential Energy Surface (PES)
E tot � (R�*�
Global Structure OptimizationPotential Energy Surface (PES)
E tot � (R�*�
Global Structure Optimization
D. J. Wales, J. P. K. Doye, M. A. Miller, P. N. Mortenson, and T. R. Walsh, Adv. Chem. Phys. 115, (2000)
Z. Li, and H. A. Scheraga, Proc. Natl. Acad. Sci. U.S.A. 84, 6611 (1987)
Basin-Hopping� random variations of atomic coordinates followed by local structural relaxations
� many different flavours of “trial moves” possible
Global Structure Optimization
further methods...� Genetic Algorithms1:
two “parents” mate and create a “child”
the fittest (energetically lowest) children “survive”
talk by Matt Probert, Friday, 26th June, 9:00, “Structure predictions in materials science”
1D. M. Deaven, K. M. Ho, Phys. Rev. Lett. 75, 288 (1995)
� Minima-Hopping, Basin-Paving, Conformational Space Annealing,...
Summary� How to get Etot in DFT
density-mixing schemes (Pulay, Broyden)direct minimization
� Taking the derivative of Etot
atomic forcesmolecular vibrations
� What to do with Etot and its derivativelocal structural relaxation (steepest-descent, conjugate gradient, BFGS)global structure optimization (Basin-Hopping, Genetic Algorithms,...)
Summary� How to get Etot in DFT
density-mixing schemes (Pulay, Broyden)direct minimization
� Taking the derivative of Etot
atomic forcesmolecular vibrations
� What to do with Etot and its derivativelocal structural relaxation (steepest-descent, conjugate gradient, BFGS)global structure optimization (Basin-Hopping, Genetic Algorithms,...)
Let's do it !!
today, 14:00 – 18:00first practical session
lecture hall