Skip to content

Commit 4ed1725

Browse files
committed
Merge branch 'refactor' of https://github.com/ErjieWu/abacus-develop into refactor
2 parents 7d718e6 + 70b7f58 commit 4ed1725

File tree

101 files changed

+4046
-2709
lines changed

Some content is hidden

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

101 files changed

+4046
-2709
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ jobs:
3333
run: |
3434
cmake -B build -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON -DENABLE_MLKEDF=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_PAW=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1
3535
36-
- uses: pre-commit/[email protected]
37-
with:
38-
extra_args:
39-
--from-ref ${{ github.event.pull_request.base.sha }}
40-
--to-ref ${{ github.event.pull_request.head.sha }}
41-
continue-on-error: true
42-
- uses: pre-commit-ci/[email protected]
36+
# Temporarily removed because no one maintains this now.
37+
# And it will break the CI test workflow.
38+
39+
# - uses: pre-commit/[email protected]
40+
# with:
41+
# extra_args:
42+
# --from-ref ${{ github.event.pull_request.base.sha }}
43+
# --to-ref ${{ github.event.pull_request.head.sha }}
44+
# continue-on-error: true
45+
# - uses: pre-commit-ci/[email protected]
4346

4447
- name: Build
4548
run: |

CMakeLists.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ option(ENABLE_PEXSI "Enable support for PEXSI." OFF)
4242
option(ENABLE_CUSOLVERMP "Enable cusolvermp." OFF)
4343
option(USE_DSP "Enable DSP usage." OFF)
4444
option(USE_CUDA_ON_DCU "Enable CUDA on DCU" OFF)
45+
option(USE_CUDA_MPI "Enable CUDA-aware MPI" OFF)
4546

4647
# enable json support
4748
if(ENABLE_RAPIDJSON)
@@ -132,6 +133,10 @@ if (USE_CUDA_ON_DCU)
132133
add_compile_definitions(__CUDA_ON_DCU)
133134
endif()
134135

136+
if (USE_CUDA_MPI)
137+
add_compile_definitions(__CUDA_MPI)
138+
endif()
139+
135140
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
136141

137142
if(ENABLE_COVERAGE)
@@ -257,8 +262,12 @@ if(ENABLE_MPI)
257262
endif()
258263

259264
if (USE_DSP)
260-
target_link_libraries(${ABACUS_BIN_NAME} ${DIR_MTBLAS_LIBRARY})
261265
add_compile_definitions(__DSP)
266+
target_link_libraries(${ABACUS_BIN_NAME} ${OMPI_LIBRARY1})
267+
include_directories(${MTBLAS_FFT_DIR}/libmtblas/include)
268+
include_directories(${MT_HOST_DIR}/include)
269+
target_link_libraries(${ABACUS_BIN_NAME} ${MT_HOST_DIR}/hthreads/lib/libhthread_device.a)
270+
target_link_libraries(${ABACUS_BIN_NAME} ${MT_HOST_DIR}/hthreads/lib/libhthread_host.a)
262271
endif()
263272

264273
find_package(Threads REQUIRED)
@@ -429,10 +438,8 @@ else()
429438
find_package(Lapack REQUIRED)
430439
include_directories(${FFTW3_INCLUDE_DIRS})
431440
list(APPEND math_libs FFTW3::FFTW3 LAPACK::LAPACK BLAS::BLAS)
432-
433441
find_package(ScaLAPACK REQUIRED)
434442
list(APPEND math_libs ScaLAPACK::ScaLAPACK)
435-
436443
if(USE_OPENMP)
437444
list(APPEND math_libs FFTW3::FFTW3_OMP)
438445
endif()

cmake/FindMKL.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ endif()
8383
endif() # MKL::MKL
8484

8585
# For compatibility with legacy libpaw_interface CMakeLists.txt
86-
if(TARGET MKL::MKL)
86+
if(TARGET MKL::MKL AND NOT TARGET IntelMKL::MKL)
8787
add_library(IntelMKL::MKL ALIAS MKL::MKL)
8888
endif()
8989

docs/advanced/input_files/input-main.md

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
- [kspacing](#kspacing)
2121
- [min\_dist\_coef](#min_dist_coef)
2222
- [device](#device)
23-
- [nb2d](#nb2d)
2423
- [precision](#precision)
24+
- [nb2d](#nb2d)
2525
- [Variables related to input files](#variables-related-to-input-files)
2626
- [stru\_file](#stru_file)
2727
- [kpoint\_file](#kpoint_file)
@@ -224,6 +224,8 @@
224224
- [of\_ml\_q](#of_ml_q)
225225
- [of\_ml\_tanhp](#of_ml_tanhp)
226226
- [of\_ml\_tanhq](#of_ml_tanhq)
227+
- [of\_ml\_chi\_p](#of_ml_chi_p)
228+
- [of\_ml\_chi\_q](#of_ml_chi_q)
227229
- [of\_ml\_gammanl](#of_ml_gammanl)
228230
- [of\_ml\_pnl](#of_ml_pnl)
229231
- [of\_ml\_qnl](#of_ml_qnl)
@@ -234,8 +236,6 @@
234236
- [of\_ml\_tanh\_qnl](#of_ml_tanh_qnl)
235237
- [of\_ml\_tanhp\_nl](#of_ml_tanhp_nl)
236238
- [of\_ml\_tanhq\_nl](#of_ml_tanhq_nl)
237-
- [of\_ml\_chi\_p](#of_ml_chi_p)
238-
- [of\_ml\_chi\_q](#of_ml_chi_q)
239239
- [of\_ml\_chi\_xi](#of_ml_chi_xi)
240240
- [of\_ml\_chi\_pnl](#of_ml_chi_pnl)
241241
- [of\_ml\_chi\_qnl](#of_ml_chi_qnl)
@@ -583,7 +583,7 @@ These variables are used to control general system parameters.
583583
### init_wfc
584584

585585
- **Type**: String
586-
- **Description**: Only useful for plane wave basis only now. It is the name of the starting wave functions. In the future. we should also make this variable available for localized orbitals set.
586+
- **Description**: The type of the starting wave functions.
587587

588588
Available options are:
589589

@@ -593,6 +593,8 @@ These variables are used to control general system parameters.
593593
- random: random numbers
594594
- nao: from numerical atomic orbitals. If they are not enough, other wave functions are initialized with random numbers.
595595
- nao+random: add small random numbers on numerical atomic orbitals
596+
597+
> Only the `file` option is useful for the lcao basis set, which is mostly used when [calculation](#calculation) is set to `set_wf` and `get_pchg`. See more details in [out_wfc_lcao](#out_wfc_lcao).
596598
- **Default**: atomic
597599

598600
### init_chg
@@ -1234,6 +1236,7 @@ Note: In new angle mixing, you should set `mixing_beta_mag >> mixing_beta`. The
12341236
- **Type**: Real
12351237
- **Description**: It's the density threshold for electronic iteration. It represents the charge density error between two sequential densities from electronic iterations. Usually for local orbitals, usually 1e-6 may be accurate enough.
12361238
- **Default**: 1.0e-9 (plane-wave basis), or 1.0e-7 (localized atomic orbital basis).
1239+
- **Unit**: Ry if `scf_thr_type=1`, **dimensionless** if `scf_thr_type=2`
12371240

12381241
### scf_ene_thr
12391242

@@ -1246,10 +1249,8 @@ Note: In new angle mixing, you should set `mixing_beta_mag >> mixing_beta`. The
12461249

12471250
- **Type**: Integer
12481251
- **Description**: Choose the calculation method of convergence criterion.
1249-
- **1**: the criterion is defined as $\Delta\rho_G = \frac{1}{2}\iint{\frac{\Delta\rho(r)\Delta\rho(r')}{|r-r'|}d^3r d^3r'}$.
1250-
- **2**: the criterion is defined as $\Delta\rho_R = \frac{1}{N_e}\int{|\Delta\rho(r)|d^3r}$, where $N_e$ is the number of electron.
1251-
1252-
Note: This parameter is still under testing and the default setting is usually sufficient.
1252+
- **1**: the criterion is defined as $\Delta\rho_G = \frac{1}{2}\iint{\frac{\Delta\rho(r)\Delta\rho(r')}{|r-r'|}d^3r d^3r'}$, which is used in SCF of PW basis with unit Ry.
1253+
- **2**: the criterion is defined as $\Delta\rho_R = \frac{1}{N_e}\int{|\Delta\rho(r)|d^3r}$, where $N_e$ is the number of electron, which is used in SCF of LCAO with unit **dimensionless**.
12531254

12541255
- **Default**: 1 (plane-wave basis), or 2 (localized atomic orbital basis).
12551256

@@ -2488,7 +2489,7 @@ These variables are relevant to electric field and dipole correction
24882489
- True:A dipole correction is also added to the bare ionic potential.
24892490
- False: A dipole correction is not added to the bare ionic potential.
24902491

2491-
> Note: If you want no electric field, parameter efield_amp should be zero. Must be used ONLY in a slab geometry for surface alculations, with the discontinuity FALLING IN THE EMPTY SPACE.
2492+
> Note: If you do not want any electric field, the parameter `efield_amp` should be set to zero. This should ONLY be used in a slab geometry for surface calculations, with the discontinuity FALLING IN THE EMPTY SPACE.
24922493
24932494
- **Default**: False
24942495

@@ -3475,9 +3476,10 @@ These variables are used to control berry phase and wannier90 interface paramete
34753476
- **Type**: Integer
34763477
- **Description**:
34773478
method of propagator
3478-
- 0: Crank-Nicolson.
3479+
- 0: Crank-Nicolson, based on matrix inversion.
34793480
- 1: 4th Taylor expansions of exponential.
34803481
- 2: enforced time-reversal symmetry (ETRS).
3482+
- 3: Crank-Nicolson, based on solving linear equation.
34813483
- **Default**: 0
34823484

34833485
### td_vext
@@ -3537,19 +3539,29 @@ These variables are used to control berry phase and wannier90 interface paramete
35373539

35383540
- **Type**: Real
35393541
- **Description**:
3540-
cut1 of interval in length gauge\
3541-
E = E0 , cut1<x<cut2\
3542-
E = -E0/(cut1+1-cut2) , x<cut1 or cut2<x<1
3542+
`td_lcut1` is the lower bound of the interval in the length gauge RT-TDDFT, where $x$ is the fractional coordinate:
3543+
$$
3544+
E(x)=
3545+
\begin{cases}
3546+
E_0, & \mathtt{cut1}\leqslant x \leqslant \mathtt{cut2} \\
3547+
-E_0\left(\dfrac{1}{\mathtt{cut1}+1-\mathtt{cut2}}-1\right), & \text{$0<x<\mathtt{cut1}$ or $\mathtt{cut2}<x<1$}
3548+
\end{cases}
3549+
$$
35433550
- **Default**: 0.05
35443551

35453552
### td_lcut2
35463553

35473554
- **Type**: Real
35483555
- **Description**:
3549-
cut2 of interval in length gauge\
3550-
E = E0 , cut1<x<cut2\
3551-
E = -E0/(cut1+1-cut2) , x<cut1 or cut2<x<1
3552-
- **Default**: 0.05
3556+
`td_lcut2` is the upper bound of the interval in the length gauge RT-TDDFT, where $x$ is the fractional coordinate:
3557+
$$
3558+
E(x)=
3559+
\begin{cases}
3560+
E_0, & \mathtt{cut1}\leqslant x \leqslant \mathtt{cut2} \\
3561+
-E_0\left(\dfrac{1}{\mathtt{cut1}+1-\mathtt{cut2}}-1\right), & \text{$0<x<\mathtt{cut1}$ or $\mathtt{cut2}<x<1$}
3562+
\end{cases}
3563+
$$
3564+
- **Default**: 0.95
35533565

35543566
### td_gauss_freq
35553567

docs/advanced/install.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ To build NVIDIA GPU support for ABACUS, define `USE_CUDA` flag. You can also spe
115115
cmake -B build -DUSE_CUDA=1 -DCMAKE_CUDA_COMPILER=${path to cuda toolkit}/bin/nvcc
116116
```
117117

118+
If you are confident that your MPI supports CUDA Aware, you can add `-DUSE_CUDA_MPI=ON`. In this case, the program will directly communicate data with the CUDA hardware, rather than transferring it to the CPU first before communication. But note that if CUDA Aware is not supported, adding `-DUSE_CUDA_MPI=ON` will cause the program to throw an error.
119+
118120
## Build math library from source
119121

120122
> Note: We recommend using the latest available compiler sets, since they offer faster implementations of math functions.

docs/advanced/interface/ase.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
```bash
1010
git clone https://gitlab.com/1041176461/ase-abacus.git
1111
cd ase-abacus
12-
python3 setup.py install
12+
pip install .
13+
```
14+
15+
Another direct way:
16+
```bash
17+
pip install git+https://gitlab.com/1041176461/ase-abacus.git
1318
```
1419

1520
## Environment variables
@@ -25,6 +30,8 @@ python3 setup.py install
2530

2631
For PW calculations, only `ABACUS_PP_PATH` is needed. For LCAO calculations, both `ABACUS_PP_PATH` and `ABACUS_ORBITAL_PATH` should be set.
2732

33+
Also, one can manally set the paths of PP and ORB when using ABACUS calculator in ASE.
34+
2835
## ABACUS Calculator
2936

3037
The default initialization command for the ABACUS calculator is
@@ -49,22 +56,41 @@ For more information on pseudopotentials and numerical orbitals, please visit [A
4956

5057
The input parameters can be set like::
5158
```python
52-
calc = Abacus(profile=profile, ntype=1, ecutwfc=50, scf_nmax=50, smearing_method='gaussian', smearing_sigma=0.01, basis_type='pw', ks_solver='cg', calculation='scf' pp=pp, basis=basis, kpts=kpts)
59+
# for ABACUS calculator
60+
calc = Abacus(profile=profile,
61+
ecutwfc=100,
62+
scf_nmax=100,
63+
smearing_method='gaussian',
64+
smearing_sigma=0.01,
65+
basis_type='pw',
66+
ks_solver='dav',
67+
calculation='scf',
68+
pp=pp,
69+
basis=basis,
70+
kpts=kpts)
5371
```
5472

5573
The command to run jobs can be set by specifying `AbacusProfile`::
5674

5775
```python
5876
from ase.calculators.abacus import AbacusProfile
59-
abacus = '/usr/local/bin/abacus'
60-
profile = AbacusProfile(argv=['mpirun','-n','2',abacus])
77+
# for OpenMP setting inside python env
78+
import os
79+
os.environ("OMP_NUM_THREADS") = 1
80+
# for MPI setting used in abacus
81+
mpi_num = 4
82+
# for ABACUS Profile
83+
abacus = '/usr/local/bin/abacus' # specify abacus exec
84+
profile = AbacusProfile(command=f'mpirun -n {mpi_num} {abacus}') # directly the command for running ABACUS
6185
```
6286

6387
in which `abacus` sets the absolute path of the `abacus` executable.
6488

6589
## MD Analysis
6690
After molecular dynamics calculations, the log file `running_md.log` can be read. If the 'STRU_MD_*' files are not continuous (e.g. 'STRU_MD_0', 'STRU_MD_5', 'STRU_MD_10'...), the index parameter of read should be as a slice object. For example, when using the command `read('running_md.log', index=slice(0, 15, 5), format='abacus-out')` to parse 'running_md.log', 'STRU_MD_0', 'STRU_MD_5' and 'STRU_MD_10' will be read.
6791

92+
The `MD_dump` file is also supported to be read-in by `read('MD_dump', format='abacus-md')`
93+
6894

6995
## SPAP Analysis
7096

docs/quick_start/input.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ Below is an example `INPUT` file with some of the most important parameters that
1010

1111
```plaintext
1212
INPUT_PARAMETERS
13-
suffix MgO
14-
ntype 2
15-
pseudo_dir ./
16-
orbital_dir ./
13+
suffix MgO # the output files will be in OUT.{suffix} directory
14+
pseudo_dir ./ # where the pseudopotential for each element is
15+
orbital_dir ./ # where the orbital file for each element is
1716
ecutwfc 100 # in Rydberg
18-
scf_thr 1e-4 # Rydberg
19-
basis_type lcao
17+
scf_thr 1e-6 # dimensionless for LCAO, Rydberg for PW. See documents for details.
18+
basis_type lcao # lcao or pw
2019
calculation scf # this is the key parameter telling abacus to do a scf calculation
21-
out_chg True
20+
out_chg 0 # only output binary charge file for restart
2221
```
2322

2423
The parameter list always starts with key word `INPUT_PARAMETERS`. Any content before `INPUT_PARAMETERS` will be ignored.
@@ -36,19 +35,18 @@ Furthermore, if a given parameter name appeared more than once in the input file
3635
3736
In the above example, the meanings of the parameters are:
3837

39-
- `suffix` : the name of the system, default `ABACUS`
40-
- `ntype` : how many types of elements in the unit cell
41-
- `pseudo_dir` : the directory where pseudopotential files are provided
42-
- `orbital_dir` : the directory where orbital files are provided
43-
- `ecutwfc` : the plane-wave energy cutoff for the wave function expansion (UNIT: Rydberg)
44-
- `scf_thr` : the threshold for the convergence of charge density (UNIT: Rydberg)
45-
- `basis_type` : the type of basis set for expanding the electronic wave functions
38+
- `suffix` : the name of the system, default `ABACUS`, and output files will be in OUT.{suffix} directory.
39+
- `pseudo_dir` : the directory where pseudopotential files are provided.
40+
- `orbital_dir` : the directory where orbital files are provided.
41+
- `ecutwfc` : the plane-wave energy cutoff for the wave function expansion (UNIT: Rydberg).
42+
- `scf_thr` : the threshold for the convergence of charge density (UNIT: Rydberg for PW, dimensionless for LCAO), we recommend `1e-7` for LCAO and `1e-9` for PW basis.
43+
- `basis_type` : the type of basis set for expanding the electronic wave functions, one can set lcao or pw.
4644
- `calculation` : the type of calculation to be performed by ABACUS
47-
- `out_chg` : if true, output the charge density on real space grid
45+
- `out_chg` : setting for output the charge density in real space grid, -1 for no output, 0 for binary output, 1 for binary and cube output.
4846

4947
For a complete list of input parameters, please consult this [instruction](../advanced/input_files/input-main.md).
5048

51-
> **Note:** Users cannot change the filename “INPUT” to other names. Boolean paramerters such as `out_chg` can be set by using `True` and `False`, `1` and `0`, or `T` and `F`. It is case insensitive so that other preferences such as `true` and `false`, `TRUE` and `FALSE`, and `t` and `f` for setting boolean values are also supported. Specifically for the `out_chg`, `-1` option is also available, which means turn off the checkpoint of charge density in binary (always dumped in `OUT.{suffix}`, whose name ends with `CHARGE-DENSITY.restart`). Some parameters controlling the output also support a second option to control the output precision, e.g., `out_chg True 8` will output the charge density on realspace grid with 8 digits after the decimal point.
49+
> **Note:** Users cannot change the filename “INPUT” to other names. Boolean paramerters such as `out_chg` can be set by using `True` and `False`, `1` and `0`, or `T` and `F`. It is case insensitive so that other preferences such as `true` and `false`, `TRUE` and `FALSE`, and `t` and `f` for setting boolean values are also supported. Specifically for the `out_chg`, `-1` option is also available, which means turn off the checkpoint of charge density in binary (always dumped in `OUT.{suffix}`, whose name ends with `CHARGE-DENSITY.restart`). Some parameters controlling the output also support a second option to control the output precision, e.g., `out_chg 1 8` will output the charge density on realspace grid with 8 digits after the decimal point.
5250
5351
## *STRU*
5452

@@ -69,7 +67,8 @@ Mg_gga_8au_100Ry_4s2p1d.orb
6967
O_gga_8au_100Ry_2s2p1d.orb
7068
7169
LATTICE_CONSTANT
72-
1.8897259886 # 1.8897259886 Bohr = 1.0 Angstrom
70+
1.889726126 # 1.0 Ang = 1/a_0 = 1/0.529177210544
71+
# Bohr radius ref: https://physics.nist.gov/cgi-bin/cuu/Value?bohrrada0
7372
7473
LATTICE_VECTORS
7574
4.25648 0.00000 0.00000

source/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ if(USE_ROCM)
104104
)
105105
endif()
106106

107+
if(USE_DSP)
108+
list(APPEND device_srcs
109+
module_base/kernels/dsp/dsp_connector.cpp
110+
)
111+
endif()
112+
113+
107114
add_library(device OBJECT ${device_srcs})
108115

109116
if(USE_CUDA)

source/Makefile.Objects

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ OBJS_ESOLVER=esolver.o\
260260
OBJS_ESOLVER_LCAO=esolver_ks_lcao.o\
261261
esolver_ks_lcao_tddft.o\
262262
lcao_before_scf.o\
263+
lcao_after_scf.o\
263264
esolver_gets.o\
264265
lcao_others.o\
265266

@@ -572,6 +573,7 @@ OBJS_LCAO=evolve_elec.o\
572573
td_velocity.o\
573574
td_current.o\
574575
snap_psibeta_half_tddft.o\
576+
solve_propagation.o\
575577
upsi.o\
576578
FORCE_STRESS.o\
577579
FORCE_gamma.o\

source/module_base/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ add_library(
6565
)
6666

6767
target_link_libraries(base PUBLIC container)
68-
68+
if (USE_DSP)
69+
target_link_libraries(base PUBLIC ${MTBLAS_FFT_DIR}/libmtblas/lib/libmtblas.a)
70+
target_link_libraries(base PUBLIC ${MTBLAS_FFT_DIR}/libmtblas/lib/libmtblasdev.a)
71+
endif()
6972
add_subdirectory(module_container)
7073

7174
if(ENABLE_COVERAGE)

0 commit comments

Comments
 (0)