Skip to content

Commit

Permalink
Merge branch 'devel' into 3866
Browse files Browse the repository at this point in the history
  • Loading branch information
Chengqian-Zhang committed Sep 4, 2024
2 parents dde48fd + 46632f9 commit 4d8934f
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ repos:
exclude: ^source/3rdparty
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.2
rev: v0.6.3
hooks:
- id: ruff
args: ["--fix"]
Expand Down Expand Up @@ -146,7 +146,7 @@ repos:
exclude: .pre-commit-config.yaml|source/lmp
# customized pylint rules
- repo: https://github.com/pylint-dev/pylint/
rev: v3.2.6
rev: v3.2.7
hooks:
- id: pylint
entry: env PYTHONPATH=source/checker pylint
Expand Down
16 changes: 13 additions & 3 deletions deepmd/pt/infer/deep_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import numpy as np
import torch

from deepmd.dpmodel.common import PRECISION_DICT as NP_PRECISION_DICT
from deepmd.dpmodel.output_def import (
ModelOutputDef,
OutputVariableCategory,
Expand Down Expand Up @@ -57,6 +58,7 @@
from deepmd.pt.utils.env import (
DEVICE,
GLOBAL_PT_FLOAT_PRECISION,
RESERVED_PRECISON_DICT,
)
from deepmd.pt.utils.utils import (
to_torch_tensor,
Expand Down Expand Up @@ -392,14 +394,22 @@ def _eval_model(
natoms = len(atom_types[0])

coord_input = torch.tensor(
coords.reshape([nframes, natoms, 3]),
coords.reshape([nframes, natoms, 3]).astype(
NP_PRECISION_DICT[RESERVED_PRECISON_DICT[GLOBAL_PT_FLOAT_PRECISION]]
),
dtype=GLOBAL_PT_FLOAT_PRECISION,
device=DEVICE,
)
type_input = torch.tensor(atom_types, dtype=torch.long, device=DEVICE)
type_input = torch.tensor(
atom_types.astype(NP_PRECISION_DICT[RESERVED_PRECISON_DICT[torch.long]]),
dtype=torch.long,
device=DEVICE,
)
if cells is not None:
box_input = torch.tensor(
cells.reshape([nframes, 3, 3]),
cells.reshape([nframes, 3, 3]).astype(
NP_PRECISION_DICT[RESERVED_PRECISON_DICT[GLOBAL_PT_FLOAT_PRECISION]]
),
dtype=GLOBAL_PT_FLOAT_PRECISION,
device=DEVICE,
)
Expand Down
22 changes: 11 additions & 11 deletions doc/install/install-lammps.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_2Aug2023_update3.tar.gz
tar xf stable_2Aug2023_update3.tar.gz
wget https://github.com/lammps/lammps/archive/stable_29Aug2024.tar.gz
tar xf stable_29Aug2024.tar.gz
```

The source code of LAMMPS is stored in the directory `lammps-stable_2Aug2023_update3`.
The source code of LAMMPS is stored in the directory `lammps-stable_29Aug2024`.

Then, you can [build LAMMPS](https://docs.lammps.org/Build.html) with either make or CMake.

Expand All @@ -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_2Aug2023_update3/src/
cd lammps-stable_29Aug2024/src/
cp -r $deepmd_source_dir/source/build/USER-DEEPMD .
make yes-kspace
make yes-extra-fix
Expand Down Expand Up @@ -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_2Aug2023_update3/build/
cd lammps-stable_2Aug2023_update3/build/
mkdir -p lammps-stable_29Aug2024/build/
cd lammps-stable_29Aug2024/build/
```

Patch the LAMMPS `CMakeLists.txt` file:
Expand Down Expand Up @@ -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_2Aug2023_update3.tar.gz
tar xf stable_2Aug2023_update3.tar.gz
wget https://github.com/lammps/lammps/archive/stable_29Aug2024.tar.gz
tar xf stable_29Aug2024.tar.gz
```

The source code of LAMMPS is stored in the directory `lammps-stable_2Aug2023_update3`. 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_29Aug2024`. 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_2Aug2023_update3/build/
cd lammps-stable_2Aug2023_update3/build/
mkdir -p lammps-stable_29Aug2024/build/
cd lammps-stable_29Aug2024/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.
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ docs = [
"sphinxcontrib-moderncmakedomain",
]
lmp = [
"lammps~=2023.8.2.3.0",
"lammps~=2024.8.29.0.0",
]
ipi = [
"ipi",
Expand Down Expand Up @@ -222,7 +222,7 @@ repair-wheel-command = """delocate-wheel --require-archs {delocate_archs} -w {de

[tool.cibuildwheel.macos.environment]
PIP_PREFER_BINARY = "1"
DP_LAMMPS_VERSION = "stable_2Aug2023_update3"
DP_LAMMPS_VERSION = "stable_29Aug2024"
DP_ENABLE_IPI = "1"
DP_ENABLE_PYTORCH = "1"
# for unclear reason, when enabling PyTorch, OpenMP is found accidentally
Expand Down Expand Up @@ -258,7 +258,7 @@ before-build = [
]
[tool.cibuildwheel.linux.environment]
PIP_PREFER_BINARY = "1"
DP_LAMMPS_VERSION = "stable_2Aug2023_update3"
DP_LAMMPS_VERSION = "stable_29Aug2024"
DP_ENABLE_IPI = "1"
DP_ENABLE_PYTORCH = "1"
MPI_HOME = "/usr/lib64/mpich"
Expand Down
2 changes: 1 addition & 1 deletion source/install/build_cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cmake -D ENABLE_TENSORFLOW=ON \
-D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-D USE_TF_PYTHON_LIBS=TRUE \
${CUDA_ARGS} \
-D LAMMPS_VERSION=stable_2Aug2023_update3 \
-D LAMMPS_VERSION=stable_29Aug2024 \
..
cmake --build . -j${NPROC}
cmake --install .
Expand Down
2 changes: 1 addition & 1 deletion source/install/build_from_c.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_2Aug2023_update3 ..
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DDEEPMD_C_ROOT=${DEEPMD_C_ROOT} -DLAMMPS_VERSION=stable_29Aug2024 ..
cmake --build . -j${NPROC}
cmake --install .
cmake --build . --target=lammps
Expand Down
2 changes: 1 addition & 1 deletion source/install/build_lammps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_2Aug2023_update3
LAMMPS_VERSION=stable_29Aug2024
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
Expand Down
2 changes: 1 addition & 1 deletion source/install/test_cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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_2Aug2023_update3 ${CUDA_ARGS} ..
cmake -DINSTALL_TENSORFLOW=TRUE -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DTENSORFLOW_ROOT=${INSTALL_PREFIX} -DBUILD_TESTING:BOOL=TRUE -DLAMMPS_VERSION=stable_29Aug2024 ${CUDA_ARGS} ..
cmake --build . -j${NPROC}
cmake --install .
ctest --output-on-failure
2 changes: 1 addition & 1 deletion source/install/test_cc_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ cmake \
-D USE_TF_PYTHON_LIBS=TRUE \
-D CMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
-D BUILD_TESTING:BOOL=TRUE \
-D LAMMPS_VERSION=stable_2Aug2023_update3 \
-D LAMMPS_VERSION=stable_29Aug2024 \
${CUDA_ARGS} ..
cmake --build . -j${NPROC}
cmake --install .
Expand Down
2 changes: 2 additions & 0 deletions source/lmp/fix_dplr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ FixDPLR::FixDPLR(LAMMPS *lmp, int narg, char **arg)
#endif

scalar_flag = 1;
extscalar = 1;
vector_flag = 1;
extvector = 1;
size_vector = 3;
qe2f = force->qe2f;
xstyle = ystyle = zstyle = NONE;
Expand Down

0 comments on commit 4d8934f

Please sign in to comment.