<spanid="index-0"></span><h1>compute command<aclass="headerlink"href="#compute-command"title="Permalink to this headline">¶</a></h1>
<divclass="section"id="syntax">
<h2>Syntax<aclass="headerlink"href="#syntax"title="Permalink to this headline">¶</a></h2>
<divclass="highlight-python"><divclass="highlight"><pre>compute ID group-ID style args
</pre></div>
</div>
<ulclass="simple">
<li>ID = user-assigned name for the computation</li>
<li>group-ID = ID of the group of atoms to perform the computation on</li>
<li>style = one of a list of possible style names (see below)</li>
<li>args = arguments used by a particular style</li>
</ul>
</div>
<divclass="section"id="examples">
<h2>Examples<aclass="headerlink"href="#examples"title="Permalink to this headline">¶</a></h2>
<divclass="highlight-python"><divclass="highlight"><pre>compute 1 all temp
compute newtemp flow temp/partial 1 1 0
compute 3 all ke/atom
</pre></div>
</div>
</div>
<divclass="section"id="description">
<h2>Description<aclass="headerlink"href="#description"title="Permalink to this headline">¶</a></h2>
<p>Define a computation that will be performed on a group of atoms.
Quantities calculated by a compute are instantaneous values, meaning
they are calculated from information about atoms on the current
timestep or iteration, though a compute may internally store some
information about a previous state of the system. Defining a compute
does not perform a computation. Instead computes are invoked by other
LAMMPS commands as needed, e.g. to calculate a temperature needed for
a thermostat fix or to generate thermodynamic or dump file output.
See this <aclass="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 computes.</p>
<p>The ID of a compute can only contain alphanumeric characters and
underscores.</p>
<hrclass="docutils"/>
<p>Computes calculate one of three styles of quantities: global,
per-atom, or local. A global quantity is one or more system-wide
values, e.g. the temperature of the system. A per-atom quantity is
one or more values per atom, e.g. the kinetic energy of each atom.
Per-atom values are set to 0.0 for atoms not in the specified compute
group. Local quantities are calculated by each processor based on the
atoms it owns, but there may be zero or more per atom, e.g. a list of
bond distances. Computes that produce per-atom quantities have the
word “atom” in their style, e.g. <em>ke/atom</em>. Computes that produce
local quantities have the word “local” in their style,
e.g. <em>bond/local</em>. Styles with neither “atom” or “local” in their
style produce global quantities.</p>
<p>Note that a single compute produces either global or per-atom or local
quantities, 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 compute describes the style and kind of values it
produces, e.g. a per-atom vector. Some computes produce more than one
kind of a single style, e.g. a global scalar and a global vector.</p>
<p>When a compute 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 compute:</p>
<tableborder="1"class="docutils">
<colgroup>
<colwidth="21%"/>
<colwidth="79%"/>
</colgroup>
<tbodyvalign="top">
<trclass="row-odd"><td>c_ID</td>
<td>entire scalar, vector, or array</td>
</tr>
<trclass="row-even"><td>c_ID[I]</td>
<td>one element of vector, one column of array</td>
</tr>
<trclass="row-odd"><td>c_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 compute values as input can also process elements of a
vector or array.</p>
<p>Note that commands and <aclass="reference internal"href="variable.html"><em>variables</em></a> which use compute
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 compute quantity as c_ID even if it
produces, for example, both a scalar and vector. The doc pages for
various commands explain the details.</p>
<hrclass="docutils"/>
<p>In LAMMPS, the values generated by a compute can be used in several
ways:</p>
<ulclass="simple">
<li>The results of computes that calculate a global temperature or
pressure can be used by fixes that do thermostatting or barostatting
or when atom velocities are created.</li>
<li>Global values can be output via the <aclass="reference internal"href="thermo_style.html"><em>thermo_style custom</em></a> or <aclass="reference internal"href="fix_ave_time.html"><em>fix ave/time</em></a> command.
Or the values can be referenced in a <aclass="reference internal"href="variable.html"><em>variable equal</em></a> or
<li>Per-atom values can be output via the <aclass="reference internal"href="dump.html"><em>dump custom</em></a> command
or the <aclass="reference internal"href="fix_ave_spatial.html"><em>fix ave/spatial</em></a> command. Or they can be
time-averaged via the <aclass="reference internal"href="fix_ave_atom.html"><em>fix ave/atom</em></a> command or
reduced by the <aclass="reference internal"href="compute_reduce.html"><em>compute reduce</em></a> command. Or the
per-atom values can be referenced in an <aclass="reference internal"href="variable.html"><em>atom-style variable</em></a>.</li>
<li>Local values can be reduced by the <aclass="reference internal"href="compute_reduce.html"><em>compute reduce</em></a> command, or histogrammed by the <aclass="reference internal"href="fix_ave_histo.html"><em>fix ave/histo</em></a> command, or output by the <aclass="reference internal"href="dump.html"><em>dump local</em></a> command.</li>
</ul>
<p>The results of computes 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.
<aclass="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 compute value is accessed in another way, e.g. by a
<aclass="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
computes for further info.</p>
<hrclass="docutils"/>
<p>LAMMPS creates its own computes internally for thermodynamic output.
Three computes are always created, named “thermo_temp”,
“thermo_press”, and “thermo_pe”, as if these commands had been invoked
in the input script:</p>
<divclass="highlight-python"><divclass="highlight"><pre>compute thermo_temp all temp
compute thermo_press all pressure thermo_temp
compute thermo_pe all pe
</pre></div>
</div>
<p>Additional computes for other quantities are created if the thermo
<p>Fixes that calculate temperature or pressure, i.e. for thermostatting
or barostatting, may also create computes. These are discussed in the
documentation for specific <aclass="reference internal"href="fix.html"><em>fix</em></a> commands.</p>
<p>In all these cases, the default computes LAMMPS creates can be
replaced by computes defined by the user in the input script, as
described by the <aclass="reference internal"href="thermo_modify.html"><em>thermo_modify</em></a> and <aclass="reference internal"href="fix_modify.html"><em>fix modify</em></a> commands.</p>
<p>Properties of either a default or user-defined compute can be modified
via the <aclass="reference internal"href="compute_modify.html"><em>compute_modify</em></a> command.</p>
<p>Computes can be deleted with the <aclass="reference internal"href="uncompute.html"><em>uncompute</em></a> command.</p>
<p>Code for new computes can be added to LAMMPS (see <aclass="reference internal"href="Section_modify.html"><em>this section</em></a> of the manual) and the results of their
calculations accessed in the various ways described above.</p>
<hrclass="docutils"/>
<p>Each compute style has its own doc page which describes its arguments
and what it does. Here is an alphabetic list of compute styles
available in LAMMPS. They are also given in more compact form in the
compute section of <aclass="reference internal"href="Section_commands.html#cmd-5"><span>this page</span></a>.</p>
<p>There are also additional compute 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 compute
section of <aclass="reference internal"href="Section_commands.html#cmd-5"><span>this page</span></a>.</p>
<p>There are also additional accelerated compute styles (note 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 compute section of <aclass="reference internal"href="Section_commands.html#cmd-5"><span>this page</span></a>.</p>
<ulclass="simple">
<li><aclass="reference internal"href="compute_bond_local.html"><em>angle/local</em></a> - theta and energy of each angle</li>
<li><aclass="reference internal"href="compute_body_local.html"><em>body/local</em></a> - attributes of body sub-particles</li>
<li><aclass="reference internal"href="compute_bond_local.html"><em>bond/local</em></a> - distance and energy of each bond</li>
<li><aclass="reference internal"href="compute_centro_atom.html"><em>centro/atom</em></a> - centro-symmetry parameter for each atom</li>
<li><aclass="reference internal"href="compute_cluster_atom.html"><em>cluster/atom</em></a> - cluster ID for each atom</li>
<li><aclass="reference internal"href="compute_cna_atom.html"><em>cna/atom</em></a> - common neighbor analysis (CNA) for each atom</li>
<li><aclass="reference internal"href="compute_com.html"><em>com</em></a> - center-of-mass of group of atoms</li>
<li><aclass="reference internal"href="compute_com_chunk.html"><em>com/chunk</em></a> - center-of-mass for each chunk</li>
<li><aclass="reference internal"href="compute_contact_atom.html"><em>contact/atom</em></a> - contact count for each spherical particle</li>
<li><aclass="reference internal"href="compute_coord_atom.html"><em>coord/atom</em></a> - coordination number for each atom</li>
<li><aclass="reference internal"href="compute_damage_atom.html"><em>damage/atom</em></a> - Peridynamic damage for each atom</li>
<li><aclass="reference internal"href="compute_dihedral_local.html"><em>dihedral/local</em></a> - angle of each dihedral</li>
<li><aclass="reference internal"href="compute_dilatation_atom.html"><em>dilatation/atom</em></a> - Peridynamic dilatation for each atom</li>
<li><aclass="reference internal"href="compute_displace_atom.html"><em>displace/atom</em></a> - displacement of each atom</li>
<li><aclass="reference internal"href="compute_erotate_asphere.html"><em>erotate/asphere</em></a> - rotational energy of aspherical particles</li>
<li><aclass="reference internal"href="compute_erotate_rigid.html"><em>erotate/rigid</em></a> - rotational energy of rigid bodies</li>
<li><aclass="reference internal"href="compute_erotate_sphere.html"><em>erotate/sphere</em></a> - rotational energy of spherical particles</li>
<li><aclass="reference internal"href="compute_erotate_sphere.html"><em>erotate/sphere/atom</em></a> - rotational energy for each spherical particle</li>
<li><aclass="reference internal"href="compute_event_displace.html"><em>event/displace</em></a> - detect event on atom displacement</li>
<li><aclass="reference internal"href="compute_group_group.html"><em>group/group</em></a> - energy/force between two groups of atoms</li>
<li><aclass="reference internal"href="compute_gyration.html"><em>gyration</em></a> - radius of gyration of group of atoms</li>
<li><aclass="reference internal"href="compute_gyration_chunk.html"><em>gyration/chunk</em></a> - radius of gyration for each chunk</li>
<li><aclass="reference internal"href="compute_heat_flux.html"><em>heat/flux</em></a> - heat flux through a group of atoms</li>
<li><aclass="reference internal"href="compute_improper_local.html"><em>improper/local</em></a> - angle of each improper</li>
<li><aclass="reference internal"href="compute_inertia_chunk.html"><em>inertia/chunk</em></a> - inertia tensor for each chunk</li>
<li><aclass="reference internal"href="compute_pe_atom.html"><em>pe/atom</em></a> - potential energy for each atom</li>
<li><aclass="reference internal"href="compute_plasticity_atom.html"><em>plasticity/atom</em></a> - Peridynamic plasticity for each atom</li>
<li><aclass="reference internal"href="compute_pressure.html"><em>pressure</em></a> - total pressure and pressure tensor</li>
<li><aclass="reference internal"href="compute_property_atom.html"><em>property/atom</em></a> - convert atom attributes to per-atom vectors/arrays</li>
<li><aclass="reference internal"href="compute_property_local.html"><em>property/local</em></a> - convert local attributes to localvectors/arrays</li>
<li><aclass="reference internal"href="compute_property_chunk.html"><em>property/chunk</em></a> - extract various per-chunk attributes</li>
<li><aclass="reference internal"href="compute_rdf.html"><em>rdf</em></a> - radial distribution function g(r) histogram of group of atoms</li>
<li><aclass="reference internal"href="compute_reduce.html"><em>reduce</em></a> - combine per-atom quantities into a single global value</li>
<li><aclass="reference internal"href="compute_reduce.html"><em>reduce/region</em></a> - same as compute reduce, within a region</li>
<li><aclass="reference internal"href="compute_slice.html"><em>slice</em></a> - extract values from global vector or array</li>
<li><codeclass="xref doc docutils literal"><spanclass="pre">sna/atom</span></code> - calculate bispectrum coefficients for each atom</li>
<li><codeclass="xref doc docutils literal"><spanclass="pre">snad/atom</span></code> - derivative of bispectrum coefficients for each atom</li>
<li><codeclass="xref doc docutils literal"><spanclass="pre">snav/atom</span></code> - virial contribution from bispectrum coefficients for each atom</li>
<li><aclass="reference internal"href="compute_stress_atom.html"><em>stress/atom</em></a> - stress tensor for each atom</li>
<li><aclass="reference internal"href="compute_temp.html"><em>temp</em></a> - temperature of group of atoms</li>
<li><aclass="reference internal"href="compute_temp_asphere.html"><em>temp/asphere</em></a> - temperature of aspherical particles</li>
<li><aclass="reference internal"href="compute_temp_chunk.html"><em>temp/chunk</em></a> - temperature of each chunk</li>
<li><aclass="reference internal"href="compute_temp_com.html"><em>temp/com</em></a> - temperature after subtracting center-of-mass velocity</li>
<li><aclass="reference internal"href="compute_temp_deform.html"><em>temp/deform</em></a> - temperature excluding box deformation velocity</li>
<li><aclass="reference internal"href="compute_temp_partial.html"><em>temp/partial</em></a> - temperature excluding one or more dimensions of velocity</li>
<li><aclass="reference internal"href="compute_temp_profile.html"><em>temp/profile</em></a> - temperature excluding a binned velocity profile</li>
<li><aclass="reference internal"href="compute_temp_ramp.html"><em>temp/ramp</em></a> - temperature excluding ramped velocity component</li>
<li><aclass="reference internal"href="compute_temp_region.html"><em>temp/region</em></a> - temperature of a region of atoms</li>
<li><aclass="reference internal"href="compute_temp_sphere.html"><em>temp/sphere</em></a> - temperature of spherical particles</li>
<li><aclass="reference internal"href="compute_ti.html"><em>ti</em></a> - thermodyanmic integration free energy values</li>
<li><aclass="reference internal"href="compute_torque_chunk.html"><em>torque/chunk</em></a> - torque applied on each chunk</li>
<li><aclass="reference internal"href="compute_vacf.html"><em>vacf</em></a> - velocity-autocorrelation function of group of atoms</li>
<li><aclass="reference internal"href="compute_vcm_chunk.html"><em>vcm/chunk</em></a> - velocity of center-of-mass for each chunk</li>
<li><aclass="reference internal"href="compute_voronoi_atom.html"><em>voronoi/atom</em></a> - Voronoi volume and neighbors for each atom</li>
</ul>
<p>There are also additional compute styles submitted by users which are
included in the LAMMPS distribution. The list of these with links to
the individual styles are given in the compute section of <aclass="reference internal"href="Section_commands.html#cmd-5"><span>this page</span></a>.</p>
<p>There are also additional accelerated compute styles 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 pair
section of <aclass="reference internal"href="Section_commands.html#cmd-5"><span>this page</span></a>.</p>
</div>
<divclass="section"id="restrictions">
<h2>Restrictions<aclass="headerlink"href="#restrictions"title="Permalink to this headline">¶</a></h2>
<blockquote>
<div>none</div></blockquote>
</div>
<divclass="section"id="related-commands">
<h2>Related commands<aclass="headerlink"href="#related-commands"title="Permalink to this headline">¶</a></h2>
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>.