Skip to content

Commit 8f606db

Browse files
committed
merge TD and dev and solve conflicts
2 parents 55d3c09 + f8a645f commit 8f606db

File tree

171 files changed

+136021
-1390
lines changed

Some content is hidden

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

171 files changed

+136021
-1390
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
env:
2828
GTEST_COLOR: 'yes'
2929
run: |
30-
cmake -B build -DBUILD_TESTING=ON
30+
cmake -B build -DBUILD_TESTING=ON -DENABLE_DEEPKS=ON
3131
cmake --build build -j8
3232
cmake --install build
3333
cmake --build build --target test ARGS="-V"

CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,14 @@ else()
167167
message(WARNING "Cannot find the correct library for Fortran.")
168168
endif()
169169
endif()
170-
target_link_libraries(${ABACUS_BIN_NAME} ${math_libs})
171170

172171
if(ENABLE_DEEPKS)
173172
set(CMAKE_CXX_STANDARD 14)
174173
find_package(Torch REQUIRED)
175174
include_directories(${TORCH_INCLUDE_DIRS})
176-
target_link_libraries(${ABACUS_BIN_NAME} ${TORCH_LIBRARIES})
175+
target_link_libraries(${ABACUS_BIN_NAME} deepks)
176+
list(APPEND math_libs ${TORCH_LIBRARIES})
177+
177178
add_compile_options(${TORCH_CXX_FLAGS})
178179

179180
find_path(libnpy_SOURCE_DIR
@@ -192,6 +193,8 @@ if(ENABLE_DEEPKS)
192193
add_compile_definitions(__DEEPKS)
193194
endif()
194195

196+
target_link_libraries(${ABACUS_BIN_NAME} ${math_libs})
197+
195198
if(DEFINED Libxc_DIR)
196199
set(ENABLE_LIBXC ON)
197200
endif()

Dockerfile.intel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ RUN source /opt/intel/oneapi/setvars.sh \
3838
&& wget https://elpa.mpcdf.mpg.de/software/tarball-archive/Releases/2021.05.002/elpa-2021.05.002.tar.gz \
3939
&& tar xzf elpa-2021.05.002.tar.gz && rm elpa-2021.05.002.tar.gz \
4040
&& cd elpa-2021.05.002 && mkdir build && cd build \
41-
&& ../configure FCFLAGS="-mkl=cluster" \
41+
&& ../configure FCFLAGS="-qmkl=cluster" \
4242
&& make -j8 \
4343
&& make PREFIX=/usr/local install \
4444
&& ln -s /usr/local/include/elpa-2021.05.002/elpa /usr/local/include/ \

doc/developers.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ To add a unit test:
4646
AddTest(
4747
TARGET <module_name>_<test_name> # this is the executable file name of the test
4848
SOURCES <test_name>.cpp
49+
50+
# OPTIONAL: if this test requires external libraries, add them with "LIBS" statement.
51+
LIBS math_libs # `math_libs` includes all math libraries in ABACUS.
4952
)
5053
```
5154

doc/input-main.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
[nurse](#nurse) | [t_in_h](#t-in-h) | [vl_in_h](#vl-in-h) | [vnl_in_h](#vnl-in-h) | [test_force](#test-force) | [test_stress](#test-stress) | [colour](#colour) | [test_just_neighbor](#test-just-neighbor)
6363
- [DeePKS](#deepks)
6464

65-
[out_descriptor](#out-descriptor) | [lmax_descriptor](#lmax-descriptor) | [deepks_scf](#deepks-scf) | [model_file](#model-file)
65+
[deepks_out_labels](#out-descriptor) | [deepks_descriptor_lmax](#lmax-descriptor) | [deepks_scf](#deepks-scf) | [deepks_model](#model-file)
6666

6767
[back to main page](../README.md)
6868

@@ -919,7 +919,7 @@ This part of variables are used to control the calculation of DOS.
919919
This part of variables are used to control the usage of DeePKS method (a comprehensive data-driven approach to improve accuracy of DFT).
920920
Warning: this function is not robust enough for version 2.2.0. Please try these variables in https://github.com/deepmodeling/abacus-develop/tree/deepks .
921921
922-
- out_descriptor<a id="out-descriptor"></a>
922+
- deepks_out_labels<a id="out-descriptor"></a>
923923
- *Type*: Boolean
924924
- *Description*: when set to 1, ABACUS will calculate and output descriptor for DeePKS training. In `LCAO` calculation, a path of *.orb file is needed to be specified under `NUMERICAL_DESCRIPTOR`in `STRU`file. For example:
925925
```
@@ -933,7 +933,7 @@ Warning: this function is not robust enough for version 2.2.0. Please try these
933933
- *Default*: 0
934934
935935
[back to top](#input-file)
936-
- lmax_descriptor<a id="lmax-descriptor"></a>
936+
- deepks_descriptor_lmax<a id="lmax-descriptor"></a>
937937
- *Type*: Integer
938938
- *Description*: control the max angular momentum of descriptor basis.
939939
- *Default*: 0
@@ -945,7 +945,7 @@ Warning: this function is not robust enough for version 2.2.0. Please try these
945945
- *Default*: 0
946946
947947
[back to top](#input-file)
948-
- model_file<a id="model-file"></a>
948+
- deepks_model<a id="model-file"></a>
949949
- *Type*: String
950950
- *Description*: the path of the trained, traced NN model file (generated by deepks-kit). used when deepks_scf is set to 1.
951951
- *Default*: None

examples/H2O-deepks-lcao/INPUT

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ mixing_beta 0.4
2626
#Parameters (6.Deepks)
2727
force 1
2828
test_force 1
29-
out_descriptor 1
30-
lmax_descriptor 2
29+
deepks_out_labels 1
30+
deepks_descriptor_lmax 2
3131
newdm 1
3232
deepks_scf 1
33-
model_file model.ptg
33+
deepks_model model.ptg

examples/H2O-deepks-pw/INPUT

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ mixing_beta 0.4
2525

2626
#Parameters (6.File)
2727
out_band 0
28-
out_descriptor 1
29-
lmax_descriptor 2
28+
deepks_out_labels 1
29+
deepks_descriptor_lmax 2

source/Makefile.Objects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ gint_k_init.o\
121121
gint_k_vl.o\
122122
gint_k_rho.o\
123123
gint_k_fvl.o\
124-
grid_base.o\
125124
grid_base_beta.o\
126125
ORB_control.o\
127126
ORB_read.o\
@@ -158,6 +157,7 @@ LCAO_diago.o\
158157
LCAO_evolve.o\
159158
LCAO_deepks.o\
160159
LCAO_deepks_fdelta.o\
160+
LCAO_deepks_odelta.o\
161161
LCAO_deepks_io.o\
162162
LCAO_deepks_mpi.o\
163163
LCAO_deepks_pdm.o\

source/input.cpp

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,11 @@ void Input::Default(void)
240240
out_charge = 0;
241241
out_dm = 0;
242242

243-
out_descriptor = 0; // caoyu added 2020-11-24, mohan added 2021-01-03
244-
lmax_descriptor = 2; // mohan added 2021-01-03
243+
deepks_out_labels = 0; // caoyu added 2020-11-24, mohan added 2021-01-03
244+
deepks_scf = 0;
245+
deepks_bandgap = 0;
246+
deepks_out_unittest = 0;
247+
deepks_descriptor_lmax = 2; // mohan added 2021-01-03
245248

246249
out_potential = 0;
247250
out_wf = 0;
@@ -912,22 +915,30 @@ bool Input::Read(const std::string &fn)
912915
{
913916
read_value(ifs, out_dm);
914917
}
915-
else if (strcmp("out_descriptor", word) == 0) // caoyu added 2020-11-24, mohan modified 2021-01-03
918+
else if (strcmp("deepks_out_labels", word) == 0) // caoyu added 2020-11-24, mohan modified 2021-01-03
916919
{
917-
read_value(ifs, out_descriptor);
920+
read_value(ifs, deepks_out_labels);
918921
}
919-
else if (strcmp("lmax_descriptor", word) == 0)// mohan added 2021-01-03
920-
{
921-
read_value(ifs, lmax_descriptor);
922-
}
923-
else if (strcmp("deepks_scf", word) == 0) // caoyu added 2021-06-02
922+
else if (strcmp("deepks_scf", word) == 0) // caoyu added 2020-11-24, mohan modified 2021-01-03
924923
{
925924
read_value(ifs, deepks_scf);
925+
}
926+
else if (strcmp("deepks_bandgap", word) == 0) // caoyu added 2020-11-24, mohan modified 2021-01-03
927+
{
928+
read_value(ifs, deepks_bandgap);
929+
}
930+
else if (strcmp("deepks_out_unittest", word) == 0)// mohan added 2021-01-03
931+
{
932+
read_value(ifs, deepks_out_unittest);
926933
}
927-
else if (strcmp("model_file", word) == 0) // caoyu added 2021-06-03
934+
else if (strcmp("deepks_model", word) == 0) // caoyu added 2021-06-03
928935
{
929-
read_value(ifs, model_file);
936+
read_value(ifs, deepks_model);
930937
}
938+
else if (strcmp("deepks_descriptor_lmax", word) == 0) // QO added 2021-12-15
939+
{
940+
read_value(ifs, deepks_descriptor_lmax);
941+
}
931942
else if (strcmp("out_potential", word) == 0)
932943
{
933944
read_value(ifs, out_potential);
@@ -1840,16 +1851,19 @@ void Input::Bcast()
18401851
Parallel_Common::bcast_string( charge_extrap );//xiaohui modify 2015-02-01
18411852
Parallel_Common::bcast_int( out_charge );
18421853
Parallel_Common::bcast_int( out_dm );
1843-
Parallel_Common::bcast_int( out_descriptor ); // caoyu added 2020-11-24, mohan modified 2021-01-03
1844-
Parallel_Common::bcast_int( lmax_descriptor ); // mohan modified 2021-01-03
1845-
Parallel_Common::bcast_int( deepks_scf ); // caoyu add 2021-06-02
1846-
Parallel_Common::bcast_string( model_file ); // caoyu add 2021-06-03
1854+
1855+
Parallel_Common::bcast_bool( deepks_out_labels ); // caoyu added 2020-11-24, mohan modified 2021-01-03
1856+
Parallel_Common::bcast_bool( deepks_scf );
1857+
Parallel_Common::bcast_bool( deepks_bandgap );
1858+
Parallel_Common::bcast_bool( deepks_out_unittest );
1859+
Parallel_Common::bcast_string( deepks_model );
1860+
Parallel_Common::bcast_int( deepks_descriptor_lmax );
18471861

18481862
Parallel_Common::bcast_int(out_potential);
18491863
Parallel_Common::bcast_int( out_wf );
18501864
Parallel_Common::bcast_int( out_wf_r );
18511865
Parallel_Common::bcast_int( out_dos );
1852-
Parallel_Common::bcast_int( out_band );
1866+
Parallel_Common::bcast_int( out_band );
18531867
Parallel_Common::bcast_int( out_hs );
18541868
Parallel_Common::bcast_int( out_hs2 ); //LiuXh add 2019-07-15
18551869
Parallel_Common::bcast_int( out_r_matrix ); // jingan add 2019-8-14

source/input.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,10 +372,18 @@ class Input
372372
//==========================================================
373373
// DeepKS -- added by caoyu and mohan
374374
//==========================================================
375-
int out_descriptor; // (need libnpy) output descritpor for deepks. caoyu added 2020-11-24, mohan modified 2021-01-03
376-
int lmax_descriptor; //lmax used in descriptor, mohan added 2021-01-03
377-
int deepks_scf; //(need libnpy and libtorch) if set 1, a trained model would be needed to cal V_delta and F_delta
378-
string model_file; //needed when deepks_scf=1
375+
bool deepks_out_labels; // (need libnpy) prints energy and force labels and descriptors for training, wenfei 2022-1-12
376+
bool deepks_scf; //(need libnpy and libtorch) if set 1, a trained model would be needed to cal V_delta and F_delta
377+
bool deepks_bandgap; //for bandgap label. QO added 2021-12-15
378+
379+
bool deepks_out_unittest; //if set 1, prints intermediate quantities that shall be used for making unit test
380+
381+
string deepks_model; //needed when deepks_scf=1
382+
383+
//the following 3 are used when generating jle.orb
384+
int deepks_descriptor_lmax; //lmax used in descriptor, mohan added 2021-01-03
385+
double deepks_descriptor_rcut;
386+
double deepks_descriptor_ecut;
379387

380388
//==========================================================
381389
// variables for test only

0 commit comments

Comments
 (0)