<p>Use the Muller-Plathe algorithm described in <aclass="reference internal"href="#muller-plathe"><spanclass="std std-ref">this paper</span></a> to exchange momenta between two particles in
different regions of the simulation box every N steps. This induces a
shear velocity profile in the system. As described below this enables
a viscosity of the fluid to be calculated. This algorithm is
sometimes called a reverse non-equilibrium MD (reverse NEMD) approach
to computing viscosity. This is because the usual NEMD approach is to
impose a shear velocity profile on the system and measure the response
via an off-diagonal component of the stress tensor, which is
proportional to the momentum flux. In the Muller-Plathe method, the
momentum flux is imposed, and the shear velocity profile is the
system’s response.</p>
<p>The simulation box is divided into <em>Nbin</em> layers in the <em>pdim</em>
direction, where the layer 1 is at the low end of that dimension and
the layer <em>Nbin</em> is at the high end. Every N steps, Nswap pairs of
atoms are chosen in the following manner. Only atoms in the fix group
are considered. Nswap atoms in layer 1 with positive velocity
components in the <em>vdim</em> direction closest to the target value <em>V</em> are
selected. Similarly, Nswap atoms in the “middle” layer (see below) with
negative velocity components in the <em>vdim</em> direction closest to the
negative of the target value <em>V</em> are selected. The two sets of Nswap
atoms are paired up and their <em>vdim</em> momenta components are swapped
within each pair. This resets their velocities, typically in opposite
directions. Over time, this induces a shear velocity profile in the
system which can be measured using commands such as the following,
which writes the profile to the file tmp.profile:</p>
<p>Note that by default, Nswap = 1 and vtarget = INF, though this can be
changed by the optional <em>swap</em> and <em>vtarget</em> keywords. When vtarget =
INF, one or more atoms with the most positive and negative velocity
components are selected. Setting these parameters appropriately, in
conjunction with the swap rate N, allows the momentum flux rate to be
adjusted across a wide range of values, and the momenta to be
exchanged in large chunks or more smoothly.</p>
<p>The “middle” layer for momenta swapping is defined as the <em>Nbin</em>/2 + 1
layer. Thus if <em>Nbin</em> = 20, the two swapping layers are 1 and 11.
This should lead to a symmetric velocity profile since the two layers
are separated by the same distance in both directions in a periodic
sense. This is why <em>Nbin</em> is restricted to being an even number.</p>
<p>As described below, the total momentum transferred by these velocity
swaps is computed by the fix and can be output. Dividing this
quantity by time and the cross-sectional area of the simulation box
yields a momentum flux. The ratio of momentum flux to the slope of
the shear velocity profile is proportional to the viscosity of the
fluid, in appropriate units. See the <aclass="reference internal"href="#muller-plathe"><spanclass="std std-ref">Muller-Plathe paper</span></a> for details.</p>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">If your system is periodic in the direction of the momentum
flux, then the flux is going in 2 directions. This means the
effective momentum flux in one direction is reduced by a factor of 2.
You will see this in the equations for viscosity in the Muller-Plathe
paper. LAMMPS is simply tallying momentum which does not account for
whether or not your system is periodic; you must use the value
appropriately to yield a viscosity for your system.</p>
</div>
<divclass="admonition note">
<pclass="first admonition-title">Note</p>
<pclass="last">After equilibration, if the velocity profile you observe is not
linear, then you are likely swapping momentum too frequently and are
not in a regime of linear response. In this case you cannot
accurately infer a viscosity and should try increasing the Nevery
parameter.</p>
</div>
<p>An alternative method for calculating a viscosity is to run a NEMD
simulation, as described in <aclass="reference internal"href="Section_howto.html#howto-13"><spanclass="std std-ref">Section_howto 13</span></a> of the manual. NEMD simulations
deform the simmulation box via the <aclass="reference internal"href="fix_deform.html"><spanclass="doc">fix deform</span></a>
command. Thus they cannot be run on a charged system using a <aclass="reference internal"href="kspace_style.html"><spanclass="doc">PPPM solver</span></a> since PPPM does not currently support
non-orthogonal boxes. Using fix viscosity keeps the box orthogonal;
<p>No information about this fix is written to <aclass="reference internal"href="restart.html"><spanclass="doc">binary restart files</span></a>. None of the <aclass="reference internal"href="fix_modify.html"><spanclass="doc">fix_modify</span></a> options
are relevant to this fix.</p>
<p>This fix computes a global scalar which can be accessed by various
<aclass="reference internal"href="Section_howto.html#howto-15"><spanclass="std std-ref">output commands</span></a>. The scalar is the
cummulative momentum transferred between the bottom and middle of the
simulation box (in the <em>pdim</em> direction) is stored as a scalar
quantity by this fix. This quantity is zeroed when the fix is defined
and accumlates thereafter, once every N steps. The units of the
quantity are momentum = mass*velocity. The scalar value calculated by
this fix is “intensive”.</p>
<p>No parameter of this fix can be used with the <em>start/stop</em> keywords of
the <aclass="reference internal"href="run.html"><spanclass="doc">run</span></a> command. This fix is not invoked during <aclass="reference internal"href="minimize.html"><spanclass="doc">energy minimization</span></a>.</p>
</div>
<divclass="section"id="restrictions">
<h2>Restrictions</h2>
<p>This fix is part of the MISC package. It is only enabled if LAMMPS
was built with that package. See the <aclass="reference internal"href="Section_start.html#start-3"><spanclass="std std-ref">Making LAMMPS</span></a> section for more info.</p>
<p>Swaps conserve both momentum and kinetic energy, even if the masses of
the swapped atoms are not equal. Thus you should not need to
thermostat the system. If you do use a thermostat, you may want to
apply it only to the non-swapped dimensions (other than <em>vdim</em>).</p>
<p>LAMMPS does not check, but you should not use this fix to swap
velocities of atoms that are in constrained molecules, e.g. via <aclass="reference internal"href="fix_shake.html"><spanclass="doc">fix shake</span></a> or <aclass="reference internal"href="fix_rigid.html"><spanclass="doc">fix rigid</span></a>. This is because
application of the constraints will alter the amount of transferred
momentum. You should, however, be able to use flexible molecules.
See the <aclass="reference internal"href="#maginn"><spanclass="std std-ref">Maginn paper</span></a> for an example of using this algorithm
in a computation of alcohol molecule properties.</p>
<p>When running a simulation with large, massive particles or molecules
in a background solvent, you may want to only exchange momenta bewteen
Built with <ahref="http://sphinx-doc.org/">Sphinx</a> using a <ahref="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <ahref="https://readthedocs.org">Read the Docs</a>.