Skip to content

Commit e51fe84

Browse files
committed
Merge branch 'develop' of https://github.com/deepmodeling/abacus-develop into planewave
2 parents bf26381 + 00979ac commit e51fe84

File tree

103 files changed

+11811
-4600
lines changed

Some content is hidden

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

103 files changed

+11811
-4600
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ result.out
99
.cache
1010
.vscode
1111
html
12+
run.log

CMakeLists.txt

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ if(MKLROOT)
114114
find_package(IntelMKL REQUIRED)
115115
add_definitions(-D__MKL -DMKL_ILP64)
116116
include_directories(${MKL_INCLUDE_DIRS} ${MKL_INCLUDE_DIRS}/fftw)
117-
117+
118118
# Since libtorch will find its own MKL, the fftw part conflicts with the original one.
119119
# When enable deepks, mkl will be linked within ${TORCH_LIBRARIES}.
120120
if(ENABLE_DEEPKS)
@@ -138,6 +138,11 @@ else()
138138
LAPACK::LAPACK
139139
ScaLAPACK::ScaLAPACK
140140
)
141+
if(CMAKE_COMPILER_IS_GNUCXX)
142+
target_link_libraries(${ABACUS_BIN_NAME}
143+
-lgfortran
144+
)
145+
endif()
141146
endif()
142147

143148
if(ENABLE_DEEPKS)
@@ -155,7 +160,7 @@ if(ENABLE_DEEPKS)
155160
include(FetchContent)
156161
FetchContent_Declare(
157162
libnpy
158-
GIT_REPOSITORY https://github.com.cnpmjs.org/llohse/libnpy.git
163+
GIT_REPOSITORY https://github.com/llohse/libnpy.git
159164
)
160165
FetchContent_MakeAvailable(libnpy)
161166
endif()
@@ -191,6 +196,39 @@ add_compile_definitions(
191196
TEST_EXX_RADIAL=1
192197
)
193198

199+
IF (BUILD_TESTING)
200+
include(CTest)
201+
enable_testing()
202+
find_package(Threads)
203+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
204+
include(FetchContent)
205+
FetchContent_Declare(
206+
googletest
207+
GIT_REPOSITORY https://github.com/google/googletest.git
208+
GIT_TAG "origin/main"
209+
)
210+
FetchContent_MakeAvailable(googletest)
211+
# TODO: Find GoogleTest Locally
212+
213+
add_subdirectory(tests) # Contains integration tests
214+
215+
endif()
216+
function(AddTest)
217+
cmake_parse_arguments(UT "DYN" "TARGET" "LIBS;DYN_LIBS;STATIC_LIBS;SOURCES;DEPENDS" ${ARGN})
218+
add_executable(${UT_TARGET} ${UT_SOURCES})
219+
#dependencies & link library
220+
get_target_property(ABACUS_LINK_LIBRARIES ${ABACUS_BIN_NAME} LINK_LIBRARIES)
221+
target_link_libraries(${UT_TARGET} ${UT_LIBS} ${ABACUS_LINK_LIBRARIES}
222+
base cell symmetry md symmetry
223+
neighbor orb io ions lcao parallel mrrr pdiag pw ri driver
224+
pthread gtest_main)
225+
install(TARGETS ${UT_TARGET} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/../../../tests )
226+
add_test(NAME ${UT_TARGET}
227+
COMMAND ${UT_TARGET}
228+
WORKING_DIRECTORY $<TARGET_FILE_DIR:${UT_TARGET}>
229+
)
230+
endfunction(AddTest)
231+
194232
add_subdirectory(source)
195233

196234
target_link_libraries(${ABACUS_BIN_NAME}
@@ -212,19 +250,8 @@ target_link_libraries(${ABACUS_BIN_NAME}
212250
driver
213251
-lm
214252
)
215-
if(CMAKE_COMPILER_IS_GNUCXX)
216-
target_link_libraries(${ABACUS_BIN_NAME}
217-
-lgfortran
218-
)
219-
endif()
220253

221254
install(PROGRAMS ${ABACUS_BIN_PATH}
222255
TYPE BIN
223256
#DESTINATION ${CMAKE_INSTALL_BINDIR}
224257
)
225-
226-
include(CTest)
227-
enable_testing()
228-
IF (BUILD_TESTING)
229-
add_subdirectory(tests)
230-
endif()

doc/developers.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,38 @@ Raising issues on GitHub is a convernient way to notify the develper team about
1919

2020
## Modularization and module tests
2121

22-
The ABACUS code is reconstructed to form several self-contained modules. A description of modules can be found in the [installation guide](install.md#structure-of-source-code). We also provide module tests for the modules.
22+
The ABACUS code is refactored to several self-contained modules. A description of modules can be found in the [installation guide](install.md#structure-of-source-code). We also provide module unit tests.
23+
24+
### Add a unit test
25+
26+
If there are currently no unit tests provided for the module, do as follows. `module_base` provides a simple demonstration.
27+
28+
- Add a folder named `test` under the module.
29+
- Append the content below to `CMakeLists.txt` of the module:
30+
31+
```cmake
32+
IF (BUILD_TESTING)
33+
add_subdirectory(test)
34+
endif()
35+
```
36+
37+
- Add a blank `CMakeLists.txt` under `module*/test`.
38+
39+
To add a unit test:
40+
41+
- Write your test under `GoogleTest` framework.
42+
- Add your testing source code with suffix `*_test.cpp` in `test` directory.
43+
- Append the content below to `CMakeLists.txt` of the module:
44+
45+
```cmake
46+
AddTest(
47+
TARGET <module_name>_<test_name> # this is the executable file name of the test
48+
SOURCES <test_name>.cpp
49+
)
50+
```
51+
52+
- Build with `-D BUILD_TESTING=1` flag. You can find built testing programs under `build/source/<module_name>/test`.
53+
- Follow the installing procedure of CMake. The tests will move to `build/test`.
2354

2455
[back to top](#for-developers)
2556

@@ -91,7 +122,7 @@ For comments that need to be shown in documents, these formats should be used --
91122

92123
A helpful VS Code extension -- Doxygen Documentation Generator, can help you formating comments.
93124

94-
An practical example is class [LCAO_Descriptor](https://github.com/deepmodeling/abacus-develop/blob/deepks/source/src_lcao/LCAO_descriptor.h), the effects can be seen on [readthedocs page](https://abacus-deepks.readthedocs.io/en/latest/DeePKS_API/classLCAO__Descriptor.html#exhale-class-classLCAO-Descriptor)
125+
An practical example is class [LCAO_Deepks](https://github.com/deepmodeling/abacus-develop/blob/deepks/source/module_deepks/LCAO_deepks.h), the effects can be seen on [readthedocs page](https://abacus-deepks.readthedocs.io/en/latest/DeePKS_API/classLCAO__Descriptor.html#exhale-class-classLCAO-Descriptor)
95126

96127
- Detailed Comment Block
97128

doc/examples/md.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ md_dt 1 //time step
3838
md_tfirst 700 //the first target temperature
3939
md_rstmd 0 //whether restart md
4040
md_qmass 1 //mass of themostat
41-
md_dumpmdfred 10 //The period to dump MD information for monitoring and restarting MD
41+
md_dumpfred 10 //The period to dump MD information for monitoring and restarting MD
4242
```
4343

4444
These MD parameters means that ABACUS will use NVT ensemble with Nosé-hoover themostat; the time step is 1fs, and target temperature is 700K; start renew without restart file, set the mass of themostat as 1g/mol, and calculate the MSD and diffusion coefficent from first step.
@@ -50,7 +50,7 @@ Note: *Please turn off symmetry when do MD simulation.*
5050
- md_tfirst : target temperature in md simulation(K), you should set parameter md_tlast and md_fixtemperature when you want to change temperature during md simulation.
5151
- md_rstmd : 0, no need of restart ; 1, restart with restart file, you must repalce STRU file with STRU_MD before you run the restart task.
5252
- md_qmass : mass of thermostat, set by experience, if you don’t know how to set, set it to 0 will have a number autosetted by ABACUS
53-
- md_dumpmdfred : frequency for output consequence of md simulation
53+
- md_dumpfred : frequency for output consequence of md simulation
5454

5555
The STRU file is:
5656
```

doc/examples/tddft.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ md_nresn 3
3535
md_nyosh 3
3636
md_qmass 0
3737
md_tlast 30
38-
md_dumpmdfred 1
38+
md_dumpfred 1
3939
md_domsd 0
4040
md_domsdatom 0
4141
md_outputstressperiod 0

doc/input-main.md

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
- [Molecular dynamics](#molecular-dynamics)
4545

46-
[md_type](#md-type) | [md_potential](#md-potential) | [md_rstmd](#md-rstmd) | [md_dt](#md_dt) | [md_t](#md-t) | [md_qmass](#md-qmass) | [md_dumpmdfred](#md-dumpmdfred) | [md_tfreq](#md-tfreq) | [md_fixtemperature](#md-fixtemperature) | [NVT_control](#nvt-control) | [NVT_tau](#nvt-tau) | [MNHC](#mnhc) | [md_ediff](#md-ediff) | [md_ediffg](#md-ediffg) | [rcut_lj](#rcut_lj) | [epsilon_lj](#epsilon_lj) | [sigma_lj](#sigma_lj) | [direction](#direction) | [velocity](#velocity) | [viscosity](#viscosity) | [tscale](#tscale) | [damp](#damp)
46+
[md_type](#md-type) | [md_potential](#md-potential) | [md_rstmd](#md-rstmd) | [md_dt](#md_dt) | [md_t](#md-t) | [md_qmass](#md-qmass) | [md_dumpfred](#md-dumpfred) | [md_rstfred](#md-rstfred) | [md_tfreq](#md-tfreq) | [MNHC](#mnhc) | [rcut_lj](#rcut_lj) | [epsilon_lj](#epsilon_lj) | [sigma_lj](#sigma_lj) | [direction](#direction) | [velocity](#velocity) | [viscosity](#viscosity) | [tscale](#tscale) | [damp](#damp)
4747

4848
- [DFT+U correction](#DFT_U-correction)
4949

@@ -1157,45 +1157,26 @@ This part of variables are used to control the molecular dynamics calculations.
11571157
- *Default*: No default
11581158
11591159
[back to top](#input-file)
1160-
- md_dumpmdfred<a id="md-dumpmdfred"></a>
1160+
- md_dumpfred<a id="md-dumpfred"></a>
11611161
- *Type*: Integer
1162-
- *Description*:This is the steps to control the frequence to output md information
1162+
- *Description*:This is the frequence to dump md information.
11631163
- *Default*: 1
11641164
11651165
[back to top](#input-file)
11661166
1167-
- md_tfreq<a id="md-tfreq"></a>
1168-
- *Type*: Real
1169-
- *Description*:
1170-
- Oscillation frequency, used to determine Qmass of NHC;
1171-
- 1/(md_tfreq*md_dt) is collision probability in Anderson method.
1172-
- *Default*: 1.0
1173-
1174-
[back to top](#input-file)
1175-
1176-
- md_fixtemperature<a id="md-fixtemperature"></a>
1177-
- *Type*: Integer
1178-
- *Description*:
1179-
- n:when set to n (n > 1), ABACUS will read the file "ChangeTemp.dat" and change system’s temperature every n steps
1180-
- 0,1:When set to 0 or 1, ABACUS won’t change the temperature during running MD.
1181-
- *Default*: 1
1182-
1183-
[back to top](#input-file)
1184-
1185-
- NVT_control<a id="nvt-control"></a>
1167+
- md_rstfred<a id="md-rstfred"></a>
11861168
- *Type*: Integer
1187-
- *Description*: Specifies which type of thermostat is used.
1188-
- 1: Nose-Hoover-chains
1189-
- 2: Langevin
1190-
- 3: Andersen
1169+
- *Description*:This is the frequence to output restart information.
11911170
- *Default*: 1
11921171
11931172
[back to top](#input-file)
11941173
1195-
- NVT_tau<a id="nvt-tau"></a>
1174+
- md_tfreq<a id="md-tfreq"></a>
11961175
- *Type*: Real
1197-
- *Description*: Parameter for adjust effect of thermostat corresponding to the time scale of collision, in fs. If te input value is less than 1d-10, then it is automatically set in ABACUS.
1198-
- *Default*: 0
1176+
- *Description*:
1177+
- Oscillation frequency, used to determine Qmass of NHC;
1178+
- 1/(md_tfreq*md_dt) is collision probability in Anderson method.
1179+
- *Default*: 1.0
11991180
12001181
[back to top](#input-file)
12011182
@@ -1206,20 +1187,6 @@ This part of variables are used to control the molecular dynamics calculations.
12061187
12071188
[back to top](#input-file)
12081189
1209-
- md_ediff<a id="md-ediff"></a>
1210-
- *Type*: Real
1211-
- *Description*: Parameter for constraining total energy change.
1212-
- *Default*: 0.0001
1213-
1214-
[back to top](#input-file)
1215-
1216-
- md_ediffg<a id="md-ediffg"></a>
1217-
- *Type*: Real
1218-
- *Description*: Parameter for constraining max force change
1219-
- *Default*: 0.001
1220-
1221-
[back to top](#input-file)
1222-
12231190
- rcut_lj<a id="rcut_lj"></a>
12241191
- *Type*: Real
12251192
- *Description*: Cut-off radius for Leonard Jones potential (angstrom).

source/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_subdirectory(module_symmetry)
44
add_subdirectory(module_neighbor)
55
add_subdirectory(module_orbital)
66
add_subdirectory(module_md)
7+
add_subdirectory(module_deepks)
78
add_subdirectory(src_io)
89
add_subdirectory(src_ions)
910
add_subdirectory(src_lcao)

source/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ VPATH=./src_global\
1414
:./module_cell\
1515
:./module_base\
1616
:./module_md\
17+
:./module_deepks\
1718
:./src_pw\
1819
:./src_lcao\
1920
:./src_ions\

source/Makefile.Objects

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,14 @@ LCAO_matrix.o\
160160
LCAO_nnr.o \
161161
LCAO_diago.o\
162162
LCAO_evolve.o\
163-
LCAO_descriptor.o\
164-
LCAO_descriptor_old.o\
165-
LCAO_descriptor_io.o\
166-
LCAO_descriptor_dV.o\
163+
LCAO_deepks.o\
164+
LCAO_deepks_fdelta.o\
165+
LCAO_deepks_io.o\
166+
LCAO_deepks_mpi.o\
167+
LCAO_deepks_pdm.o\
168+
LCAO_deepks_psialpha.o\
169+
LCAO_deepks_torch.o\
170+
LCAO_deepks_vdelta.o\
167171
ylm.o\
168172
FORCE_STRESS.o\
169173
FORCE_gamma.o\
@@ -226,7 +230,6 @@ parallel_reduce.o\
226230
parallel_pw.o\
227231
ft.o\
228232
parallel_grid.o\
229-
parallel_deepks.o \
230233

231234
OBJS_FIRST_PRINCIPLES=$(OBJS_MAIN)\
232235
$(OBJS_PW)\
@@ -246,6 +249,16 @@ read_rho.o\
246249
read_atoms.o\
247250
read_cell_pseudopots.o\
248251
read_dm.o\
252+
read_txt_tools.o\
253+
read_txt_stru.o\
254+
read_txt_input_value.o\
255+
read_txt_input_item.o\
256+
read_txt_input_list.o\
257+
read_txt_input_process.o\
258+
read_txt_input_process_global.o\
259+
read_txt_input-general.o\
260+
read_txt_input-pw.o\
261+
read_txt_input-spectrum.o\
249262
write_pot.o\
250263
write_rho.o\
251264
write_rho_cube.o\

source/input.cpp

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,14 +1145,6 @@ bool Input::Read(const std::string &fn)
11451145
{
11461146
read_value(ifs, mdp.mdtype);
11471147
}
1148-
else if (strcmp("nvt_tau",word) == 0)
1149-
{
1150-
read_value(ifs, mdp.NVT_tau);
1151-
}
1152-
else if (strcmp("nvt_control",word) == 0)
1153-
{
1154-
read_value(ifs,mdp.NVT_control );
1155-
}
11561148
else if (strcmp("md_dt",word) == 0)
11571149
{
11581150
read_value(ifs, mdp.dt);
@@ -1173,30 +1165,18 @@ bool Input::Read(const std::string &fn)
11731165
{
11741166
read_value(ifs,mdp.tlast );
11751167
}
1176-
else if (strcmp("md_dumpmdfred",word) == 0)
1168+
else if (strcmp("md_dumpfred",word) == 0)
11771169
{
1178-
read_value(ifs, mdp.recordFreq);
1170+
read_value(ifs, mdp.dumpfreq);
11791171
}
1180-
else if (strcmp("md_mdoutpath",word) == 0)
1172+
else if (strcmp("md_rstfred",word) == 0)
11811173
{
1182-
read_value(ifs,mdp.mdoutputpath );
1174+
read_value(ifs, mdp.rstfreq);
11831175
}
11841176
else if (strcmp("md_rstmd",word) == 0)
11851177
{
11861178
read_value(ifs,mdp.rstMD );
11871179
}
1188-
else if (strcmp("md_fixtemperature",word) == 0)
1189-
{
1190-
read_value(ifs,mdp.fixTemperature );
1191-
}
1192-
else if (strcmp("md_ediff",word) == 0)
1193-
{
1194-
read_value(ifs,mdp.ediff );
1195-
}
1196-
else if (strcmp("md_ediffg",word) == 0)
1197-
{
1198-
read_value(ifs,mdp.ediffg );
1199-
}
12001180
//added by zheng daye
12011181
//----------------------------------------------------------
12021182
// Classic MD
@@ -2153,19 +2133,14 @@ void Input::Bcast()
21532133
*/
21542134
//zheng daye add 2014/5/5
21552135
Parallel_Common::bcast_int(mdp.mdtype);
2156-
Parallel_Common::bcast_double(mdp.NVT_tau);
2157-
Parallel_Common::bcast_int(mdp.NVT_control);
21582136
Parallel_Common::bcast_double(mdp.dt);
21592137
Parallel_Common::bcast_int(mdp.MNHC);
21602138
Parallel_Common::bcast_double(mdp.Qmass);
21612139
Parallel_Common::bcast_double(mdp.tfirst);
21622140
Parallel_Common::bcast_double(mdp.tlast);
2163-
Parallel_Common::bcast_int(mdp.recordFreq);
2164-
Parallel_Common::bcast_string(mdp.mdoutputpath);
2141+
Parallel_Common::bcast_int(mdp.dumpfreq);
2142+
Parallel_Common::bcast_int(mdp.rstfreq);
21652143
Parallel_Common::bcast_int(mdp.rstMD);
2166-
Parallel_Common::bcast_int(mdp.fixTemperature);
2167-
Parallel_Common::bcast_double(mdp.ediff);
2168-
Parallel_Common::bcast_double(mdp.ediffg);
21692144
Parallel_Common::bcast_double(mdp.rcut_lj);
21702145
Parallel_Common::bcast_double(mdp.epsilon_lj);
21712146
Parallel_Common::bcast_double(mdp.sigma_lj);

0 commit comments

Comments
 (0)