Skip to content

Commit ddeaff3

Browse files
committed
merge modificaitons
2 parents 4a3b2bf + 6742c15 commit ddeaff3

File tree

241 files changed

+36247
-21896
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

241 files changed

+36247
-21896
lines changed

.github/workflows/build_test_cmake.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
name: "Build with Intel toolchain"
1818

1919
- tag: gnu
20-
build_args: "-DENABLE_LIBXC=1 -DENABLE_DEEPKS=1 -DENABLE_MLKEDF=1 -DENABLE_LIBRI=1"
20+
build_args: "-DENABLE_LIBXC=1 -DDENABLE_MLALGO=1 -DENABLE_LIBRI=1"
2121
name: "Build extra components with GNU toolchain"
2222
- tag: intel
23-
build_args: "-DENABLE_LIBXC=1 -DENABLE_DEEPKS=1 -DENABLE_MLKEDF=1 -DENABLE_LIBRI=1"
23+
build_args: "-DENABLE_LIBXC=1 -DENABLE_MLALGO=1 -DENABLE_LIBRI=1"
2424
name: "Build extra components with Intel toolchain"
2525

2626
- tag: cuda

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
apt update && apt install -y lcov gpg curl jq ca-certificates
1919
- name: Building
2020
run: |
21-
cmake -B build -DENABLE_COVERAGE=ON -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON
21+
cmake -B build -DENABLE_COVERAGE=ON -DBUILD_TESTING=ON -DENABLE_MLALGO=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON
2222
cmake --build build -j`nproc`
2323
cmake --install build
2424
- name: Testing

.github/workflows/dynamic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v4
1717
- name: Building
1818
run: |
19-
cmake -B build -DENABLE_ASAN=1 -DENABLE_DEEPKS=1 -DENABLE_LIBXC=1
19+
cmake -B build -DENABLE_ASAN=1 -DENABLE_MLALGO=1 -DENABLE_LIBXC=1
2020
cmake --build build -j8
2121
cmake --install build
2222
- name: Testing

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
3232
- name: Configure
3333
run: |
34-
cmake -B build -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_MLKEDF=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DENABLE_FLOAT_FFTW=ON
34+
cmake -B build -DBUILD_TESTING=ON -DENABLE_MLALGO=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DENABLE_FLOAT_FFTW=ON
3535
3636
# Temporarily removed because no one maintains this now.
3737
# And it will break the CI test workflow.

CMakeLists.txt

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ option(USE_DSP "Enable DSP" OFF)
2121
option(USE_ABACUS_LIBM "Build libmath from source to speed up" OFF)
2222
option(ENABLE_LIBXC "Enable using the LibXC package" OFF)
2323
option(ENABLE_FLOAT_FFTW "Enable using single-precision FFTW library." OFF)
24-
option(ENABLE_DEEPKS "Enable the DeePKS algorithm" OFF)
25-
option(ENABLE_MLKEDF "Enable the Machine-Learning-based KEDF for OFDFT" OFF)
24+
25+
# option(ENABLE_DEEPKS "Enable the DeePKS algorithm" OFF)
26+
# option(ENABLE_MLKEDF "Enable the Machine-Learning-based KEDF for OFDFT" OFF)
27+
28+
option(ENABLE_MLALGO "Enable the machine learning algorithms" OFF)
2629

2730
option(ENABLE_LCAO "Enable LCAO algorithm" ON)
2831
option(USE_ELPA "Enable ELPA for LCAO" ON)
@@ -115,7 +118,7 @@ endif()
115118
# Serial version of ABACUS will not use ELPA
116119
if(NOT ENABLE_MPI)
117120
set(USE_ELPA OFF)
118-
set(ENABLE_DEEPKS OFF)
121+
set(ENABLE_MLALGO OFF)
119122
endif()
120123

121124
# Different exe files of ABACUS
@@ -253,7 +256,7 @@ if(ENABLE_LCAO)
253256
add_compile_definitions(__NEW_GINT)
254257
endif()
255258
else()
256-
set(ENABLE_DEEPKS OFF)
259+
set(ENABLE_MLALGO OFF)
257260
set(ENABLE_LIBRI OFF)
258261
endif()
259262

@@ -480,8 +483,9 @@ if(ENABLE_FLOAT_FFTW)
480483
add_definitions(-D__ENABLE_FLOAT_FFTW)
481484
endif()
482485

483-
if(ENABLE_DEEPKS)
484-
target_link_libraries(${ABACUS_BIN_NAME} deepks)
486+
if(ENABLE_MLALGO)
487+
target_link_libraries(${ABACUS_BIN_NAME} deepks) # deepks
488+
target_link_libraries(${ABACUS_BIN_NAME} hamilt_mlkedf) # mlkedf
485489

486490
find_path(libnpy_SOURCE_DIR npy.hpp HINTS ${libnpy_INCLUDE_DIR})
487491
if(NOT libnpy_SOURCE_DIR)
@@ -496,32 +500,14 @@ if(ENABLE_DEEPKS)
496500
include_directories(${libnpy_INCLUDE_DIR})
497501
endif()
498502
include_directories(${libnpy_SOURCE_DIR}/include)
499-
add_compile_definitions(__DEEPKS)
500-
endif()
501-
502-
if(ENABLE_MLKEDF)
503-
target_link_libraries(${ABACUS_BIN_NAME} hamilt_mlkedf)
504-
505-
find_path(libnpy_SOURCE_DIR npy.hpp HINTS ${libnpy_INCLUDE_DIR})
506-
if(NOT libnpy_SOURCE_DIR)
507-
include(FetchContent)
508-
FetchContent_Declare(
509-
libnpy
510-
GIT_REPOSITORY https://github.com/llohse/libnpy.git
511-
GIT_SHALLOW TRUE
512-
GIT_PROGRESS TRUE)
513-
FetchContent_MakeAvailable(libnpy)
514-
else()
515-
include_directories(${libnpy_INCLUDE_DIR})
516-
endif()
517-
include_directories(${libnpy_SOURCE_DIR}/include)
518-
add_compile_definitions(__MLKEDF)
503+
504+
add_compile_definitions(__MLALGO)
519505
endif()
520506

521507
# Torch uses outdated components to detect CUDA arch, causing failure on
522508
# latest CUDA kits. Set CMake variable TORCH_CUDA_ARCH_LIST in the form of
523509
# "major.minor" if required.
524-
if(ENABLE_DEEPKS OR ENABLE_MLKEDF OR DEFINED Torch_DIR)
510+
if(ENABLE_MLALGO OR DEFINED Torch_DIR)
525511
find_package(Torch REQUIRED)
526512
if(NOT Torch_VERSION VERSION_LESS "2.1.0")
527513
set_if_higher(CMAKE_CXX_STANDARD 17)

Dockerfile.gnu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ ADD https://api.github.com/repos/deepmodeling/abacus-develop/git/refs/heads/deve
3434

3535
RUN git clone https://github.com/deepmodeling/abacus-develop.git --depth 1 && \
3636
cd abacus-develop && \
37-
cmake -B build -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_RAPIDJSON=ON && \
37+
cmake -B build -DENABLE_MLALGO=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_RAPIDJSON=ON && \
3838
cmake --build build -j`nproc` && \
3939
cmake --install build && \
4040
rm -rf build

Dockerfile.intel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ADD https://api.github.com/repos/deepmodeling/abacus-develop/git/refs/heads/deve
5858
RUN source /opt/intel/oneapi/setvars.sh && \
5959
git clone https://github.com/deepmodeling/abacus-develop.git --depth 1 && \
6060
cd abacus-develop && \
61-
cmake -B build -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_RAPIDJSON=ON && \
61+
cmake -B build -DENABLE_MLALGO=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_RAPIDJSON=ON && \
6262
cmake --build build -j`nproc` && \
6363
cmake --install build && \
6464
rm -rf build && \

conda/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ build:
2626
skip: true # [not linux]
2727
script: |
2828
export CMAKE_PREFIX_PATH=`python -c "import torch;print(torch.__path__[0])"`/share/cmake:$CMAKE_PREFIX_PATH
29-
cmake -B conda_build ${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release -DENABLE_DEEPKS=1 -DENABLE_LIBXC=1
29+
cmake -B conda_build ${CMAKE_ARGS} -DCMAKE_BUILD_TYPE=Release -DENABLE_MLALGO=1 -DENABLE_LIBXC=1
3030
cmake --build conda_build -j`nproc`
3131
cmake --install conda_build
3232
# ${CMAKE_ARGS} applys restrictions for CMake to search libs under conda building env.

docs/advanced/input_files/input-main.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
- [nupdown](#nupdown)
6666
- [dft\_functional](#dft_functional)
6767
- [xc\_temperature](#xc_temperature)
68+
- [xc\_exch\_ext](#xc_exch_ext)
69+
- [xc\_corr\_ext](#xc_corr_ext)
6870
- [pseudo\_rcut](#pseudo_rcut)
6971
- [pseudo\_mesh](#pseudo_mesh)
7072
- [nspin](#nspin)
@@ -1060,6 +1062,26 @@ calculations.
10601062
- **Default**: 0.0
10611063
- **Unit**: Ry
10621064

1065+
### xc_exch_ext
1066+
1067+
- **Type**: Integer Real ...
1068+
- **Description**: Customized parameterization on the exchange part of XC functional. The first value should be the LibXC ID of the original functional, and latter values are external parameters. Default values are those of Perdew-Burke-Ernzerhof (PBE) functional. For more information on LibXC ID of functionals, please refer to [LibXC](https://libxc.gitlab.io/functionals/). For parameters of functionals of interest, please refer to the source code of LibXC, such as PBE functional interface in LibXC: [gga_x_pbe.c](https://gitlab.com/libxc/libxc/-/blob/7.0.0/src/gga_x_pbe.c).
1069+
- **Default**: 101 0.8040 0.2195149727645171
1070+
- **Note**:
1071+
1. Solely setting this keyword will take no effect on XC functionals. One should also set `dft_functional` to corresponding functional to apply the customized parameterization. For example, if you want to use the PBE functional with customized parameters, you should set `dft_functional` to `GGA_X_PBE+GGA_C_PBE` and `xc_exch_ext` to `101 0.8040 0.2195149727645171`.
1072+
2. For functionals that do not have separate exchange and correlation parts, such as HSE06 whose corresponding LibXC notation is `HYB_GGA_XC_HSE06` and LibXC id is 428, you can set either `xc_exch_ext` or `xc_corr_ext` to `428 0.25 0.11 0.11` (which means 25% Hartree-Fock fraction, 0.11 as range-seperation) and leave the other one unset.
1073+
3. Presently this feature can only support parameterization on **one** exchange functional.
1074+
1075+
### xc_corr_ext
1076+
1077+
- **Type**: Integer Real ...
1078+
- **Description**: Customized parameterization on the correlation part of XC functional. The first value should be the LibXC ID of the original functional, and latter values are external parameters. Default values are those of Perdew-Burke-Ernzerhof (PBE) functional. For more information on LibXC ID of functionals, please refer to [LibXC](https://libxc.gitlab.io/functionals/). For parameters of functionals of interest, please refer to the source code of LibXC, such as PBE functional interface in LibXC: [gga_c_pbe.c](https://gitlab.com/libxc/libxc/-/blob/7.0.0/src/gga_c_pbe.c).
1079+
- **Default**: 130 0.06672455060314922 0.031090690869654895034 1.0
1080+
- **Note**:
1081+
1. Solely setting this keyword will take no effect on XC functionals. One should also set `dft_functional` to corresponding functional to apply the customized parameterization. For example, if you want to use the PBE functional with customized parameters, you should set `dft_functional` to `GGA_X_PBE+GGA_C_PBE` and `xc_corr_ext` to `130 0.06672455060314922 0.031090690869654895034 1.0`.
1082+
2. For functionals that do not have separate exchange and correlation parts, such as HSE06 whose corresponding LibXC notation is `HYB_GGA_XC_HSE06` and LibXC id is 428, you can set either `xc_exch_ext` or `xc_corr_ext` to `428 0.25 0.11 0.11` (which means 25% Hartree-Fock fraction, 0.11 as range-seperation) and leave the other one unset.
1083+
3. Presently this feature can only support parameterization on **one** correlation functional.
1084+
10631085
### pseudo_rcut
10641086

10651087
- **Type**: Real
@@ -2378,8 +2400,29 @@ Warning: this function is not robust enough for the current version. Please try
23782400
### of_ml_gene_data
23792401

23802402
- **Type**: Boolean
2381-
- **Availability**: OFDFT
2382-
- **Description**: Generate training data or not.
2403+
- **Availability**: Used only for KSDFT with plane wave basis
2404+
- **Description**: Controls the generation of machine learning training data. When enabled, training data in `.npy` format will be saved in the directory `OUT.${suffix}/MLKEDF_Descriptors/`. The generated descriptors are categorized as follows:
2405+
- Local/Semilocal Descriptors. Files are named as `{var}.npy`, where `{var}` corresponds to the descriptor type:
2406+
- `gamma`: Enabled by [of_ml_gamma](#of_ml_gamma)
2407+
- `p`: Enabled by [of_ml_p](#of_ml_p)
2408+
- `q`: Enabled by [of_ml_q](#of_ml_q)
2409+
- `tanhp`: Enabled by [of_ml_tanhp](#of_ml_tanhp)
2410+
- `tanhq`: Enabled by [of_ml_tanhq](#of_ml_tanhq)
2411+
- Nonlocal Descriptors generated using kernels configured via [of_ml_nkernel](#of_ml_nkernel), [of_ml_kernel](#of_ml_kernel), and [of_ml_kernel_scaling](#of_ml_kernel_scaling). Files follow the naming convention `{var}_{kernel_type}_{kernel_scaling}.npy`, where `{kernel_type}` and `{kernel_scaling}` are specified by [of_ml_kernel](#of_ml_kernel), and [of_ml_kernel_scaling](#of_ml_kernel_scaling), respectively, and `{val}` denotes the kind of the descriptor, including
2412+
- `gammanl`: Enabled by [of_ml_gammanl](#of_ml_gammanl)
2413+
- `pnl`: Enabled by [of_ml_pnl](#of_ml_pnl)
2414+
- `qnl`: Enabled by [of_ml_qnl](#of_ml_qnl)
2415+
- `xi`: Enabled by [of_ml_xi](#of_ml_xi)
2416+
- `tanhxi`: Enabled by [of_ml_tanhxi](#of_ml_tanhxi)
2417+
- `tanhxi_nl`: Enabled by [of_ml_tanhxi_nl](#of_ml_tanhxi_nl)
2418+
- `tanh_pnl`: Enabled by [of_ml_tanh_pnl](#of_ml_tanh_pnl)
2419+
- `tanh_qnl`: Enabled by [of_ml_tanh_qnl](#of_ml_tanh_qnl)
2420+
- `tanhp_nl`: Enabled by [of_ml_tanhp_nl](#of_ml_tanhp_nl)
2421+
- `tanhq_nl`: Enabled by [of_ml_tanhq_nl](#of_ml_tanhq_nl)
2422+
- Training Targets, including key quantum mechanical quantities:
2423+
- `enhancement.npy`: Pauli energy enhancement factor $T_\theta/T_{\rm{TF}}$, where $T_{\rm{TF}}$ is the Thomas-Fermi functional
2424+
- `pauli.npy`: Pauli potential $V_\theta$
2425+
- `veff.npy`: Effective potential
23832426
- **Default**: False
23842427

23852428
### of_ml_device

docs/advanced/install.md

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,17 @@ If Libxc is not installed in standard path (i.e. installed with a custom prefix
1616
cmake -B build -DLibxc_DIR=~/libxc
1717
```
1818

19-
## Build with DeePKS
19+
## Build with ML-ALGO
2020

21-
If DeePKS feature is required for [DeePKS-kit](https://github.com/deepmodeling/deepks-kit), the following prerequisites and steps are needed:
22-
23-
- C++ compiler, supporting **C++14** (GCC >= 5 is sufficient)
24-
- CMake >= 3.18
25-
- [LibTorch](https://pytorch.org/) with cxx11 ABI supporting CPU
26-
- [Libnpy](https://github.com/llohse/libnpy/)
27-
28-
```bash
29-
cmake -B build -DENABLE_DEEPKS=1 -DTorch_DIR=~/libtorch/share/cmake/Torch/ -Dlibnpy_INCLUDE_DIR=~/libnpy/include
30-
```
31-
32-
> CMake will try to download Libnpy if it cannot be found locally.
33-
34-
## Build with ML-KEDF
35-
36-
If machine learning based kinetic energy density functional (ML-KEDF) is required for OFDFT calculation, the following prerequisites and steps are needed:
21+
If machine learning algorithms, including DeePKS and machine learning based kinetic energy density functional (ML-KEDF) for OFDFT, is required for DFT calculation, the following prerequisites and steps are needed:
3722

3823
- C++ compiler, supporting **C++14** (GCC >= 5 is sufficient)
3924
- CMake >= 3.18
4025
- [LibTorch](https://pytorch.org/) with cxx11 ABI supporting CPU or GPU
4126
- [Libnpy](https://github.com/llohse/libnpy/)
4227

4328
```bash
44-
cmake -B build -DENABLE_MLKEDF=1 -DTorch_DIR=~/libtorch/share/cmake/Torch/ -Dlibnpy_INCLUDE_DIR=~/libnpy/include
29+
cmake -B build -DENABLE_MLALGO=1 -DTorch_DIR=~/libtorch/share/cmake/Torch/ -Dlibnpy_INCLUDE_DIR=~/libnpy/include
4530
```
4631

4732
> CMake will try to download Libnpy if it cannot be found locally.
@@ -206,8 +191,8 @@ CEREAL_DIR = /usr/local/include/cereal
206191

207192

208193
##------------------- OPTIONAL LIBS ---------------------------------
209-
## To use DEEPKS: set ENABLE_DEEPKS = ON, and set LIBTORCH_DIR and LIBNPY_DIR
210-
## To use MLKEDF: set ENABLE_MLKEDF = ON, and set LIBTORCH_DIR and LIBNPY_DIR
194+
## To use MLALGO: set ENABLE_MLALGO = ON, and set LIBTORCH_DIR and LIBNPY_DIR
195+
211196
## To use LIBXC: set LIBXC_DIR which contains include and lib/libxc.a (>5.1.7)
212197
## To use DeePMD: set DeePMD_DIR LIBTORCH_DIR and TensorFlow_DIR
213198
## To use LibRI: set LIBRI_DIR and LIBCOMM_DIR
@@ -216,8 +201,7 @@ CEREAL_DIR = /usr/local/include/cereal
216201

217202
# LIBTORCH_DIR = /usr/local
218203
# LIBNPY_DIR = /usr/local
219-
ENABLE_DEEPKS = OFF
220-
ENABLE_MLKEDF = OFF
204+
ENABLE_MLALGO = OFF
221205

222206
# LIBXC_DIR = /public/soft/libxc
223207

@@ -292,25 +276,16 @@ make LIBXC_DIR=/pulic/soft/libxc
292276

293277
directly.
294278

295-
### Add DeePKS Support
279+
### Add ML-ALGO Support
296280

297-
To compile ABACUS with DEEPKS, you need to set `ENABLE_DEEPKS = ON`, and define `LIBTORCH_DIR` and `LIBNPY_DIR` in the file `Makefile.vars` or use
281+
To compile ABACUS with machine learning algorithms, you need to set `ENABLE_MLALGO = ON`, and define `LIBTORCH_DIR` and `LIBNPY_DIR` in the file `Makefile.vars` or use
298282

299283
```makefile
300-
make ENABLE_DEEPKS=ON LIBTORCH_DIR=/opt/libtorch/ LIBNPY_DIR=/opt/libnpy/
284+
make ENABLE_MLALGO=ON LIBTORCH_DIR=/opt/libtorch/ LIBNPY_DIR=/opt/libnpy/
301285
```
302286

303287
directly.
304288

305-
### Add ML-KEDF Support
306-
307-
To compile ABACUS with ML-KEDF, you need to set `ENABLE_MLKEDF = ON`, and define `LIBTORCH_DIR` and `LIBNPY_DIR` in the file `Makefile.vars` or use
308-
309-
```makefile
310-
make ENABLE_MLKEDF=ON LIBTORCH_DIR=/opt/libtorch/ LIBNPY_DIR=/opt/libnpy/
311-
```
312-
313-
directly.
314289

315290
### Add DeePMD-kit Support
316291

0 commit comments

Comments
 (0)