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:

Create 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. There are two kinds of computes, "global" computes that calculate one or more values for the entire group of atoms, and "per-atom" computes that calculate one or more values for each atom in the group. The latter has the word "atom" in its style name.

In LAMMPS, a "compute" can be used in several ways. The results of global computes 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. The results of computes that calculate a global temperature or pressure can be used by fixes that do thermostatting or barostatting and when atom velocities are created.

The results of per-atom computes can be output via the dump custom command or the fix ave/spatial command. Or the per-atom values can be time-averaged via the fix ave/atom command and then output via the dump custom or fix ave/spatial commands. Or the per-atom values can be referenced in a variable atom command. Note that the value of per-atom computes will be 0.0 for atoms not in the specified compute group.

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.

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 depending on the "thermo_modify norm" setting. But if a compute value is accessed in another way, e.g. by a variable, you may need to know whether it is an intensive or extensive value. See the doc page for individual computes for further info.

LAMMPS creates its own global computes 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 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:

- centro/atom - centro-symmetry parameter for each atom
- cna/atom - common neighbor analysis (CNA) for each atom
- coord/atom - coordination number for each atom
- damage/atom - Peridynamic damage for each atom
- displace/atom - displacement of each atom
- erotate/asphere - rotational energy of aspherical particles
- erotate/sphere - rotational energy of spherical particles
- group/group - energy/force between two groups of atoms
- ke - translational kinetic energy
- ke/atom - kinetic energy for each atom
- pe - potential energy
- pe/atom - potential energy for each atom
- pressure - total pressure and pressure tensor
- reduce - combine per-atom quantities into a single global value
- reduce/region - same as compute reduce, within a region
- stress/atom - stress tensor for each atom
- temp - temperature of group of atoms
- temp/asphere - temperature of aspherical particles
- 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

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.

Restrictions: none

Related commands:

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

Default: none