Skip to content
Draft
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
34 changes: 1 addition & 33 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,41 +80,10 @@ jobs:
run: |
cd toolchain
./install_abacus_toolchain_new.sh --with-dftd4=install --dry-run -j8
./scripts/stage3/install_libxc.sh
./scripts/stage4/install_stage4.sh
cd ..

# Keep the image's LibXC version: only enable the KXC needed by LR gradients.
- name: Identify LibXC version
id: libxc
run: echo "version=$(pkg-config --modversion libxc)" >> "${GITHUB_OUTPUT}"

- name: Cache LibXC with KXC
id: libxc-cache
uses: actions/cache@v6
with:
path: toolchain/install/libxc-kxc
key: libxc-kxc-v1-${{ runner.os }}-${{ runner.arch }}-${{ steps.compiler.outputs.fingerprint }}-${{ steps.libxc.outputs.version }}

- name: Build LibXC with KXC
if: steps.libxc-cache.outputs.cache-hit != 'true'
env:
LIBXC_VERSION: ${{ steps.libxc.outputs.version }}
run: |
wget -q "https://gitlab.com/libxc/libxc/-/archive/${LIBXC_VERSION}/libxc-${LIBXC_VERSION}.tar.gz" -O /tmp/libxc-kxc.tar.gz
mkdir -p /tmp/libxc-kxc-source
tar -xzf /tmp/libxc-kxc.tar.gz --strip-components=1 -C /tmp/libxc-kxc-source
cmake -S /tmp/libxc-kxc-source -B /tmp/libxc-kxc-build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${GITHUB_WORKSPACE}/toolchain/install/libxc-kxc" \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=ON -DENABLE_FORTRAN=OFF -DBUILD_TESTING=OFF \
-DDISABLE_KXC=OFF -DDISABLE_LXC=ON
cmake --build /tmp/libxc-kxc-build -j8
cmake --install /tmp/libxc-kxc-build

- name: Use KXC-enabled LibXC at runtime
run: echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/toolchain/install/libxc-kxc/lib:${LD_LIBRARY_PATH:-}" >> "${GITHUB_ENV}"

- name: Test LR excited-state tracking checker
run: python3 tests/integrate/validation_tools/test_es_check.py
Comment thread
Growl1234 marked this conversation as resolved.
Resolved

Expand All @@ -126,7 +95,6 @@ jobs:
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_MLALGO=ON \
-DENABLE_LIBXC=ON \
-DLibxc_DIR="${GITHUB_WORKSPACE}/toolchain/install/libxc-kxc/share/cmake/Libxc" \
-DENABLE_LIBRI=ON \
-DENABLE_GOOGLEBENCH=OFF \
-DENABLE_JSON=ON \
Expand Down
31 changes: 29 additions & 2 deletions toolchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ Mix online and offline packages as needed - the toolchain automatically detects
| ScaLAPACK | 2.2.3 / 2.2.1 | Parallel linear algebra | BSD-3-Clause | Install |
| **Scientific Libraries** |||||
| FFTW | 3.3.11 / 3.3.10 | Fast Fourier Transform | GPL-2.0-or-later | Install |
| LibXC | 7.0.0 / 6.2.2 | Exchange-correlation | MPL-2.0 | Install |
| LibXC | 7.1.2 / 7.0.0 | Exchange-correlation | MPL-2.0 | Install |
| ELPA | 2026.02.001 / 2024.05.001 | Eigenvalue solver | LGPL-3.0-only | Install |
| **Advanced Features** |||||
| Cereal | pinned commit | C++ Serialization | BSD | Install |
Expand Down Expand Up @@ -247,14 +247,41 @@ CMAKE_VERSION="main" # main=3.31.7, alt=3.30.5
OPENMPI_VERSION="main" # main=5.0.10, alt=4.1.8
OPENBLAS_VERSION="main" # main=0.3.33, alt=0.3.30
ELPA_VERSION="main" # main=2026.02.001, alt=2024.05.001
LIBXC_VERSION="main" # main=7.0.0, alt=6.2.2
LIBXC_VERSION="main" # main=7.1.2, alt=7.0.0
SCALAPACK_VERSION="main" # main=2.2.3, alt=2.2.1
# Optional Libraries
LIBTORCH_VERSION="main" # main=2.1.2, alt=1.12.1 (use alt for older GLIBC)
```

and other `toolchain_*.sh` scripts share the same version selection.

#### LibXC KXC and HSE excited-state forces

The default LibXC `main` version is 7.1.2; `alt` selects 7.0.0.
The installer enables third derivatives (KXC) with `-DMAXORDER=3` for
LibXC 7.1 and newer, or `-DDISABLE_KXC=OFF -DDISABLE_LXC=ON` for older
versions. These settings apply when the toolchain builds LibXC, not when
using a system or externally installed library.

Starting with LibXC 7.1.0, the standard omega-PBEH (WPBEH) functional and
its HSE03/HSE06 combinations provide derivatives only through second order
(FXC). Enabling KXC at build time does not restore KXC for those functionals.
Upstream restricted their derivative order because of insufficient smoothness
at piecewise junctions and numerical stability issues; see the
[upstream change](https://gitlab.com/libxc/libxc/-/commit/df265b822368651dce578707bd5753d015480feb).
This limitation concerns HSE LR-TDDFT analytical excited-state forces;
it does not by itself prevent ground-state HSE calculations or spectra
requiring only FXC.

Users requiring the existing HSE LR-TDDFT force path can select the older
version when installing dependencies:

```bash
cd toolchain
./toolchain_gnu.sh --package-version libxc:alt
source install/setup
```

#### Global Version Strategy

- **Default Behavior**: All packages use their **main** versions unless explicitly overridden
Expand Down
12 changes: 10 additions & 2 deletions toolchain/scripts/stage3/install_libxc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,23 @@ case "$with_libxc" in
cd libxc-${libxc_ver}
mkdir build
cd build
# LibXC 7.1 replaced the per-order switches with MAXORDER.
IFS=. read -r libxc_major libxc_minor libxc_patch <<< "${libxc_ver}"
if (( libxc_major > 7 || (libxc_major == 7 && libxc_minor >= 1) )); then
libxc_derivative_args=(-DMAXORDER=3)
else
libxc_derivative_args=(-DDISABLE_KXC=OFF -DDISABLE_LXC=ON)
fi
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${pkg_install_dir} \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DENABLE_FORTRAN=ON \
-DENABLE_PYTHON=OFF \
-DBUILD_TESTING=OFF .. \
-DBUILD_TESTING=OFF \
"${libxc_derivative_args[@]}" .. \
> configure.log 2>&1 || tail -n ${LOG_LINES} configure.log
make -j $(get_nprocs) > make.log 2>&1 || tail -n ${LOG_LINES} make.log
make install > install.log 2>&1 || tail -n ${LOG_LINES} install.log
Expand Down
Loading