Skip to content

Commit c2f57de

Browse files
committed
Merge branch 'develop' of github.com:deepmodeling/abacus-develop into HSolver
2 parents e761300 + babd750 commit c2f57de

Some content is hidden

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

80 files changed

+1177
-410
lines changed

CMakeLists.txt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ option(USE_OPENMP " Enable OpenMP in abacus." ON)
2020
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
2121
option(BUILD_TESTING "Build ABACUS unit tests" OFF)
2222
option(GENERATE_TEST_REPORTS "Enable test report generation" OFF)
23+
option(INFO "Enable gathering of math library information" OFF)
2324

2425
set(ABACUS_BIN_NAME abacus)
2526
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/modules)
@@ -217,7 +218,7 @@ if(ENABLE_DEEPKS)
217218
HINTS ${libnpy_INCLUDE_DIR}
218219
)
219220
if(NOT libnpy_SOURCE_DIR)
220-
include(FetchContent)
221+
include(FetchContent)
221222
FetchContent_Declare(
222223
libnpy
223224
GIT_REPOSITORY https://github.com/llohse/libnpy.git
@@ -237,14 +238,22 @@ if(DEFINED Libxc_DIR)
237238
set(ENABLE_LIBXC ON)
238239
endif()
239240
if(ENABLE_LIBXC)
240-
find_package(Libxc)
241+
find_package(Libxc HINTS ${Libxc_DIR}/share/cmake/Libxc)
241242
if(${Libxc_FOUND})
242243
message("Using Libxc.")
243244
add_compile_definitions(USE_LIBXC)
244245
target_link_libraries(${ABACUS_BIN_NAME} Libxc::xc)
245246
include_directories(${Libxc_INCLUDE_DIRS})
246247
else()
247-
message(WARNING "Will not use Libxc.")
248+
include(FetchContent)
249+
FetchContent_Declare(
250+
Libxc
251+
GIT_REPOSITORY https://gitlab.com/libxc/libxc.git
252+
GIT_TAG "5.2.3"
253+
GIT_SHALLOW TRUE
254+
GIT_PROGRESS TRUE
255+
)
256+
FetchContent_MakeAvailable(Libxc)
248257
endif()
249258
endif()
250259

@@ -261,6 +270,12 @@ add_compile_definitions(
261270
TEST_EXX_RADIAL=1
262271
)
263272

273+
if(INFO)
274+
message(STATUS "Will gather math lib info.")
275+
add_compile_definitions(GATHER_INFO)
276+
# modifications on blas_connector and lapack_connector
277+
endif()
278+
264279
IF (BUILD_TESTING)
265280
set(CMAKE_CXX_STANDARD 14) # Required in orbital
266281
include(CTest)
@@ -319,7 +334,7 @@ target_link_libraries(${ABACUS_BIN_NAME}
319334
pw
320335
ri
321336
driver
322-
xc
337+
xc_
323338
hsolver
324339
elecstate
325340
hamilt

docs/input-main.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,9 +597,9 @@ This part of variables are used to control the parameters of stochastic DFT (SDF
597597
- **Description**:
598598
- Different method to do SDFT.
599599
- 1: SDFT calculates $T_n(\hat{h})\ket{\chi}$ twice, where $T_n(x)$ is the n-th order Chebyshev polynomial and $\hat{h}=\frac{\hat{H}-\bar{E}}{\Delta E}$ owning eigen-value $\in(-1,1)$. This method cost less memory but slow.
600-
- 2: SDFT calculates $T_n(\hat{h})\ket{\chi}$ once but need much more memory. This method is fast but when memory is not enough, only method 1 can be used.
601-
- other: use 1
602-
- **Default**: 1
600+
- 2: SDFT calculates $T_n(\hat{h})\ket{\chi}$ once but need much more memory. This method is much faster. Besides, it calculate $N_e$ with $\bra{\chi}\sqrt{\hat f}\sqrt{\hat f}\ket{\chi}$, which needs smaller [nche_sto](#nche_sto). However, when memory is not enough, only method 1 can be used.
601+
- other: use 2
602+
- **Default**: 2
603603
604604
#### nbands_sto
605605
@@ -642,6 +642,12 @@ This part of variables are used to control the parameters of stochastic DFT (SDF
642642
- **Description**: Frequency (once each initsto_freq steps) to generate new stochastic orbitals when running md.
643643
- **Default**:1000
644644
645+
#### npart_sto
646+
647+
- **Type**: Integer
648+
- **Description**: Make memory cost to 1/npart_sto times of previous one when running post process of SDFT like DOS with method_sto = 2.
649+
- **Default**:1
650+
645651
### Geometry relaxation
646652
647653
This part of variables are used to control the geometry relaxation.

docs/install.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ To compile ABACUS, please make sure that the following prerequisites are present
3434

3535
- C++ compiler, supporting C++11. You can use [Intel® C++ compiler](https://software.intel.com/enus/c-compilers) or [GCC](https://gcc.gnu.org/).
3636
- MPI compiler. The recommended version are [Intel MPI](https://software.intel.com/enus/mpi-library) or [MPICH](https://www.mpich.org/).
37-
- Fortran compiler for building `BLAS`, `LAPACK`, `ScaLAPACK` or `ELPA`. You can use[Intel® Fortran Compiler](https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html) [GFortran](https://gcc.gnu.org/fortran/).
37+
- Fortran compiler if you are building `BLAS`, `LAPACK`, `ScaLAPACK`, and `ELPA` from source file. You can use[Intel® Fortran Compiler](https://www.intel.com/content/www/us/en/developer/tools/oneapi/fortran-compiler.html) [GFortran](https://gcc.gnu.org/fortran/).
3838
- [BLAS](http://www.netlib.org/blas/). You can use [OpenBLAS](https://www.openblas.net/).
3939
- [LAPACK](http://www.netlib.org/lapack/).
4040
- [ScaLAPACK](http://www.netlib.org/scalapack/).
4141
- [FFTW3](http://www.fftw.org/).
4242
- [ELPA](https://elpa.mpcdf.mpg.de/) >= 2017.
4343
- [CEREAL](https://uscilab.github.io/cereal/).
4444

45+
> GCC version 5.1 or later is required: Intel compilers also use GCC headers and libraries[(ref)](https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compatibility-and-portability/gcc-compatibility-and-interoperability.html#gcc-compatibility-and-interoperability_GUID-52CB6FE0-83DA-4028-9EF4-0DFAF1652736).
46+
4547
These packages can be installed with popular package management system, such as `apt` and `yum`:
4648

4749
```bash
@@ -50,7 +52,7 @@ sudo apt update && sudo apt install -y libopenblas-dev liblapack-dev libscalapac
5052

5153
> Installing ELPA by apt only matches requirements on Ubuntu 22.04. For earlier linux distributions, you may install elpa from source.
5254
53-
Alternatively, you can choose [Intel® oneAPI toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/commercial-base-hpc.html) (former Parallel Studio) as toolchain. The [Intel® oneAPI Base Toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/all-toolkits.html#base-kit) contains Intel® oneAPI Math Kernel Library (aka `MKL`), including `BLAS`, `LAPACK`, `ScaLAPACK` and `FFTW3`, - this means that no Fortran compiler required anymore. The [Intel® oneAPI HPC Toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/all-toolkits.html#hpc-kit) contains Intel® MPI Library, and C++ compiler(including MPI compiler). Please noted that building `elpa` with a different MPI library may cause conflict between MPI libraries. Don't forget to [set environment variables](https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-intel-oneapi-render-linux/top/configure-your-system.html) before you start! `cmake` will use Intel MKL if the environment variable `MKLROOT` is set.
55+
Alternatively, you can choose [Intel® oneAPI toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/commercial-base-hpc.html) (former Parallel Studio) as toolchain. The [Intel® oneAPI Base Toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/all-toolkits.html#base-kit) contains Intel® oneAPI Math Kernel Library (aka `MKL`), including `BLAS`, `LAPACK`, `ScaLAPACK` and `FFTW3`. The [Intel® oneAPI HPC Toolkit](https://software.intel.com/content/www/us/en/develop/tools/oneapi/all-toolkits.html#hpc-kit) contains Intel® MPI Library, and C++ compiler(including MPI compiler). Please noted that building `elpa` with a different MPI library may cause conflict between MPI libraries. Don't forget to [set environment variables](https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-intel-oneapi-render-linux/top/configure-your-system.html) before you start! `cmake` will use Intel MKL if the environment variable `MKLROOT` is set.
5456

5557
> Please refer to our [guide](https://github.com/deepmodeling/abacus-develop/wiki/Building-and-Running-ABACUS) on requirements.
5658
@@ -95,13 +97,13 @@ cmake -B build -DFFTW3_ROOT=/opt/fftw3
9597

9698
If environment variable `MKLROOT` exists, `cmake` will take MKL as a preference, i.e. not using `LAPACK` and `ScaLAPACK`. To disable MKL, unset environment variable `MKLROOT`, or pass `-DMKLROOT=OFF` to `cmake`.
9799

98-
You can also choose to build with which components.
100+
You can also choose to build with which components, e.g.:
99101

100102
```bash
101103
cmake -B build -DUSE_LIBXC=1 -DUSE_CUDA=1
102104
```
103105

104-
If Libxc is not installed in standard path (i.e. installed with a custom prefix path), you may add the installation prefix of `FindLibxc.cmake` to `CMAKE_MODULE_PATH` environment variable, or set `Libxc_DIR` to the directory containing the file.
106+
If Libxc is not installed in standard path (i.e. installed with a custom prefix path), you can set `Libxc_DIR` to the corresponding directory.
105107

106108
```bash
107109
cmake -B build -DLibxc_DIR=~/libxc
@@ -241,9 +243,9 @@ This part of installation is based on [Installation](#installation). If DeePKS f
241243

242244
### Extra prerequisites
243245

244-
- C++ compiler, supporting **C++14**. For example, Intel C++ compiler 18
245-
- [LibTorch](https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.9.0%2Bcpu.zip) for cpu, with c++11 ABI;
246-
- [Libnpy](https://github.com.cnpmjs.org/llohse/libnpy/);
246+
- C++ compiler, supporting **C++14**
247+
- [LibTorch](https://pytorch.org/) with cxx11 ABI supporting CPU
248+
- [Libnpy](https://github.com/llohse/libnpy/)
247249

248250
### Extra settings for building
249251

source/Makefile.Objects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ OBJS_SURCHEM=H_correction_pw.o\
245245
corrected_energy.o\
246246
minimize_cg.o\
247247
efield.o\
248+
sol_force.o\
248249

249250
OBJS_XC=xc_funct_corr_gga.o \
250251
xc_funct_corr_lda.o \

source/input.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ void Input::Default(void)
144144
bndpar = 1;
145145
kpar = 1;
146146
initsto_freq = 1000;
147-
method_sto = 1;
147+
method_sto = 2;
148+
npart_sto = 1;
148149
cal_cond = false;
149150
dos_nche = 100;
150151
cond_nche = 20;
@@ -407,6 +408,7 @@ void Input::Default(void)
407408
// test only
408409
//==========================================================
409410
test_just_neighbor = false;
411+
test_skip_ewald = false;
410412

411413
//==========================================================
412414
// DFT+U Xin Qu added on 2020-10-29
@@ -595,6 +597,10 @@ bool Input::Read(const std::string &fn)
595597
{
596598
read_value(ifs, method_sto);
597599
}
600+
else if (strcmp("npart_sto", word) == 0)
601+
{
602+
read_value(ifs, npart_sto);
603+
}
598604
else if (strcmp("cal_cond", word) == 0)
599605
{
600606
read_value(ifs, cal_cond);
@@ -1505,6 +1511,10 @@ bool Input::Read(const std::string &fn)
15051511
{
15061512
read_value(ifs, test_just_neighbor);
15071513
}
1514+
else if (strcmp("test_skip_ewald", word) == 0)
1515+
{
1516+
read_value(ifs, test_skip_ewald);
1517+
}
15081518
//--------------
15091519
//----------------------------------------------------------------------------------
15101520
// Xin Qu added on 2020-10-29 for DFT+U
@@ -1940,6 +1950,10 @@ void Input::Default_2(void) // jiyy add 2019-08-04
19401950
}
19411951
if(calculation.substr(0,3) != "sto") bndpar = 1;
19421952
if(bndpar > GlobalV::NPROC) bndpar = GlobalV::NPROC;
1953+
if(method_sto != 1 && method_sto != 2)
1954+
{
1955+
method_sto = 2;
1956+
}
19431957
}
19441958
#ifdef __MPI
19451959
void Input::Bcast()
@@ -1974,6 +1988,7 @@ void Input::Bcast()
19741988
Parallel_Common::bcast_double(emin_sto);
19751989
Parallel_Common::bcast_int(initsto_freq);
19761990
Parallel_Common::bcast_int(method_sto);
1991+
Parallel_Common::bcast_int(npart_sto);
19771992
Parallel_Common::bcast_bool(cal_cond);
19781993
Parallel_Common::bcast_int(cond_nche);
19791994
Parallel_Common::bcast_double(cond_dw);
@@ -2203,6 +2218,7 @@ void Input::Bcast()
22032218
Parallel_Common::bcast_int(td_vextout);
22042219
Parallel_Common::bcast_int(td_dipoleout);
22052220
Parallel_Common::bcast_bool(test_just_neighbor);
2221+
Parallel_Common::bcast_bool(test_skip_ewald);
22062222
Parallel_Common::bcast_int(GlobalV::ocp);
22072223
Parallel_Common::bcast_string(GlobalV::ocp_set);
22082224
Parallel_Common::bcast_int(out_mul); // qifeng add 2019/9/10

source/input.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class Input
7272
int bndpar; //parallel for stochastic/deterministic bands
7373
int initsto_freq; //frequency to init stochastic orbitals when running md
7474
int method_sto; //different methods for sdft, 1: slow, less memory 2: fast, more memory
75+
int npart_sto; //for method_sto = 2, reduce memory
7576
bool cal_cond; //calculate electronic conductivities
7677
int cond_nche; //orders of Chebyshev expansions for conductivities
7778
double cond_dw; //d\omega for conductivities
@@ -421,7 +422,8 @@ class Input
421422
//==========================================================
422423
// variables for test only
423424
//==========================================================
424-
bool test_just_neighbor;
425+
bool test_just_neighbor = false;
426+
bool test_skip_ewald = false;
425427

426428
private:
427429
//==========================================================

source/input_conv.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ void Input_Conv::Convert(void)
135135
GlobalV::VION_IN_H = INPUT.vion_in_h;
136136
GlobalV::TEST_FORCE = INPUT.test_force;
137137
GlobalV::TEST_STRESS = INPUT.test_stress;
138+
GlobalV::test_skip_ewald = INPUT.test_skip_ewald;
138139

139140
//----------------------------------------------------------
140141
// iteration (1/3)

source/module_base/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_library(
77
export.cpp
88
integral.cpp
99
inverse_matrix.cpp
10+
gather_math_lib_info.cpp
1011
global_file.cpp
1112
global_function.cpp
1213
global_function_ddotreal.cpp
@@ -16,7 +17,7 @@ add_library(
1617
math_polyint.cpp
1718
math_sphbes.cpp
1819
math_ylmreal.cpp
19-
math_bspline.cpp
20+
math_bspline.cpp
2021
math_chebyshev.cpp
2122
mathzone.cpp
2223
mathzone_add1.cpp

0 commit comments

Comments
 (0)