This pair style allows you to use NequIP models in LAMMPS simulations.
Note: MPI is not supported due to the message-passing nature of the network.
- NequIP >= 0.4.0
- Pytorch or LibTorch >= 1.9.0
pair_style nequip
pair_coeff * * deployed.pth <type name 1> <type name 2> ...
where deployed.pth is the filename of your trained model.
The names after the model path indicate, in order, the names of the NequIP model's atom types to use for LAMMPS atom types 1, 2, and so on. The number of names given must be equal to the number of atom types in the lammps configuration (not the NequIP model!).
The element string should be consistent with the names specified in the NequIP training YAML in chemical_symbol_to_type or type_names.
git clone --depth 1 git@github.com:lammps/lammpsor your preferred method.
(--depth 1 prevents the entire history of the LAMMPS repository from being downloaded.)
git clone git@github.com:mir-group/pair_nequipFrom the pair_nequip directory, run:
./patch_lammps.sh /path/to/lammps/First copy the source files of the pair style:
cp /path/to/pair_nequip/*.cpp /path/to/lammps/src/
cp /path/to/pair_nequip/*.h /path/to/lammps/src/Then make the following modifications to lammps/cmake/CMakeLists.txt:
- Change
set(CMAKE_CXX_STANDARD 11)toset(CMAKE_CXX_STANDARD 14) - Append the following lines:
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
target_link_libraries(lammps PUBLIC "${TORCH_LIBRARIES}")If you have PyTorch installed:
cd lammps
mkdir build
cd build
cmake ../cmake -DCMAKE_PREFIX_PATH=`python -c 'import torch;print(torch.utils.cmake_prefix_path)'`If you don't have PyTorch installed, you need to download LibTorch from the PyTorch download page. Unzip the downloaded file, then configure LAMMPS:
cd lammps
mkdir build
cd build
cmake ../cmake -DCMAKE_PREFIX_PATH=/path/to/libtorchCMake will look for MKL and, optionally, CUDA and cuDNN. You may have to explicitly provide the path for your CUDA installation (e.g. -DCUDA_TOOLKIT_ROOT_DIR=/usr/lib/cuda/) and your MKL installation (e.g. -DMKL_INCLUDE_DIR=/usr/include/).
Note that the CUDA that comes with PyTorch when installed with conda (the cudatoolkit package) may not be sufficient (see here, for example) and you may have to install full CUDA seperately.
Pay attention to warnings and error messages.
make -j$(nproc)This gives lammps/build/lmp, which can be run as usual with /path/to/lmp -in in.script. If you specify -DCMAKE_INSTALL_PREFIX=/somewhere/in/$PATH (the default is $HOME/.local), you can do make install and just run lmp -in in.script.