|
1 | 1 | # Running MD with GROMACS |
2 | 2 |
|
3 | | -:::{note} |
4 | | -See [Environment variables](../env.md) for the runtime environment variables. |
5 | | -::: |
6 | | - |
7 | | -## DP/MM Simulation |
8 | | - |
9 | | -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`. |
10 | | - |
11 | | -### Topology Preparation |
12 | | - |
13 | | -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. |
14 | | - |
15 | | -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`): |
16 | | - |
17 | | -``` |
18 | | -[ atomtypes ] |
19 | | -;name btype mass charge ptype sigma epsilon |
20 | | - c3 c3 0.0 0.0 A 0.339771 0.451035 |
21 | | - hc hc 0.0 0.0 A 0.260018 0.087027 |
22 | | -
|
23 | | -[ moleculetype ] |
24 | | -;name nrexcl |
25 | | - methane 3 |
26 | | -
|
27 | | -[ atoms ] |
28 | | -; nr type resnr residue atom cgnr charge mass |
29 | | - 1 c3 1 MOL C1 1 -0.1068 12.010 |
30 | | - 2 hc 1 MOL H1 2 0.0267 1.008 |
31 | | - 3 hc 1 MOL H2 3 0.0267 1.008 |
32 | | - 4 hc 1 MOL H3 4 0.0267 1.008 |
33 | | - 5 hc 1 MOL H4 5 0.0267 1.008 |
34 | | -
|
35 | | -[ bonds ] |
36 | | -; i j func b0 kb |
37 | | - 1 2 5 |
38 | | - 1 3 5 |
39 | | - 1 4 5 |
40 | | - 1 5 5 |
41 | | -
|
42 | | -[ exclusions ] |
43 | | -; ai aj1 aj2 aj3 aj4 |
44 | | - 1 2 3 4 5 |
45 | | - 2 1 3 4 5 |
46 | | - 3 1 2 4 5 |
47 | | - 4 1 2 3 5 |
48 | | - 5 1 2 3 4 |
49 | | -``` |
50 | | - |
51 | | -For comparison, the original topology file generated by `acpype` will be: |
52 | | - |
53 | | -``` |
54 | | -; methane_GMX.itp created by acpype (v: 2021-02-05T22:15:50CET) on Wed Sep 8 01:21:53 2021 |
55 | | -
|
56 | | -[ atomtypes ] |
57 | | -;name bond_type mass charge ptype sigma epsilon Amb |
58 | | - c3 c3 0.00000 0.00000 A 3.39771e-01 4.51035e-01 ; 1.91 0.1078 |
59 | | - hc hc 0.00000 0.00000 A 2.60018e-01 8.70272e-02 ; 1.46 0.0208 |
60 | | -
|
61 | | -[ moleculetype ] |
62 | | -;name nrexcl |
63 | | - methane 3 |
64 | | -
|
65 | | -[ atoms ] |
66 | | -; nr type resi res atom cgnr charge mass ; qtot bond_type |
67 | | - 1 c3 1 MOL C1 1 -0.106800 12.01000 ; qtot -0.107 |
68 | | - 2 hc 1 MOL H1 2 0.026700 1.00800 ; qtot -0.080 |
69 | | - 3 hc 1 MOL H2 3 0.026700 1.00800 ; qtot -0.053 |
70 | | - 4 hc 1 MOL H3 4 0.026700 1.00800 ; qtot -0.027 |
71 | | - 5 hc 1 MOL H4 5 0.026700 1.00800 ; qtot 0.000 |
| 3 | +::::{important} |
72 | 4 |
|
73 | | -[ bonds ] |
74 | | -; ai aj funct r k |
75 | | - 1 2 1 1.0970e-01 3.1455e+05 ; C1 - H1 |
76 | | - 1 3 1 1.0970e-01 3.1455e+05 ; C1 - H2 |
77 | | - 1 4 1 1.0970e-01 3.1455e+05 ; C1 - H3 |
78 | | - 1 5 1 1.0970e-01 3.1455e+05 ; C1 - H4 |
79 | | -
|
80 | | -[ angles ] |
81 | | -; ai aj ak funct theta cth |
82 | | - 2 1 3 1 1.0758e+02 3.2635e+02 ; H1 - C1 - H2 |
83 | | - 2 1 4 1 1.0758e+02 3.2635e+02 ; H1 - C1 - H3 |
84 | | - 2 1 5 1 1.0758e+02 3.2635e+02 ; H1 - C1 - H4 |
85 | | - 3 1 4 1 1.0758e+02 3.2635e+02 ; H2 - C1 - H3 |
86 | | - 3 1 5 1 1.0758e+02 3.2635e+02 ; H2 - C1 - H4 |
87 | | - 4 1 5 1 1.0758e+02 3.2635e+02 ; H3 - C1 - H4 |
88 | | -``` |
89 | | - |
90 | | -### DeePMD-kit Settings |
91 | | - |
92 | | -Before running simulations, we need to tell GROMACS to use DeepPotential by setting the environment variable `GMX_DEEPMD_INPUT_JSON`: |
93 | | - |
94 | | -```bash |
95 | | -export GMX_DEEPMD_INPUT_JSON=input.json |
96 | | -``` |
97 | | - |
98 | | -Then, in your working directories, we have to write `input.json` file: |
99 | | - |
100 | | -```json |
101 | | -{ |
102 | | - "graph_file": "/path/to/graph.pb", |
103 | | - "type_file": "type.raw", |
104 | | - "index_file": "index.raw", |
105 | | - "lambda": 1.0, |
106 | | - "pbc": false |
107 | | -} |
108 | | -``` |
109 | | - |
110 | | -Here is an explanation for these settings: |
111 | | - |
112 | | -- `graph_file` : The [model file](../backend.md) generated by `dp freeze` command |
113 | | -- `type_file` : File to specify DP atom types (in space-separated format). Here, `type.raw` looks like |
114 | | - |
115 | | -``` |
116 | | -1 0 0 0 0 |
117 | | -``` |
118 | | - |
119 | | -- `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 |
120 | | - |
121 | | -``` |
122 | | -0 1 2 3 4 |
123 | | -``` |
124 | | - |
125 | | -- `lambda`: Optional, default 1.0. Used in alchemical calculations. |
126 | | -- `pbc`: Optional, default true. If true, the GROMACS periodic condition is passed to DeePMD-kit. |
127 | | - |
128 | | -### Run Simulation |
129 | | - |
130 | | -Finally, you can run GROMACS using `gmx mdrun` as usual. |
131 | | - |
132 | | -## All-atom DP Simulation |
| 5 | +:::{deprecated} v3.2.0 |
| 6 | +The official in-tree GROMACS patch was removed from DeePMD-kit in v3.2.0 and is no longer maintained. |
| 7 | +::: |
133 | 8 |
|
134 | | -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`: |
| 9 | +:::: |
135 | 10 |
|
136 | | -``` |
137 | | -[ atomtypes ] |
138 | | -; name at.num mass charge ptype sigma epsilon |
139 | | -HW 1 1.008 0.0000 A 0.00000e+00 0.00000e+00 |
140 | | -OW 8 16.00 0.0000 A 0.00000e+00 0.00000e+00 |
141 | | -``` |
| 11 | +DeePMD-kit may still be used with GROMACS through third-party integrations maintained outside this repository. |
142 | 12 |
|
143 | | -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. |
144 | | - |
| 13 | +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). |
145 | 14 |
|
146 | | -However, we still recommend you run an all-atom DP simulation using LAMMPS since it is more stable and efficient. |
| 15 | +For currently known external implementations, see [Interfaces out of DeePMD-kit](./out-of-deepmd-kit.md#third-party-gromacs-interface-to-deepmd-kit). |
0 commit comments