Skip to content

Commit 6bf64a9

Browse files
committed
Merge branch 'develop' into Exx_Opt_Orb
2 parents 33539b5 + 3984296 commit 6bf64a9

File tree

480 files changed

+10481
-8077
lines changed

Some content is hidden

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

480 files changed

+10481
-8077
lines changed

.github/workflows/coverage.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
uses: actions/checkout@v4
1616
- name: Install Requirements for Coverage Testing
1717
run: |
18-
apt update && apt install -y lcov
18+
apt update && apt install -y lcov gpg
1919
- name: Building
2020
run: |
21-
cmake -B build -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DBUILD_TESTING=ON -DENABLE_COVERAGE=ON
21+
cmake -B build -DENABLE_COVERAGE=ON -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_PAW=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON
2222
cmake --build build -j`nproc`
2323
cmake --install build
2424
- name: Testing

CMakeLists.txt

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ option(ENABLE_RAPIDJSON "Enable rapid-json usage." OFF)
3939
option(ENABLE_CNPY "Enable cnpy usage." OFF)
4040
option(ENABLE_PEXSI "Enable support for PEXSI." OFF)
4141
option(ENABLE_CUSOLVERMP "Enable cusolvermp." OFF)
42+
option(USE_DSP "Enable DSP usage." OFF)
4243

4344
# enable json support
4445
if(ENABLE_RAPIDJSON)
@@ -119,6 +120,12 @@ elseif(ENABLE_LCAO AND NOT ENABLE_MPI)
119120
set(ABACUS_BIN_NAME abacus_serial)
120121
endif()
121122

123+
if (USE_DSP)
124+
set(USE_ELPA OFF)
125+
set(ENABLE_LCAO OFF)
126+
set(ABACUS_BIN_NAME abacus_dsp)
127+
endif()
128+
122129
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
123130

124131
if(ENABLE_COVERAGE)
@@ -240,6 +247,11 @@ if(ENABLE_MPI)
240247
list(APPEND math_libs MPI::MPI_CXX)
241248
endif()
242249

250+
if (USE_DSP)
251+
target_link_libraries(${ABACUS_BIN_NAME} ${DIR_MTBLAS_LIBRARY})
252+
add_compile_definitions(__DSP)
253+
endif()
254+
243255
find_package(Threads REQUIRED)
244256
target_link_libraries(${ABACUS_BIN_NAME} Threads::Threads)
245257

@@ -436,22 +448,6 @@ if(ENABLE_FLOAT_FFTW)
436448
endif()
437449

438450
if(ENABLE_DEEPKS)
439-
# Torch uses outdated components to detect CUDA arch, causing failure on
440-
# latest CUDA kits. Set CMake variable TORCH_CUDA_ARCH_LIST in the form of
441-
# "major.minor" if required.
442-
find_package(Torch REQUIRED)
443-
if(NOT Torch_VERSION VERSION_LESS "2.1.0")
444-
set_if_higher(CMAKE_CXX_STANDARD 17)
445-
elseif(NOT Torch_VERSION VERSION_LESS "1.5.0")
446-
set_if_higher(CMAKE_CXX_STANDARD 14)
447-
endif()
448-
include_directories(${TORCH_INCLUDE_DIRS})
449-
if(MKL_FOUND)
450-
list(PREPEND math_libs ${TORCH_LIBRARIES})
451-
else()
452-
list(APPEND math_libs ${TORCH_LIBRARIES})
453-
endif()
454-
add_compile_options(${TORCH_CXX_FLAGS})
455451
target_link_libraries(${ABACUS_BIN_NAME} deepks)
456452

457453
find_path(libnpy_SOURCE_DIR npy.hpp HINTS ${libnpy_INCLUDE_DIR})
@@ -470,6 +466,25 @@ if(ENABLE_DEEPKS)
470466
add_compile_definitions(__DEEPKS)
471467
endif()
472468

469+
# Torch uses outdated components to detect CUDA arch, causing failure on
470+
# latest CUDA kits. Set CMake variable TORCH_CUDA_ARCH_LIST in the form of
471+
# "major.minor" if required.
472+
if(ENABLE_DEEPKS OR DEFINED Torch_DIR)
473+
find_package(Torch REQUIRED)
474+
if(NOT Torch_VERSION VERSION_LESS "2.1.0")
475+
set_if_higher(CMAKE_CXX_STANDARD 17)
476+
elseif(NOT Torch_VERSION VERSION_LESS "1.5.0")
477+
set_if_higher(CMAKE_CXX_STANDARD 14)
478+
endif()
479+
include_directories(${TORCH_INCLUDE_DIRS})
480+
if(MKL_FOUND)
481+
list(PREPEND math_libs ${TORCH_LIBRARIES})
482+
else()
483+
list(APPEND math_libs ${TORCH_LIBRARIES})
484+
endif()
485+
add_compile_options(${TORCH_CXX_FLAGS})
486+
endif()
487+
473488
if (ENABLE_CNPY)
474489
find_path(cnpy_SOURCE_DIR
475490
cnpy.h
@@ -590,13 +605,14 @@ if(DEFINED DeePMD_DIR)
590605
add_compile_definitions(__DPMDC)
591606
else()
592607
target_link_libraries(${ABACUS_BIN_NAME} DeePMD::deepmd_cc)
593-
if(NOT DEFINED TensorFlow_DIR)
594-
set(TensorFlow_DIR ${DeePMD_DIR})
595-
endif()
596-
find_package(TensorFlow REQUIRED)
597-
if(TensorFlow_FOUND)
598-
target_link_libraries(${ABACUS_BIN_NAME} TensorFlow::tensorflow_cc)
599-
endif()
608+
endif()
609+
endif()
610+
611+
if(DEFINED TensorFlow_DIR)
612+
find_package(TensorFlow REQUIRED)
613+
include_directories(${TensorFlow_DIR}/include)
614+
if(TensorFlow_FOUND)
615+
target_link_libraries(${ABACUS_BIN_NAME} TensorFlow::tensorflow_cc)
600616
endif()
601617
endif()
602618

docs/advanced/acceleration/cuda.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The ABACUS program will automatically determine whether the current ELPA support
3636
## Run with the GPU support by editing the INPUT script:
3737

3838
In `INPUT` file we need to set the input parameter [device](../input_files/input-main.md#device) to `gpu`. If this parameter is not set, ABACUS will try to determine if there are available GPUs.
39-
- Set `ks_solver`: For the PW basis, CG, BPCG and Davidson methods are supported on GPU; set the input parameter [ks_solver](../input_files/input-main.md#ks_solver) to `cg`, `bpcg` or `dav`. For the LCAO basis, `cusolver` and `elpa` is supported on GPU.
39+
- Set `ks_solver`: For the PW basis, CG, BPCG and Davidson methods are supported on GPU; set the input parameter [ks_solver](../input_files/input-main.md#ks_solver) to `cg`, `bpcg` or `dav`. For the LCAO basis, `cusolver`, `cusolvermp` and `elpa` is supported on GPU.
4040
- **multi-card**: ABACUS allows for multi-GPU acceleration. If you have multiple GPU cards, you can run ABACUS with several MPI processes, and each process will utilize one GPU card. For example, the command `mpirun -n 2 abacus` will by default launch two GPUs for computation. If you only have one card, this command will only start one GPU.
4141

4242
## Examples

docs/advanced/elec_properties/Berry_phase.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pseudo_dir ../../../tests/PP_ORB //the path to locate the pesudopotential
2323
orbital_dir ../../../tests/PP_ORB //the path to locate the numerical orbital files
2424
ntype 3
2525
ecutwfc 50 // Ry
26-
symmetry 0 // turn off symmetry
26+
symmetry -1 // turn off symmetry
2727
calculation nscf // non-self-consistent calculation
2828
basis_type lcao // atomic basis
2929
init_chg file // read charge from files
@@ -70,4 +70,6 @@ The results are shown as follows:
7070
P = 0.8906925 (mod 2.1748536) ( 0.0000000, 0.0000000, 0.8906925) C/m^2
7171
```
7272

73-
The electric polarization **P** is multivalued, which modulo a quantum e**R**/V~cell~. Note: the values in parentheses are the components of the **P** along the c axis in the x, y, z Cartesian coordinates when set gdir = 3 in INPUT file.
73+
The electric polarization **P** is multivalued, which modulo a quantum e**R**/V~cell~.
74+
75+
Note: The vectors R1, R2, and R3 refer to the three lattice vectors of the unit cell. When gdir=3, the calculated polarization is along the R3 direction. The three values in parentheses represent the re-projection of the polarization along the R3 direction onto the Cartesian coordinate system (i.e., the xyz coordinate system). To obtain the full polarization components in the Cartesian system, you need to calculate the polarization for R1, R2, and R3 separately, and then sum their respective x, y, and z components.

docs/advanced/input_files/input-main.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
- [pw\_diag\_thr](#pw_diag_thr)
4040
- [pw\_diag\_nmax](#pw_diag_nmax)
4141
- [pw\_diag\_ndim](#pw_diag_ndim)
42-
- [diago\_full\_acc](#diago_full_acc)
4342
- [erf\_ecut](#erf_ecut)
4443
- [fft\_mode](#fft_mode)
4544
- [erf\_height](#erf_height)
@@ -779,12 +778,6 @@ These variables are used to control the plane wave related parameters.
779778
- **Description**: Only useful when you use `ks_solver = dav` or `ks_solver = dav_subspace`. It indicates dimension of workspace(number of wavefunction packets, at least 2 needed) for the Davidson method. A larger value may yield a smaller number of iterations in the algorithm but uses more memory and more CPU time in subspace diagonalization.
780779
- **Default**: 4
781780

782-
### diago_full_acc
783-
784-
- **Type**: bool
785-
- **Description**: Only useful when you use `ks_solver = dav_subspace`. If `TRUE`, all the empty states are diagonalized at the same level of accuracy of the occupied ones. Otherwise the empty states are diagonalized using a larger threshold (10-5) (this should not affect total energy, forces, and other ground-state properties).
786-
- **Default**: false
787-
788781
### erf_ecut
789782

790783
- **Type**: Real
@@ -925,14 +918,16 @@ calculations.
925918
- **cg**: cg method.
926919
- **bpcg**: bpcg method, which is a block-parallel Conjugate Gradient (CG) method, typically exhibits higher acceleration in a GPU environment.
927920
- **dav**: the Davidson algorithm.
928-
- **dav_subspace**: subspace Davidson algorithm
921+
- **dav_subspace**: Davidson algorithm without orthogonalization operation, this method is the most recommended for efficiency. `pw_diag_ndim` can be set to 2 for this method.
929922

930923
For atomic orbitals basis,
931924

932925
- **lapack**: This method is only avaliable for serial version. For parallel version please use **scalapack_gvx**.
933926
- **genelpa**: This method should be used if you choose localized orbitals.
934927
- **scalapack_gvx**: Scalapack can also be used for localized orbitals.
935928
- **cusolver**: This method needs building with CUDA and at least one gpu is available.
929+
- **cusolvermp**: This method supports multi-GPU acceleration and needs building with CUDA。 Note that when using cusolvermp, you should set the number of MPI processes to be equal to the number of GPUs.
930+
- **elpa**: The ELPA solver supports both CPU and GPU. By setting the `device` to GPU, you can launch the ELPA solver with GPU acceleration (provided that you have installed a GPU-supported version of ELPA, which requires you to manually compile and install ELPA, and the ABACUS should be compiled with -DUSE_ELPA=ON and -DUSE_CUDA=ON). The ELPA solver also supports multi-GPU acceleration.
936931

937932
If you set ks_solver=`genelpa` for basis_type=`pw`, the program will be stopped with an error message:
938933

@@ -941,7 +936,13 @@ calculations.
941936
```
942937

943938
Then the user has to correct the input file and restart the calculation.
944-
- **Default**: cg (plane-wave basis), or genelpa (localized atomic orbital basis, if compiling option `USE_ELPA` has been set),lapack (localized atomic orbital basis, if compiling option `ENABLE_MPI` has not been set), scalapack_gvx, (localized atomic orbital basis, if compiling option `USE_ELPA` has not been set and if compiling option `ENABLE_MPI` has been set)
939+
- **Default**:
940+
- **PW basis**: cg.
941+
- **LCAO basis**:
942+
- genelpa (if compiling option `USE_ELPA` has been set)
943+
- lapack (if compiling option `ENABLE_MPI` has not been set)
944+
- scalapack_gvx (if compiling option `USE_ELPA` has not been set and compiling option `ENABLE_MPI` has been set)
945+
- cusolver (if compiling option `USE_CUDA` has been set)
945946

946947
### nbands
947948

@@ -3956,6 +3957,13 @@ Currently supported: `RPA`, `LDA`, `PBE`, `HSE`, `HF`.
39563957
- **Description**: The number of 2-particle states to be solved
39573958
- **Default**: 0
39583959

3960+
### lr_unrestricted
3961+
- **Type**: Boolean
3962+
- **Description**: Whether to use unrestricted construction for LR-TDDFT (the matrix size will be doubled).
3963+
- True: Always use unrestricted LR-TDDFT.
3964+
- False: Use unrestricted LR-TDDFT only when the system is open-shell.
3965+
- **Default**: False
3966+
39593967
### abs_wavelen_range
39603968

39613969
- **Type**: Real Real

docs/advanced/input_files/kpt.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ABACUS uses periodic boundary conditions for both crystals and finite systems. F
88

99
## Gamma-only Calculations
1010

11-
In ABACUS, we offer th option of running gamma-only calculations for LCAO basis by setting [gamma_only](./input-main.md#gamma_only) to be 1. Due to details of implementation, gamma-only calculation will be slightly faster than running a non gamma-only calculation and explicitly setting gamma point to be the only the k-point, but the results should be consistent.
11+
In ABACUS, we offer the option of running gamma-only calculations for LCAO basis by setting [gamma_only](./input-main.md#gamma_only) to be 1. Due to details of implementation, gamma-only calculation will be slightly faster than running a non gamma-only calculation and explicitly setting gamma point to be the only the k-point, but the results should be consistent.
1212

1313
> If gamma_only is set to 1, the KPT file will be overwritten. So make sure to turn off gamma_only for multi-k calculations.
1414
@@ -23,7 +23,7 @@ method to generate k-mesh, and the following is an example input k-point (`KPT`)
2323
K_POINTS //keyword for start
2424
0 //total number of k-point, `0' means generate automatically
2525
Gamma //which kind of Monkhorst-Pack method, `Gamma' or `MP'
26-
2 2 2 0 0 0 //first three number: subdivisions along recpri. vectors
26+
2 2 2 0 0 0 //first three number: subdivisions along reciprocal vectors
2727
//last three number: shift of the mesh
2828
```
2929

@@ -63,8 +63,8 @@ Direct //`Direct' or `Cartesian' coordinate
6363
## Band structure calculations
6464

6565
ABACUS uses specified high-symmetry directions of the Brillouin zone for band structure
66-
calculations. The third line of k-point file should start with Line or Line_Cartesian for
67-
line mode. Line means the positions below are in Direct coordinates, while Line_Cartesian
66+
calculations. The third line of k-point file should start with 'Line' or 'Line_Cartesian' for
67+
line mode. 'Line' means the positions below are in Direct coordinates, while 'Line_Cartesian'
6868
means in Cartesian coordinates:
6969

7070
```

docs/advanced/install.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,22 @@ cmake -B build -DENABLE_DEEPKS=1 -DTorch_DIR=~/libtorch/share/cmake/Torch/ -Dlib
3838
If the Deep Potential model is employed in Molecule Dynamics calculations, the following prerequisites and steps are needed:
3939

4040
- [DeePMD-kit](https://github.com/deepmodeling/deepmd-kit)
41-
- [TensorFlow](https://www.tensorflow.org/)
41+
- [TensorFlow](https://www.tensorflow.org/) (optional)
42+
- [LibTorch](https://pytorch.org/) (optional)
4243

44+
In the simplest case, the `tensorflow_cc` and `torch` libraries are in the same directory as the `deepmd_c`/`deepmd_cc` libraries, then
4345
```bash
44-
cmake -B build -DDeePMD_DIR=~/deepmd-kit -DTensorFlow_DIR=~/tensorflow
46+
cmake -B build -DDeePMD_DIR=/dir_to_deepmd-kit
4547
```
48+
DeePMD-kit supports TensorFlow backend but its libraries are placed at another directory, then
4649

47-
> `deepmd_c`/`deepmd_cc` and `tensorflow_cc` libraries would be called according to `DeePMD_DIR` and `TensorFlow_DIR`, which is showed in detail in [this page](https://github.com/deepmodeling/deepmd-kit/blob/master/doc/inference/cxx.md). If `TensorFlow_DIR` is not defined, it will be the same as `DeePMD_DIR`. Note that `tensorflow_cc` is not required if `deepmd_c` is found.
50+
```bash
51+
cmake -B build -DDeePMD_DIR=/dir_to_deepmd-kit -DTensorFlow_DIR=/dir_to_tensorflow
52+
```
53+
Similarly, DeePMD-kit supports PyTorch backend but its libraries are placed at another directory, then
54+
```bash
55+
cmake -B build -DDeePMD_DIR=/dir_to_deepmd-kit -DTorch_DIR=/dir_to_pytorch
56+
```
4857

4958
## Build with LibRI and LibComm
5059

@@ -93,9 +102,9 @@ cmake -B build -DUSE_CUDA=1 -DCMAKE_CUDA_COMPILER=${path to cuda toolkit}/bin/nv
93102

94103
## Build math library from source
95104

96-
> Note: This flag is **enabled by default**. It will get better performance than the standard implementation on `gcc` and `clang`. But it **will be disabled** when using `Intel Compiler` since the math functions will get wrong results and the performance is also unexpectly poor.
105+
> Note: We recommend using the latest available compiler sets, since they offer faster implementations of math functions.
97106
98-
To build math functions from source code, instead of using c++ standard implementation, define `USE_ABACUS_LIBM` flag.
107+
This flag is disabled by default. To build math functions from source code, define `USE_ABACUS_LIBM` flag. It is expected to get a better performance on legacy versions of `gcc` and `clang`.
99108

100109
Currently supported math functions:
101110
`sin`, `cos`, `sincos`, `exp`, `cexp`
@@ -282,15 +291,21 @@ directly.
282291

283292
> Note: This part is only required if you want to load a trained DeeP Potential and run molecular dynamics with that. To train the DeeP Potential with DP-GEN, no extra prerequisite is needed and please refer to [this page](http://abacus.deepmodeling.com/en/latest/advanced/interface/dpgen.html) for ABACUS interface with DP-GEN.
284293
285-
To compile ABACUS with DeePMD-kit, you need to define `DeePMD_DIR` and `TensorFlow_DIR` in the file `Makefile.vars` or use
294+
To compile ABACUS with DeePMD-kit, you need to define `DeePMD_DIR` and `TensorFlow_DIR` (TensorFlow Backend, optional) and/or `LIBTORCH_DIR` (PyTorch Backend, optional) in the file `Makefile.vars`.
286295

296+
Or the `tensorflow_cc` and `torch` libraries are in the same directory as the `deepmd_c`/`deepmd_cc` libraries, then
287297
```makefile
288-
make DeePMD_DIR=~/deepmd-kit TensorFlow_DIR=~/tensorflow
298+
make DeePMD_DIR=/dir_to_deepmd-kit
289299
```
300+
DeePMD-kit supports TensorFlow backend but its libraries are placed at another directory, then
290301

291-
directly.
292-
293-
> `deepmd_c`/`deepmd_cc` and `tensorflow_cc` libraries would be called according to `DeePMD_DIR` and `TensorFlow_DIR`, which is showed in detail in [this page](https://github.com/deepmodeling/deepmd-kit/blob/master/doc/inference/cxx.md). If `TensorFlow_DIR` is not defined, it will be the same as `DeePMD_DIR`. Note that `tensorflow_cc` is not required if `deepmd_c` is found.
302+
```makefile
303+
make DeePMD_DIR=/dir_to_deepmd-kit TensorFlow_DIR=/dir_to_tensorflow
304+
```
305+
Similarly, DeePMD-kit supports PyTorch backend but its libraries are placed at another directory, then
306+
```makefile
307+
make DeePMD_DIR=/dir_to_deepmd-kit Torch_DIR=/dir_to_pytorch
308+
```
294309

295310
### Add LibRI Support
296311
To use new EXX, you need two libraries: [LibRI](https://github.com/abacusmodeling/LibRI) and [LibComm](https://github.com/abacusmodeling/LibComm) and need to define `LIBRI_DIR` and `LIBCOMM_DIR` in the file `Makefile.vars` or use

0 commit comments

Comments
 (0)