Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ C:
LAMMPS:
- changed-files:
- any-glob-to-any-file: source/lmp/**/*
Gromacs:
- changed-files:
- any-glob-to-any-file: source/gmx/**/*
i-PI:
- changed-files:
- any-glob-to-any-file: source/ipi/**/*
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DeePMD-kit

DeePMD-kit is a deep learning package for many-body potential energy representation and molecular dynamics. It supports multiple backends (TensorFlow, PyTorch, JAX, Paddle) and integrates with MD packages like LAMMPS, GROMACS, and i-PI.
DeePMD-kit is a deep learning package for many-body potential energy representation and molecular dynamics. It supports multiple backends (TensorFlow, PyTorch, JAX, Paddle) and integrates with MD packages like LAMMPS and i-PI.

**Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here.**

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ The code is organized as follows:
- `source/nodejs`: source code of the Node.js API.
- `source/ipi`: source code of i-PI client.
- `source/lmp`: source code of LAMMPS module.
- `source/gmx`: source code of Gromacs plugin.

# Contributing

Expand Down
2 changes: 1 addition & 1 deletion doc/getting-started/quick_start.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"\n",
"In this tutorial, we will take the gaseous methane molecule as an example to provide a detailed introduction to the training and application of the Deep Potential (DP) model.\n",
"\n",
"DeePMD-kit is a software tool that employs neural networks to fit potential energy models based on first-principles data for molecular dynamics simulations. Without manual intervention, it can end-to-end transform the data provided by users into a deep potential model in a matter of hours. This model can seamlessly integrate with common molecular dynamics simulation software (like LAMMPS, OpenMM, and GROMACS).\n",
"DeePMD-kit is a software tool that employs neural networks to fit potential energy models based on first-principles data for molecular dynamics simulations. Without manual intervention, it can end-to-end transform the data provided by users into a deep potential model in a matter of hours. This model can seamlessly integrate with common molecular dynamics simulation software (like LAMMPS and OpenMM).\n",
"\n",
"DeePMD-kit significantly elevates the limits of molecular dynamics through high-performance computing and machine learning, achieving system scales of up to hundreds of millions of atoms while still maintaining the high accuracy of \"ab initio\" calculations. The simulation time scale is improved by at least 1000 times compared to traditional methods. Its achievements earned the 2020 ACM Gordon Bell Prize, one of the highest honors in the field of high-performance computing, and it has been used by over a thousand research groups in physics, chemistry, materials science, biology, and other fields globally.\n",
"\n",
Expand Down
1 change: 0 additions & 1 deletion doc/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Installation
install-from-c-library
install-lammps
install-ipi
install-gromacs
build-conda
install-nodejs
easy-install-dev
6 changes: 3 additions & 3 deletions doc/install/install-from-c-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
**Supported backends**: TensorFlow {{ tensorflow_icon }}, JAX {{ jax_icon }}
:::

DeePMD-kit provides pre-compiled C library package (`libdeepmd_c.tar.gz`) in each [release](https://github.com/deepmodeling/deepmd-kit/releases). It can be used to build the [LAMMPS plugin](./install-lammps.md) and [GROMACS patch](./install-gromacs.md), as well as many [third-party software packages](../third-party/out-of-deepmd-kit.md), without building TensorFlow and DeePMD-kit on one's own.
DeePMD-kit provides pre-compiled C library package (`libdeepmd_c.tar.gz`) in each [release](https://github.com/deepmodeling/deepmd-kit/releases). It can be used to build the [LAMMPS plugin](./install-lammps.md) and the [i-PI driver](./install-ipi.md), as well as many [third-party software packages](../third-party/out-of-deepmd-kit.md), without building TensorFlow and DeePMD-kit on one's own.
It can be downloaded via the shell command:

```sh
Expand All @@ -14,7 +14,7 @@ tar xzf libdeepmd_c.tar.gz

The library is built in Linux (GLIBC 2.17) with CUDA 12.2 (`libdeepmd_c.tar.gz`). It's noted that this package does not contain CUDA Toolkit and cuDNN, so one needs to download them from the NVIDIA website.

## Use Pre-compiled C Library to build the LAMMPS plugin, i-PI driver, and GROMACS patch
## Use Pre-compiled C Library to build the LAMMPS plugin and i-PI driver

When one [installs DeePMD-kit's C++ interface](./install-from-source.md#install-deepmd-kits-c-interface), one can use the CMake argument {cmake:variable}`DEEPMD_C_ROOT` to the path `libdeepmd_c`.

Expand All @@ -28,7 +28,7 @@ make install
```

Then the i-PI driver `dp_ipi` will be built and installed.
One can also follow the manual [Install LAMMPS](./install-lammps.md) and/or [Install GROMACS](./install-gromacs.md).
One can also follow the manual [Install LAMMPS](./install-lammps.md). For historical GROMACS context, see the [deprecation notice](./install-gromacs.md).

:::{cmake:variable} DEEPMD_C_ROOT

Expand Down
45 changes: 11 additions & 34 deletions doc/install/install-gromacs.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,17 @@
# Install GROMACS with DeePMD-kit
---
orphan: true
---

Before following this section, [DeePMD-kit C++ interface](install-from-source.md) should have be installed.
# GROMACS patch was removed from DeePMD-kit

## Patch source code of GROMACS
::::{danger}

Download the source code of a supported GROMACS version (2020.2) from https://manual.gromacs.org/2020.2/download.html. Run the following command:
:::{deprecated} v3.2.0
The in-tree GROMACS patch was removed from the DeePMD-kit repository in v3.2.0 and is no longer maintained.

```bash
export PATH=$PATH:$deepmd_kit_root/bin
dp_gmx_patch -d $gromacs_root -v $version -p
```
For supported production workflows, use the official [LAMMPS interface](./install-lammps.md).

where `deepmd_kit_root` is the directory where the latest version of DeePMD-kit is installed, and `gromacs_root` refers to the source code directory of GROMACS. And `version` represents the version of GROMACS, where **only 2020.2 is supported now**. If attempting to patch another version of GROMACS you will still need to set `version` to `2020.2` as this is the only supported version, we cannot guarantee that patching other versions of GROMACS will work.
If you need a GROMACS-based workflow, see the third-party overview in [Running MD with GROMACS](../third-party/gromacs.md) and [Interfaces out of DeePMD-kit](../third-party/out-of-deepmd-kit.md).
:::

<!-- ## Install C++ api of deepmd-kit and tensorflow
The C++ interface of `deepmd-kit 2.x` and `tensorflow 2.x` are required. -->

<!-- + Tips: C++ api of deepmd and TensorFlow could be easily installed from the deepmd-kit offline packages. But before using tensorflow, you need to manually change the protobuf package to [version 3.9.2](https://github.com/protocolbuffers/protobuf/releases/tag/v3.9.2) in `$deepmd_env_dir/include/google/protobuf` (the offline package will install a version of 3.14, which will cause incompatibility). Here `deepmd_env_dir` refers to the directory of conda environment created by the deepmd-kit offline packages. -->

## Compile GROMACS with deepmd-kit

The C++ interface of `Deepmd-kit 2.x` and `TensorFlow 2.x` are required. And be aware that only DeePMD-kit with **high precision** is supported now since we cannot ensure single precision is enough for a GROMACS simulation. Here is a sample compile script:

```bash
#!/bin/bash
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
export CMAKE_PREFIX_PATH="/path/to/fftw-3.3.9" # fftw libraries
mkdir build
cd build

cmake3 .. -DCMAKE_CXX_STANDARD=14 \ # not required, but c++14 seems to be more compatible with higher version of tensorflow
-DGMX_MPI=ON \
-DGMX_GPU=CUDA \ # Gromacs on ROCm has not been fully developed yet
-DCUDAToolkit_ROOT=/path/to/cuda \
-DCMAKE_INSTALL_PREFIX=/path/to/gromacs-2020.2-deepmd
make -j
make install
```
::::
147 changes: 8 additions & 139 deletions doc/third-party/gromacs.md
Original file line number Diff line number Diff line change
@@ -1,146 +1,15 @@
# Running MD with GROMACS

:::{note}
See [Environment variables](../env.md) for the runtime environment variables.
:::

## DP/MM Simulation

This part gives a simple tutorial on how to run a DP/MM simulation for methane in water, which means using DP for methane and TIP3P for water. All relevant files can be found in `examples/methane`.

### Topology Preparation

Similar to QM/MM simulation, the internal interactions (including bond, angle, dihedrals, LJ, Columb) of the region described by a neural network potential (NNP) have to be **turned off**. In GROMACS, bonded interactions can be turned off by modifying `[ bonds ]`, `[ angles ]`, `[ dihedrals ]` and `[ pairs ]` sections. And LJ and Columb interactions must be turned off by `[ exclusions ]` section.

For example, if one wants to simulate ethane in water, using DeepPotential for methane and TIP3P for water, the topology of methane should be like the following (as presented in `examples/methane/methane.itp`):

```
[ atomtypes ]
;name btype mass charge ptype sigma epsilon
c3 c3 0.0 0.0 A 0.339771 0.451035
hc hc 0.0 0.0 A 0.260018 0.087027

[ moleculetype ]
;name nrexcl
methane 3

[ atoms ]
; nr type resnr residue atom cgnr charge mass
1 c3 1 MOL C1 1 -0.1068 12.010
2 hc 1 MOL H1 2 0.0267 1.008
3 hc 1 MOL H2 3 0.0267 1.008
4 hc 1 MOL H3 4 0.0267 1.008
5 hc 1 MOL H4 5 0.0267 1.008

[ bonds ]
; i j func b0 kb
1 2 5
1 3 5
1 4 5
1 5 5

[ exclusions ]
; ai aj1 aj2 aj3 aj4
1 2 3 4 5
2 1 3 4 5
3 1 2 4 5
4 1 2 3 5
5 1 2 3 4
```

For comparison, the original topology file generated by `acpype` will be:

```
; methane_GMX.itp created by acpype (v: 2021-02-05T22:15:50CET) on Wed Sep 8 01:21:53 2021

[ atomtypes ]
;name bond_type mass charge ptype sigma epsilon Amb
c3 c3 0.00000 0.00000 A 3.39771e-01 4.51035e-01 ; 1.91 0.1078
hc hc 0.00000 0.00000 A 2.60018e-01 8.70272e-02 ; 1.46 0.0208

[ moleculetype ]
;name nrexcl
methane 3

[ atoms ]
; nr type resi res atom cgnr charge mass ; qtot bond_type
1 c3 1 MOL C1 1 -0.106800 12.01000 ; qtot -0.107
2 hc 1 MOL H1 2 0.026700 1.00800 ; qtot -0.080
3 hc 1 MOL H2 3 0.026700 1.00800 ; qtot -0.053
4 hc 1 MOL H3 4 0.026700 1.00800 ; qtot -0.027
5 hc 1 MOL H4 5 0.026700 1.00800 ; qtot 0.000
::::{important}

[ bonds ]
; ai aj funct r k
1 2 1 1.0970e-01 3.1455e+05 ; C1 - H1
1 3 1 1.0970e-01 3.1455e+05 ; C1 - H2
1 4 1 1.0970e-01 3.1455e+05 ; C1 - H3
1 5 1 1.0970e-01 3.1455e+05 ; C1 - H4

[ angles ]
; ai aj ak funct theta cth
2 1 3 1 1.0758e+02 3.2635e+02 ; H1 - C1 - H2
2 1 4 1 1.0758e+02 3.2635e+02 ; H1 - C1 - H3
2 1 5 1 1.0758e+02 3.2635e+02 ; H1 - C1 - H4
3 1 4 1 1.0758e+02 3.2635e+02 ; H2 - C1 - H3
3 1 5 1 1.0758e+02 3.2635e+02 ; H2 - C1 - H4
4 1 5 1 1.0758e+02 3.2635e+02 ; H3 - C1 - H4
```

### DeePMD-kit Settings

Before running simulations, we need to tell GROMACS to use DeepPotential by setting the environment variable `GMX_DEEPMD_INPUT_JSON`:

```bash
export GMX_DEEPMD_INPUT_JSON=input.json
```

Then, in your working directories, we have to write `input.json` file:

```json
{
"graph_file": "/path/to/graph.pb",
"type_file": "type.raw",
"index_file": "index.raw",
"lambda": 1.0,
"pbc": false
}
```

Here is an explanation for these settings:

- `graph_file` : The [model file](../backend.md) generated by `dp freeze` command
- `type_file` : File to specify DP atom types (in space-separated format). Here, `type.raw` looks like

```
1 0 0 0 0
```

- `index_file` : File containing indices of DP atoms (in space-separated format), which should be consistent with the indices' order in .gro file but **starting from zero**. Here, `index.raw` looks like

```
0 1 2 3 4
```

- `lambda`: Optional, default 1.0. Used in alchemical calculations.
- `pbc`: Optional, default true. If true, the GROMACS periodic condition is passed to DeePMD-kit.

### Run Simulation

Finally, you can run GROMACS using `gmx mdrun` as usual.

## All-atom DP Simulation
:::{deprecated} v3.2.0
The official in-tree GROMACS patch was removed from DeePMD-kit in v3.2.0 and is no longer maintained.
:::

This part gives an example of how to simulate all atoms described by a DeepPotential with Gromacs, taking water as an example. Instead of using `[ exclusions ]` to turn off the non-bonded energies, we can simply do this by setting LJ parameters (i.e. epsilon and sigma) and partial charges to 0, as shown in `examples/water/gmx/water.top`:
::::

```
[ atomtypes ]
; name at.num mass charge ptype sigma epsilon
HW 1 1.008 0.0000 A 0.00000e+00 0.00000e+00
OW 8 16.00 0.0000 A 0.00000e+00 0.00000e+00
```
DeePMD-kit may still be used with GROMACS through third-party integrations maintained outside this repository.

As mentioned in the above section, `input.json` and relevant files (`index.raw`, `type.raw`) should also be created. Then, we can start the simulation under the NVT ensemble and plot the radial distribution function (RDF) by `gmx rdf` command. We can see that the RDF given by Gromacs+DP matches perfectly with LAMMPS+DP, which further provides an evidence on the validity of our simulation.
![rdf](../../examples/water/gmx/rdf.png)
For supported production workflows maintained in-tree, prefer the official [LAMMPS interface](../install/install-lammps.md) together with the [LAMMPS runtime documentation](./lammps-command.md).

However, we still recommend you run an all-atom DP simulation using LAMMPS since it is more stable and efficient.
For currently known external implementations, see [Interfaces out of DeePMD-kit](./out-of-deepmd-kit.md#third-party-gromacs-interface-to-deepmd-kit).
21 changes: 21 additions & 0 deletions doc/third-party/out-of-deepmd-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ It is also the first example to the DeePMD-kit [plugin mechanism](../development

## C/C++ interface used by other packages

### Third-party GROMACS interface to DeePMD-kit

A third-party GROMACS interface to DeePMD-kit is available outside this repository at [HuXioAn/gromacs/tree/deepmd-oneModel](https://github.com/HuXioAn/gromacs/tree/deepmd-oneModel). It is based on the GROMACS Neural Network Potentials (NNPot) infrastructure and is described in [Enabling AI Deep Potentials for Ab Initio-quality Molecular Dynamics Simulations in GROMACS](https://arxiv.org/abs/2602.02234).

According to that implementation and paper, this interface supports

- DeePMD-kit inference through the C++/CUDA backend;
- multiple DeePMD model families, including `se_e2_a`, `DPA`, `DPA2`, and `DPA3`;
- hybrid workflows where DeePMD-kit is applied to selected atom groups inside a GROMACS simulation.

The reported examples use protein-in-water systems, where DeePMD-kit is applied to the protein internal interactions while water and protein-water interactions remain classical.

Users should also be aware of the current scope reported by the third-party project:

- the published benchmarks enable DeePMD only in the production MD stage, not in EM/NVT/NPT;
- the reported implementation uses single-rank inference in the current GROMACS NNPot workflow;
- scalability and domain-decomposed inference are described as future optimization targets;
- some DPA3 benchmark cases run out of GPU memory on the tested hardware.

This interface is maintained outside DeePMD-kit. Please refer to the corresponding third-party repository for installation instructions, supported GROMACS versions, and runtime details.

### OpenMM plugin for DeePMD-kit

An [OpenMM](https://github.com/openmm/openmm) plugin is provided from [JingHuangLab/openmm_deepmd_plugin](https://github.com/JingHuangLab/openmm_deepmd_plugin), written by the [Huang Lab](http://www.compbiophysics.org/) at Westlake University.
Expand Down
2 changes: 1 addition & 1 deletion doc/troubleshooting/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Inadequate versions of gcc/g++

Sometimes you may use a gcc/g++ of version < 4.8. In this way, you can still compile all the parts of TensorFlow and most of the parts of DeePMD-kit, but i-PI and GROMACS plugins will be disabled automatically. Or if you have a gcc/g++ of version > 4.8, say, 7.2.0, you may choose to use it by doing
Sometimes you may use a gcc/g++ of version < 4.8. In this way, you can still compile all the parts of TensorFlow and most of the parts of DeePMD-kit, but the i-PI driver will be disabled automatically. Or if you have a gcc/g++ of version >= 4.8, say, 7.2.0, you may choose to use it by doing

```bash
export CC=/path/to/gcc-7.2.0/bin/gcc
Expand Down
1 change: 0 additions & 1 deletion examples/methane/index.raw

This file was deleted.

7 changes: 0 additions & 7 deletions examples/methane/input.json

This file was deleted.

Loading
Loading