diff --git a/source/lmp/CMakeLists.txt b/source/lmp/CMakeLists.txt index 178413a68a..2ce941cc3d 100644 --- a/source/lmp/CMakeLists.txt +++ b/source/lmp/CMakeLists.txt @@ -19,5 +19,5 @@ endfunction() _add_lmp_variant("${HIGH_PREC_VARIANT}" "${HIGH_PREC_DEF}") _add_lmp_variant("${LOW_PREC_VARIANT}" "${LOW_PREC_DEF}") -configure_file("pair_deepmd.h.in" "pair_deepmd.h" @ONLY) +configure_file("deepmd_version.h.in" "deepmd_version.h" @ONLY) configure_file("lammps_install_list.txt.in" "lammps_install_list.txt" @ONLY) diff --git a/source/lmp/deepmd_version.h.in b/source/lmp/deepmd_version.h.in new file mode 100644 index 0000000000..f4c72c8413 --- /dev/null +++ b/source/lmp/deepmd_version.h.in @@ -0,0 +1,17 @@ +#define GIT_SUMM @GIT_SUMM@ +#define GIT_HASH @GIT_HASH@ +#define GIT_BRANCH @GIT_BRANCH@ +#define GIT_DATE @GIT_DATE@ +#define DEEPMD_ROOT @CMAKE_INSTALL_PREFIX@ +#define TensorFlow_INCLUDE_DIRS @TensorFlow_INCLUDE_DIRS@ +#define TensorFlow_LIBRARY @TensorFlow_LIBRARY@ +#define DPMD_CVT_STR(x) #x +#define DPMD_CVT_ASSTR(X) DPMD_CVT_STR(X) +#define STR_GIT_SUMM DPMD_CVT_ASSTR(GIT_SUMM) +#define STR_GIT_HASH DPMD_CVT_ASSTR(GIT_HASH) +#define STR_GIT_BRANCH DPMD_CVT_ASSTR(GIT_BRANCH) +#define STR_GIT_DATE DPMD_CVT_ASSTR(GIT_DATE) +#define STR_FLOAT_PREC DPMD_CVT_ASSTR(FLOAT_PREC) +#define STR_DEEPMD_ROOT DPMD_CVT_ASSTR(DEEPMD_ROOT) +#define STR_TensorFlow_INCLUDE_DIRS DPMD_CVT_ASSTR(TensorFlow_INCLUDE_DIRS) +#define STR_TensorFlow_LIBRARY DPMD_CVT_ASSTR(TensorFlow_LIBRARY) diff --git a/source/lmp/pair_deepmd.cpp b/source/lmp/pair_deepmd.cpp index 2d46543de7..b5b3faa6ff 100644 --- a/source/lmp/pair_deepmd.cpp +++ b/source/lmp/pair_deepmd.cpp @@ -26,6 +26,7 @@ #include "fix_ttm_dp.h" #endif +#include "deepmd_version.h" #include "pair_deepmd.h" using namespace LAMMPS_NS; diff --git a/source/lmp/pair_deepmd.h.in b/source/lmp/pair_deepmd.h similarity index 56% rename from source/lmp/pair_deepmd.h.in rename to source/lmp/pair_deepmd.h index a288b472c2..39a236b875 100644 --- a/source/lmp/pair_deepmd.h.in +++ b/source/lmp/pair_deepmd.h @@ -4,7 +4,7 @@ #ifdef PAIR_CLASS -PairStyle(deepmd,PairDeepMD) +PairStyle(deepmd, PairDeepMD) #else @@ -17,31 +17,14 @@ PairStyle(deepmd,PairDeepMD) #else #include "deepmd/DeepPot.h" #endif -#include #include +#include -#define GIT_SUMM @GIT_SUMM@ -#define GIT_HASH @GIT_HASH@ -#define GIT_BRANCH @GIT_BRANCH@ -#define GIT_DATE @GIT_DATE@ #ifdef HIGH_PREC #define FLOAT_PREC double #else #define FLOAT_PREC float #endif -#define DEEPMD_ROOT @CMAKE_INSTALL_PREFIX@ -#define TensorFlow_INCLUDE_DIRS @TensorFlow_INCLUDE_DIRS@ -#define TensorFlow_LIBRARY @TensorFlow_LIBRARY@ -#define DPMD_CVT_STR(x) #x -#define DPMD_CVT_ASSTR(X) DPMD_CVT_STR(X) -#define STR_GIT_SUMM DPMD_CVT_ASSTR(GIT_SUMM) -#define STR_GIT_HASH DPMD_CVT_ASSTR(GIT_HASH) -#define STR_GIT_BRANCH DPMD_CVT_ASSTR(GIT_BRANCH) -#define STR_GIT_DATE DPMD_CVT_ASSTR(GIT_DATE) -#define STR_FLOAT_PREC DPMD_CVT_ASSTR(FLOAT_PREC) -#define STR_DEEPMD_ROOT DPMD_CVT_ASSTR(DEEPMD_ROOT) -#define STR_TensorFlow_INCLUDE_DIRS DPMD_CVT_ASSTR(TensorFlow_INCLUDE_DIRS) -#define STR_TensorFlow_LIBRARY DPMD_CVT_ASSTR(TensorFlow_LIBRARY) namespace LAMMPS_NS { @@ -61,19 +44,21 @@ class PairDeepMD : public Pair { void unpack_reverse_comm(int, int *, double *) override; void print_summary(const std::string pre) const; int get_node_rank(); - std::string get_file_content(const std::string & model); - std::vector get_file_content(const std::vector & models); + std::string get_file_content(const std::string &model); + std::vector get_file_content( + const std::vector &models); + protected: virtual void allocate(); double **scale; -private: + private: deepmd::DeepPot deep_pot; deepmd::DeepPotModelDevi deep_pot_model_devi; unsigned numb_models; double cutoff; int numb_types; - std::vector > all_force; + std::vector > all_force; std::ofstream fp; int out_freq; std::string out_file; @@ -87,51 +72,51 @@ class PairDeepMD : public Pair { bool multi_models_no_mod_devi; bool is_restart; #ifdef HIGH_PREC - std::vector fparam; - std::vector aparam; + std::vector fparam; + std::vector aparam; double eps; double eps_v; #else - std::vector fparam; - std::vector aparam; + std::vector fparam; + std::vector aparam; float eps; float eps_v; #endif void make_fparam_from_compute( #ifdef HIGH_PREC - std::vector & fparam + std::vector &fparam #else - std::vector & fparam + std::vector &fparam #endif - ); + ); bool do_compute; std::string compute_id; - void make_ttm_fparam( + void make_ttm_fparam( #ifdef HIGH_PREC - std::vector & fparam + std::vector &fparam #else - std::vector & fparam + std::vector &fparam #endif - ); + ); void make_ttm_aparam( #ifdef HIGH_PREC - std::vector & dparam + std::vector &dparam #else - std::vector & dparam + std::vector &dparam #endif - ); + ); bool do_ttm; std::string ttm_fix_id; - int *counts,*displacements; + int *counts, *displacements; tagint *tagsend, *tagrecv; double *stdfsend, *stdfrecv; std::vector type_idx_map; }; -} +} // namespace LAMMPS_NS #endif #endif diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index 8d20b0866c..76b2380b20 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -41,8 +41,8 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) PARENT_SCOPE) message(STATUS "LAMMPS version is ${LAMMPS_VERSION_NUMBER}") - configure_file("../pair_deepmd.h.in" - "${CMAKE_CURRENT_BINARY_DIR}/pair_deepmd.h" @ONLY) + configure_file("../deepmd_version.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/deepmd_version.h" @ONLY) file(GLOB LMP_SRC deepmdplugin.cpp ../*.cpp ${LAMMPS_SOURCE_ROOT}/src/kspace.cpp # for pppm_dplr diff --git a/source/lmp/plugin/deepmdplugin.cpp b/source/lmp/plugin/deepmdplugin.cpp index e8794d1a5c..bcaf617e6a 100644 --- a/source/lmp/plugin/deepmdplugin.cpp +++ b/source/lmp/plugin/deepmdplugin.cpp @@ -2,6 +2,7 @@ * See https://docs.lammps.org/Developer_plugins.html */ #include "compute_deeptensor_atom.h" +#include "deepmd_version.h" #include "fix_dplr.h" #include "lammpsplugin.h" #include "pair_deepmd.h"