diff --git a/.devcontainer/build_cxx.sh b/.devcontainer/build_cxx.sh index 007c99b9e5..432d7d32db 100755 --- a/.devcontainer/build_cxx.sh +++ b/.devcontainer/build_cxx.sh @@ -13,7 +13,7 @@ cmake -D ENABLE_TENSORFLOW=ON \ -D ENABLE_PYTORCH=ON \ -D ENABLE_PADDLE=ON \ -D CMAKE_INSTALL_PREFIX=${SCRIPT_PATH}/../dp/ \ - -D LAMMPS_VERSION=stable_29Aug2024_update1 \ + -D LAMMPS_VERSION=stable_22Jul2025 \ -D CMAKE_BUILD_TYPE=Debug \ -D BUILD_TESTING:BOOL=TRUE \ -D TENSORFLOW_ROOT=${TENSORFLOW_ROOT} \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 27c40bbe6a..85d67db2a9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,7 +11,6 @@ "PATH": "${containerEnv:PATH}:${containerWorkspaceFolder}/.venv/bin", "DP_ENABLE_PYTORCH": "1", "DP_VARIANT": "cpu", - "LMP_CXX11_ABI_0": "1", "UV_EXTRA_INDEX_URL": "https://download.pytorch.org/whl/cpu" } } diff --git a/.github/workflows/test_cc.yml b/.github/workflows/test_cc.yml index cd4eca96f7..7d76e60ba1 100644 --- a/.github/workflows/test_cc.yml +++ b/.github/workflows/test_cc.yml @@ -41,7 +41,6 @@ jobs: OMP_NUM_THREADS: 1 TF_INTRA_OP_PARALLELISM_THREADS: 1 TF_INTER_OP_PARALLELISM_THREADS: 1 - LMP_CXX11_ABI_0: 1 CMAKE_GENERATOR: Ninja CXXFLAGS: ${{ matrix.check_memleak && '-fsanitize=leak' || '' }} LSAN_OPTIONS: suppressions=${{ github.workspace }}/.github/workflows/suppr.txt diff --git a/.github/workflows/test_cuda.yml b/.github/workflows/test_cuda.yml index 5f6b0e73ab..14c051123c 100644 --- a/.github/workflows/test_cuda.yml +++ b/.github/workflows/test_cuda.yml @@ -30,10 +30,6 @@ jobs: with: python-version: '3.11' # cache: 'pip' - - name: Setup MPI - uses: mpi4py/setup-mpi@v1 - with: - mpi: mpich - name: Install wget and unzip run: apt-get update && apt-get install -y wget unzip - uses: lukka/get-cmake@latest @@ -74,7 +70,6 @@ jobs: OMP_NUM_THREADS: 1 TF_INTRA_OP_PARALLELISM_THREADS: 1 TF_INTER_OP_PARALLELISM_THREADS: 1 - LMP_CXX11_ABI_0: 1 CMAKE_GENERATOR: Ninja DP_VARIANT: cuda DP_USE_MPICH2: 1 diff --git a/backend/dp_backend.py b/backend/dp_backend.py index 81c3f20f19..e32d5db38b 100644 --- a/backend/dp_backend.py +++ b/backend/dp_backend.py @@ -1,6 +1,8 @@ # SPDX-License-Identifier: LGPL-3.0-or-later """A PEP-517 backend to find TensorFlow.""" +import os + from scikit_build_core import build as _orig from .find_pytorch import ( @@ -39,10 +41,15 @@ def __dir__() -> list[str]: def get_requires_for_build_wheel( config_settings: dict, ) -> list[str]: + if os.environ.get("CIBUILDWHEEL", "0") == "1": + cibw_deps = ["mpich"] + else: + cibw_deps = [] return ( _orig.get_requires_for_build_wheel(config_settings) + find_tensorflow()[1] + find_pytorch()[1] + + cibw_deps ) diff --git a/backend/find_pytorch.py b/backend/find_pytorch.py index c51c8905b8..2a40fc40e6 100644 --- a/backend/find_pytorch.py +++ b/backend/find_pytorch.py @@ -124,6 +124,11 @@ def get_pt_requirement(pt_version: str = "") -> dict: raise RuntimeError("Unsupported CUDA version") from None if pt_version == "": pt_version = os.environ.get("PYTORCH_VERSION", "") + if os.environ.get("CIBUILDWHEEL", "0") == "1": + # PyTorch OP library is built against mpich + mpi_requirement = ["mpich"] + else: + mpi_requirement = [] return { "torch": [ @@ -134,7 +139,8 @@ def get_pt_requirement(pt_version: str = "") -> dict: f"torch=={Version(pt_version).base_version}.*" if pt_version != "" # https://github.com/pytorch/pytorch/commit/7e0c26d4d80d6602aed95cb680dfc09c9ce533bc - else "torch>=2.1.0" + else "torch>=2.1.0", + *mpi_requirement, ], } diff --git a/backend/read_env.py b/backend/read_env.py index f28e2917f3..482f9766a0 100644 --- a/backend/read_env.py +++ b/backend/read_env.py @@ -119,6 +119,7 @@ def get_argument_from_env() -> tuple[str, list, list, dict, str, str]: cmake_args = [ "-DBUILD_PY_IF:BOOL=TRUE", + f"-DCIBUILDWHEEL={os.environ.get('CIBUILDWHEEL', '0')}", *cmake_args, ] return ( diff --git a/deepmd/lmp.py b/deepmd/lmp.py index 15959cf243..7ac1570f0f 100644 --- a/deepmd/lmp.py +++ b/deepmd/lmp.py @@ -81,7 +81,6 @@ def get_library_path(module: str, filename: str) -> list[str]: pt_dir = os.path.join(torch.__path__[0], "lib") op_dir = str(SHARED_LIB_DIR) - cuda_library_paths = [] if platform.system() == "Linux": cuda_library_paths.extend( diff --git a/deepmd/lmp_check_build.py b/deepmd/lmp_check_build.py new file mode 100644 index 0000000000..dc81a31d8e --- /dev/null +++ b/deepmd/lmp_check_build.py @@ -0,0 +1,19 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +from deepmd.env import ( + GLOBAL_CONFIG, +) + +if GLOBAL_CONFIG.get("lammps_version", "") == "": + + def get_op_dir() -> str: + """Get the directory of the deepmd-kit OP library.""" + # empty + return "" +else: + from deepmd.lmp import ( + get_op_dir, + ) + +__all__ = [ + "get_op_dir", +] diff --git a/deepmd/pt/cxx_op.py b/deepmd/pt/cxx_op.py index f7922a5c52..1106a8887f 100644 --- a/deepmd/pt/cxx_op.py +++ b/deepmd/pt/cxx_op.py @@ -1,5 +1,12 @@ # SPDX-License-Identifier: LGPL-3.0-or-later import platform +from ctypes import ( + CDLL, + RTLD_GLOBAL, +) +from importlib import ( + metadata, +) import torch from packaging.version import ( @@ -87,6 +94,29 @@ def load_library(module_name: str) -> bool: return False +def load_mpi_library() -> None: + """Load MPI library. + + When building with cibuildwheel, the link to the MPI library is lost + after the wheel is repaired. + """ + if platform.system() == "Linux": + libname = "libmpi.so.*" + elif platform.system() == "Darwin": + libname = "libmpi.*.dylib" + else: + raise RuntimeError("Unsupported platform") + MPI_LIB = next(p for p in metadata.files("mpich") if p.match(libname)).locate() + # use CDLL to load the library + CDLL(MPI_LIB, mode=RTLD_GLOBAL) + + +if GLOBAL_CONFIG.get("cibuildwheel", "0") == "1" and platform.system() in ( + "Linux", + "Darwin", +): + load_mpi_library() + ENABLE_CUSTOMIZED_OP = load_library("deepmd_op_pt") __all__ = [ diff --git a/doc/install/easy-install.md b/doc/install/easy-install.md index d28c0d0773..bbf8d9b1d9 100644 --- a/doc/install/easy-install.md +++ b/doc/install/easy-install.md @@ -227,4 +227,4 @@ If your platform is not supported, or you want to build against the installed ba pip install deepmd-kit[gpu,cu12,lmp,ipi] ``` -MPICH is required for parallel running. +MPICH will be installed automatically - you do not need to install a MPI library by yourself. diff --git a/doc/install/install-lammps.md b/doc/install/install-lammps.md index 00b887e9c3..91d2435066 100644 --- a/doc/install/install-lammps.md +++ b/doc/install/install-lammps.md @@ -17,11 +17,11 @@ DeePMD-kit will generate a module called `USER-DEEPMD` in the `build` directory, ```bash cd /some/workspace -wget https://github.com/lammps/lammps/archive/stable_29Aug2024_update1.tar.gz -tar xf stable_29Aug2024_update1.tar.gz +wget https://github.com/lammps/lammps/archive/stable_22Jul2025.tar.gz +tar xf stable_22Jul2025.tar.gz ``` -The source code of LAMMPS is stored in the directory `lammps-stable_29Aug2024_update1`. +The source code of LAMMPS is stored in the directory `lammps-stable_22Jul2025`. Then, you can [build LAMMPS](https://docs.lammps.org/Build.html) with either make or CMake. @@ -30,7 +30,7 @@ Then, you can [build LAMMPS](https://docs.lammps.org/Build.html) with either mak Now go into the LAMMPS code and copy the DeePMD-kit module like this ```bash -cd lammps-stable_29Aug2024_update1/src/ +cd lammps-stable_22Jul2025/src/ cp -r $deepmd_source_dir/source/build/USER-DEEPMD . make yes-kspace make yes-extra-fix @@ -60,8 +60,8 @@ make no-user-deepmd Now go into the LAMMPS directory and create a directory called `build`: ```bash -mkdir -p lammps-stable_29Aug2024_update1/build/ -cd lammps-stable_29Aug2024_update1/build/ +mkdir -p lammps-stable_22Jul2025/build/ +cd lammps-stable_22Jul2025/build/ ``` Patch the LAMMPS `CMakeLists.txt` file: @@ -94,15 +94,15 @@ Now download the LAMMPS code (`8Apr2021` or later), and uncompress it: ```bash cd /some/workspace -wget https://github.com/lammps/lammps/archive/stable_29Aug2024_update1.tar.gz -tar xf stable_29Aug2024_update1.tar.gz +wget https://github.com/lammps/lammps/archive/stable_22Jul2025.tar.gz +tar xf stable_22Jul2025.tar.gz ``` -The source code of LAMMPS is stored in the directory `lammps-stable_29Aug2024_update1`. The directory of the source code should be specified as the CMAKE argument `LAMMPS_SOURCE_ROOT` during installation of the DeePMD-kit C++ interface. Now go into the LAMMPS directory and create a directory called `build` +The source code of LAMMPS is stored in the directory `lammps-stable_22Jul2025`. The directory of the source code should be specified as the CMAKE argument `LAMMPS_SOURCE_ROOT` during installation of the DeePMD-kit C++ interface. Now go into the LAMMPS directory and create a directory called `build` ```bash -mkdir -p lammps-stable_29Aug2024_update1/build/ -cd lammps-stable_29Aug2024_update1/build/ +mkdir -p lammps-stable_22Jul2025/build/ +cd lammps-stable_22Jul2025/build/ ``` Now build LAMMPS. Note that `PLUGIN` must be enabled, and `BUILD_SHARED_LIBS` must be set to `yes`. You can install any other package you want. diff --git a/pyproject.toml b/pyproject.toml index feb790527b..a877ea5a8c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -58,7 +58,7 @@ requires-python = ">=3.9" keywords = ["deepmd"] [project.entry-points."lammps.plugins"] -deepmd = "deepmd.lmp:get_op_dir" +deepmd = "deepmd.lmp_check_build:get_op_dir" [project.entry-points."dpgui"] "DeePMD-kit" = "deepmd.utils.argcheck:gen_args" @@ -108,7 +108,7 @@ docs = [ "sphinx-remove-toctrees", ] lmp = [ - "lammps~=2024.8.29.1.0", + "lammps[mpi]~=2025.7.22.0.2", ] ipi = [ "ipi", @@ -238,14 +238,11 @@ manylinux-x86_64-image = "quay.io/pypa/manylinux_2_28_x86_64:2022-11-19-1b19e81" manylinux-aarch64-image = "manylinux_2_28" [tool.cibuildwheel.macos] -before-all = [ - '''pip install mpich''', -] repair-wheel-command = """delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} --ignore-missing-dependencies""" [tool.cibuildwheel.macos.environment] PIP_PREFER_BINARY = "1" -DP_LAMMPS_VERSION = "stable_29Aug2024_update1" +DP_LAMMPS_VERSION = "stable_22Jul2025" DP_ENABLE_IPI = "1" DP_ENABLE_PYTORCH = "1" DP_ENABLE_PADDLE = "1" @@ -259,7 +256,7 @@ inherit.environment = "append" environment.MACOSX_DEPLOYMENT_TARGET = "11.0" [tool.cibuildwheel.linux] -repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so --exclude _pywrap_tensorflow_internal.so --exclude libtensorflow_cc.so.2 --exclude libc10.so --exclude libtorch.so --exclude libtorch_cpu.so -w {dest_dir} {wheel}" +repair-wheel-command = "auditwheel repair --exclude libtensorflow_framework.so.2 --exclude libtensorflow_framework.so.1 --exclude libtensorflow_framework.so --exclude _pywrap_tensorflow_internal.so --exclude libtensorflow_cc.so.2 --exclude libc10.so --exclude libtorch.so --exclude libtorch_cpu.so --exclude libmpi.so.12 -w {dest_dir} {wheel}" environment-pass = [ "CIBW_BUILD", "DP_VARIANT", @@ -272,7 +269,6 @@ before-all = [ # https://almalinux.org/blog/2023-12-20-almalinux-8-key-update/ """rpm --import https://repo.almalinux.org/almalinux/RPM-GPG-KEY-AlmaLinux""", """{ if [ "$(uname -m)" = "x86_64" ] ; then yum config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo && yum install -y cuda-nvcc-${CUDA_VERSION/./-} cuda-cudart-devel-${CUDA_VERSION/./-}; fi }""", - '''/opt/python/cp311-cp311/bin/python -m pip install mpich''', # uv is not available in the old manylinux image """{ if [ "$(uname -m)" = "x86_64" ] ; then pipx install uv; fi }""", ] @@ -282,18 +278,14 @@ before-build = [ ] [tool.cibuildwheel.linux.environment] PIP_PREFER_BINARY = "1" -DP_LAMMPS_VERSION = "stable_29Aug2024_update1" +DP_LAMMPS_VERSION = "stable_22Jul2025" DP_ENABLE_IPI = "1" DP_ENABLE_PYTORCH = "1" DP_ENABLE_PADDLE = "1" -MPI_HOME = "/usr/lib64/mpich" -PATH = "/usr/lib64/mpich/bin:$PATH" # use CPU version of torch for building, which should also work for GPU # note: uv has different behavior from pip on extra index url # https://github.com/astral-sh/uv/blob/main/PIP_COMPATIBILITY.md#packages-that-exist-on-multiple-indexes UV_EXTRA_INDEX_URL = "https://download.pytorch.org/whl/cpu" -# trick to find the correction version of mpich -CMAKE_PREFIX_PATH="/opt/python/cp311-cp311/" [tool.cibuildwheel.windows] test-extras = ["cpu", "torch", "paddle"] diff --git a/source/config/run_config.ini b/source/config/run_config.ini index 7bb6041af9..596be911db 100644 --- a/source/config/run_config.ini +++ b/source/config/run_config.ini @@ -18,3 +18,5 @@ PD_VERSION = @PADDLE_VERSION@ PD_INFERENCE_DIR = @PADDLE_INFERENCE_DIR@ MODEL_VERSION=@MODEL_VERSION@ DP_VARIANT=@DP_VARIANT@ +LAMMPS_VERSION = @LAMMPS_VERSION@ +CIBUILDWHEEL = @CIBUILDWHEEL@ diff --git a/source/install/build_cc.sh b/source/install/build_cc.sh index dc66343cb2..0a3b3e5903 100755 --- a/source/install/build_cc.sh +++ b/source/install/build_cc.sh @@ -26,7 +26,7 @@ cmake -D ENABLE_TENSORFLOW=ON \ -D USE_TF_PYTHON_LIBS=TRUE \ -D USE_PT_PYTHON_LIBS=TRUE \ ${CUDA_ARGS} \ - -D LAMMPS_VERSION=stable_29Aug2024_update1 \ + -D LAMMPS_VERSION=stable_22Jul2025 \ .. cmake --build . -j${NPROC} cmake --install . diff --git a/source/install/build_from_c.sh b/source/install/build_from_c.sh index 22739ec531..8122fad603 100755 --- a/source/install/build_from_c.sh +++ b/source/install/build_from_c.sh @@ -13,7 +13,7 @@ NPROC=$(nproc --all) BUILD_TMP_DIR=${SCRIPT_PATH}/../build mkdir -p ${BUILD_TMP_DIR} cd ${BUILD_TMP_DIR} -cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DDEEPMD_C_ROOT=${DEEPMD_C_ROOT} -DLAMMPS_VERSION=stable_29Aug2024_update1 .. +cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DDEEPMD_C_ROOT=${DEEPMD_C_ROOT} -DLAMMPS_VERSION=stable_22Jul2025 .. cmake --build . -j${NPROC} cmake --install . cmake --build . --target=lammps diff --git a/source/install/build_lammps.sh b/source/install/build_lammps.sh index d101714739..04c2d372c6 100755 --- a/source/install/build_lammps.sh +++ b/source/install/build_lammps.sh @@ -14,7 +14,7 @@ BUILD_TMP_DIR=${SCRIPT_PATH}/../build_lammps mkdir -p ${BUILD_TMP_DIR} cd ${BUILD_TMP_DIR} # download LAMMMPS -LAMMPS_VERSION=stable_29Aug2024_update1 +LAMMPS_VERSION=stable_22Jul2025 if [ ! -d "lammps-${LAMMPS_VERSION}" ]; then curl -L -o lammps.tar.gz https://github.com/lammps/lammps/archive/refs/tags/${LAMMPS_VERSION}.tar.gz tar vxzf lammps.tar.gz diff --git a/source/install/test_cc.sh b/source/install/test_cc.sh index 1626f36193..dd3e0476a9 100755 --- a/source/install/test_cc.sh +++ b/source/install/test_cc.sh @@ -17,7 +17,7 @@ INSTALL_PREFIX=${SCRIPT_PATH}/../../dp_test BUILD_TMP_DIR=${SCRIPT_PATH}/../build_tests mkdir -p ${BUILD_TMP_DIR} cd ${BUILD_TMP_DIR} -cmake -DINSTALL_TENSORFLOW=TRUE -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DTENSORFLOW_ROOT=${INSTALL_PREFIX} -DBUILD_TESTING:BOOL=TRUE -DLAMMPS_VERSION=stable_29Aug2024_update1 ${CUDA_ARGS} .. +cmake -DINSTALL_TENSORFLOW=TRUE -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DTENSORFLOW_ROOT=${INSTALL_PREFIX} -DBUILD_TESTING:BOOL=TRUE -DLAMMPS_VERSION=stable_22Jul2025 ${CUDA_ARGS} .. cmake --build . -j${NPROC} cmake --install . ctest --output-on-failure diff --git a/source/install/test_cc_local.sh b/source/install/test_cc_local.sh index 8152b6f1a4..776c8a70cf 100755 --- a/source/install/test_cc_local.sh +++ b/source/install/test_cc_local.sh @@ -28,7 +28,7 @@ cmake \ -D USE_PT_PYTHON_LIBS=TRUE \ -D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \ -D BUILD_TESTING:BOOL=TRUE \ - -D LAMMPS_VERSION=stable_29Aug2024_update1 \ + -D LAMMPS_VERSION=stable_22Jul2025 \ ${CUDA_ARGS} .. cmake --build . -j${NPROC} cmake --install . diff --git a/source/lmp/builtin.cmake b/source/lmp/builtin.cmake index f29e9d3319..e051e5c24a 100644 --- a/source/lmp/builtin.cmake +++ b/source/lmp/builtin.cmake @@ -5,7 +5,52 @@ # assume LAMMPS CMake file has been executed, so these target/variables exist: # lammps LAMMPS_SOURCE_DIR get_lammps_version -get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION_NUMBER) +# Since May 15, 2025, the output of get_lammps_version is changed. We vendor the +# old get_lammps_version +# https://github.com/lammps/lammps/commit/b3e7121535863df3db487cd3e6a68c080bf2a6b4#diff-1214db0d1c015a50103f61f8ff7896053dec7ebc1edb930d6ef8bb07282f52abR75 +function(_get_lammps_version version_header variable) + file(STRINGS ${version_header} line REGEX LAMMPS_VERSION) + set(MONTHS + x + Jan + Feb + Mar + Apr + May + Jun + Jul + Aug + Sep + Oct + Nov + Dec) + string(REGEX + REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" + "\\1" day "${line}") + string(REGEX + REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" + "\\2" month "${line}") + string(REGEX + REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" + "\\3" year "${line}") + string(STRIP ${day} day) + string(STRIP ${month} month) + string(STRIP ${year} year) + list(FIND MONTHS "${month}" month) + string(LENGTH ${day} day_length) + string(LENGTH ${month} month_length) + if(day_length EQUAL 1) + set(day "0${day}") + endif() + if(month_length EQUAL 1) + set(month "0${month}") + endif() + set(${variable} + "${year}${month}${day}" + PARENT_SCOPE) +endfunction() + +_get_lammps_version(${LAMMPS_SOURCE_DIR}/version.h LAMMPS_VERSION_NUMBER) configure_file("${CMAKE_CURRENT_LIST_DIR}/deepmd_version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/deepmd_version.h" @ONLY) diff --git a/source/lmp/plugin/CMakeLists.txt b/source/lmp/plugin/CMakeLists.txt index a0998b3ce9..a4e7d9e430 100644 --- a/source/lmp/plugin/CMakeLists.txt +++ b/source/lmp/plugin/CMakeLists.txt @@ -38,8 +38,54 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) # get_lammps_version # https://github.com/lammps/lammps/blob/c2a12f97c5f665852fb38fdd4922f7dd2e77a0a1/cmake/Modules/LAMMPSUtils.cmake#L27-L46 - include(${LAMMPS_SOURCE_ROOT}/cmake/Modules/LAMMPSUtils.cmake) - get_lammps_version(${LAMMPS_HEADER_DIR}/version.h LAMMPS_VERSION_NUMBER) + # include(${LAMMPS_SOURCE_ROOT}/cmake/Modules/LAMMPSUtils.cmake) Since May 15, + # 2025, the output of get_lammps_version is changed. We vendor the old + # get_lammps_version + # https://github.com/lammps/lammps/commit/b3e7121535863df3db487cd3e6a68c080bf2a6b4#diff-1214db0d1c015a50103f61f8ff7896053dec7ebc1edb930d6ef8bb07282f52abR75 + + function(_get_lammps_version version_header variable) + file(STRINGS ${version_header} line REGEX LAMMPS_VERSION) + set(MONTHS + x + Jan + Feb + Mar + Apr + May + Jun + Jul + Aug + Sep + Oct + Nov + Dec) + string(REGEX + REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" + "\\1" day "${line}") + string(REGEX + REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" + "\\2" month "${line}") + string(REGEX + REPLACE "#define LAMMPS_VERSION \"([0-9]+) ([A-Za-z]+) ([0-9]+)\"" + "\\3" year "${line}") + string(STRIP ${day} day) + string(STRIP ${month} month) + string(STRIP ${year} year) + list(FIND MONTHS "${month}" month) + string(LENGTH ${day} day_length) + string(LENGTH ${month} month_length) + if(day_length EQUAL 1) + set(day "0${day}") + endif() + if(month_length EQUAL 1) + set(month "0${month}") + endif() + set(${variable} + "${year}${month}${day}" + PARENT_SCOPE) + endfunction() + + _get_lammps_version(${LAMMPS_HEADER_DIR}/version.h LAMMPS_VERSION_NUMBER) set(LAMMPS_VERSION_NUMBER ${LAMMPS_VERSION_NUMBER} PARENT_SCOPE) @@ -75,8 +121,7 @@ if(DEFINED LAMMPS_SOURCE_ROOT OR DEFINED LAMMPS_VERSION) target_link_libraries(${libname} PUBLIC ${LIB_DEEPMD_C}) target_precompile_headers(${libname} PUBLIC [["deepmd.hpp"]]) remove_definitions(-D_GLIBCXX_USE_CXX11_ABI=${OP_CXX_ABI}) - if("$ENV{CIBUILDWHEEL}" STREQUAL "1" OR "$ENV{LMP_CXX11_ABI_0}" STREQUAL - "1") + if("$ENV{LMP_CXX11_ABI_0}" STREQUAL "1") add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) endif() else() diff --git a/source/lmp/tests/test_deeptensor.py b/source/lmp/tests/test_deeptensor.py index 6fb7cde746..41d1c10ed6 100644 --- a/source/lmp/tests/test_deeptensor.py +++ b/source/lmp/tests/test_deeptensor.py @@ -142,7 +142,7 @@ def test_compute_deeptensor_atom(lammps) -> None: lammps.variable("tensor atom c_tensor[1]") lammps.dump("1 all custom 1 dump id c_tensor[1]") lammps.run(0) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 assert np.array(lammps.variables["tensor"].value) == pytest.approx( expected_d[idx_map] ) @@ -155,7 +155,7 @@ def test_compute_deeptensor_atom_si(lammps_si) -> None: lammps_si.variable("tensor atom c_tensor[1]") lammps_si.dump("1 all custom 1 dump id c_tensor[1]") lammps_si.run(0) - idx_map = lammps_si.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_si.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 assert np.array(lammps_si.variables["tensor"].value) == pytest.approx( expected_d[idx_map] * constants.dist_metal2si ) diff --git a/source/lmp/tests/test_dplr.py b/source/lmp/tests/test_dplr.py index 21d1f18658..bf8783f233 100644 --- a/source/lmp/tests/test_dplr.py +++ b/source/lmp/tests/test_dplr.py @@ -357,7 +357,7 @@ def test_pair_deepmd_sr(lammps) -> None: lammps.pair_coeff("* *") lammps.run(0) assert lammps.eval("pe") == pytest.approx(expected_e_sr) - id_list = lammps.lmp.numpy.extract_atom("id") + id_list = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] for ii in range(6): assert lammps.atoms[np.where(id_list == (ii + 1))[0][0]].force == pytest.approx( expected_f_sr[ii] @@ -378,7 +378,7 @@ def test_pair_deepmd_sr_virial(lammps) -> None: ) lammps.dump_modify("1 sort id") lammps.run(0) - id_list = lammps.lmp.numpy.extract_atom("id") + id_list = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] idx_list = [np.where(id_list == i)[0][0] for i in range(1, 7)] assert lammps.eval("pe") == pytest.approx(expected_e_sr) for ii in range(6): @@ -445,7 +445,7 @@ def test_pair_deepmd_lr_efield_constant(lammps) -> None: ) lammps.fix_modify("0 energy yes virial yes") lammps.run(0) - id_list = lammps.lmp.numpy.extract_atom("id") + id_list = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] assert lammps.eval("evdwl") == pytest.approx(expected_evdwl_lr_efield_constant) assert lammps.eval("f_0") == pytest.approx(expected_e_efield_constant) assert lammps.eval("pe") == pytest.approx(expected_e_lr_efield_constant) @@ -481,7 +481,7 @@ def test_pair_deepmd_lr_efield_variable(lammps) -> None: ) lammps.fix_modify("0 energy yes virial yes") lammps.run(0) - id_list = lammps.lmp.numpy.extract_atom("id") + id_list = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] assert lammps.eval("evdwl") == pytest.approx(expected_evdwl_lr_efield_variable) assert lammps.eval("f_0") == pytest.approx(expected_e_efield_variable) assert lammps.eval("pe") == pytest.approx(expected_e_lr_efield_variable) diff --git a/source/lmp/tests/test_lammps.py b/source/lmp/tests/test_lammps.py index ad8f8cdaac..c24f032cf6 100644 --- a/source/lmp/tests/test_lammps.py +++ b/source/lmp/tests/test_lammps.py @@ -340,7 +340,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 assert np.array(lammps.variables["eatom"].value) == pytest.approx( expected_ae[idx_map] ) @@ -408,7 +408,7 @@ def test_pair_deepmd_model_devi_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 assert np.array(lammps.variables["eatom"].value) == pytest.approx( expected_ae[idx_map] ) @@ -545,7 +545,7 @@ def test_pair_deepmd_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value @@ -604,7 +604,7 @@ def test_pair_deepmd_model_devi_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_3types.py b/source/lmp/tests/test_lammps_3types.py index f0cbe19ddf..a99a83b758 100644 --- a/source/lmp/tests/test_lammps_3types.py +++ b/source/lmp/tests/test_lammps_3types.py @@ -320,7 +320,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -371,7 +371,7 @@ def test_pair_deepmd_model_devi_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_dpa_jax.py b/source/lmp/tests/test_lammps_dpa_jax.py index 4867b5f84e..65991b9732 100644 --- a/source/lmp/tests/test_lammps_dpa_jax.py +++ b/source/lmp/tests/test_lammps_dpa_jax.py @@ -334,7 +334,7 @@ def test_pair_deepmd_virial(lammps): assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -385,7 +385,7 @@ def test_pair_deepmd_model_devi_virial(lammps): assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -511,7 +511,7 @@ def test_pair_deepmd_virial_real(lammps_real): assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value @@ -570,7 +570,7 @@ def test_pair_deepmd_model_devi_virial_real(lammps_real): assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_dpa_pt.py b/source/lmp/tests/test_lammps_dpa_pt.py index e66b93e09e..2768332c71 100644 --- a/source/lmp/tests/test_lammps_dpa_pt.py +++ b/source/lmp/tests/test_lammps_dpa_pt.py @@ -330,7 +330,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -381,7 +381,7 @@ def test_pair_deepmd_model_devi_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -507,7 +507,7 @@ def test_pair_deepmd_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value @@ -566,7 +566,7 @@ def test_pair_deepmd_model_devi_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_dpa_pt_nopbc.py b/source/lmp/tests/test_lammps_dpa_pt_nopbc.py index 563650c714..1c2e145c84 100644 --- a/source/lmp/tests/test_lammps_dpa_pt_nopbc.py +++ b/source/lmp/tests/test_lammps_dpa_pt_nopbc.py @@ -328,7 +328,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -379,7 +379,7 @@ def test_pair_deepmd_model_devi_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -505,7 +505,7 @@ def test_pair_deepmd_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value @@ -564,7 +564,7 @@ def test_pair_deepmd_model_devi_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_dpa_sel_pt.py b/source/lmp/tests/test_lammps_dpa_sel_pt.py index 9ff2883fc1..e758251f18 100644 --- a/source/lmp/tests/test_lammps_dpa_sel_pt.py +++ b/source/lmp/tests/test_lammps_dpa_sel_pt.py @@ -333,7 +333,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -384,7 +384,7 @@ def test_pair_deepmd_model_devi_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -510,7 +510,7 @@ def test_pair_deepmd_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value @@ -569,7 +569,7 @@ def test_pair_deepmd_model_devi_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_faparam.py b/source/lmp/tests/test_lammps_faparam.py index 4206aa68fb..4f744119b6 100644 --- a/source/lmp/tests/test_lammps_faparam.py +++ b/source/lmp/tests/test_lammps_faparam.py @@ -213,7 +213,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_jax.py b/source/lmp/tests/test_lammps_jax.py index 5d88cfca12..0c488cd1bc 100644 --- a/source/lmp/tests/test_lammps_jax.py +++ b/source/lmp/tests/test_lammps_jax.py @@ -332,7 +332,7 @@ def test_pair_deepmd_virial(lammps): assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -383,7 +383,7 @@ def test_pair_deepmd_model_devi_virial(lammps): assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -509,7 +509,7 @@ def test_pair_deepmd_virial_real(lammps_real): assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value @@ -568,7 +568,7 @@ def test_pair_deepmd_model_devi_virial_real(lammps_real): assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_pd.py b/source/lmp/tests/test_lammps_pd.py index 31ee2e482a..92b00aba29 100644 --- a/source/lmp/tests/test_lammps_pd.py +++ b/source/lmp/tests/test_lammps_pd.py @@ -333,7 +333,7 @@ def test_pair_deepmd_virial(lammps): assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -384,7 +384,7 @@ def test_pair_deepmd_model_devi_virial(lammps): assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1], RTOL, ATOL ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -516,7 +516,7 @@ def test_pair_deepmd_virial_real(lammps_real): RTOL, ATOL, ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value @@ -581,7 +581,7 @@ def test_pair_deepmd_model_devi_virial_real(lammps_real): RTOL, ATOL, ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_pt.py b/source/lmp/tests/test_lammps_pt.py index 9aed014b62..f675b2b671 100644 --- a/source/lmp/tests/test_lammps_pt.py +++ b/source/lmp/tests/test_lammps_pt.py @@ -330,7 +330,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -381,7 +381,7 @@ def test_pair_deepmd_model_devi_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps.variables[f"virial{ii}"].value @@ -507,7 +507,7 @@ def test_pair_deepmd_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value @@ -566,7 +566,7 @@ def test_pair_deepmd_model_devi_virial_real(lammps_real) -> None: assert lammps_real.atoms[ii].force == pytest.approx( expected_f[lammps_real.atoms[ii].id - 1] * constants.force_metal2real ) - idx_map = lammps_real.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps_real.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 for ii in range(9): assert np.array( lammps_real.variables[f"virial{ii}"].value diff --git a/source/lmp/tests/test_lammps_spin.py b/source/lmp/tests/test_lammps_spin.py index 39e12b03fc..9ab7271f5f 100644 --- a/source/lmp/tests/test_lammps_spin.py +++ b/source/lmp/tests/test_lammps_spin.py @@ -172,7 +172,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 assert np.array(lammps.variables["eatom"].value) == pytest.approx( expected_ae[idx_map] ) diff --git a/source/lmp/tests/test_lammps_spin_pt.py b/source/lmp/tests/test_lammps_spin_pt.py index e15a10ee72..9a0771d047 100644 --- a/source/lmp/tests/test_lammps_spin_pt.py +++ b/source/lmp/tests/test_lammps_spin_pt.py @@ -168,7 +168,7 @@ def test_pair_deepmd_virial(lammps) -> None: assert lammps.atoms[ii].force == pytest.approx( expected_f[lammps.atoms[ii].id - 1] ) - idx_map = lammps.lmp.numpy.extract_atom("id") - 1 + idx_map = lammps.lmp.numpy.extract_atom("id")[: coord.shape[0]] - 1 assert np.array(lammps.variables["eatom"].value) == pytest.approx( expected_ae[idx_map] )