Add optional DFT-D4 support#7380
Open
Growl1234 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds DFT-D4 (Grimme) van der Waals dispersion support across the build/toolchain and the ABACUS runtime, including new input knobs and output reporting.
Changes:
- Toolchain: add DFT-D4 package/version wiring and a stage-4 installer script.
- Core: implement
vdw_method=d4via a newVdwd4backend calling the DFT-D4 C API and exposevdw_d4_xc. - Build/IO: add
ENABLE_DFTD4CMake option + linking, update energy/stress printing, and fix VDW stress output in LCAO.
Reviewed changes
Copilot reviewed 21 out of 22 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| toolchain/toolchain_intel.sh | Adds WITH_DFTD4 option passthrough to toolchain installer. |
| toolchain/toolchain_gnu.sh | Adds WITH_DFTD4 option passthrough to toolchain installer. |
| toolchain/toolchain_gcc-mkl.sh | Adds WITH_DFTD4 option passthrough to toolchain installer. |
| toolchain/scripts/stage4/install_stage4.sh | Runs the new DFT-D4 stage4 install step. |
| toolchain/scripts/stage4/install_dftd4.sh | New installer for the DFT-D4 library. |
| toolchain/scripts/package_versions.sh | Adds DFT-D4 version + checksum + loader case. |
| toolchain/scripts/lib/version_helper.sh | Fixes export line formatting. |
| toolchain/scripts/lib/package_manager.sh | Declares DFT-D4 dependency and fixes formatting. |
| toolchain/scripts/lib/config_manager.sh | Adds dftd4 to package lists and default config. |
| toolchain/build_abacus_intel.sh | Enables DFT-D4 in ABACUS CMake invocation. |
| toolchain/build_abacus_gnu.sh | Enables DFT-D4 in ABACUS CMake invocation. |
| toolchain/build_abacus_gcc-mkl.sh | Enables DFT-D4 in ABACUS CMake invocation. |
| source/source_pw/module_ofdft/of_print_info.cpp | Prints D4 energy label when used. |
| source/source_lcao/FORCE_STRESS.cpp | Fixes VDW stress printing to use stress_vdw. |
| source/source_io/module_parameter/read_input_item_model.cpp | Adds d4 to vdw_method, introduces vdw_d4_xc, and adjusts D4 defaults. |
| source/source_io/module_parameter/input_parameter.h | Adds vdw_d4_xc input field. |
| source/source_hamilt/module_vdw/vdwd4.h | New DFT-D4 VdW backend header. |
| source/source_hamilt/module_vdw/vdwd4.cpp | New DFT-D4 backend implementation using the DFT-D4 C API. |
| source/source_hamilt/module_vdw/vdw.cpp | Adds vdw_method == "d4" factory path. |
| source/source_hamilt/module_vdw/CMakeLists.txt | Conditionally builds/links DFT-D4 backend when enabled. |
| source/source_estate/elecstate_print.cpp | Prints D4 energy label in total-energy reporting. |
| CMakeLists.txt | Adds ENABLE_DFTD4 option and wires find_package(dftd4)/link flags. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3499c27 to
e5ed740
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Towards #5260.
This PR adds optional DFT-D4 support through the external dftd4 package. ABACUS provides a thin wrapper that passes atomic numbers, Cartesian positions, lattice vectors, periodic flags, the functional name, and cutoff settings to the DFT-D4 library. The returned dispersion energy, gradient, and virial/sigma are converted to ABACUS energy, force, and stress units and injected through the existing vdW correction framework. DFT-D4 internal damping parameters are used; no D4 parameter table is maintained in ABACUS.
Here is a simple test that shows the consistency with reference binary: d4-test.zip
Note:
dftd4-config*.cmake(with environment variableCMAKE_PREFIX_PATH) without requiring a customFindDFTD4.cmakeon the ABACUS side. This indicates that the conda package of dftd4 (built with meson and does not provide CMake package files) would not be supported.with_dftd4is not set toinstallfor toolchain scripts regarding AMD compilers and math libs, because these build are not tested yet.