Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lmp: extract deepmd version information to a seperated file #2480

Merged
merged 2 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion source/lmp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
17 changes: 17 additions & 0 deletions source/lmp/deepmd_version.h.in
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions source/lmp/pair_deepmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "fix_ttm_dp.h"
#endif

#include "deepmd_version.h"
#include "pair_deepmd.h"

using namespace LAMMPS_NS;
Expand Down
63 changes: 24 additions & 39 deletions source/lmp/pair_deepmd.h.in → source/lmp/pair_deepmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#ifdef PAIR_CLASS

PairStyle(deepmd,PairDeepMD)
PairStyle(deepmd, PairDeepMD)

#else

Expand All @@ -17,31 +17,14 @@ PairStyle(deepmd,PairDeepMD)
#else
#include "deepmd/DeepPot.h"
#endif
#include <iostream>
#include <fstream>
#include <iostream>

#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 {

Expand All @@ -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<std::string> get_file_content(const std::vector<std::string> & models);
std::string get_file_content(const std::string &model);
std::vector<std::string> get_file_content(
const std::vector<std::string> &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<std::vector<double > > all_force;
std::vector<std::vector<double> > all_force;
std::ofstream fp;
int out_freq;
std::string out_file;
Expand All @@ -87,51 +72,51 @@ class PairDeepMD : public Pair {
bool multi_models_no_mod_devi;
bool is_restart;
#ifdef HIGH_PREC
std::vector<double > fparam;
std::vector<double > aparam;
std::vector<double> fparam;
std::vector<double> aparam;
double eps;
double eps_v;
#else
std::vector<float > fparam;
std::vector<float > aparam;
std::vector<float> fparam;
std::vector<float> aparam;
float eps;
float eps_v;
#endif

void make_fparam_from_compute(
#ifdef HIGH_PREC
std::vector<double > & fparam
std::vector<double> &fparam
#else
std::vector<float > & fparam
std::vector<float> &fparam
#endif
);
);
bool do_compute;
std::string compute_id;

void make_ttm_fparam(
void make_ttm_fparam(
#ifdef HIGH_PREC
std::vector<double > & fparam
std::vector<double> &fparam
#else
std::vector<float > & fparam
std::vector<float> &fparam
#endif
);
);

void make_ttm_aparam(
#ifdef HIGH_PREC
std::vector<double > & dparam
std::vector<double> &dparam
#else
std::vector<float > & dparam
std::vector<float> &dparam
#endif
);
);
bool do_ttm;
std::string ttm_fix_id;
int *counts,*displacements;
int *counts, *displacements;
tagint *tagsend, *tagrecv;
double *stdfsend, *stdfrecv;
std::vector<int> type_idx_map;
};

}
} // namespace LAMMPS_NS

#endif
#endif
4 changes: 2 additions & 2 deletions source/lmp/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions source/lmp/plugin/deepmdplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down