From e94d89ee3c84a3f7c8671beb50a2cabaed051647 Mon Sep 17 00:00:00 2001 From: James Michael Goff Date: Wed, 14 Feb 2024 17:02:07 -0700 Subject: [PATCH] added mliap_enable_ace to opt in/out of ace functionality in mliap --- cmake/Modules/Packages/ML-IAP.cmake | 15 +++++++++++++++ src/ML-IAP/compute_mliap.cpp | 10 ++++++++-- src/ML-IAP/mliap_descriptor_ace.cpp | 3 +++ src/ML-IAP/pair_mliap.cpp | 11 +++++++++-- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/Packages/ML-IAP.cmake b/cmake/Modules/Packages/ML-IAP.cmake index d6059c44b8..a9c447d8c1 100644 --- a/cmake/Modules/Packages/ML-IAP.cmake +++ b/cmake/Modules/Packages/ML-IAP.cmake @@ -10,6 +10,15 @@ endif() option(MLIAP_ENABLE_PYTHON "Build ML-IAP package with Python support" ${MLIAP_ENABLE_PYTHON_DEFAULT}) +# if ML-PACE package is included we may also include ML-PACE support in ML-IAP +set(MLIAP_ENABLE_ACE_DEFAULT OFF) +if(PKG_ML-PACE) + set(MLIAP_ENABLE_PYTHON_DEFAULT ON) +endif() + +option(MLIAP_ENABLE_PYTHON "Build ML-IAP package with Python support" ${MLIAP_ENABLE_PYTHON_DEFAULT}) +option(MLIAP_ENABLE_ACE "Build ML-IAP package with ACE support" ${MLIAP_ENABLE_ACE_DEFAULT}) + if(MLIAP_ENABLE_PYTHON) find_package(Cythonize REQUIRED) find_package(Python COMPONENTS NumPy REQUIRED) @@ -19,6 +28,12 @@ if(MLIAP_ENABLE_PYTHON) if(Python_VERSION VERSION_LESS 3.6) message(FATAL_ERROR "Python support in ML-IAP requires Python 3.6 or later") endif() + if(MLIAP_ENABLE_ACE) + if(NOT PKG_ML-PACE) + message(FATAL_ERROR "Must enable PYTHON package and ML-PACE package for including ACE support in ML-IAP") + endif() + target_compile_definitions(lammps PRIVATE -DMLIAP_ACE) + endif() set(MLIAP_BINARY_DIR ${CMAKE_BINARY_DIR}/cython) file(GLOB MLIAP_CYTHON_SRC CONFIGURE_DEPENDS ${LAMMPS_SOURCE_DIR}/ML-IAP/*.pyx) diff --git a/src/ML-IAP/compute_mliap.cpp b/src/ML-IAP/compute_mliap.cpp index 1f858b608b..46b2958924 100644 --- a/src/ML-IAP/compute_mliap.cpp +++ b/src/ML-IAP/compute_mliap.cpp @@ -23,7 +23,9 @@ #include "mliap_model_quadratic.h" #include "mliap_descriptor_snap.h" #include "mliap_descriptor_so3.h" +#ifdef MLIAP_ACE #include "mliap_descriptor_ace.h" +#endif #ifdef MLIAP_PYTHON #include "mliap_model_python.h" #endif @@ -95,11 +97,15 @@ ComputeMLIAP::ComputeMLIAP(LAMMPS *lmp, int narg, char **arg) : if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); descriptor = new MLIAPDescriptorSO3(lmp,arg[iarg+2]); iarg += 3; - } else if (strcmp(arg[iarg+1],"ace") == 0) { + } +#ifdef MLIAP_ACE + else if (strcmp(arg[iarg+1],"ace") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); descriptor = new MLIAPDescriptorACE(lmp,arg[iarg+2]); iarg += 3; - } else error->all(FLERR,"Illegal compute mliap command"); + } +#endif + else error->all(FLERR,"Illegal compute mliap command"); descriptorflag = 1; } else if (strcmp(arg[iarg],"gradgradflag") == 0) { if (iarg+1 > narg) error->all(FLERR,"Illegal compute mliap command"); diff --git a/src/ML-IAP/mliap_descriptor_ace.cpp b/src/ML-IAP/mliap_descriptor_ace.cpp index 2604a3d974..f87025026c 100644 --- a/src/ML-IAP/mliap_descriptor_ace.cpp +++ b/src/ML-IAP/mliap_descriptor_ace.cpp @@ -14,6 +14,7 @@ /* ---------------------------------------------------------------------- Contributing author: James Goff (SNL) ------------------------------------------------------------------------- */ +#ifdef MLIAP_ACE #include "mliap_descriptor_ace.h" @@ -427,3 +428,5 @@ double MLIAPDescriptorACE::memory_usage() return bytes; } + +#endif diff --git a/src/ML-IAP/pair_mliap.cpp b/src/ML-IAP/pair_mliap.cpp index f68e9c0b56..c242f4cdcc 100644 --- a/src/ML-IAP/pair_mliap.cpp +++ b/src/ML-IAP/pair_mliap.cpp @@ -21,7 +21,9 @@ #include "mliap_data.h" #include "mliap_descriptor_snap.h" #include "mliap_descriptor_so3.h" +#ifdef MLIAP_ACE #include "mliap_descriptor_ace.h" +#endif #include "mliap_model_linear.h" #include "mliap_model_nn.h" #include "mliap_model_quadratic.h" @@ -182,10 +184,15 @@ void PairMLIAP::settings(int narg, char ** arg) if (iarg+3 > narg) utils::missing_cmd_args(FLERR, "pair_style mliap descriptor so3", error); descriptor = new MLIAPDescriptorSO3(lmp,arg[iarg+2]); iarg += 3; - } else if (strcmp(arg[iarg+1],"ace") == 0) { + } +#ifdef MLIAP_ACE + else if (strcmp(arg[iarg+1],"ace") == 0) { + if (iarg+3 > narg) error->all(FLERR,"Illegal pair_style mliap command"); descriptor = new MLIAPDescriptorACE(lmp,arg[iarg+2]); iarg += 3; - } else error->all(FLERR,"Illegal pair_style mliap command"); + } +#endif + else error->all(FLERR,"Illegal pair_style mliap command"); } else if (strcmp(arg[iarg], "unified") == 0) { #ifdef MLIAP_PYTHON if (model != nullptr) error->all(FLERR,"Illegal multiple pair_style mliap model definitions");