Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ If human developers forgets to define `CLAUDE.local.md`, you should ask them to
General rules
- This repository should live at `LIBXC_REPO_PATH`, which is defined in `CLAUDE.local.md`.
- **This repository should not be modified**, unless you are going to checkout specific tags (versions) of libxc.
- Main branch is `devel`, useful tags can be `6.2.2` and `7.0.0` (latest stable version at current time).
- Main branch is `devel`, useful tags can be `6.2.2`, `7.0.0` and `7.1.2` (latest stable version at current time).

Important files for FFI and wrapper development:
- `src/*.h`: the headers. Note that these files are also copied to this project under `libxc-ffi/headers` folder.
Expand Down Expand Up @@ -66,7 +66,7 @@ We will currently separating CPU and CUDA implementation. CUDA will always have

For this FFI wrapper, we will start from libxc v6.2.2.

At current time (2026-may), the latest stable version is v7.0.0, and developer version is v7.1.0. We will handle three versions: v6.2, v7.0, v7.1.
At current time (2026-sep), the latest stable version is v7.1.2, and the `devel` branch is under development towards the next version. We will handle three released versions: v6.2, v7.0, v7.1.
The cargo feature will activate the corresponding version of header (`api-v6_2`, `api-v7_0`, `api-v7_1`), and the default version is v7.0.
We will save libxc headers in folder `libxc-ffi/headers`.

Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/cuda-testing/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GPUs, CUDA testing is manual and local-only.

**Please note that you must pass the correct cargo feature to the corresponding version of the libxc shared library**:
- `api-v7_0` for libxc v7.0
- `api-v7_1` for libxc v7.1 (or the `devel` branch of libxc)
- `api-v7_1` for libxc v7.1 (released as 7.1.0–7.1.2)

For cuda tests, you also need to pass the `cuda` feature (which implies `api-v7_1`).

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-v7_0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: conda-incubator/setup-miniconda@v3
- name: run tests
run: |
conda install libxc -c conda-forge
conda install "libxc=7.0.*" -c conda-forge
ls /usr/share/miniconda/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/share/miniconda/lib
cargo test -p libxc --no-default-features --features="api-v7_0" -- --nocapture
cargo test -p libxc --no-default-features --features="api-v7_0,dynamic_loading" -- --nocapture
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# Changelog

## v0.1.3 -- 2026-09-08

Fix:

- libxc 6.2.x support
- the workspace `libxc-ffi` dependency now sets `default-features = false`,
so api-version features are selected exclusively through the `libxc`
crate; previously `--no-default-features --features api-v6_2` still
compiled the v7.0 struct layout of `xc_func_type` and read garbage
against a v6.2.2 shared library
- mGGA tau handling: `needs_tau()` falls back to the functional family for
pre-v7.0 libraries; zeroed scratch substituted for null lapl/tau inputs
and for tau-family outputs missing from the layout/output map (libxc
6.2.x aborts the process otherwise)
- CI: the v7.0 test workflow now selects `dynamic_loading` explicitly and
pins conda-forge `libxc` to `7.0.*`; it previously relied on the implicit
feature unification fixed above, and conda-forge's default libxc is now
7.1.2

Enhancement:

- Refresh headers from released libxc tags: `xc_funcs_v7.1.h` and `xc.h`
from 7.1.2 (the v7.1 line is now released upstream as 7.1.0–7.1.2; it was
previously snapshotted from the unreleased `devel` branch), and
`xc_funcs_v6.2.h` from 6.2.2. `XcFuncId` enums regenerated.
- v7.1: add `T_HLE17`, `LDA_C_BJ89`, `GGA_X_LLP`, `LDA_C_LP96_B`,
`LDA_K_LP96_B`, `LDA_C_RPAF`, `HYB_MGGA_XC_COACH`,
`MGGA_X_SREGTM_V1/V2/V3`; remove `MS2BS`, `MVSB`, `MVSBS`, `OPB3LYP`
(present only in the pre-release snapshot, never in a released v7.1)
- v6.2: remove functional IDs that do not exist in libxc 6.2.2; fix
`LDA_C_1D_CSS` -> `LDA_C_1D_CSC` and `LDA_XC_TH_FL` -> `GGA_XC_TH_FL`;
add `MGGA_X_MK00`

## v0.1.2 -- 2026-05-25

Enhancement:
Expand Down
10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ members = [
[workspace.package]
edition = "2021"
rust-version = "1.82"
version = "0.1.2"
version = "0.1.3"
description = "libxc FFI bindings and wrappers"
repository = "https://github.com/RESTGroup/libxc-rs"
keywords = ["ffi", "chemistry"]
categories = ["science"]
license = "Apache-2.0"

[workspace.dependencies]
libxc-ffi = { path = "libxc-ffi", version = "0.1.2" }
# default-features = false: the api-version features (api-v6_2/v7_0/v7_1) and
# dynamic_loading must be selected exclusively through the `libxc` crate's
# features. Otherwise libxc-ffi's own defaults (api-v7_0 + dynamic_loading)
# are always unified in, and e.g. `--features api-v6_2` would still compile
# the v7.0 struct layout of `xc_func_type` — which reads out of bounds when
# a v6.2.2 shared library is loaded at runtime.
libxc-ffi = { path = "libxc-ffi", version = "0.1.3", default-features = false }
4 changes: 4 additions & 0 deletions libxc-ffi/headers/versioning_xc.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ xc_func_get_ext_params_value

# v7.1

Released upstream as v7.1.0–v7.1.2. The v7.1 headers in this project track
the released 7.1.2 tag (earlier they were snapshotted from the `devel`
branch before the release).

## Introduced in v7.1

xc_func_info_get_default_flags
Expand Down
23 changes: 18 additions & 5 deletions libxc-ffi/headers/xc.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ const char *xc_version_string(void);
#define XC_NOARG
#define XC_COMMA ,

/* the following macros *do not* include zk */
/* the following macros are probably to DELETE */
/* Expansion lists of every per-order derivative output (excluding zk) for
each family, in canonical order. They exist only to spell out the
parameter lists of the legacy flat evaluators (xc_lda/xc_gga/xc_mgga,
declared below) and the composite mix plumbing. New code
should use the struct interface (xc_*_new) or the convenience entry
points instead; these macros can go once those last users are migrated. */

#define LDA_OUT_PARAMS_NO_EXC(P1_, P2_) \
P1_ P2_ ## vrho \
Expand Down Expand Up @@ -420,13 +424,22 @@ void xc_mgga_new(const xc_func_type *func, int order, size_t np,
const double *rho, const double *sigma, const double *lapl,
const double *tau, xc_mgga_out_params *out);

/** Evaluate an LDA functional */
/**
* Legacy flat-argument evaluation interface.
*
* Every derivative output is a separate pointer argument, spelled out by
* the *_OUT_PARAMS_NO_EXC macros, so xc_mgga() has 70+ parameters. These
* are kept for backward compatibility (and are still used internally by
* the composite mix evaluators); new code should prefer
* - the per-order convenience entry points -- xc_lda_exc, xc_gga_exc_vxc,
* xc_mgga_exc_vxc_fxc, ... -- which take only the outputs requested; or
* - the struct interface xc_{lda,gga,mgga}_new(p, order, np, ..., &out)
* with an xc_{lda,gga,mgga}_out_params whose unused fields are NULL.
*/
void xc_lda (const xc_func_type *p, size_t np, const double *rho,
double *zk LDA_OUT_PARAMS_NO_EXC(XC_COMMA double *, ));
/** Evaluate a GGA functional */
void xc_gga (const xc_func_type *p, size_t np, const double *rho, const double *sigma,
double *zk GGA_OUT_PARAMS_NO_EXC(XC_COMMA double *, ));
/** Evaluate a meta-GGA functional */
void xc_mgga(const xc_func_type *p, size_t np,
const double *rho, const double *sigma, const double *lapl_rho, const double *tau,
double *zk MGGA_OUT_PARAMS_NO_EXC(XC_COMMA double *, ));
Expand Down
58 changes: 9 additions & 49 deletions libxc-ffi/headers/xc_funcs_v6.2.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define XC_LDA_C_WIGNER 2 /* Wigner */
#define XC_LDA_C_RPA 3 /* Random Phase Approximation (RPA) */
#define XC_LDA_C_HL 4 /* Hedin & Lundqvist */
#define XC_LDA_C_GL 5 /* Gunnarsson & Lundqvist */
#define XC_LDA_C_GL 5 /* Gunnarson & Lundqvist */
#define XC_LDA_C_XALPHA 6 /* Slater's Xalpha */
#define XC_LDA_C_VWN 7 /* Vosko, Wilk & Nusair (VWN5) */
#define XC_LDA_C_VWN_RPA 8 /* Vosko, Wilk & Nusair (VWN5_RPA) */
Expand All @@ -15,7 +15,7 @@
#define XC_LDA_C_2D_AMGB 15 /* AMGB (for 2D systems) */
#define XC_LDA_C_2D_PRM 16 /* PRM (for 2D systems) */
#define XC_LDA_C_VBH 17 /* von Barth & Hedin */
#define XC_LDA_C_1D_CSS 18 /* Casula, Sorella & Senatore */
#define XC_LDA_C_1D_CSC 18 /* Casula, Sorella & Senatore */
#define XC_LDA_X_2D 19 /* Slater exchange */
#define XC_LDA_XC_TETER93 20 /* Teter 93 */
#define XC_LDA_X_1D_SOFT 21 /* Exchange in 1D for an soft-Coulomb interaction */
Expand Down Expand Up @@ -101,7 +101,6 @@
#define XC_GGA_X_PBE 101 /* Perdew, Burke & Ernzerhof */
#define XC_GGA_X_PBE_R 102 /* Revised PBE from Zhang & Yang */
#define XC_GGA_X_B86 103 /* Becke 86 */
#define XC_HYB_LDA_XC_B93 104 /* Becke's original half-and-half functional: 50% HF and 50% LDA xc */
#define XC_GGA_X_B86_MGC 105 /* Becke 86 with modified gradient correction */
#define XC_GGA_X_B88 106 /* Becke 88 */
#define XC_GGA_X_G96 107 /* Gill 96 */
Expand Down Expand Up @@ -193,7 +192,7 @@
#define XC_GGA_X_LAG 193 /* Local Airy Gas */
#define XC_GGA_XC_MOHLYP 194 /* Functional for organometallic chemistry */
#define XC_GGA_XC_MOHLYP2 195 /* Functional for barrier heights */
#define XC_LDA_XC_TH_FL 196 /* Tozer and Handy v. FL */
#define XC_GGA_XC_TH_FL 196 /* Tozer and Handy v. FL */
#define XC_GGA_XC_TH_FC 197 /* Tozer and Handy v. FC */
#define XC_GGA_XC_TH_FCFO 198 /* Tozer and Handy v. FCFO */
#define XC_GGA_XC_TH_FCO 199 /* Tozer and Handy v. FCO */
Expand Down Expand Up @@ -227,7 +226,7 @@
#define XC_MGGA_X_MN12_L 227 /* Minnesota MN12-L exchange functional */
#define XC_MGGA_X_MS2_REV 228 /* MS2 exchange of Sun, et al with revised value for c */
#define XC_MGGA_XC_CC06 229 /* Cancio and Chou 2006 */
#define XC_MGGA_X_GP86 230 /* Ghosh-Parr 1986 meta-GGA exchange, later reinvestigated by Manby and Knowles */
#define XC_MGGA_X_MK00 230 /* Exchange for accurate virtual orbital energies */
#define XC_MGGA_C_TPSS 231 /* Tao, Perdew, Staroverov & Scuseria */
#define XC_MGGA_C_VSXC 232 /* VSXC (correlation part) */
#define XC_MGGA_C_M06_L 233 /* Minnesota M06-L correlation functional */
Expand Down Expand Up @@ -323,30 +322,7 @@
#define XC_MGGA_C_TPSS_GAUSSIAN 323 /* Tao, Perdew, Staroverov & Scuseria with parameters from Gaussian */
#define XC_GGA_X_NCAPR 324 /* Nearly correct asymptotic potential revised */
#define XC_HYB_GGA_XC_RELPBE0 325 /* relPBE0 a.k.a. relPBE: PBE0 refitted for actinide compounds */
#define XC_MGGA_X_EEL 326 /* Exact exchange-like exchange of Aschebrock et al */
#define XC_GGA_XC_B97_3C 327 /* Becke 97-3c by Grimme et. al. */
#define XC_LDA_C_EPC17 328 /* epc17(-1): electron-proton correlation 2017 */
#define XC_LDA_C_EPC17_2 329 /* epc17-2: electron-proton correlation 2017 for proton affinities */
#define XC_LDA_C_EPC18_1 330 /* epc18-1: electron-proton correlation 2018 */
#define XC_LDA_C_EPC18_2 331 /* epc18-2: electron-proton correlation 2018 for proton affinities */
#define XC_GGA_XC_DLB97 332 /* dispersionless-optimized B97 */
#define XC_MGGA_X_MSCAN 333 /* Modified SCAN (mSCAN) exchange of Desmarais, Erba, Vignale, and Pittalis */
#define XC_MGGA_C_MSCAN 334 /* Modified SCAN (mSCAN) correlation of Desmarais, Erba, Vignale, and Pittalis */
#define XC_GGA_X_T_PBE1 335 /* PBE reparametrization (version 1) for band gaps */
#define XC_GGA_X_T_PBE2 336 /* PBE reparametrization (version 2) for band gaps */
#define XC_LDA_X_T_SLOC 337 /* SLOC reparametrization for band gaps */
#define XC_GGA_X_BKL1 338 /* Exchange part of type-I band gap functional by Bhattacharjee, Koshi and Lee */
#define XC_GGA_X_BKL2 339 /* Exchange part of type-II band gap functional by Bhattacharjee, Koshi and Lee */
#define XC_HYB_MGGA_X_CF22D 340 /* Minnesota CF22D hybrid exchange functional */
#define XC_MGGA_C_CF22D 341 /* Minnesota CF22D correlation functional */
#define XC_MGGA_X_LAK 342 /* Lebeda-Aschebrock-Kummel meta-GGA exchange */
#define XC_GGA_C_BKL1 343 /* Correlation part of type-I band gap functional by Bhattacharjee, Koshi and Lee */
#define XC_GGA_C_BKL2 344 /* Correlation part of type-II band gap functional by Bhattacharjee, Koshi and Lee */
#define XC_MGGA_C_LAK 345 /* Lebeda-Aschebrock-Kummel meta-GGA correlation */
#define XC_GGA_X_DF3_OPT1 346 /* Becke 88 reoptimized by Chakraborty et al for use with vdW functional */
#define XC_GGA_X_DF3_OPT2 347 /* Becke 86 reoptimized by Chakraborty et al for use with vdW functional */
#define XC_HYB_GGA_XC_CQTP25 385 /* CAM-B3LYP retuned for core electron ionization energies */
#define XC_HYB_GGA_XC_OPB3LYP 386 /* opB3LYP: B3LYP reoptimized in 6-311++G(2d,2p) basis set */
#define XC_MGGA_C_CC 387 /* Self-interaction corrected correlation functional by Schmidt et al */
#define XC_MGGA_C_CCALDA 388 /* Iso-orbital corrected LDA correlation by Lebeda et al */
#define XC_HYB_MGGA_XC_BR3P86 389 /* BR3P86 hybrid meta-GGA from Neumann and Handy */
Expand Down Expand Up @@ -395,8 +371,8 @@
#define XC_HYB_GGA_XC_HJS_B97X 432 /* HJS hybrid screened exchange B97x version */
#define XC_HYB_GGA_XC_CAM_B3LYP 433 /* CAM version of B3LYP */
#define XC_HYB_GGA_XC_TUNED_CAM_B3LYP 434 /* CAM version of B3LYP, tuned for excitations and properties */
#define XC_HYB_GGA_XC_BHANDH 435 /* BHandH: 50% LDA exchange and 50% HF exchange with 100% LYP correlation */
#define XC_HYB_GGA_XC_BHANDHLYP 436 /* BHandHLYP a.k.a. BHLYP: 50% B88 exchange and 50% HF exchange with 100% LYP correlation */
#define XC_HYB_GGA_XC_BHANDH 435 /* BHandH i.e. BHLYP */
#define XC_HYB_GGA_XC_BHANDHLYP 436 /* BHandHLYP */
#define XC_HYB_GGA_XC_MB3LYP_RC04 437 /* B3LYP with RC04 LDA */
#define XC_HYB_MGGA_X_M05 438 /* Minnesota M05 hybrid exchange functional */
#define XC_HYB_MGGA_X_M05_2X 439 /* Minnesota M05-2X hybrid exchange functional */
Expand Down Expand Up @@ -456,7 +432,7 @@
#define XC_MGGA_X_RSCAN 493 /* Regularized SCAN exchange by Bartok and Yates */
#define XC_MGGA_C_RSCAN 494 /* Regularized SCAN correlation by Bartok and Yates */
#define XC_GGA_X_S12G 495 /* Swart 2012 GGA exchange */
#define XC_HYB_GGA_X_S12H 496 /* Swart 2012 hybrid GGA exchange */
#define XC_HYB_GGA_X_S12H 496 /* Swart 2012 hybrid exchange */
#define XC_MGGA_X_R2SCAN 497 /* Re-regularized SCAN exchange by Furness et al */
#define XC_MGGA_C_R2SCAN 498 /* Re-regularized SCAN correlation by Furness et al */
#define XC_HYB_GGA_XC_BLYP35 499 /* BLYP35 */
Expand Down Expand Up @@ -519,12 +495,12 @@
#define XC_GGA_C_GAPLOC 556 /* Gaploc */
#define XC_GGA_C_ZVPBEINT 557 /* another spin-dependent correction to PBEint */
#define XC_GGA_C_ZVPBESOL 558 /* another spin-dependent correction to PBEsol */
#define XC_GGA_C_TM_LYP 559 /* Thakkar and McCarthy reparametrization, also known as reLYP */
#define XC_GGA_C_TM_LYP 559 /* Takkar and McCarthy reparametrization */
#define XC_GGA_C_TM_PBE 560 /* Thakkar and McCarthy reparametrization */
#define XC_GGA_C_W94 561 /* Wilson 94 (Eq. 25) */
#define XC_MGGA_C_KCIS 562 /* Krieger, Chen, Iafrate, and Savin */
#define XC_HYB_MGGA_XC_B0KCIS 563 /* Hybrid based on KCIS */
#define XC_MGGA_XC_LP90 564 /* Lee & Parr, Eq. (60) */
#define XC_MGGA_XC_LP90 564 /* Lee & Parr, Eq. (56) */
#define XC_GGA_C_CS1 565 /* A dynamical correlation functional */
#define XC_HYB_MGGA_XC_MPW1KCIS 566 /* MPW1KCIS for barrier heights */
#define XC_HYB_MGGA_XC_MPWKCIS1K 567 /* MPWKCIS1K for barrier heights */
Expand Down Expand Up @@ -613,16 +589,10 @@
#define XC_MGGA_X_R4SCAN 650 /* r$^{4}$SCAN, a functional that satisfies the same exact constraints that SCAN does */
#define XC_MGGA_X_VCML 651 /* Exchange part of VCML-rVV10 by Trepte and Voss */
#define XC_MGGA_XC_VCML_RVV10 652 /* VCML-rVV10 by Trepte and Voss */
#define XC_HYB_LDA_X_ERF 653 /* Long-range corrected functional based on short-range LDA exchange (erfc) */
#define XC_LDA_C_PW_ERF 654 /* Short ranged correlation LDA (erfc) */
#define XC_GGA_X_PBE_ERF_GWS 655 /* Short ranged PBE exchange (erfc) */
#define XC_HYB_GGA_X_PBE_ERF_GWS 656 /* Short-range PBE (GWS) exchange (erfc) + long-range exact exchange */
#define XC_GGA_C_PBE_ERF_GWS 657 /* Short ranged PBE correlation (erfc) */
#define XC_HYB_MGGA_XC_GAS22 658 /* Google Accelerated Science 22 */
#define XC_HYB_MGGA_XC_R2SCANH 659 /* r2SCANh: r2SCAN hybrid like TPSSh with 10% exact exchange */
#define XC_HYB_MGGA_XC_R2SCAN0 660 /* r2SCAN0: r2SCAN hybrid like PBE0 with 25% exact exchange */
#define XC_HYB_MGGA_XC_R2SCAN50 661 /* r2SCAN50: r2SCAN hybrid like PBE50 with 50% exact exchange */
#define XC_HYB_MGGA_X_WR2SCAN 662 /* Range-separated re-regularized SCAN exchange by Wittmann et al */
#define XC_HYB_GGA_XC_CAM_PBEH 681 /* CAM hybrid screened exchange PBE version */
#define XC_HYB_GGA_XC_CAMY_PBEH 682 /* CAMY hybrid screened exchange PBE version */
#define XC_LDA_C_UPW92 683 /* Ruggeri, Rios, and Alavi unrestricted fit */
Expand Down Expand Up @@ -684,13 +654,3 @@
#define XC_MGGA_X_KTBM_23 758 /* KTBM learned exchange - 23 */
#define XC_MGGA_X_KTBM_24 759 /* KTBM learned exchange - 24 */
#define XC_MGGA_X_KTBM_GAP 760 /* KTBM learned exchange - GAP */
#define XC_MGGA_X_MSPBEL 761 /* MS-PBEl, a PBE-like meta-GGA exchange */
#define XC_MGGA_X_RMSPBEL 762 /* regularized MS-PBEl */
#define XC_MGGA_X_MSRPBEL 763 /* MS-RPBEl, a RPBE-like meta-GGA exchange */
#define XC_MGGA_X_RMSRPBEL 764 /* regularized MS-RPBEl */
#define XC_MGGA_X_MSB86BL 765 /* MS-B86bl, a B86b-like meta-GGA exchange */
#define XC_MGGA_X_RMSB86BL 766 /* regularized MS-B86bl */
#define XC_HYB_MGGA_X_PI_M06_2X_DL 767 /* Dispersionless physically-informed Minnesota M06-2X hybrid exchange functional */
#define XC_MGGA_C_PI_M06_2X_DL 768 /* Dispersionless physically-informed Minnesota M06-2X correlation functional */
#define XC_HYB_MGGA_X_PI_M06_2X 769 /* Physically-informed Minnesota M06-2X hybrid exchange functional */
#define XC_MGGA_C_PI_M06_2X 770 /* Physically-informed Minnesota M06-2X correlation functional */
Loading
Loading