Libxc: a library of exchange and correlation functionals for density ...

26 downloads 15360 Views 240KB Size Report
Jun 28, 2012 - Center for Computational Physics, University of Coimbra, ..... call xc_f90_func_init(xc_func, xc_info, func_id, XC_UNPOLARIZED) ... amount of metadata that is quite useful for both the calling program and for the end user. This.
Libxc: a library of exchange and correlation functionals for density functional theory Miguel A. L. Marques∗ Universit´e de Lyon, F-69000 Lyon, France and LPMCN, CNRS, UMR 5586, Universit´e Lyon 1, F-69622 Villeurbanne, France

Micael J. T. Oliveira Center for Computational Physics, University of Coimbra, Rua Larga, 3004-516 Coimbra, Portugal

Tobias Burnus

arXiv:1203.1739v2 [cond-mat.mtrl-sci] 28 Jun 2012

Peter Gr¨ unberg Institut and Institute for Advanced Simulation, Forschungszentrum J¨ ulich, and J¨ ulich Aachen Research Alliance, 52425 J¨ ulich, Germany The central quantity of density functional theory is the so-called exchange-correlation functional. This quantity encompasses all non-trivial many-body effects of the ground-state and has to be approximated in any practical application of the theory. For the past 50 years, hundreds of such approximations have appeared, with many successfully persisting in the electronic structure community and literature. Here, we present a library that contains routines to evaluate many of these functionals (around 180) and their derivatives.

I.

INTRODUCTION

Density functional theory (DFT) is perhaps one of the most successful theories in Physics and in Chemistry of the last half-century [1–4]. It is currently used to predict the structure and the properties of atoms, molecules, and solids; it is a key ingredient of the new field of Materials Design, where one tries to create new materials with specific properties; it is making its way in Biology as an important tool in the investigation of proteins, DNA, etc. These are only a few examples of a discipline that even now, almost 50 years after its birth, is growing at an exponential rate. Almost all applications of DFT are performed within the so-called Kohn-Sham scheme [5], that uses a non-interacting electronic system to calculate the density of the interacting system [6]. The Kohn-Sham scheme leeds to the following equations. (Hartree atomic units are used throughout the paper, i.e. e2 = ¯h = me = 1.)   ∇2 + vext (r) + vHartree [n](r) + vxc [n](r) ψi (r) = εi ψi (r) , (1) − 2 where the first term represents the kinetic energy of the electrons; the second is the external potential usually generated by a set of Coulombic point charges (sometimes described by pseudopotentials); the third term is the Hartree potential that describes the classical electrostatic repulsion between the electrons, Z n(r′ ) vHartree [n](r) = d3 r′ , (2) |r − r′ | and the exchange-correlation (xc) potential vxc [n] is defined by vxc [n](r) =

δExc [n] . δn(r)

(3)

Exc [n] is the xc energy functional. Note that by [n] we denote that the quantity is a functional of the electronic density, n(r) =

occ. X i

where the sum runs over the occupied states.

∗ Corresponding

author. Electronic address: [email protected]

|ψi (r)|2 ,

(4)

2 Chemical accuracy

ψi (r) (empty)

EXX with partial exact correlation

ψi (r) (occupied)

EXX with correlation

∇2 n(r), τ (r)

meta-GGA

∇n(r)

GGA

n(r)

LDA

Hartree world FIG. 1: Jacob’s ladder of density functional approximations for the xc energy.

The central quantity of this scheme is the xc energy Exc [n] that describes all non-trivial many-body effects. Clearly, the exact form of this quantity is unknown and it must be approximated in any practical application of DFT. We emphasize that the precision of any DFT calculation depends solely on the form of this quantity, as this is the only real approximation in DFT (neglecting numerical approximations that are normally controllable). The first approximation to the exchange energy, the local density approximation (LDA), was already proposed by Kohn and Sham in the same paper where they described their Kohn-Sham scheme [5]. It states that the value of xc energy density at any point in space is simply given by the xc energy density of a homogeneous electron gas (HEG) with electronic density n(r). Mathematically, this is written as Z LDA Exc = d3 r n(r)eHEG (5) xc (n(r)) , where eHEG xc (n) is the xc energy per electron of the HEG. Note that this quantity is a function of n. While the exchange contribution eHEG (n) can be easily calculated analytically, the correlation contribution is usually taken from Quantum x Monte-Carlo simulations [7, 8]. As defined, the LDA is unique, but, as we will see in the A, even such precise definition can give rise to many different parameterizations. During the past 50 years, hundreds of different forms appeared [9] and they are usually arranged in families, which have names such as generalized-gradient approximations (GGAs), meta-GGAs, hybrid functionals, etc. In 2001, John Perdew came up with a beautiful idea on how to illustrate these families and their relationship [10]. He ordered these families as rungs in a ladder that leads to the heaven of “chemical accuracy”, and that he christened the Jacob’s ladder of density functional approximations for the xc energy (see Fig. 1). Every rung adds a dependency on another quantity, thereby increasing the precision of the functional but also increasing the numerical complexity and the computational time. At the bottom of the ladder we find the LDA, a functional that depends locally on the density only. The second rung is occupied by the GGA Z GGA Exc = d3 r n(r)eGGA (n(r), ∇n(r)) . (6) xc As one can see, one now adds the gradient of the density, a semi-local quantity that depends on an infinitesimal region around r, as a parameter to the energy density. Note that there is a considerable amount of craftsmanship and physical/chemical intuition going into the creation of the function eGGA (n, ∇n), but also a fair quantity of xc arbitrariness. It is therefore not surprising that many different forms were proposed over the years. The same is true for the functionals on the next rung, the meta-GGAs Z mGGA Exc = d3 r n(r)emGGA (n(r), ∇n(r), ∇2 n(r), τ (r)) . (7) xc

3 This time one adds the Laplacian of the density ∇2 n(r) and also (twice) the kinetic energy density τ (r) =

occ X

|∇ψi (r)|2 .

(8)

i

Note that the meta-GGAs are effectively orbital functionals due to the dependence in τ (r). The forth rung is occupied by functionals that include the exact-exchange (EXX) contribution to the energy Z Z ψi (r)ψi∗ (r′ )ψj (r′ )ψj∗ (r) 1 . ExEXX = − d3 r d3 r′ 2 |r − r′ |

(9)

These functionals can include the whole ExEXX or only a fraction of it, and ExEXX can be evaluated with the bare Coulomb interaction or with a screened version of it. Furthermore, one can add a (semi-)local xc term or one that depends on the orbitals. In any case, the fourth rung only includes functionals that depend on the occupied orbitals only. Notorious examples of functionals on this rung are the hybrid functionals Hyb mGGA Exc = ax ExEXX + Exc [n(r), ∇n(r), ∇2 n(r), τ (r)] .

(10)

Note that the local part of this functional can be a meta-GGA, a GGA, or even an LDA. Finally, on the last rung of Jacob’s ladder one finds functionals that depend on the empty (virtual) Kohn-Sham orbitals. Perhaps the best known example of these functionals is the random-phase approximation (RPA). In a practical DFT calculation one needs typically to evaluate both Exc and vxc . Furthermore, to obtain response properties higher derivatives of Exc are required. For example, in first order one can get the electric polarizability, the magnetic susceptibility, phonon frequencies, etc., and these usually require the knowledge of the xc kernel fxc (r, r′ ) =

δExc . δn(r)δn(r′ )

(11)

In second order one can obtain, e.g., hyperpolarizabilities, Raman tensors, etc., but these calculations usually require kxc (r, r′ , r′′ ) =

δExc . δn(r)δn(r′ )δn(r′′ )

(12)

The calculation of these derivatives is fairly straightforward by using basic functional analysis and the chain rule for functional derivatives. We give here as an example the case of the xc potential for a GGA Z ∂eGGA xc GGA GGA 3 vxc (r) = exc (n(r), ∇n(r)) + d r n(r) δ(r − r′ ) ∂n n = n(r) ∇n = ∇n(r) Z ∂eGGA xc 3 ∇δ(r − r′ ) . (13) + d r n(r) ∂∇n n = n(r) ∇n = ∇n(r)

Integrating by parts the third term, one finally arrives at GGA vxc (r)

=

eGGA (n(r), ∇n(r)) xc

+

∂eGGA xc n(r) ∂n

n = n(r) ∇n = ∇n(r)





∂eGGA xc  ∇ n(r) ∂∇n

n = n(r) ∇n = ∇n(r)



.

(14)

Clearly, higher functional derivatives of Exc involve higher partial derivatives of exc . By now it is clear what a code needs to implement for the functionals of the first three rungs: given n(r), and possibly ∇n(r), ∇2 n(r), and τ (r), one needs the xc energy density exc (r) and all relevant partial derivatives of this quantity. This is indeed the information that is provided by Libxc. For hybrid functionals the library also returns, besides the semi-local part, also the mixing coefficient ax . Unfortunately, EXX and other functionals of the forth and fifth rang are too dependent on the actual numerical representation of the wave-functions and can not be easily included in a generic library. Finally, we would like to mention that some applications of DFT do not use the Kohn-Sham scheme, but try to approximate the kinetic energy functional directly in terms of the density. This approach follows the path that was laid down in the 1927 by Thomas and Fermi [11, 12], and is sometimes referred to as “orbital-free DFT” [13]. In this case, we also need a functional form (either an LDA or a GGA) for the kinetic energy, and many of these are present in Libxc. A good review of functionals for the kinetic energy density can be found in Ref. [14]. Note that even if the discussion above was restricted to spin-compensated systems for the sake of simplicity, all functionals of Libxc can also be used with spin-polarization.

4 II.

SOME HISTORY

Libxc started as a spin-off project during the initial development of the (time-dependent) DFT code Octopus [15– 18]. At that point it became clear that the task of evaluation of the xc functional was completely independent of the main structure of Octopus, and could therefore be transformed into a library. The first steps into the development of Libxc were taken in September 2006, and the first usable version of the library included a few of the most popular LDA and GGA functionals. At the same time, the European Theoretical Spectroscopy Facility was carrying a coordinate effort to improve code interoperability and re-usability of its software suite, so efforts were almost immediately made to interface those codes with Libxc. This catalyzed the development of the library and accelerated its dissemination in the community. During the following years, the library was expanded following two main lines: (i) To include as many functionals as possible (by now we include around 180 — see A). This was done for several reasons. First, we implemented nearly all of the “old” functionals that played an important role in the development of DFT. From this perspective, we can look at Libxc as a “living museum” of the history of this important discipline. It also allows users to reproduce old results with little effort. Secondly, many of the functionals that are proposed nowadays are implemented in Libxc within weeks from the moment they are published. In this way new developments are very rapidly available in several different codes, allowing for these new functionals to be quickly tested and benchmarked. Note that we have an agnostic policy, i.e. we try to include the maximum possible number of functionals, without making any judgment of value concerning their beauty, elegance, or usefulness. This judgment is left for the final user to perform. (ii) To include derivatives of the xc energy up to high orders. As we stated before, to perform a standard KohnSham calculation one only requires the xc energy functional and its first derivatives. However, higher derivatives are essential in order to obtain response properties. Of course, these higher derivatives can be calculated numerically from lower-order derivatives, but this procedure tends to introduce unnecessary errors and instabilities in the calculations. We therefore implemented derivatives up to the third order for the LDAs and up to second order for the other functionals. We note that these derivatives are hand-coded, and not automatically generated from the output of symbolic manipulation software [19, 20]. Even if the latter approach is excellent in order to test implementations, the automatically generated code is often extremely verbose, inefficient, and unreadable. Note that Libxc includes automatic procedures to check the implementation of the analytic derivatives. At the beginning, Libxc was used exclusively in the code Octopus. However, since then several other codes from both the Solid-State Physics and Quantum Chemistry communities started to use this library. The list of codes that use Libxc at the time of writing is as follows (in alphabetical order): • Abinit [21–23] (http://www.abinit.org/) — This is a general purpose plane-wave code. Besides the basic functionality, Abinit also includes options to optimize the geometry, to perform molecular dynamics simulations, or to calculate dynamical matrices, Born effective charges, dielectric tensors, and many more properties. • APE [24] (http://www.tddft.org/programs/APE) — The atomic pseudopotential engine (APE) is a tool for generating atomic pseudopotentials within DFT. It is distributed under the GPL and it produces pseudopotential files suitable for use with several codes. • AtomPAW [25] (http://www.wfu.edu/~natalie/papers/pwpaw/man.html) — The computer program AtomPaw generates projector and basis functions which are needed for performing electronic structure calculations based on the projector augmented wave (PAW) method. The program is applicable to materials throughout the periodic table. • Atomistix ToolKit [26, 27] (http://quantumwise.com) — This is a software package that uses nonequilibrium Green’s functions simulations to study transport properties like I-V characteristics of nanoelectronic devices. It uses a powerful combination of DFT, semi-empirical tight-binding, and classical potentials. • BigDFT [28, 29] (http://inac.cea.fr/L_Sim/BigDFT/) — BigDFT is a DFT massively parallel electronic structure code using a wavelet basis set. Wavelets form a real space basis set distributed on an adaptive mesh. Thanks to its Poisson solver based on a Green’s function formalism, periodic systems, surfaces and isolated systems can be simulated with the proper boundary conditions. • DP [30] (http://www.dp-code.org/) — Dielectric properties (DP) is a Linear Response TDDFT code, in frequency-reciprocal and frequency-real space, that uses a plane-wave basis set. • Elk (http://elk.sourceforge.net/) — An all-electron full-potential linearized augmented-plane wave (FPLAPW) code with many advanced features. This code is designed to be as simple as possible so that new

5 developments in the field of density functional theory (DFT) can be added quickly and reliably. The code is freely available under the GNU General Public License. • ERKALE (http://erkale.googlecode.com) — ERKALE is a quantum chemistry program developed by J. Lehtola used to solve the electronic structure of atoms, molecules and molecular clusters. The main use of ERKALE is the computation of X-ray properties, such as ground-state electron momentum densities and Compton profiles, and core (X-ray absorption and X-ray Raman scattering) and valence electron excitation spectra of atoms and molecules. • Exciting [31, 32] (http://exciting-code.org/) — Exciting is a full-potential all-electron DFT package based on the linearized augmented plane-wave (LAPW) method. It can be applied to all kinds of materials, irrespective of the atomic species involved, and also allows for the investigation of the atomic-core region. • GPAW [33, 34] (https://wiki.fysik.dtu.dk/gpaw) — GPAW is a DFT Python code based on the projectoraugmented wave (PAW) method and the atomic simulation environment (ASE). It uses real-space uniform grids and multigrid methods or atom-centered basis-functions. • Hippo [35–37] — This is an electronic structure code, developed by N. Lathiotakis, that implements Reduced Density Matrix Functionals for atomic and molecular systems using Gaussian-type orbitals . • Octopus [15–18] (http://www.tddft.org/programs/octopus/) — Octopus is a scientific program aimed at the ab initio virtual experimentation on a hopefully ever-increasing range of system types. Electrons are described quantum-mechanically within density-functional theory (DFT), and in its time-dependent form (TDDFT) when doing simulations in time. Nuclei are described classically as point particles. Electron-nucleus interaction is described within the pseudopotential approximation. • Yambo [38] (http://www.yambo-code.org/) — Yambo is a Fortran/C code for many-body calculations in solid state and molecular physics. The code was originally developed in the Condensed Matter Theoretical Group of the Physics Department at the University of Rome “Tor Vergata” by A. Marini. Previous to its release under the GPL license, Yambo was known as SELF. This diversity of codes is extremely important, because in this way a certain functional can be tested and used with a variety of methods in different physical situations. For example, a meta-GGA developed within a certain code to get good band-gaps of solids can be immediately used in a different code (often after a simple recompilation) to obtain the ionization potential of molecules. Libxc is freely available from http://www.tddft.org/programs/Libxc, and it is distributed under the GNU Lesser General Public License v3.0. This license not only allows everyone to read, modify, and distribute the code, but also allows Libxc to be linked from close-source codes. The reader is also referred to the web site to obtain more information, updated documentation, examples, new versions, etc. As most open source projects, we strongly encourage contributions from researchers willing to contribute with the implementation of new functionals, higher derivatives, bug corrections, or even bug reports. III. A.

AN EXAMPLE Calling Libxc

Probably the best way to explain the usage of Libxc is through an example. The following small program calculates the xc energy for a given functional for several values of the density; the available C bindings can be found in header file xc.h. More information and examples can be found in the manual and in the header files. #include #include int main() { xc_func_type func; double rho[5] = {0.1, 0.2, 0.3, 0.4, 0.5}; double sigma[5] = {0.2, 0.3, 0.4, 0.5, 0.6}; double ek[5];

6 int i, func_id = 1; /* initialize the functional */ if(xc_func_init(&func, func_id, XC_UNPOLARIZED) != 0) { fprintf(stderr, "Functional ’%d’ not found\n", func_id); return 1; } /* evaluate the functional */ switch(func.info->family) { case XC_FAMILY_LDA: xc_lda_exc(&func, 5, rho, ek); break; case XC_FAMILY_GGA: case XC_FAMILY_HYB_GGA: xc_gga_exc(&func, 5, rho, sigma, ek); break; } for(i=0; i

Suggest Documents