<p>Use the Muller-Plathe algorithm described in <a class="reference internal" href="#muller-plathe"><span class="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 <a class="reference internal" href="#muller-plathe"><span class="std std-ref">Muller-Plathe paper</span></a> for details.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="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>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="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 <a class="reference internal" href="Section_howto.html#howto-13"><span class="std std-ref">Section 6.13</span></a> of the manual. NEMD simulations
deform the simmulation box via the <a class="reference internal" href="fix_deform.html"><span class="doc">fix deform</span></a>
command. Thus they cannot be run on a charged system using a <a class="reference internal" href="kspace_style.html"><span class="doc">PPPM solver</span></a> since PPPM does not currently support
non-orthogonal boxes. Using fix viscosity keeps the box orthogonal;
thus it does not suffer from this limitation.</p>
<p><strong>Restart, fix_modify, output, run start/stop, minimize info:</strong></p>
<p>No information about this fix is written to <a class="reference internal" href="restart.html"><span class="doc">binary restart files</span></a>. None of the <a class="reference internal" href="fix_modify.html"><span class="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
<a class="reference internal" href="Section_howto.html#howto-15"><span class="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 <a class="reference internal" href="run.html"><span class="doc">run</span></a> command. This fix is not invoked during <a class="reference internal" href="minimize.html"><span class="doc">energy minimization</span></a>.</p>
</div>
<div class="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 <a class="reference internal" href="Section_start.html#start-3"><span class="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 <a class="reference internal" href="fix_shake.html"><span class="doc">fix shake</span></a> or <a class="reference internal" href="fix_rigid.html"><span class="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 <a class="reference internal" href="#maginn"><span class="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 <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.