Skip to content

Commit

Permalink
bump lammps to stable_2Aug2023 (deepmodeling#2717)
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored Aug 7, 2023
1 parent ea27f29 commit 30c78c0
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 49 deletions.
18 changes: 9 additions & 9 deletions doc/install/install-lammps.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ make lammps
DeePMD-kit will generate a module called `USER-DEEPMD` in the `build` directory, which supports either double or single float precision interface. Now download the LAMMPS code, and uncompress it.
```bash
cd /some/workspace
wget https://github.com/lammps/lammps/archive/stable_23Jun2022_update4.tar.gz
tar xf stable_23Jun2022_update4.tar.gz
wget https://github.com/lammps/lammps/archive/stable_2Aug2023.tar.gz
tar xf stable_2Aug2023.tar.gz
```
The source code of LAMMPS is stored in the directory `lammps-stable_23Jun2022_update4`. Now go into the LAMMPS code and copy the DeePMD-kit module like this
The source code of LAMMPS is stored in the directory `lammps-stable_2Aug2023`. Now go into the LAMMPS code and copy the DeePMD-kit module like this
```bash
cd lammps-stable_23Jun2022_update4/src/
cd lammps-stable_2Aug2023/src/
cp -r $deepmd_source_dir/source/build/USER-DEEPMD .
make yes-kspace
make yes-extra-fix
Expand All @@ -46,15 +46,15 @@ Starting from `8Apr2021`, LAMMPS also provides a plugin mode, allowing one to bu
Now download the LAMMPS code (`8Apr2021` or later), and uncompress it:
```bash
cd /some/workspace
wget https://github.com/lammps/lammps/archive/stable_23Jun2022_update4.tar.gz
tar xf stable_23Jun2022_update4.tar.gz
wget https://github.com/lammps/lammps/archive/stable_2Aug2023.tar.gz
tar xf stable_2Aug2023.tar.gz
```

The source code of LAMMPS is stored in the directory `lammps-stable_23Jun2022_update4`. 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_2Aug2023`. 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_23Jun2022_update4/build/
cd lammps-stable_23Jun2022_update4/build/
mkdir -p lammps-stable_2Aug2023/build/
cd lammps-stable_2Aug2023/build/
```
Now build LAMMPS. Note that `PLUGIN` and `KSPACE` packages must be enabled, and `BUILD_SHARED_LIBS` must be set to `yes`. You can install any other package you want.
```bash
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ manylinux-x86_64-image = "quay.io/pypa/manylinux_2_28_x86_64:2022-11-19-1b19e81"
manylinux-aarch64-image = "quay.io/pypa/manylinux_2_28_aarch64:2022-11-19-1b19e81"

[tool.cibuildwheel.macos]
environment = { PIP_PREFER_BINARY="1", DP_LAMMPS_VERSION="stable_23Jun2022_update4", DP_ENABLE_IPI="1" }
environment = { PIP_PREFER_BINARY="1", DP_LAMMPS_VERSION="stable_2Aug2023", DP_ENABLE_IPI="1" }
before-all = [
"""if [[ "$CIBW_BUILD" != *macosx_arm64* ]]; then brew install mpich; fi""",
]
Expand All @@ -88,7 +88,7 @@ repair-wheel-command = """if [[ "$CIBW_BUILD" == *macosx_arm64* ]]; then rm -rf
[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 -w {dest_dir} {wheel}"
environment-pass = ["CIBW_BUILD", "DP_VARIANT"]
environment = { PIP_PREFER_BINARY="1", DP_VARIANT="cuda", DP_LAMMPS_VERSION="stable_23Jun2022_update4", DP_ENABLE_IPI="1", MPI_HOME="/usr/lib64/mpich", PATH="/usr/lib64/mpich/bin:$PATH" }
environment = { PIP_PREFER_BINARY="1", DP_VARIANT="cuda", DP_LAMMPS_VERSION="stable_2Aug2023", DP_ENABLE_IPI="1", MPI_HOME="/usr/lib64/mpich", PATH="/usr/lib64/mpich/bin:$PATH" }
before-all = [
"""{ if [ "$(uname -m)" = "x86_64" ] ; then curl https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run -O && bash cuda_11.8.0_520.61.05_linux.run --silent --toolkit; fi }""",
"yum install -y mpich-devel",
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ def get_tag(self):
"sphinxcontrib-bibtex",
],
"lmp": [
"lammps~=2022.6.23.4.0; platform_system=='Linux'",
"lammps~=2022.6.23.4.0; platform_system!='Linux'",
"lammps~=2023.8.2.0.0; platform_system=='Linux'",
"lammps~=2023.8.2.0.0; platform_system!='Linux'",
*find_libpython_requires,
],
"ipi": [
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 @@ -20,7 +20,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} -DUSE_TF_PYTHON_LIBS=TRUE ${CUDA_ARGS} -DLAMMPS_VERSION=stable_23Jun2022_update4 ..
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DUSE_TF_PYTHON_LIBS=TRUE ${CUDA_ARGS} -DLAMMPS_VERSION=stable_2Aug2023 ..
make -j${NPROC}
make 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_23Jun2022_update4 ..
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DDEEPMD_C_ROOT=${DEEPMD_C_ROOT} -DLAMMPS_VERSION=stable_2Aug2023 ..
make -j${NPROC}
make install
make 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_23Jun2022_update4
LAMMPS_VERSION=stable_2Aug2023
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 @@ -11,7 +11,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_23Jun2022_update4 ..
cmake -DINSTALL_TENSORFLOW=TRUE -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DTENSORFLOW_ROOT=${INSTALL_PREFIX} -DBUILD_TESTING:BOOL=TRUE -DLAMMPS_VERSION=stable_2Aug2023 ..
make -j${NPROC}
make install

Expand Down
2 changes: 1 addition & 1 deletion source/install/test_cc_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,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=FALSE -DUSE_TF_PYTHON_LIBS=TRUE -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DBUILD_TESTING:BOOL=TRUE -DLAMMPS_VERSION=stable_23Jun2022_update4 ..
cmake -DINSTALL_TENSORFLOW=FALSE -DUSE_TF_PYTHON_LIBS=TRUE -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} -DBUILD_TESTING:BOOL=TRUE -DLAMMPS_VERSION=stable_2Aug2023 ..
make -j${NPROC}
make install

Expand Down
9 changes: 7 additions & 2 deletions source/lmp/tests/test_deeptensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ def _lammps(data_file) -> PyLammps:

@pytest.fixture
def lammps():
yield _lammps(data_file=data_file)
lmp = _lammps(data_file=data_file)
yield lmp
lmp.close()


# @pytest.fixture
Expand All @@ -114,4 +116,7 @@ def test_compute_deeptensor_atom(lammps):
lammps.variable("tensor atom c_tensor[1]")
lammps.dump("1 all custom 1 dump id c_tensor[1]")
lammps.run(0)
assert np.array(lammps.variables["tensor"].value) == pytest.approx(expected_d)
idx_map = lammps.lmp.numpy.extract_atom("id") - 1
assert np.array(lammps.variables["tensor"].value) == pytest.approx(
expected_d[idx_map]
)
26 changes: 19 additions & 7 deletions source/lmp/tests/test_dplr.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,9 @@ def _lammps(data_file) -> PyLammps:

@pytest.fixture
def lammps():
yield _lammps(data_file=data_file)
lmp = _lammps(data_file=data_file)
yield lmp
lmp.close()


def test_pair_deepmd_sr(lammps):
Expand Down Expand Up @@ -350,12 +352,18 @@ def test_pair_deepmd_lr(lammps):
lammps.fix(f"0 all dplr model {pb_file.resolve()} type_associate 1 3 bond_type 1")
lammps.fix_modify("0 virial yes")
lammps.run(0)
for ii in range(2):
assert lammps.atoms[6 + ii].position == pytest.approx(expected_WC[ii])
for ii in range(8):
if lammps.atoms[ii].id > 6:
assert lammps.atoms[ii].position == pytest.approx(
expected_WC[lammps.atoms[ii].id - 7]
)
assert lammps.eval("elong") == pytest.approx(expected_e_kspace)
assert lammps.eval("pe") == pytest.approx(expected_e_lr)
for ii in range(6):
assert lammps.atoms[ii].force == pytest.approx(expected_f_lr[ii])
for ii in range(8):
if lammps.atoms[ii].id <= 6:
assert lammps.atoms[ii].force == pytest.approx(
expected_f_lr[lammps.atoms[ii].id - 1]
)
lammps.run(1)


Expand Down Expand Up @@ -443,8 +451,12 @@ def test_min_dplr(lammps):
lammps.min_style("cg")
lammps.minimize("0 1.0e-6 2 2")
for ii in range(8):
assert lammps.atoms[ii].position == pytest.approx(expected_x_min_step1[ii])
assert lammps.atoms[ii].position == pytest.approx(
expected_x_min_step1[lammps.atoms[ii].id - 1]
)
assert lammps.eval("pe") == pytest.approx(expected_e_min_step1)
assert lammps.eval("elong") == pytest.approx(expected_e_kspace_min_step1)
for ii in range(8):
assert lammps.atoms[ii].force == pytest.approx(expected_f_min_step1[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f_min_step1[lammps.atoms[ii].id - 1]
)
42 changes: 31 additions & 11 deletions source/lmp/tests/test_lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,16 @@ def _lammps(data_file) -> PyLammps:

@pytest.fixture
def lammps():
yield _lammps(data_file=data_file)
lmp = _lammps(data_file=data_file)
yield lmp
lmp.close()


@pytest.fixture
def lammps_type_map():
yield _lammps(data_file=data_type_map_file)
lmp = _lammps(data_file=data_type_map_file)
yield lmp
lmp.close()


def test_pair_deepmd(lammps):
Expand All @@ -275,7 +279,9 @@ def test_pair_deepmd(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(6):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
lammps.run(1)


Expand All @@ -292,11 +298,14 @@ def test_pair_deepmd_virial(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(6):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
idx_map = lammps.lmp.numpy.extract_atom("id") - 1
for ii in range(9):
assert np.array(
lammps.variables[f"virial{ii}"].value
) / nktv2p == pytest.approx(expected_v[:, ii])
) / nktv2p == pytest.approx(expected_v[idx_map, ii])


def test_pair_deepmd_model_devi(lammps):
Expand All @@ -309,7 +318,9 @@ def test_pair_deepmd_model_devi(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(6):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
# load model devi
md = np.loadtxt(md_file.resolve())
expected_md_f = np.linalg.norm(np.std([expected_f, expected_f2], axis=0), axis=1)
Expand Down Expand Up @@ -342,11 +353,14 @@ def test_pair_deepmd_model_devi_virial(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(6):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
idx_map = lammps.lmp.numpy.extract_atom("id") - 1
for ii in range(9):
assert np.array(
lammps.variables[f"virial{ii}"].value
) / nktv2p == pytest.approx(expected_v[:, ii])
) / nktv2p == pytest.approx(expected_v[idx_map, ii])
# load model devi
md = np.loadtxt(md_file.resolve())
expected_md_f = np.linalg.norm(np.std([expected_f, expected_f2], axis=0), axis=1)
Expand All @@ -373,7 +387,9 @@ def test_pair_deepmd_model_devi_atomic_relative(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(6):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
# load model devi
md = np.loadtxt(md_file.resolve())
norm = np.linalg.norm(np.mean([expected_f, expected_f2], axis=0), axis=1)
Expand Down Expand Up @@ -402,7 +418,9 @@ def test_pair_deepmd_model_devi_atomic_relative_v(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(6):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
md = np.loadtxt(md_file.resolve())
expected_md_f = np.linalg.norm(np.std([expected_f, expected_f2], axis=0), axis=1)
assert md[7:] == pytest.approx(expected_md_f)
Expand Down Expand Up @@ -430,5 +448,7 @@ def test_pair_deepmd_type_map(lammps_type_map):
lammps_type_map.run(0)
assert lammps_type_map.eval("pe") == pytest.approx(expected_e)
for ii in range(6):
assert lammps_type_map.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps_type_map.atoms[ii].force == pytest.approx(
expected_f[lammps_type_map.atoms[ii].id - 1]
)
lammps_type_map.run(1)
42 changes: 31 additions & 11 deletions source/lmp/tests/test_lammps_3types.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,16 @@ def _lammps(data_file) -> PyLammps:

@pytest.fixture
def lammps():
yield _lammps(data_file=data_file)
lmp = _lammps(data_file=data_file)
yield lmp
lmp.close()


@pytest.fixture
def lammps_type_map():
yield _lammps(data_file=data_type_map_file)
lmp = _lammps(data_file=data_type_map_file)
yield lmp
lmp.close()


def test_pair_deepmd(lammps):
Expand All @@ -302,7 +306,9 @@ def test_pair_deepmd(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(7):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
lammps.run(1)


Expand All @@ -319,11 +325,14 @@ def test_pair_deepmd_virial(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(7):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
idx_map = lammps.lmp.numpy.extract_atom("id") - 1
for ii in range(9):
assert np.array(
lammps.variables[f"virial{ii}"].value
) / nktv2p == pytest.approx(expected_v[:, ii])
) / nktv2p == pytest.approx(expected_v[idx_map, ii])


def test_pair_deepmd_model_devi(lammps):
Expand All @@ -336,7 +345,9 @@ def test_pair_deepmd_model_devi(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(7):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
# load model devi
md = np.loadtxt(md_file.resolve())
expected_md_f = np.linalg.norm(np.std([expected_f, expected_f2], axis=0), axis=1)
Expand Down Expand Up @@ -369,11 +380,14 @@ def test_pair_deepmd_model_devi_virial(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(7):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
idx_map = lammps.lmp.numpy.extract_atom("id") - 1
for ii in range(9):
assert np.array(
lammps.variables[f"virial{ii}"].value
) / nktv2p == pytest.approx(expected_v[:, ii])
) / nktv2p == pytest.approx(expected_v[idx_map, ii])
# load model devi
md = np.loadtxt(md_file.resolve())
expected_md_f = np.linalg.norm(np.std([expected_f, expected_f2], axis=0), axis=1)
Expand All @@ -400,7 +414,9 @@ def test_pair_deepmd_model_devi_atomic_relative(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(7):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
# load model devi
md = np.loadtxt(md_file.resolve())
norm = np.linalg.norm(np.mean([expected_f, expected_f2], axis=0), axis=1)
Expand Down Expand Up @@ -429,7 +445,9 @@ def test_pair_deepmd_model_devi_atomic_relative_v(lammps):
lammps.run(0)
assert lammps.eval("pe") == pytest.approx(expected_e)
for ii in range(7):
assert lammps.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps.atoms[ii].force == pytest.approx(
expected_f[lammps.atoms[ii].id - 1]
)
md = np.loadtxt(md_file.resolve())
expected_md_f = np.linalg.norm(np.std([expected_f, expected_f2], axis=0), axis=1)
assert md[7:] == pytest.approx(expected_md_f)
Expand Down Expand Up @@ -457,5 +475,7 @@ def test_pair_deepmd_type_map(lammps_type_map):
lammps_type_map.run(0)
assert lammps_type_map.eval("pe") == pytest.approx(expected_e)
for ii in range(7):
assert lammps_type_map.atoms[ii].force == pytest.approx(expected_f[ii])
assert lammps_type_map.atoms[ii].force == pytest.approx(
expected_f[lammps_type_map.atoms[ii].id - 1]
)
lammps_type_map.run(1)

0 comments on commit 30c78c0

Please sign in to comment.