-
Notifications
You must be signed in to change notification settings - Fork 648
breaking(gmx): remove in-tree GROMACS patch integration #5377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
iProzd
merged 4 commits into
deepmodeling:master
from
njzjz-bothub:fix/issue-5360-remove-gmx
Apr 8, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
7769e98
build(cmake): remove in-tree GROMACS patch integration
njzjz-bot cd17e99
docs(gromacs): clarify third-party support status
njzjz-bot 42cbfe3
docs(readme): keep interface list wording neutral
njzjz-bot 584f44b
docs(gromacs): tighten manual wording and review fixes
njzjz-bot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 has been deprecated | ||
|
|
||
| ## 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} next release | ||
| The in-tree GROMACS patch that used to ship with DeePMD-kit is no longer maintained and has been removed from the repository. | ||
|
njzjz-bot marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```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 still need a GROMACS-based workflow, consider the third-party implementation mentioned in [issue #5360](https://github.com/deepmodeling/deepmd-kit/issues/5360), which was reported at <https://arxiv.org/abs/2602.02234>. | ||
| ::: | ||
|
|
||
| <!-- ## 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 | ||
| ``` | ||
| :::: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,146 +1,17 @@ | ||
| # Running MD with GROMACS | ||
| --- | ||
| orphan: true | ||
| --- | ||
|
|
||
| :::{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 | ||
| # GROMACS support has been deprecated | ||
|
|
||
| [ 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 | ||
| ::::{danger} | ||
|
|
||
| [ 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 | ||
| ``` | ||
| :::{deprecated} next release | ||
| The official GROMACS patch that used to live in the DeePMD-kit repository is no longer maintained and has been removed. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### DeePMD-kit Settings | ||
| For supported production use, prefer the official [LAMMPS interface](../install/install-lammps.md) together with the [LAMMPS runtime documentation](./lammps-command.md). | ||
|
|
||
| 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 | ||
|
|
||
| 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 | ||
| ``` | ||
|
|
||
| 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. | ||
|  | ||
| If you still need a GROMACS-based workflow, consider the third-party implementation mentioned in [issue #5360](https://github.com/deepmodeling/deepmd-kit/issues/5360), which was reported at <https://arxiv.org/abs/2602.02234>. | ||
| ::: | ||
|
|
||
| However, we still recommend you run an all-atom DP simulation using LAMMPS since it is more stable and efficient. | ||
| :::: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.