First general additions to the documentation
[gromacs.git] / docs / user-guide / mdrun-features.rst
blobf18afcdba144d7c615b53cb73ba979f63c7080e8
1 Useful mdrun features
2 =======================
3 This section discusses features in :ref:`gmx mdrun` that don't fit well
4 elsewhere.
6 .. _single-point energy:
8 Re-running a simulation
9 -----------------------
10 The rerun feature allows you to take any trajectory file ``traj.trr``
11 and compute quantities based upon the coordinates in that file using
12 the model physics supplied in the ``topol.tpr`` file. It can be used
13 with command lines like ``mdrun -s topol -rerun traj.trr``. That :ref:`tpr`
14 could be different from the one that generated the trajectory. This
15 can be used to compute the energy or forces for exactly the
16 coordinates supplied as input, or to extract quantities based on
17 subsets of the molecular system (see :ref:`gmx convert-tpr` and
18 :ref:`gmx trjconv`). It is easier to do a correct "single-point" energy
19 evaluation with this feature than a 0-step simulation.
21 Neighbor searching is normally performed for every frame in the
22 trajectory, since :ref:`gmx mdrun` can no longer assume anything about how the
23 structures were generated. If :mdp:`nstlist` is zero, then only one
24 neighbor list will be constructed. Naturally, no update or constraint
25 algorithms are ever used.
27 Running a simulation in reproducible mode
28 -----------------------------------------
29 It is generally difficult to run an efficient parallel MD simulation
30 that is based primarily on floating-point arithmetic and is fully
31 reproducible. By default, :ref:`gmx mdrun` will observe how things are going
32 and vary how the simulation is conducted in order to optimize
33 throughput. However, there is a "reproducible mode" available with
34 ``mdrun -reprod`` that will systematically eliminate all sources of
35 variation within that run; repeated invocations on the same input and
36 hardware will be binary identical. However, running in this mode on
37 different hardware, or with a different compiler, etc. will not be
38 reproducible. This should normally only be used when investigating
39 possible problems.
41 Running multi-simulations
42 -------------------------
43 There are numerous situations where running a related set of
44 simulations within the same invocation of mdrun are necessary or
45 useful. Running a replica-exchange simulation requires it, as do
46 simulations using ensemble-based distance or orientation restraints.
47 Running a related series of lambda points for a free-energy
48 computation is also convenient to do this way.
50 This feature requires
51 :ref:`configuring |Gromacs| with an external MPI library <mpi-support>`
52 so that the set of
53 simulations can communicate. The ``n`` simulations within the set can
54 use internal MPI parallelism also, so that ``mpirun -np x mdrun_mpi``
55 for ``x`` a multiple of ``n`` will use ``x/n`` ranks per simulation.
57 There are two ways of organizing files when running such
58 simulations. All of the normal mechanisms work in either case,
59 including ``-deffnm``.
61 ``-multidir``
62    You must create a set of ``n`` directories for the ``n`` simulations,
63    place all the relevant input files in those directories (e.g. named
64    ``topol.tpr``), and run with
65    ``mpirun -np x gmx_mpi mdrun -s topol -multidir <names-of-directories>``.
66    If the order of the simulations
67    within the multi-simulation is significant, then you are responsible
68    for ordering their names when you provide them to ``-multidir``. Be
69    careful with shells that do filename globbing dictionary-style, e.g.
70    ``dir1 dir10 dir11 ... dir2 ...``. This option is generally the
71    most convenient to use. ``gmx mdrun -table`` for the group cutoff-scheme
72    works only in this mode.
74 ``-multi``
75    You must organize that the filenames for each simulation in a set of
76    ``n`` simulations have an integer ``0`` through ``n-1`` appended to
77    the filename (e.g. ``topol2.tpr``), and run with
78    ``mpirun -np x gmx mdrun -multi n -s input``. The order of simulations
79    within the set is determined by the integer appended.
81 Examples running multi-simulations
82 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
86     mpirun -np 32 gmx_mpi mdrun -multi
88 Starts a multi-simulation on 32 ranks with as many simulations ``n`` as
89 there are files named ``topol*.tpr`` for integers ``0`` to ``n-1``. Other
90 input and output files are suffixed similarly.
94     mpirun -np 32 gmx_mpi mdrun -multidir a b c d
96 Starts a multi-simulation on 32 ranks with 4 simulations. The input
97 and output files are found in directories ``a``, ``b``, ``c``, and ``d``.
101     mpirun -np 32 gmx_mpi mdrun -multidir a b c d -gpu_id 0000000011111111
103 Starts the same multi-simulation as before. On a machine with two
104 physical nodes and two GPUs per node, there will be 16 MPI ranks per
105 node, and 8 MPI ranks per simulation. The 16 MPI ranks doing PP work
106 on a node are mapped to the GPUs with IDs 0 and 1, even though they
107 come from more than one simulation. They are mapped in the order
108 indicated, so that the PP ranks from each simulation use a single
109 GPU. However, the order ``0101010101010101`` could run faster.
111 Running replica-exchange simulations
112 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
114 When running a multi-simulation, using ``gmx mdrun -replex n`` means that a
115 replica exchange is attempted every given number of steps. The number
116 of replicas is set with the ``-multi`` or ``-multidir`` option, described
117 above.  All run input files should use a different value for the
118 coupling parameter (e.g. temperature), which ascends over the set of
119 input files. The random seed for replica exchange is set with
120 ``-reseed``. After every exchange, the velocities are scaled and
121 neighbor searching is performed. See the Reference Manual for more
122 details on how replica exchange functions in |Gromacs|.
124 Controlling the length of the simulation
125 ----------------------------------------
127 Normally, the length of an MD simulation is best managed through the
128 [.mdp] option [nsteps](#nsteps), however there are situations where
129 more control is useful. `gmx mdrun -nsteps 100` overrides the [.mdp] file
130 and executes 100 steps. `gmx mdrun -maxh 2.5` will terminate the
131 simulation shortly before 2.5 hours elapse, which can be useful when
132 running under cluster queues (as long as the queuing system does not
133 ever suspend the simulation).
135 Running a membrane protein embedding simulation
136 -----------------------------------------------
138 This is a module to help embed a membrane protein into an equilibrated
139 lipid bilayer at a position and orientation specified by the user. 
141 This method was initially described as a ProtSqueeze technique 
142 (`Yesylevskyy S.O., J Chem Inf Model 47(5) (2007) 1986-94`_) and 
143 later implemented in |Gromacs| as g_membed tool (`Wolf et al, J Comp Chem 31 (2010) 2169-2174`_). 
144 Currently the functionality of g_membed is available in mdrun if 
145 ``-membed`` option is specified (see below).
147 .. _Yesylevskyy S.O., J Chem Inf Model 47(5) (2007) 1986-94: https://dx.doi.org/10.1021/ci600553y
148 .. _Wolf et al, J Comp Chem 31 (2010) 2169-2174: http://onlinelibrary.wiley.com/doi/10.1002/jcc.21507/full
150 The main advantage is that it is possible to use very complex lipid bilayers
151 with a number of different components that have been relaxed for a
152 long time in a previous simulation. In theory that could be accomplished
153 with a procedure similar to :ref:`gmx solvate`, but since lipids are much larger
154 than water molecules it will lead to a large vacuum layer between the
155 protein and membrane if we remove all molecules where any atom is
156 overlapping. Instead, this module works by first artificially shrinking
157 the protein in the xy-plane, then it removes lipids that overlap with
158 a much smaller core, after which we gradually push the protein atoms
159 back to their initial positions, while using normal dynamics for the
160 rest of the system so lipids adapt to the protein.
162 To use membrane embedding, start by building a lipid bilayer that is
163 just-so-slightly larger in the xy-plane than what you expect to need
164 in the end, and make sure you have enough water outside the membrane
165 to accommodate globular domains. Place the protein in the same coordinate
166 file (and topology) as your lipid bilayer, and make sure it is in the
167 orientation and position you want right in the middle of the bilayer.
169 The first settings have to be entered in the mdp file that controls
170 your simulation. You need an energy group corresponding to your
171 protein, this group should be frozen (all dimensions), and we should
172 exclude all interactions inside the protein to avoid problems when it
173 is distorted. For instance:
177     integrator     = md
178     energygrps     = Protein
179     freezegrps     = Protein
180     freezedim      = Y Y Y
181     energygrp_excl = Protein Protein
183 You will also need a number of settings for the actual membrane
184 embedding process. These are entered as similar name and value pairs,
185 but in the separate text data file ``embed.dat`` that you provide as
186 the argument to the ``-membed`` option (we refer to the below
187 when explaining the process). The embedding works in for stages:
189 1. The protein is resized around its center of mass by a factor
190    ``xy`` in the xy-plane (the bilayer plane), and a factor ``z``
191    along the z-axis (normal to the bilayer). If the height of the
192    protein is the same or smaller than the thickness of the
193    membrane, a z-fraction larger than 1.0 can prevent the protein
194    from being enveloped by the lipids.
196 2. All lipid and solvent molecules overlapping with the resized
197    protein are removed. All interactions inside the protein are
198    turned off to prevent numerical issues for small values of the
199    scaling fractions.
201 3. A single md step is performed, where atoms in the rest of the
202    system are moved.
204 4. The resize factors are adjusted by the small amounts
205    (1-xy)/nxy and (1-z)/nz, where ``nxy`` and ``nz`` are the
206    number of iterations to use.  The resize factor for the xy-plane
207    is adjusted first. The resize factor for the z-direction is not
208    changed until the xy factor is 1.0 (after ``nxy`` iterations).
210 5. Steps 3 and 4 are repeated until the protein has again reached
211    its original size, i.e. after nxy+nz iterations. After the
212    embedding you might still want to perform a short relaxation.
214 Parameters that can be specified in ``embed.dat``, with default
215 values that will be used if the setting is omitted:
217 - ``xyinit`` (0.5) Resize factor for the protein in the xy
218   dimension before starting embedding.
220 - ``xyend`` (1.0) Final resize factor in the xy dimension.
222 - ``zinit`` (1.0) Resize factor for the protein in the z
223    dimension before starting embedding.
225 - ``zend`` (1.0) Final resize faction in the z dimension.
227 - ``nxy`` (1000) Number of iteration for the xy dimension.
229 - ``nz`` (0) Number of iterations for the z dimension.
231 - ``rad`` (0.22) Probe radius to check for overlap between
232   the group to embed and the membrane.
234 - ``pieces`` (1) Perform piecewise resize. Select parts of the group
235   to insert and resize these with respect to their own geometrical center.
237 - ``asymmetry`` (no) Allow asymmetric insertion, i.e. the number of
238   lipids removed from the upper and lower leaflet will not be checked.
240 - ``ndiff`` (0) Number of lipids that will additionally be removed
241   from the lower (negative number) or upper (positive number)
242   membrane leaflet.
244 - ``maxwarn`` (0) Largest number of membed warnings allowed.