LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands

### compute command

Syntax:

    compute ID group-ID style args

- ID = user-assigned name for the computation
- group-ID = ID of the group of atoms to perform the computation on
- style = one of a list of possible style names (see below)
- args = arguments used by a particular style

Examples:

    compute 1 all temp
    compute newtemp flow temp/partial 1 1 0
    compute 3 all ke/atom

Description:

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 howto section for a summary of various LAMMPS output options, many of which involve computes.

The ID of a compute can only contain alphanumeric characters and underscores.

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. ke/atom. Computes that produce local quantities have the word "local" in their style, e.g. bond/local. Styles with neither "atom" or "local" in their style produce global quantities.

Note that a single compute produces either global or per-atom or local quantities, but never more than one of these (with only a few exceptions, as documented by individual compute commands).

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.

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:

c_ID | entire scalar, vector, or array
c_ID[I] | one element of vector, one column of array
c_ID[I][J] | one element of array

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.

Note that commands and variables 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.

In LAMMPS, the values generated by a compute can be used in several ways:

- 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.
- Global values can be output via the thermo_style custom or fix ave/time command. Or the values can be referenced in a variable equal or variable atom command.
- Per-atom values can be output via the dump custom command. Or they can be time-averaged via the fix ave/atom command or reduced by the compute reduce command. Or the per-atom values can be referenced in an atom-style variable.
- Local values can be reduced by the compute reduce command, or histogrammed by the fix ave/histo command, or output by the dump local command.

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. Thermodynamic output 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 variable, you may want to know whether it is an intensive or extensive value. See the doc page for individual computes for further info.

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:

    compute thermo_temp all temp
    compute thermo_press all pressure thermo_temp
    compute thermo_pe all pe

Additional computes for other quantities are created if the thermo style requires it. See the documentation for the thermo_style command.

Fixes that calculate temperature or pressure, i.e. for thermostatting or barostatting, may also create computes. These are discussed in the documentation for specific fix commands.

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 thermo_modify and fix modify commands.

Properties of either a default or user-defined compute can be modified via the compute_modify command.

Computes can be deleted with the uncompute command.

Code for new computes can be added to LAMMPS (see this section of the manual) and the results of their calculations accessed in the various ways described above.

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 this page.

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 this page.

- angle/local - theta and energy of each angle
- angmom/chunk - angular momentum for each chunk
- body/local - attributes of body sub-particles
- bond - values computed by a bond style
- bond/local - distance and energy of each bond
- centro/atom - centro-symmetry parameter for each atom
- chunk/atom - assign chunk IDs to each atom
- cluster/atom - cluster ID for each atom
- cna/atom - common neighbor analysis (CNA) for each atom
- com - center-of-mass of group of atoms
- com/chunk - center-of-mass for each chunk
- contact/atom - contact count for each spherical particle
- coord/atom - coordination number for each atom
- damage/atom - Peridynamic damage for each atom
- dihedral/local - angle of each dihedral
- dilatation/atom - Peridynamic dilatation for each atom
- displace/atom - displacement of each atom
- erotate/asphere - rotational energy of aspherical particles
- erotate/rigid - rotational energy of rigid bodies
- erotate/sphere - rotational energy of spherical particles
- erotate/sphere/atom - rotational energy for each spherical particle
- event/displace - detect event on atom displacement
- group/group - energy/force between two groups of atoms
- gyration - radius of gyration of group of atoms
- gyration/chunk - radius of gyration for each chunk
- heat/flux - heat flux through a group of atoms
- hexorder/atom - bond orientational order parameter q6
- improper/local - angle of each improper
- inertia/chunk - inertia tensor for each chunk
- ke - translational kinetic energy
- ke/atom - kinetic energy for each atom
- ke/rigid - translational kinetic energy of rigid bodies
- msd - mean-squared displacement of group of atoms
- msd/chunk - mean-squared displacement for each chunk
- msd/nongauss - MSD and non-Gaussian parameter of group of atoms
- omega/chunk - angular velocity for each chunk
- orientorder/atom - Steinhardt bond orientational order parameters Ql
- pair - values computed by a pair style
- pair/local - distance/energy/force of each pairwise interaction
- pe - potential energy
- pe/atom - potential energy for each atom
- plasticity/atom - Peridynamic plasticity for each atom
- pressure - total pressure and pressure tensor
- property/atom - convert atom attributes to per-atom vectors/arrays
- property/local - convert local attributes to localvectors/arrays
- property/chunk - extract various per-chunk attributes
- rdf - radial distribution function g(r) histogram of group of atoms
- reduce - combine per-atom quantities into a single global value
- reduce/region - same as compute reduce, within a region
- rigid/local - extract rigid body attributes
- slice - extract values from global vector or array
- sna/atom - calculate bispectrum coefficients for each atom
- snad/atom - derivative of bispectrum coefficients for each atom
- snav/atom - virial contribution from bispectrum coefficients for each atom
- stress/atom - stress tensor for each atom
- temp - temperature of group of atoms
- temp/asphere - temperature of aspherical particles
- temp/body - temperature of body particles
- temp/chunk - temperature of each chunk
- temp/com - temperature after subtracting center-of-mass velocity
- temp/deform - temperature excluding box deformation velocity
- temp/partial - temperature excluding one or more dimensions of velocity
- temp/profile - temperature excluding a binned velocity profile
- temp/ramp - temperature excluding ramped velocity component
- temp/region - temperature of a region of atoms
- temp/sphere - temperature of spherical particles
- ti - thermodyanmic integration free energy values
- torque/chunk - torque applied on each chunk
- vacf - velocity-autocorrelation function of group of atoms
- vcm/chunk - velocity of center-of-mass for each chunk
- voronoi/atom - Voronoi volume and neighbors for each atom

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 this page.

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 this page.

Restrictions: none

Related commands:

uncompute, compute_modify, fix ave/atom, fix ave/time, fix ave/histo

Default: none