Julia bindings to the libxc library for exchange-correlation functionals
Author JuliaMolSim
12 Stars
Updated Last
1 Year Ago
Started In
June 2019


Build Status License

This package provides Julia bindings to the libxc library for common exchange-correlation functionals in density-functional theory.


Install the library from Julia as usual:

import Pkg

and then for example:

using Libxc

rho = [0.1, 0.2, 0.3, 0.4, 0.5]
sigma = [0.2, 0.3, 0.4, 0.5, 0.6]

# LDA exchange
lda_x = Functional(:lda_x)
result = evaluate(lda_x, rho=rho)
@show result
# result = (vrho = [-0.457078 -0.575882 -0.659220 -0.725566 -0.781592],
#           zk = [-0.342808, -0.43191, -0.49441, -0.544174, -0.586194])

# GGA exchange
gga_x = Functional(:gga_x_pbe, n_spin=1)
result = evaluate(gga_x, rho=rho, sigma=sigma, derivative=0)
@show result
# result = (zk = [-0.452597, -0.478877, -0.520674, -0.561427, -0.598661],)


Full support for evaluating LDA, GGA and meta-GGA functionals as shown above. Hybrid or range-separated hybrids and VV10-type functionals export parameters required in the host programs as properties of the Functional Julia object. For example

b3lyp = Functional(:hyb_gga_xc_b3lyp)
@show b3lyp.exx_coefficient
# b3lyp.exx_coefficient = 0.2

See also the xc-info.jl example (modelled after the xc-info executable shipped with libxc).

Some advanced Libxc features (custom functional combinations, setting external parameters etc.) are not yet supported in the Julia wrapper. If you need those you can, however, talk to libxc directly using the low-level C-like interface, see the file src/gen/libxc.jl. This file is automatically generated from the libxc source code and offers all functions of the public interface as ccall wrappers.

Used By Packages