Skip to content

Commit ca61f69

Browse files
authored
Merge pull request #114 from amcadmus/devel
add option USE_TTM to determine if to build with TTM support
2 parents 351bdcd + 2c51c5c commit ca61f69

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

source/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ if (USE_CUDA_TOOLKIT)
124124
add_definitions("-DUSE_CUDA_TOOLKIT")
125125
endif()
126126

127+
# define USE_TTM
128+
if (NOT DEFINED USE_TTM)
129+
set(USE_TTM FALSE)
130+
endif (NOT DEFINED USE_TTM)
131+
if (USE_TTM)
132+
message(STATUS "Use TTM")
133+
set(TTM_DEF "-DUSE_TTM")
134+
endif (USE_TTM)
135+
127136
# define build type
128137
if ((NOT DEFINED CMAKE_BUILD_TYPE) OR CMAKE_BUILD_TYPE STREQUAL "")
129138
set (CMAKE_BUILD_TYPE release)

source/lmp/env.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ TF_INCLUDE_DIRS=`echo $TENSORFLOW_INCLUDE_DIRS | sed "s/;/ -I/g"`
66
TF_LIBRARY_PATH=`echo $TENSORFLOW_LIBRARY_PATH | sed "s/;/ -L/g"`
77
TF_RPATH=`echo $TENSORFLOW_LIBRARY_PATH | sed "s/;/ -Wl,-rpath=/g"`
88

9-
NNP_INC=" -std=c++11 @PREC_DEF@ -I$TF_INCLUDE_DIRS -I$DEEPMD_ROOT/include/deepmd "
9+
NNP_INC=" -std=c++11 @PREC_DEF@ @TTM_DEF@ -I$TF_INCLUDE_DIRS -I$DEEPMD_ROOT/include/deepmd "
1010
NNP_PATH=" -L$TF_LIBRARY_PATH -L$DEEPMD_ROOT/lib"
1111
NNP_LIB=" -Wl,--no-as-needed -l@LIB_DEEPMD_OP@ -l@LIB_DEEPMD@ -ltensorflow_cc -ltensorflow_framework -Wl,-rpath=$TF_RPATH -Wl,-rpath=$DEEPMD_ROOT/lib"

source/lmp/pair_nnp.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
#include "neigh_request.h"
1515
#include "modify.h"
1616
#include "fix.h"
17+
#ifdef USE_TTM
1718
#include "fix_ttm_mod.h"
19+
#endif
1820

1921
#include "pair_nnp.h"
2022

@@ -120,6 +122,7 @@ make_uniform_aparam(
120122
}
121123
}
122124

125+
#ifdef USE_TTM
123126
void PairNNP::make_ttm_aparam(
124127
#ifdef HIGH_PREC
125128
vector<double > & daparam
@@ -170,7 +173,7 @@ void PairNNP::make_ttm_aparam(
170173
}
171174
}
172175
}
173-
176+
#endif
174177

175178
PairNNP::PairNNP(LAMMPS *lmp)
176179
: Pair(lmp)
@@ -280,7 +283,9 @@ void PairNNP::compute(int eflag, int vflag)
280283
make_uniform_aparam(daparam, aparam, nlocal);
281284
}
282285
else if (do_ttm) {
286+
#ifdef USE_TTM
283287
make_ttm_aparam(daparam);
288+
#endif
284289
}
285290

286291
// compute
@@ -681,6 +686,7 @@ void PairNNP::settings(int narg, char **arg)
681686
iarg += 1 + dim_aparam ;
682687
}
683688
else if (string(arg[iarg]) == string("ttm")) {
689+
#ifdef USE_TTM
684690
for (int ii = 0; ii < 1; ++ii){
685691
if (iarg+1+ii >= narg || is_key(arg[iarg+1+ii])) {
686692
error->all(FLERR, "invalid ttm key: should be ttm ttm_fix_id(str)");
@@ -689,6 +695,9 @@ void PairNNP::settings(int narg, char **arg)
689695
do_ttm = true;
690696
ttm_fix_id = arg[iarg+1];
691697
iarg += 1 + 1;
698+
#else
699+
error->all(FLERR, "The deepmd-kit was compiled without support for TTM, please rebuild it with -DUSE_TTM");
700+
#endif
692701
}
693702
else if (string(arg[iarg]) == string("atomic")) {
694703
out_each = 1;

0 commit comments

Comments
 (0)