SkillAgentSearch skills...

Libxc.jl

Julia bindings to the libxc library for exchange-correlation functionals

Install / Use

/learn @JuliaMolSim/Libxc.jl

README

Libxc.jl

| Build Status | License | |:-------------------------------------- |:-------------------------------- | | | |

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

Usage

Install the library from Julia as usual:

import Pkg
Pkg.add("Libxc")

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, derivatives=0)
@show result
# result = (zk = [-0.452597, -0.478877, -0.520674, -0.561427, -0.598661],)

GPU support

Recently GPU support has been added. Whenever evaluate is called with CuArrays, the computation will automatically be done with the CUDA version of libxc. Due to delays in the BinaryBuilder / Yggdrasil infrastructure it often happens that the most recent CUDA version (shipped by default in CUDA.jl) is not yet supported. In this case using the package will throw a warning and you should manually set the CUDA version to a lower version, for example,

using CUDA
CUDA.set_runtime_version!(v"12.8")

Status

Full support for evaluating LDA, GGA and meta-GGA functionals on CPUs 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/api.jl. This file is automatically generated from the libxc source code and offers all functions of the public interface as ccall wrappers.

View on GitHub
GitHub Stars25
CategoryDevelopment
Updated1d ago
Forks8

Languages

Julia

Security Score

95/100

Audited on Mar 31, 2026

No findings