Libxc a library of exchange and correlation functionals
1. Libxc
a library of exchange and correlation functionals
Miguel A. L. Marques
1LPMCN, Universit´e Claude Bernard Lyon 1 and CNRS, France
2European Theoretical Spectroscopy Facility
March 2009 – ABINIT Workshop
M. A. L. Marques Libxc
2. Why the need for libxc?
The xc functional is at the heart of DFT
There are many approximations for the xc (probably of the
order of 150–200)
Most computer codes only include a very limited quantity
of functionals, typically around 10–15
Chemist and Physicists do not use the same functionals!
Difficult to reproduce older calculations with older
functionals
Difficult to reproduce calculations performed with other
codes
Difficult to perform calculations with the newest functionals
M. A. L. Marques Libxc
3. Why the need for libxc?
The xc functional is at the heart of DFT
There are many approximations for the xc (probably of the
order of 150–200)
Most computer codes only include a very limited quantity
of functionals, typically around 10–15
Chemist and Physicists do not use the same functionals!
Difficult to reproduce older calculations with older
functionals
Difficult to reproduce calculations performed with other
codes
Difficult to perform calculations with the newest functionals
M. A. L. Marques Libxc
4. Why the need for libxc?
The xc functional is at the heart of DFT
There are many approximations for the xc (probably of the
order of 150–200)
Most computer codes only include a very limited quantity
of functionals, typically around 10–15
Chemist and Physicists do not use the same functionals!
Difficult to reproduce older calculations with older
functionals
Difficult to reproduce calculations performed with other
codes
Difficult to perform calculations with the newest functionals
M. A. L. Marques Libxc
5. Why the need for libxc?
The xc functional is at the heart of DFT
There are many approximations for the xc (probably of the
order of 150–200)
Most computer codes only include a very limited quantity
of functionals, typically around 10–15
Chemist and Physicists do not use the same functionals!
Difficult to reproduce older calculations with older
functionals
Difficult to reproduce calculations performed with other
codes
Difficult to perform calculations with the newest functionals
M. A. L. Marques Libxc
6. Why the need for libxc?
The xc functional is at the heart of DFT
There are many approximations for the xc (probably of the
order of 150–200)
Most computer codes only include a very limited quantity
of functionals, typically around 10–15
Chemist and Physicists do not use the same functionals!
Difficult to reproduce older calculations with older
functionals
Difficult to reproduce calculations performed with other
codes
Difficult to perform calculations with the newest functionals
M. A. L. Marques Libxc
7. Why the need for libxc?
The xc functional is at the heart of DFT
There are many approximations for the xc (probably of the
order of 150–200)
Most computer codes only include a very limited quantity
of functionals, typically around 10–15
Chemist and Physicists do not use the same functionals!
Difficult to reproduce older calculations with older
functionals
Difficult to reproduce calculations performed with other
codes
Difficult to perform calculations with the newest functionals
M. A. L. Marques Libxc
8. Why the need for libxc?
The xc functional is at the heart of DFT
There are many approximations for the xc (probably of the
order of 150–200)
Most computer codes only include a very limited quantity
of functionals, typically around 10–15
Chemist and Physicists do not use the same functionals!
Difficult to reproduce older calculations with older
functionals
Difficult to reproduce calculations performed with other
codes
Difficult to perform calculations with the newest functionals
M. A. L. Marques Libxc
9. Kohn-Sham equations
The main equations of DFT are the Kohn-Sham equations:
−
1
2
2
+ vext(r) + vH(r) + vxc(r) ϕi(r) = iϕi(r)
where the exchange-correlation potential is defined as
vxc(r) =
δExc
δn(r)
In any practical application of the theory, we have to use an
approximation to Exc, or vxc(r).
M. A. L. Marques Libxc
10. Kohn-Sham equations
The main equations of DFT are the Kohn-Sham equations:
−
1
2
2
+ vext(r) + vH(r) + vxc(r) ϕi(r) = iϕi(r)
where the exchange-correlation potential is defined as
vxc(r) =
δExc
δn(r)
In any practical application of the theory, we have to use an
approximation to Exc, or vxc(r).
M. A. L. Marques Libxc
11. Jacob’s ladder
Local density approximation:
ELDA
xc (r) = ELDA
xc [n] n=n(r)
Generalized gradient approximation:
EGGA
xc (r) = EGGA
xc [n, n] n=n(r)
Meta-generalized gradient approximation:
EmGGA
xc (r) = EmGGA
xc [n, n, τ] n=n(r),τ=τ(r)
And more: orbital functionals, hybrid functionals, hyper-GGAs,
etc.
M. A. L. Marques Libxc
12. Jacob’s ladder
Local density approximation:
ELDA
xc (r) = ELDA
xc [n] n=n(r)
Generalized gradient approximation:
EGGA
xc (r) = EGGA
xc [n, n] n=n(r)
Meta-generalized gradient approximation:
EmGGA
xc (r) = EmGGA
xc [n, n, τ] n=n(r),τ=τ(r)
And more: orbital functionals, hybrid functionals, hyper-GGAs,
etc.
M. A. L. Marques Libxc
13. Jacob’s ladder
Local density approximation:
ELDA
xc (r) = ELDA
xc [n] n=n(r)
Generalized gradient approximation:
EGGA
xc (r) = EGGA
xc [n, n] n=n(r)
Meta-generalized gradient approximation:
EmGGA
xc (r) = EmGGA
xc [n, n, τ] n=n(r),τ=τ(r)
And more: orbital functionals, hybrid functionals, hyper-GGAs,
etc.
M. A. L. Marques Libxc
14. Jacob’s ladder
Local density approximation:
ELDA
xc (r) = ELDA
xc [n] n=n(r)
Generalized gradient approximation:
EGGA
xc (r) = EGGA
xc [n, n] n=n(r)
Meta-generalized gradient approximation:
EmGGA
xc (r) = EmGGA
xc [n, n, τ] n=n(r),τ=τ(r)
And more: orbital functionals, hybrid functionals, hyper-GGAs,
etc.
M. A. L. Marques Libxc
15. What do we need? - I
The energy is usually written as:
Exc = d3
r exc(r) = d3
r n(r) xc(r)
The potential in the LDA is:
vLDA
xc (r) =
d
dn
eLDA
xc (n)
n=n(r)
In the GGA:
vGGA
xc (r) =
∂
∂n
eLDA
xc (n, n)
n=n(r)
−
∂
∂( n)
eLDA
xc (n, n)
n=n(r)
M. A. L. Marques Libxc
16. What do we need? - II
For response properties we also need higher derivatives of exc
1st-order response (polarizabilities, phonon frequencies,
etc.):
fLDA
xc (r) =
d2
d2n
eLDA
xc (n)
n=n(r)
2st-order response (hyperpolarizabilities, etc.):
kLDA
xc (r) =
d3
d3n
eLDA
xc (n)
n=n(r)
And let’s not forget spin...
M. A. L. Marques Libxc
17. What do we need? - II
For response properties we also need higher derivatives of exc
1st-order response (polarizabilities, phonon frequencies,
etc.):
fLDA
xc (r) =
d2
d2n
eLDA
xc (n)
n=n(r)
2st-order response (hyperpolarizabilities, etc.):
kLDA
xc (r) =
d3
d3n
eLDA
xc (n)
n=n(r)
And let’s not forget spin...
M. A. L. Marques Libxc
18. An example: Perdew & Wang 91 (an LDA)
Perdew and Wang parametrized the correlation energy per unit
particle:
ec(rs, ζ) = ec(rs, 0) + αc(rs)
f(ζ)
f (0)
(1 − ζ4
) + [ec(rs, 1) − ec(rs, 0)]f(ζ)ζ4
The function f(ζ) is
f(ζ) =
[1 + ζ]4/3
+ [1 − ζ]4/3
− 2
24/3 − 2
,
while its second derivative f (0) = 1.709921. The functions ec(rs, 0),
ec(rs, 1), and −αc(rs) are all parametrized by the function
g = −2A(1 + α1rs) log 1 +
1
2A(β1r
1/2
s + β2rs + β3r
3/2
s + β4r2
s )
M. A. L. Marques Libxc
19. Libxc
Written in C from scratch
Bindings both in C and in Fortran
Lesser GNU general public license (v. 3.0)
Automatic testing of the functionals
Contains at the moment 19 LDA functionals, 55 GGA
functionals, 24 hybrids, and 7 mGGAs
Contains functionals for 1D, 2D, and 3D calculations
Returns εxc, vxc, fxc, and kxc
Quite mature: included in octopus, APE, GPAW, ABINIT,
and in the GW code of Murilo Tiago
M. A. L. Marques Libxc
20. Libxc
Written in C from scratch
Bindings both in C and in Fortran
Lesser GNU general public license (v. 3.0)
Automatic testing of the functionals
Contains at the moment 19 LDA functionals, 55 GGA
functionals, 24 hybrids, and 7 mGGAs
Contains functionals for 1D, 2D, and 3D calculations
Returns εxc, vxc, fxc, and kxc
Quite mature: included in octopus, APE, GPAW, ABINIT,
and in the GW code of Murilo Tiago
M. A. L. Marques Libxc
21. Libxc
Written in C from scratch
Bindings both in C and in Fortran
Lesser GNU general public license (v. 3.0)
Automatic testing of the functionals
Contains at the moment 19 LDA functionals, 55 GGA
functionals, 24 hybrids, and 7 mGGAs
Contains functionals for 1D, 2D, and 3D calculations
Returns εxc, vxc, fxc, and kxc
Quite mature: included in octopus, APE, GPAW, ABINIT,
and in the GW code of Murilo Tiago
M. A. L. Marques Libxc
22. Libxc
Written in C from scratch
Bindings both in C and in Fortran
Lesser GNU general public license (v. 3.0)
Automatic testing of the functionals
Contains at the moment 19 LDA functionals, 55 GGA
functionals, 24 hybrids, and 7 mGGAs
Contains functionals for 1D, 2D, and 3D calculations
Returns εxc, vxc, fxc, and kxc
Quite mature: included in octopus, APE, GPAW, ABINIT,
and in the GW code of Murilo Tiago
M. A. L. Marques Libxc
23. Libxc
Written in C from scratch
Bindings both in C and in Fortran
Lesser GNU general public license (v. 3.0)
Automatic testing of the functionals
Contains at the moment 19 LDA functionals, 55 GGA
functionals, 24 hybrids, and 7 mGGAs
Contains functionals for 1D, 2D, and 3D calculations
Returns εxc, vxc, fxc, and kxc
Quite mature: included in octopus, APE, GPAW, ABINIT,
and in the GW code of Murilo Tiago
M. A. L. Marques Libxc
24. Libxc
Written in C from scratch
Bindings both in C and in Fortran
Lesser GNU general public license (v. 3.0)
Automatic testing of the functionals
Contains at the moment 19 LDA functionals, 55 GGA
functionals, 24 hybrids, and 7 mGGAs
Contains functionals for 1D, 2D, and 3D calculations
Returns εxc, vxc, fxc, and kxc
Quite mature: included in octopus, APE, GPAW, ABINIT,
and in the GW code of Murilo Tiago
M. A. L. Marques Libxc
25. Libxc
Written in C from scratch
Bindings both in C and in Fortran
Lesser GNU general public license (v. 3.0)
Automatic testing of the functionals
Contains at the moment 19 LDA functionals, 55 GGA
functionals, 24 hybrids, and 7 mGGAs
Contains functionals for 1D, 2D, and 3D calculations
Returns εxc, vxc, fxc, and kxc
Quite mature: included in octopus, APE, GPAW, ABINIT,
and in the GW code of Murilo Tiago
M. A. L. Marques Libxc
26. Libxc
Written in C from scratch
Bindings both in C and in Fortran
Lesser GNU general public license (v. 3.0)
Automatic testing of the functionals
Contains at the moment 19 LDA functionals, 55 GGA
functionals, 24 hybrids, and 7 mGGAs
Contains functionals for 1D, 2D, and 3D calculations
Returns εxc, vxc, fxc, and kxc
Quite mature: included in octopus, APE, GPAW, ABINIT,
and in the GW code of Murilo Tiago
M. A. L. Marques Libxc
27. What is working!
εxc vxc fxc kxc
LDA OK OK OK OK
GGA OK OK PARTIAL NO
HYB GGA OK OK PARTIAL NO
mGGA TEST TEST NO NO
M. A. L. Marques Libxc
28. An example in C
switch ( x c f a m i l y f r o m i d ( xc . f u n c t i o n a l ) )
{
case XC FAMILY LDA :
i f ( xc . f u n c t i o n a l == XC LDA X)
x c l d a x i n i t (& lda func , xc . nspin , 3 , 0 ) ;
else
x c l d a i n i t (& lda func , xc . functional , xc . nspin ) ;
xc lda vxc (& lda func , xc . rho , &xc . zk , xc . vrho ) ;
xc lda end (& lda func ) ;
break ;
case XC FAMILY GGA :
x c g g a i n i t (& gga func , xc . functional , xc . nspin ) ;
xc gga vxc (& gga func , xc . rho , xc . sigma , &xc . zk , xc . vrho , xc . vsigma
xc gga end (& gga func ) ;
break ;
default :
f p r i n t f ( stderr , "Functional ’%d’ not foundn" , xc . f u n c t i o n a l ) ;
e x i t ( 1 ) ;
}
M. A. L. Marques Libxc
29. Another example in Fortran
program l x c t e s t
use l i b x c
i m p l i c i t none
real (8) : : rho , e c , v c
TYPE( xc func ) : : xc c func
TYPE( x c i n f o ) : : x c c i n f o
CALL x c f 9 0 l d a i n i t ( xc c func , xc c info , &
XC LDA C VWN, XC UNPOLARIZED)
CALL xc f90 lda vxc ( xc c func , rho , e c , v c )
CALL xc f90 lda end ( xc c func )
end program l x c t e s t
M. A. L. Marques Libxc
30. The info structure
typedef s t r u c t {
i n t number ; /∗ i n d e n t i f i e r number ∗/
i n t kind ; /∗ XC EXCHANGE or XC CORRELATION ∗/
char ∗name; /∗ name of the functional , e . g . ”PBE” ∗/
i n t family ; /∗ type of the functional , e . g . XC FAMILY GGA ∗/
char ∗ refs ; /∗ references ∗/
i n t provides ; /∗ e . g . XC PROVIDES EXC | XC PROVIDES VXC ∗/
. . .
} x c f u n c i n f o t y p e ;
This is an example on how you can use it:
xc gga type b88 ;
x c g g a i n i t (&b88 , XC GGA X B88 , XC UNPOLARIZED ) ;
p r i n t f ("The functional ’%s’ is defined in the reference(s):n%s" ,
b88 . info−>name, b88 . info−>refs ) ;
xc gga end (&b88 ) ;
M. A. L. Marques Libxc
34. Where to find us!
http://www.tddft.org/programs/octopus/wiki/
index.php/Libxc
Comput. Phys. Commun. 151, 60–78 (2003)
Phys. Stat. Sol. B 243, 2465–2488 (2006)
M. A. L. Marques Libxc