Expand description
§xcx — exchange–correlation functionals for DFT (pure-Rust, libxc-compatible)
xcx evaluates exchange–correlation (XC) functionals: given a density (and,
depending on the functional, its gradient / kinetic energy density), it
returns the XC energy per particle, its first and second derivatives (vxc
and fxc), together with metadata (family, requirements, exact-exchange
fraction, range-separation and VV10 parameters).
Each functional is written once as a scalar energy expression; derivatives are obtained by forward-mode automatic differentiation, so they are correct by construction. Functional IDs match libxc.
§Scope fence
xcx maps (rho, sigma, tau[, lapl]) → energy density + derivatives + metadata + linear mixing and nothing else — no grids, atomic-orbital
evaluation, SCF driver, or dispersion. For hybrids and VV10 it exposes the
parameters; it does not compute the exact-exchange or nonlocal integrals.
The full, semver-stable contract lives in docs/api-convention.md.
§Example
use xcx::{Functional, FunctionalId, Spin, XcInput};
// Spin-unpolarized LDA exchange over three grid points.
let f = Functional::new(FunctionalId::LdaX, Spin::Unpolarized)?;
let rho = [0.1_f64, 0.2, 0.3];
let out = f.eval(rho.len(), &XcInput::lda(&rho))?;
assert_eq!(out.exc.len(), 3); // energy per particle at each point
assert_eq!(out.vrho.len(), 3); // ∂(n·ε_xc)/∂n at each pointStructs§
- CamParams
- Range-separation (CAM) parameters: the host builds short/long-range exact exchange from these. None of the v0.1 functionals are range-separated.
- Functional
- A ready-to-evaluate functional bound to a spin treatment.
- Functional
Info - Static metadata describing a functional. See
docs/api-convention.md. - Hybrid
Info - Mixing information for hybrid functionals.
- Vv10
Params - VV10 nonlocal-correlation parameters.
xcxexposes these but never computes the nonlocal integral. None of the v0.1 functionals use VV10. - XcInput
- Inputs to a functional evaluation, as borrowed point-major slices.
- XcResult
- Energy per particle and first derivatives. Vectors are point-major; the ones not produced by a given family are left empty.
Enums§
- Family
- Functional family.
- Functional
Id - A functional identifier. Numeric values equal libxc’s for interoperability.
- Kind
- Whether a functional models exchange, correlation, both, or kinetic energy.
- Spin
- Spin treatment of the density.
- XcError
- Errors returned by the public API.