Skip to content

Commit

Permalink
Merge branch 'deepmodeling:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanchen authored May 15, 2024
2 parents 5d4b112 + 24a27b9 commit 53b674e
Show file tree
Hide file tree
Showing 145 changed files with 11,878 additions and 4,776 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ option(ENABLE_FFT_TWO_CENTER "Enable FFT-based two-center integral method." ON)
option(ENABLE_GOOGLEBENCH "Enable GOOGLE-benchmark usage." OFF)
option(ENABLE_RAPIDJSON "Enable rapid-json usage." OFF)
option(ENABLE_CNPY "Enable cnpy usage." OFF)
option(ENABLE_PEXSI "Enable support for PEXSI." OFF)

# enable json support
if(ENABLE_RAPIDJSON)
Expand Down Expand Up @@ -211,6 +212,14 @@ if(ENABLE_LCAO)
if(ENABLE_FFT_TWO_CENTER)
add_compile_definitions(USE_NEW_TWO_CENTER)
endif()

if(ENABLE_PEXSI)
find_package(PEXSI REQUIRED)
target_link_libraries(${ABACUS_BIN_NAME} ${PEXSI_LIBRARY} ${SuperLU_DIST_LIBRARY} ${ParMETIS_LIBRARY} ${METIS_LIBRARY} pexsi)
include_directories(${PEXSI_INCLUDE_DIR} ${ParMETIS_INCLUDE_DIR})
add_compile_definitions(__PEXSI)
set(CMAKE_CXX_STANDARD 14)
endif()
else()
set(ENABLE_DEEPKS OFF)
set(ENABLE_LIBRI OFF)
Expand Down
57 changes: 57 additions & 0 deletions cmake/FindPEXSI.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
###############################################################################
# - Find PEXSI
# Find PEXSI and its dependencies.
#
# PEXSI_FOUND - True if pexsi is found.
# PEXSI_INCLUDE_DIR - Where to find pexsi headers.
# PEXSI_LIBRARY - pexsi library.
# ParMETIS_INCLUDE_DIR - Where to find pexsi headers.
# ParMETIS_LIBRARY - parmetis library.
# METIS_LIBRARY - metis library.
# SuperLU_DIST_LIBRARY - superlu_dist library.

find_path(PEXSI_INCLUDE_DIR
NAMES c_pexsi_interface.h
HINTS ${PEXSI_DIR}
PATH_SUFFIXES "include"
)

find_library(PEXSI_LIBRARY
NAMES pexsi
HINTS ${PEXSI_DIR}
PATH_SUFFIXES "lib"
)

find_path(ParMETIS_INCLUDE_DIR
NAMES metis.h parmetis.h
HINTS ${ParMETIS_DIR}
PATH_SUFFIXES "include"
)

find_library(METIS_LIBRARY
NAMES metis
HINTS ${ParMETIS_DIR}
PATH_SUFFIXES "lib"
)

find_library(ParMETIS_LIBRARY
NAMES parmetis
HINTS ${ParMETIS_DIR}
PATH_SUFFIXES "lib"
)

find_library(SuperLU_DIST_LIBRARY
NAMES superlu_dist
HINTS ${SuperLU_DIST_DIR}
PATH_SUFFIXES "lib"
)

# Handle the QUIET and REQUIRED arguments and
# set PEXSI_FOUND to TRUE if all variables are non-zero.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PEXSI DEFAULT_MSG PEXSI_LIBRARY PEXSI_INCLUDE_DIR ParMETIS_LIBRARY METIS_LIBRARY SuperLU_DIST_LIBRARY)


# Copy the results to the output variables and target.
mark_as_advanced(PEXSI_LIBRARY PEXSI_INCLUDE_DIR ParMETIS_LIBRARY SuperLU_DIST_LIBRARY)

166 changes: 166 additions & 0 deletions docs/advanced/input_files/input-main.md
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,30 @@
- [qo\_strategy](#qo_strategy)
- [qo\_screening\_coeff](#qo_screening_coeff)
- [qo\_thr](#qo_thr)
- [PEXSI](#pexsi)
- [pexsi\_npole](#pexsi_npole)
- [pexsi\_inertia](#pexsi_inertia)
- [pexsi\_nmax](#pexsi_nmax)
- [pexsi\_comm](#pexsi_comm)
- [pexsi\_storage](#pexsi_storage)
- [pexsi\_ordering](#pexsi_ordering)
- [pexsi\_row\_ordering](#pexsi_row_ordering)
- [pexsi\_nproc](#pexsi_nproc)
- [pexsi\_symm](#pexsi_symm)
- [pexsi\_trans](#pexsi_trans)
- [pexsi\_method](#pexsi_method)
- [pexsi\_nproc\_pole](#pexsi_nproc_pole)
- [pexsi\_temp](#pexsi_temp)
- [pexsi\_gap](#pexsi_gap)
- [pexsi\_delta\_e](#pexsi_delta_e)
- [pexsi\_mu\_lower](#pexsi_mu_lower)
- [pexsi\_mu\_upper](#pexsi_mu_upper)
- [pexsi\_mu](#pexsi_mu)
- [pexsi\_mu\_thr](#pexsi_mu_thr)
- [pexsi\_mu\_expand](#pexsi_mu_expand)
- [pexsi\_mu\_guard](#pexsi_mu_guard)
- [pexsi\_elec\_thr](#pexsi_elec_thr)
- [pexsi\_zero\_thr](#pexsi_zero_thr)

[back to top](#full-list-of-input-keywords)

Expand Down Expand Up @@ -3530,4 +3554,146 @@ These variables are used to control the usage of QO analysis. QO further compres
- **Description**: the convergence threshold determining the cutoff of generated orbital. Lower threshold will yield orbital with larger cutoff radius.
- **Default**: 1.0e-6

## PEXSI

These variables are used to control the usage of PEXSI (Pole Expansion and Selected Inversion) method in calculations.

### pexsi_npole

- **Type**: Integer
- **Description**: the number of poles used in the pole expansion method, should be a even number.
- **Default**: 40

### pexsi_inertia

- **Type**: Boolean
- **Description**: whether inertia counting is used at the very beginning.
- **Default**: True

### pexsi_nmax

- **Type**: Integer
- **Description**: maximum number of PEXSI iterations after each inertia counting procedure.
- **Default**: 80

### pexsi_comm

- **Type**: Boolean
- **Description**: whether to construct PSelInv communication pattern.
- **Default**: True

### pexsi_storage

- **Type**: Boolean
- **Description**: whether to use symmetric storage space used by the Selected Inversion algorithm for symmetric matrices.
- **Default**: True

### pexsi_ordering

- **Type**: Integer
- **Description**: ordering strategy for factorization and selected inversion. 0: Parallel ordering using ParMETIS, 1: Sequential ordering using METIS, 2: Multiple minimum degree ordering
- **Default**: 0

### pexsi_row_ordering

- **Type**: Integer
- **Description**: row permutation strategy for factorization and selected inversion, 0: No row permutation, 1: Make the diagonal entry of the matrix larger than the off-diagonal entries.
- **Default**: 1

### pexsi_nproc

- **Type**: Integer
- **Description**: number of processors for PARMETIS. Only used if pexsi_ordering == 0.
- **Default**: 1

### pexsi_symm

- **Type**: Boolean
- **Description**: whether the matrix is symmetric.
- **Default**: True

### pexsi_trans

- **Type**: Boolean
- **Description**: whether to factorize the transpose of the matrix.
- **Default**: False

### pexsi_method

- **Type**: Integer
- **Description**: the pole expansion method to be used. 1 for Cauchy Contour Integral method, 2 for Moussa optimized method.
- **Default**: 1

### pexsi_nproc_pole

- **Type**: Integer
- **Description**: the point parallelizaion of PEXSI. Recommend two points parallelization.
- **Default**: 1

### pexsi_temp

- **Type**: Real
- **Description**: temperature in Fermi-Dirac distribution, in Ry, should have the same effect as the smearing sigma when smearing method is set to Fermi-Dirac.
- **Default**: 0.015

### pexsi_gap

- **Type**: Real
- **Description**: spectral gap, this can be set to be 0 in most cases.
- **Default**: 0

### pexsi_delta_e

- **Type**: Real
- **Description**: an upper bound for the spectral radius of $S^{-1} H$.
- **Default**: 20

### pexsi_mu_lower

- **Type**: Real
- **Description**: initial guess of lower bound for mu.
- **Default**: -10

### pexsi_mu_upper

- **Type**: Real
- **Description**: initial guess of upper bound for mu.
- **Default**: 10

### pexsi_mu

- **Type**: Real
- **Description**: initial guess for mu (for the solver).
- **Default**: 0

### pexsi_mu_thr

- **Type**: Real
- **Description**: stopping criterion in terms of the chemical potential for the inertia counting procedure.
- **Default**: 0.05

### pexsi_mu_expand

- **Type**: Real
- **Description**: if the chemical potential is not in the initial interval, the interval is expanded by this value.
- **Default**: 0.3

### pexsi_mu_guard

- **Type**: Real
- **Description**: safe guard criterion in terms of the chemical potential to reinvoke the inertia counting procedure.
- **Default**: 0.2

### pexsi_elec_thr

- **Type**: Real
- **Description**: stopping criterion of the PEXSI iteration in terms of the number of electrons compared to numElectronExact.
- **Default**: 0.001

### pexsi_zero_thr

- **Type**: Real
- **Description**: if the absolute value of CCS matrix element is less than this value, it will be considered as zero.
- **Default**: 1e-10

[back to top](#full-list-of-input-keywords)
12 changes: 12 additions & 0 deletions docs/advanced/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ Currently supported math functions:
cmake -B build -DUSE_ABACUS_LIBM=1
```

## Build with PEXSI support

ABACUS supports the PEXSI library for gamma only LCAO calculations. PEXSI version 2.0.0 is tested to work with ABACUS, please always use the latest version of PEXSI.

To build ABACUS with PEXSI support, you need to compile PEXSI (and its dependencies) first. Please refer to the [PEXSI Installation Guide](https://pexsi.readthedocs.io/en/latest/install.html) for more details. Note that PEXSI requires ParMETIS and SuperLU_DIST.

After compiling PEXSI, you can set `ENABLE_PEXSI` to `ON`. If the libraries are not installed in standard paths, you can set `PEXSI_DIR`, `ParMETIS_DIR` and `SuperLU_DIST_DIR` to the corresponding directories.

```bash
cmake -B build -DENABLE_PEXSI=ON -DPEXSI_DIR=${path to PEXSI installation directory} -DParMETIS_DIR=${path to ParMETIS installation directory} -DSuperLU_DIST_DIR=${path to SuperLU_DIST installation directory}
```

## Build ABACUS with make

> Note: We suggest using CMake to configure and compile.
Expand Down
32 changes: 32 additions & 0 deletions examples/pexsi/md_Si8/INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
INPUT_PARAMETERS
#Parameters (1.General)
suffix Si_rescaling
calculation md
nbands 20
symmetry 0
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB

#Parameters (2.Iteration)
ecutwfc 30
scf_thr 1e-5
scf_nmax 100

#Parameters (3.Basis)
basis_type lcao
ks_solver pexsi
gamma_only 1

#Parameters (5.Mixing)
mixing_type broyden
mixing_beta 0.3
chg_extrap second-order

#Parameters (6.MD)
md_type nvt
md_thermostat rescaling
md_tolerance 10
md_nstep 10
md_dt 1
md_tfirst 300
md_tfreq 0.025
4 changes: 4 additions & 0 deletions examples/pexsi/md_Si8/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
Gamma
1 1 1 0 0 0
28 changes: 28 additions & 0 deletions examples/pexsi/md_Si8/STRU
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ATOMIC_SPECIES
Si 28.085 Si_ONCV_PBE-1.0.upf

NUMERICAL_ORBITAL
Si_gga_8au_60Ry_2s2p1d.orb

LATTICE_CONSTANT
1.8897270 # 1 Angstrom = 1.8897270 bohr

LATTICE_VECTORS
5.43090 0.00000 0.00000
0.00000 5.43090 0.00000
0.00000 0.00000 5.43090

ATOMIC_POSITIONS
Direct

Si
0.0
8
0.000 0.000 0.000 1 1 1
0.000 0.500 0.500 1 1 1
0.500 0.000 0.500 1 1 1
0.500 0.500 0.000 1 1 1
0.250 0.250 0.250 1 1 1
0.250 0.750 0.750 1 1 1
0.750 0.250 0.750 1 1 1
0.750 0.750 0.250 1 1 1
20 changes: 20 additions & 0 deletions examples/pexsi/scf_Si64/INPUT
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
INPUT_PARAMETERS
suffix test
ntype 1
nbands 200
pseudo_dir ../../../tests/PP_ORB
orbital_dir ../../../tests/PP_ORB

calculation scf
mixing_beta 0.4
basis_type lcao
gamma_only 1
symmetry 0

ecutwfc 60
lcao_dr 1e-3
scf_nmax 20

ks_solver pexsi

pexsi_npole 40
4 changes: 4 additions & 0 deletions examples/pexsi/scf_Si64/KPT
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
K_POINTS
0
Gamma
1 1 1 0 0 0
Loading

0 comments on commit 53b674e

Please sign in to comment.