navigation

Libxc

Libxc is a library of exchange-correlation and kinetic energy functionals for density-functional theory. The original aim was to provide a portable, well tested and reliable set of these functionals to be used by all the codes of the European Theoretical Spectroscopy Facility (ETSF), but the library has since grown to be used in several other types of codes as well; see below for a partial list.

Libxc is written in C, but it also comes with Fortran and Python bindings. It is released under the MPL license (v. 2.0). Contributions are welcome. Bug reports and patches should be submitted over gitlab.

Citing Libxc

Following good scientific practice, any publication using functionals from Libxc should cite Libxc. To cite Libxc, the current reference is

Any program interfacing Libxc should analogously

Documenting the use of Libxc for the density functional is important, since many functionals have dissimilar implementations in various programs; see

Libxc switched to automatical code generation with Maple in version 4 in 2017, while previous versions employed hand-written C implementations. The reference for early (<= 3) versions of Libxc—which is now obsolete—is

Adding functionals to Libxc

If you are developing a new functional, we would love to implement it in Libxc for you even before the functional has been published, since many published functionals contain typos, errors and reference data, see doi:10.1063/5.0167763; please contact the Libxc maintainers (Susi Lehtola and Miguel Marques) via GitLab or email.

You can also add functionals yourself. The procedure to do this is documented in the README in the Libxc repository.

Capabilities

In Libxc you can find various types of functionals: LDA, GGA, and meta-GGA (mGGA) functionals. LDAs, GGAs, and meta-GGAs depend on local information, in the sense that the value of the density functional part of the energy density at a given point depends only on the values of the density, the gradient of the density, and the kinetic energy density and/or the density laplacian, respectively, at the given point:

$$ E^\mathrm{LDA}_\mathrm{xc} = E^\mathrm{LDA}_\mathrm{xc}[n(\vec{r})], $$

$$ E^\mathrm{GGA}_\mathrm{xc} = E^\mathrm{GGA}_{xc}[n(\vec{r}), \vec{\nabla}n(\vec{r})], $$

$$ E^\mathrm{mGGA}_\mathrm{xc} = E^\mathrm{mGGA}_\mathrm{xc}[n(\vec{r}), \vec{\nabla}n(\vec{r}), \nabla^2 n(\vec{r}), \tau(\vec{r})]. $$

Libxc is designed to evaluate this energy density and its derivatives in a correct fashion. Because several functionals are complicated in form, Libxc is based on the use of computer algebra and automatic code generation to enable the generation of bug-free code. Libxc can calculate both the functional itself, as well as its first through fourth derivatives, satisfying even the stringest requirements for applications.

Global hybrid (GH) and range-separated hybrid (RSH) functionals are also supported by Libxc: $$ E^\mathrm{GH}_\mathrm{xc} = c_x E^\mathrm{EXX} + E^\mathrm{DFT}_\mathrm{xc}[n(\vec{r}), \dots], $$

$$ E^\mathrm{RSH}_\mathrm{xc} = c_\mathrm{sr} E^\mathrm{EXX}_\mathrm{sr} + c_\mathrm{lr} E^\mathrm{EXX}_\mathrm{lr} + E^\mathrm{DFT}_\mathrm{xc}[n(\vec{r}), \dots]. $$

For these functionals, Libxc only handles the local part (as above); the evaluation of the exact exchange components must be done in the calling program. Libxc, however, does contain all the information necessary to perform the calculations (fraction of exact exchange, range separation parameter(s)).

The same can be said about dispersion corrections: several functionals are available in Libxc that were parametrized with either semiclassical dispersion corrections à la Grimme, or various van der Waals functionals; neither of these can be evaluated with the local density information provided to Libxc, and must be handled by the calling program. The necessary parameters for VV10-type correlation kernels are, however, provided by Libxc as part of the functional definition.

Support in codes

At the moment, we are aware of Libxc being used in the following codes (in alphabetical order):