<p>Define a calculation that “reduces” one or more vector inputs into
scalar values, one per listed input. The inputs can be per-atom or
local quantities; they cannot be global quantities. Atom attributes
are per-atom quantities, <aclass="reference internal"href="compute.html"><spanclass="doc">computes</span></a> and <aclass="reference internal"href="fix.html"><spanclass="doc">fixes</span></a>
may generate any of the three kinds of quantities, and <aclass="reference internal"href="variable.html"><spanclass="doc">atom-style variables</span></a> generate per-atom quantities. See the
<p>The atom attribute values (x,y,z,vx,vy,vz,fx,fy,fz) are
self-explanatory. Note that other atom attributes can be used as
inputs to this fix by using the <aclass="reference internal"href="compute_property_atom.html"><spanclass="doc">compute property/atom</span></a> command and then specifying
an input value from that compute.</p>
<p>If a value begins with “<ahref="#id1"><spanclass="problematic"id="id2">c_</span></a>”, a compute ID must follow which has been
previously defined in the input script. Computes can generate
per-atom or local quantities. See the individual
<aclass="reference internal"href="compute.html"><spanclass="doc">compute</span></a> doc page for details. If no bracketed integer
is appended, the vector calculated by the compute is used. If a
bracketed integer is appended, the Ith column of the array calculated
by the compute is used. Users can also write code for their own
compute styles and <aclass="reference internal"href="Section_modify.html"><spanclass="doc">add them to LAMMPS</span></a>.</p>
<p>If a value begins with “<ahref="#id3"><spanclass="problematic"id="id4">f_</span></a>”, a fix ID must follow which has been
previously defined in the input script. Fixes can generate per-atom
or local quantities. See the individual <aclass="reference internal"href="fix.html"><spanclass="doc">fix</span></a> doc page for
details. Note that some fixes only produce their values on certain
timesteps, which must be compatible with when compute reduce
references the values, else an error results. If no bracketed integer
is appended, the vector calculated by the fix is used. If a bracketed
integer is appended, the Ith column of the array calculated by the fix
is used. Users can also write code for their own fix style and <aclass="reference internal"href="Section_modify.html"><spanclass="doc">add them to LAMMPS</span></a>.</p>
<p>If a value begins with “<ahref="#id5"><spanclass="problematic"id="id6">v_</span></a>”, a variable name must follow which has
been previously defined in the input script. It must be an
<aclass="reference internal"href="variable.html"><spanclass="doc">atom-style variable</span></a>. Atom-style variables can
reference thermodynamic keywords and various per-atom attributes, or
invoke other computes, fixes, or variables when they are evaluated, so
this is a very general means of generating per-atom quantities to
reduce.</p>
<hrclass="docutils"/>
<p>If the <em>replace</em> keyword is used, two indices <em>vec1</em> and <em>vec2</em> are
specified, where each index ranges from 1 to the # of input values.
The replace keyword can only be used if the <em>mode</em> is <em>min</em> or <em>max</em>.
It works as follows. A min/max is computed as usual on the <em>vec2</em>
input vector. The index N of that value within <em>vec2</em> is also stored.
Then, instead of performing a min/max on the <em>vec1</em> input vector, the
stored index is used to select the Nth element of the <em>vec1</em> vector.</p>
<p>Thus, for example, if you wish to use this compute to find the bond
with maximum stretch, you can do it as follows:</p>
<p>The first two input values in the compute reduce command are vectors
with the IDs of the 2 atoms in each bond, using the <aclass="reference internal"href="compute_property_local.html"><spanclass="doc">compute property/local</span></a> command. The last input
value is bond distance, using the <aclass="reference internal"href="compute_bond_local.html"><spanclass="doc">compute bond/local</span></a> command. Instead of taking the
max of the two atom ID vectors, which does not yield useful
information in this context, the <em>replace</em> keywords will extract the
atom IDs for the two atoms in the bond of maximum stretch. These atom
IDs and the bond stretch will be printed with thermodynamic output.</p>
<hrclass="docutils"/>
<p>If a single input is specified this compute produces a global scalar
value. If multiple inputs are specified, this compute produces a
global vector of values, the length of which is equal to the number of
inputs specified.</p>
<p>As discussed below, for the <em>sum</em> and <em>sumsq</em> modes, the value(s)
produced by this compute are all “extensive”, meaning their value
scales linearly with the number of atoms involved. If normalized
values are desired, this compute can be accessed by the <aclass="reference internal"href="thermo_style.html"><spanclass="doc">thermo_style custom</span></a> command with <aclass="reference internal"href="thermo_modify.html"><spanclass="doc">thermo_modify norm yes</span></a> set as an option. Or it can be accessed by a
<aclass="reference internal"href="variable.html"><spanclass="doc">variable</span></a> that divides by the appropriate atom count.</p>
<hrclass="docutils"/>
<p><strong>Output info:</strong></p>
<p>This compute calculates a global scalar if a single input value is
specified or a global vector of length N where N is the number of
inputs, and which can be accessed by indices 1 to N. These values can
be used by any command that uses global scalar or vector values from a
compute as input. See <aclass="reference internal"href="Section_howto.html#howto-15"><spanclass="std std-ref">Section_howto 15</span></a>
for an overview of LAMMPS output options.</p>
<p>All the scalar or vector values calculated by this compute are
“intensive”, except when the <em>sum</em> or <em>sumsq</em> modes are used on
per-atom or local vectors, in which case the calculated values are
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>.