<span id="index-0"></span><h1>fix command<a class="headerlink" href="#fix-command" title="Permalink to this headline">¶</a></h1>
<div class="section" id="syntax">
<h2>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><div class="highlight"><pre>fix ID group-ID style args
</pre></div>
</div>
<ul class="simple">
<li>ID = user-assigned name for the fix</li>
<li>group-ID = ID of the group of atoms to apply the fix to</li>
<li>style = one of a long list of possible style names (see below)</li>
<li>args = arguments used by a particular style</li>
</ul>
</div>
<div class="section" id="examples">
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
<div class="highlight-python"><div class="highlight"><pre>fix 1 all nve
fix 3 all nvt temp 300.0 300.0 0.01
fix mine top setforce 0.0 NULL 0.0
</pre></div>
</div>
</div>
<div class="section" id="description">
<h2>Description<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2>
<p>Set a fix that will be applied to a group of atoms. In LAMMPS, a
“fix” is any operation that is applied to the system during
timestepping or minimization. Examples include updating of atom
positions and velocities due to time integration, controlling
temperature, applying constraint forces to atoms, enforcing boundary
conditions, computing diagnostics, etc. There are dozens of fixes
defined in LAMMPS and new ones can be added; see <a class="reference internal" href="Section_modify.html"><em>this section</em></a> for a discussion.</p>
<p>Fixes perform their operations at different stages of the timestep.
If 2 or more fixes operate at the same stage of the timestep, they are
invoked in the order they were specified in the input script.</p>
<p>The ID of a fix can only contain alphanumeric characters and
underscores.</p>
<p>Fixes can be deleted with the <a class="reference internal" href="unfix.html"><em>unfix</em></a> command.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">The <a class="reference internal" href="unfix.html"><em>unfix</em></a> command is the only way to turn
off a fix; simply specifying a new fix with a similar style will not
turn off the first one. This is especially important to realize for
integration fixes. For example, using a <a class="reference internal" href="fix_nve.html"><em>fix nve</em></a>
command for a second run after using a <a class="reference internal" href="fix_nh.html"><em>fix nvt</em></a> command
for the first run, will not cancel out the NVT time integration
invoked by the “fix nvt” command. Thus two time integrators would be
in place!</p>
</div>
<p>If you specify a new fix with the same ID and style as an existing
fix, the old fix is deleted and the new one is created (presumably
with new settings). This is the same as if an “unfix” command were
first performed on the old fix, except that the new fix is kept in the
same order relative to the existing fixes as the old one originally
was. Note that this operation also wipes out any additional changes
made to the old fix via the <a class="reference internal" href="fix_modify.html"><em>fix_modify</em></a> command.</p>
<p>The <a class="reference internal" href="fix_modify.html"><em>fix modify</em></a> command allows settings for some
fixes to be reset. See the doc page for individual fixes for details.</p>
<p>Some fixes store an internal “state” which is written to binary
restart files via the <a class="reference internal" href="restart.html"><em>restart</em></a> or
<a class="reference internal" href="write_restart.html"><em>write_restart</em></a> commands. This allows the fix to
continue on with its calculations in a restarted simulation. See the
<a class="reference internal" href="read_restart.html"><em>read_restart</em></a> command for info on how to re-specify
a fix in an input script that reads a restart file. See the doc pages
for individual fixes for info on which ones can be restarted.</p>
<hr class="docutils" />
<p>Some fixes calculate one of three styles of quantities: global,
per-atom, or local, which can be used by other commands or output as
described below. A global quantity is one or more system-wide values,
e.g. the energy of a wall interacting with particles. A per-atom
quantity is one or more values per atom, e.g. the displacement vector
for each atom since time 0. Per-atom values are set to 0.0 for atoms
not in the specified fix group. Local quantities are calculated by
each processor based on the atoms it owns, but there may be zero or
more per atoms.</p>
<p>Note that a single fix may produces either global or per-atom or local
quantities (or none at all), but never more than one of these.</p>
<p>Global, per-atom, and local quantities each come in three kinds: a
single scalar value, a vector of values, or a 2d array of values. The
doc page for each fix describes the style and kind of values it
produces, e.g. a per-atom vector. Some fixes produce more than one
kind of a single style, e.g. a global scalar and a global vector.</p>
<p>When a fix quantity is accessed, as in many of the output commands
discussed below, it can be referenced via the following bracket
notation, where ID is the ID of the fix:</p>
<table border="1" class="docutils">
<colgroup>
<col width="21%" />
<col width="79%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td>f_ID</td>
<td>entire scalar, vector, or array</td>
</tr>
<tr class="row-even"><td>f_ID[I]</td>
<td>one element of vector, one column of array</td>
</tr>
<tr class="row-odd"><td>f_ID[I][J]</td>
<td>one element of array</td>
</tr>
</tbody>
</table>
<p>In other words, using one bracket reduces the dimension of the
quantity once (vector -> scalar, array -> vector). Using two brackets
reduces the dimension twice (array -> scalar). Thus a command that
uses scalar fix values as input can also process elements of a vector
or array.</p>
<p>Note that commands and <a class="reference internal" href="variable.html"><em>variables</em></a> which use fix
quantities typically do not allow for all kinds, e.g. a command may
require a vector of values, not a scalar. This means there is no
ambiguity about referring to a fix quantity as f_ID even if it
produces, for example, both a scalar and vector. The doc pages for
various commands explain the details.</p>
<hr class="docutils" />
<p>In LAMMPS, the values generated by a fix can be used in several ways:</p>
<ul class="simple">
<li>Global values can be output via the <a class="reference internal" href="thermo_style.html"><em>thermo_style custom</em></a> or <a class="reference internal" href="fix_ave_time.html"><em>fix ave/time</em></a> command.
Or the values can be referenced in a <a class="reference internal" href="variable.html"><em>variable equal</em></a> or
<li>Per-atom values can be output via the <a class="reference internal" href="dump.html"><em>dump custom</em></a> command
or the <a class="reference internal" href="fix_ave_spatial.html"><em>fix ave/spatial</em></a> command. Or they can be
time-averaged via the <a class="reference internal" href="fix_ave_atom.html"><em>fix ave/atom</em></a> command or
reduced by the <a class="reference internal" href="compute_reduce.html"><em>compute reduce</em></a> command. Or the
per-atom values can be referenced in an <a class="reference internal" href="variable.html"><em>atom-style variable</em></a>.</li>
<li>Local values can be reduced by the <a class="reference internal" href="compute_reduce.html"><em>compute reduce</em></a> command, or histogrammed by the <a class="reference internal" href="fix_ave_histo.html"><em>fix ave/histo</em></a> command.</li>
</ul>
<p>See this <a class="reference internal" href="Section_howto.html#howto-15"><span>howto section</span></a> for a summary of
various LAMMPS output options, many of which involve fixes.</p>
<p>The results of fixes that calculate global quantities can be either
“intensive” or “extensive” values. Intensive means the value is
independent of the number of atoms in the simulation,
e.g. temperature. Extensive means the value scales with the number of
atoms in the simulation, e.g. total rotational kinetic energy.
<a class="reference internal" href="thermo_style.html"><em>Thermodynamic output</em></a> will normalize extensive
values by the number of atoms in the system, depending on the
“thermo_modify norm” setting. It will not normalize intensive values.
If a fix value is accessed in another way, e.g. by a
<a class="reference internal" href="variable.html"><em>variable</em></a>, you may want to know whether it is an
intensive or extensive value. See the doc page for individual fixes
for further info.</p>
<hr class="docutils" />
<p>Each fix style has its own documentation page which describes its
arguments and what it does, as listed below. Here is an alphabetic
list of fix styles available in LAMMPS. They are also given in more
compact form in the fix section of <a class="reference internal" href="Section_commands.html#cmd-5"><span>this page</span></a>.</p>
<p>There are also additional fix styles (not listed here) submitted by
users which are included in the LAMMPS distribution. The list of
these with links to the individual styles are given in the fix section
of <a class="reference internal" href="Section_commands.html#cmd-5"><span>this page</span></a>.</p>
<p>There are also additional accelerated fix styles (not listed here)
included in the LAMMPS distribution for faster performance on CPUs and
GPUs. The list of these with links to the individual styles are given
in the fix section of <a class="reference internal" href="Section_commands.html#cmd-5"><span>this page</span></a>.</p>
<ul class="simple">
<li><a class="reference internal" href="fix_adapt.html"><em>adapt</em></a> - change a simulation parameter over time</li>
<li><a class="reference internal" href="fix_addforce.html"><em>addforce</em></a> - add a force to each atom</li>
<li><a class="reference internal" href="fix_append_atoms.html"><em>append/atoms</em></a> - append atoms to a running simulation</li>
<li><a class="reference internal" href="fix_aveforce.html"><em>aveforce</em></a> - add an averaged force to each atom</li>
<li><a class="reference internal" href="fix_qeq_comb.html"><em>qeq/comb</em></a> - charge equilibration for COMB potential <a class="reference internal" href="fix_qeq.html"><em>qeq/dynamic</em></a> - charge equilibration via dynamic method <a class="reference internal" href="fix_qeq.html"><em>qeq/point</em></a> - charge equilibration via point method <a class="reference internal" href="fix_qeq.html"><em>qeq/shielded</em></a> - charge equilibration via shielded method <a class="reference internal" href="fix_qeq.html"><em>qeq/slater</em></a> - charge equilibration via Slater method <a class="reference internal" href="fix_reax_bonds.html"><em>reax/bonds</em></a> - write out ReaxFF bond information <a class="reference internal" href="fix_recenter.html"><em>recenter</em></a> - constrain the center-of-mass position of a group of atoms</li>
<li><a class="reference internal" href="fix_restrain.html"><em>restrain</em></a> - constrain a bond, angle, dihedral</li>
<li><a class="reference internal" href="fix_rigid.html"><em>rigid</em></a> - constrain one or more clusters of atoms to move as a rigid body with NVE integration</li>
<li><a class="reference internal" href="fix_rigid.html"><em>rigid/nph</em></a> - constrain one or more clusters of atoms to move as a rigid body with NPH integration</li>
<li><a class="reference internal" href="fix_rigid.html"><em>rigid/npt</em></a> - constrain one or more clusters of atoms to move as a rigid body with NPT integration</li>
<li><a class="reference internal" href="fix_rigid.html"><em>rigid/nve</em></a> - constrain one or more clusters of atoms to move as a rigid body with alternate NVE integration</li>
<li><a class="reference internal" href="fix_rigid.html"><em>rigid/nvt</em></a> - constrain one or more clusters of atoms to move as a rigid body with NVT integration</li>
<li><a class="reference internal" href="fix_rigid.html"><em>rigid/small</em></a> - constrain many small clusters of atoms to move as a rigid body with NVE integration</li>
<li><a class="reference internal" href="fix_setforce.html"><em>setforce</em></a> - set the force on each atom</li>
<li><a class="reference internal" href="fix_wall_region.html"><em>wall/region</em></a> - use region surface as wall</li>
<li><a class="reference internal" href="fix_wall_srd.html"><em>wall/srd</em></a> - slip/no-slip wall for SRD particles</li>
</ul>
</div>
<div class="section" id="restrictions">
<h2>Restrictions<a class="headerlink" href="#restrictions" title="Permalink to this headline">¶</a></h2>
<p>Some fix styles are part of specific packages. They are only enabled
if LAMMPS was built with that package. See the <a class="reference internal" href="Section_start.html#start-3"><span>Making LAMMPS</span></a> section for more info on packages.
The doc pages for individual fixes tell if it is part of a package.</p>
</div>
<div class="section" id="related-commands">
<h2>Related commands<a class="headerlink" href="#related-commands" title="Permalink to this headline">¶</a></h2>
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>.