libxc Interface#
REST uses the external crate libxc-rs (docs.rs) as a safe Rust wrapper around the C libxc library. It is dynamically loaded at runtime via the Cargo feature dynamic_loading; no static linking is needed.
Architecture#
┌─────────────────────┐
│ DFA4REST (mod.rs) │ Core DFT data structure, calls libxc via DFA
│ libxc_itrf.rs │ Numerical integration interface (high-order derivatives)
└────────┬────────────┘
│ xc_func_init / lda/gga/mgga_exc_vxc / eval_libxc_func_new
┌────────▼────────────┐
│ libxc_helper.rs │ Thin wrapper over libxc-rs
└────────┬────────────┘
│ LibXCFunctional / compute_lda/gga/mgga
┌────────▼────────────┐
│ libxc (external) │ Safe Rust FFI bindings to C libxc
└─────────────────────┘
Key Types#
LibXCFunctional (external crate libxc)#
Constructed via LibXCFunctional::from_number(id, spin) or REST’s xc_func_init(code, spin).
Implements Drop — resources are automatically freed when the object goes out of scope. No manual xc_func_end() needed.
Method |
Returns |
Description |
|---|---|---|
|
|
Functional family ( |
|
|
Exact-exchange coefficient, |
|
|
CAM parameters |
|
|
Whether it is a range-separated hybrid |
|
|
Whether kinetic energy density is needed (MGGA) |
|
|
Whether Laplacian is needed |
|
|
Feature flags (e.g. |
|
|
Reference list |
|
|
Human-readable description |
LibXCFamily enum changes#
Old (hand-written) |
New (external crate) |
|---|---|
|
|
|
|
(none) |
|
DFA4REST (src/dft/mod.rs)#
Method |
Description |
|---|---|
|
Initialize |
|
Initialize with parameters (e.g. omega) |
|
Compute total HFX coefficient from SCF functionals |
|
Get RSH parameters from SCF functionals |
|
Dispatch to |
libxc_helper.rs Public API#
Function |
Description |
|---|---|
|
Initialize functional from libxc id; spin=1 unpolarized / 2 polarized |
|
Map functional name (e.g. |
|
LDA energy + potential |
|
GGA energy + potential |
|
MGGA energy + potential |
|
General evaluator writing into pre-allocated buffer |
libxc_itrf.rs Integration Interface#
eval_xc_eff(func_ids, factors, xc_type, spin, rho_array, np, deriv) is the main entry point for num_int.rs and response.rs. It accepts multiple libxc functional IDs with coefficients, computes XC energy, first-order potential, and high-order derivatives, then converts from libxc’s raw output format to REST’s internal representation.
API Migration Reference#
Old ( |
New ( |
|---|---|
|
|
|
(removed, RAII) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dependency#
libxc = { version = "0.1", features = ["api-v7_0", "dynamic_loading"] }