"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c

:link(lws,http://lammps.sandia.gov)
:link(ld,Manual.html)
:link(lc,Commands_all.html)

:line

compute command :h3

[Syntax:]

compute ID group-ID style args :pre

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 :ul

[Examples:]

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

[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 the "Howto output"_Howto_output.html doc page 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.

:line

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 can produce either global or per-atom or
local quantities, but not both global and per-atom.  It can produce
local quantities in tandem with global or per-atom quantities.  The
compute doc page will explain.

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 :tb(s=|)

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"_variable.html 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.

:line

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. :ulb,l

Global values can be output via the "thermo_style
custom"_thermo_style.html or "fix ave/time"_fix_ave_time.html command.
Or the values can be referenced in a "variable equal"_variable.html or
"variable atom"_variable.html command. :l

Per-atom values can be output via the "dump custom"_dump.html command.
Or they can be time-averaged via the "fix ave/atom"_fix_ave_atom.html
command or reduced by the "compute reduce"_compute_reduce.html
command.  Or the per-atom values can be referenced in an "atom-style
variable"_variable.html. :l

Local values can be reduced by the "compute
reduce"_compute_reduce.html command, or histogrammed by the "fix
ave/histo"_fix_ave_histo.html command, or output by the "dump
local"_dump.html command. :l
:ule

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

:line

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 :pre

Additional computes for other quantities are created if the thermo
style requires it.  See the documentation for the
"thermo_style"_thermo_style.html 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"_fix.html 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"_thermo_modify.html and "fix
modify"_fix_modify.html commands.

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

Computes can be deleted with the "uncompute"_uncompute.html command.

Code for new computes can be added to LAMMPS; see the
"Modify"_Modify.html doc page for details.  The results of their
calculations accessed in the various ways described above.

:line

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 listed in more compact form on the
"Commands compute"_Commands_compute.html doc page.

There are also additional accelerated compute styles included in the
LAMMPS distribution for faster performance on CPUs, GPUs, and KNLs.
The individual style names on the "Commands
compute"_Commands_compute.html doc page are followed by one or more of
(g,i,k,o,t) to indicate which accelerated styles exist.

"ackland/atom"_compute_ackland_atom.html - determines the local lattice structure based on the Ackland formulation
"adf"_compute_adf.html - angular distribution function of triples of atoms
"aggregate/atom"_compute_cluster_atom.html - aggregate ID for each atom
"angle"_compute_angle.html - energy of each angle sub-style
"angle/local"_compute_angle_local.html - theta and energy of each angle
"angmom/chunk"_compute_angmom_chunk.html - angular momentum for each chunk
"basal/atom"_compute_basal_atom.html - calculates the hexagonal close-packed "c" lattice vector of each atom
"body/local"_compute_body_local.html - attributes of body sub-particles
"bond"_compute_bond.html - energy of each bond sub-style
"bond/local"_compute_bond_local.html - distance and energy of each bond
"centro/atom"_compute_centro_atom.html - centro-symmetry parameter for each atom
"chunk/atom"_compute_chunk_atom.html - assign chunk IDs to each atom
"chunk/spread/atom"_compute_chunk_spread_atom.html - spreads chunk values to each atom in chunk
"cluster/atom"_compute_cluster_atom.html - cluster ID for each atom
"cna/atom"_compute_cna_atom.html - common neighbor analysis (CNA) for each atom
"cnp/atom"_compute_cnp_atom.html - common neighborhood parameter (CNP) for each atom
"com"_compute_com.html - center-of-mass of group of atoms
"com/chunk"_compute_com_chunk.html - center-of-mass for each chunk
"contact/atom"_compute_contact_atom.html - contact count for each spherical particle
"coord/atom"_compute_coord_atom.html - coordination number for each atom
"damage/atom"_compute_damage_atom.html - Peridynamic damage for each atom
"dihedral"_compute_dihedral.html - energy of each dihedral sub-style
"dihedral/local"_compute_dihedral_local.html - angle of each dihedral
"dilatation/atom"_compute_dilatation_atom.html - Peridynamic dilatation for each atom
"dipole/chunk"_compute_dipole_chunk.html - dipole vector and total dipole for each chunk
"displace/atom"_compute_displace_atom.html - displacement of each atom
"dpd"_compute_dpd.html -
"dpd/atom"_compute_dpd_atom.html -
"edpd/temp/atom"_compute_edpd_temp_atom.html - per-atom temperature for each eDPD particle in a group
"entropy/atom"_compute_entropy_atom.html - pair entropy fingerprint of each atom
"erotate/asphere"_compute_erotate_asphere.html - rotational energy of aspherical particles
"erotate/rigid"_compute_erotate_rigid.html - rotational energy of rigid bodies
"erotate/sphere"_compute_erotate_sphere.html - rotational energy of spherical particles
"erotate/sphere/atom"_compute_erotate_sphere_atom.html - rotational energy for each spherical particle
"event/displace"_compute_event_displace.html - detect event on atom displacement
"fep"_compute_fep.html -
"force/tally"_compute_tally.html -
"fragment/atom"_compute_cluster_atom.html - fragment ID for each atom
"global/atom"_compute_global_atom.html -
"group/group"_compute_group_group.html - energy/force between two groups of atoms
"gyration"_compute_gyration.html - radius of gyration of group of atoms
"gyration/chunk"_compute_gyration_chunk.html - radius of gyration for each chunk
"gyration/shape"_compute_gyration_shape.html - compute shape parameters from radius of gyration tensor
"heat/flux"_compute_heat_flux.html - heat flux through a group of atoms
"heat/flux/tally"_compute_tally.html -
"hexorder/atom"_compute_hexorder_atom.html - bond orientational order parameter q6
"improper"_compute_improper.html - energy of each improper sub-style
"improper/local"_compute_improper_local.html - angle of each improper
"inertia/chunk"_compute_inertia_chunk.html - inertia tensor for each chunk
"ke"_compute_ke.html - translational kinetic energy
"ke/atom"_compute_ke_atom.html - kinetic energy for each atom
"ke/atom/eff"_compute_ke_atom_eff.html - per-atom translational and radial kinetic energy in the electron force field model
"ke/eff"_compute_ke_eff.html - kinetic energy of a group of nuclei and electrons in the electron force field model
"ke/rigid"_compute_ke_rigid.html - translational kinetic energy of rigid bodies
"meso/e/atom"_compute_meso_e_atom.html - per-atom internal energy of Smooth-Particle Hydrodynamics atoms
"meso/rho/atom"_compute_meso_rho_atom.html - per-atom mesoscopic density of Smooth-Particle Hydrodynamics atoms
"meso/t/atom"_compute_meso_t_atom.html - per-atom internal temperature of Smooth-Particle Hydrodynamics atoms
"momentum"_compute_momentum.html - translational momentum
"msd"_compute_msd.html - mean-squared displacement of group of atoms
"msd/chunk"_compute_msd_chunk.html - mean-squared displacement for each chunk
"msd/nongauss"_compute_msd_nongauss.html - MSD and non-Gaussian parameter of group of atoms
"omega/chunk"_compute_omega_chunk.html - angular velocity for each chunk
"orientorder/atom"_compute_orientorder_atom.html - Steinhardt bond orientational order parameters Ql
"pair"_compute_pair.html - values computed by a pair style
"pair/local"_compute_pair_local.html - distance/energy/force of each pairwise interaction
"pe"_compute_pe.html - potential energy
"pe/atom"_compute_pe_atom.html - potential energy for each atom
"pe/mol/tally"_compute_tally.html -
"pe/tally"_compute_tally.html -
"plasticity/atom"_compute_plasticity_atom.html - Peridynamic plasticity for each atom
"pressure"_compute_pressure.html - total pressure and pressure tensor
"pressure/cylinder"_compute_pressure_cylinder.html - pressure tensor in cylindrical coordinates
"pressure/uef"_compute_pressure_uef.html - pressure tensor in the reference frame of an applied flow field 
"property/atom"_compute_property_atom.html - convert atom attributes to per-atom vectors/arrays
"property/chunk"_compute_property_chunk.html - extract various per-chunk attributes
"property/local"_compute_property_local.html - convert local attributes to localvectors/arrays
"ptm/atom"_compute_ptm_atom.html - determines the local lattice structure based on the Polyhedral Template Matching method
"rdf"_compute_rdf.html - radial distribution function g(r) histogram of group of atoms
"reduce"_compute_reduce.html - combine per-atom quantities into a single global value
"reduce/chunk"_compute_reduce_chunk.html - reduce per-atom quantities within each chunk
"reduce/region"_compute_reduce.html - same as compute reduce, within a region
"rigid/local"_compute_rigid_local.html - extract rigid body attributes
"saed"_compute_saed.html - electron diffraction intensity on a mesh of reciprocal lattice nodes
"slice"_compute_slice.html - extract values from global vector or array
"smd/contact/radius"_compute_smd_contact_radius.html -
"smd/damage"_compute_smd_damage.html - damage status of SPH particles in Smooth Mach Dynamics
"smd/hourglass/error"_compute_smd_hourglass_error.html -
"smd/internal/energy"_compute_smd_internal_energy.html - per-particle enthalpy in Smooth Mach Dynamics
"smd/plastic/strain"_compute_smd_plastic_strain.html - equivalent plastic strain per particle in Smooth Mach Dynamics
"smd/plastic/strain/rate"_compute_smd_plastic_strain_rate.html - time rate of the equivalent plastic strain in Smooth Mach Dynamics
"smd/rho"_compute_smd_rho.html - per-particle mass density in Smooth Mach Dynamics
"smd/tlsph/defgrad"_compute_smd_tlsph_defgrad.html - deformation gradient in Smooth Mach Dynamics
"smd/tlsph/dt"_compute_smd_tlsph_dt.html - CFL-stable time increment per particle in Smooth Mach Dynamics
"smd/tlsph/num/neighs"_compute_smd_tlsph_num_neighs.html -
"smd/tlsph/shape"_compute_smd_tlsph_shape.html -
"smd/tlsph/strain"_compute_smd_tlsph_strain.html -
"smd/tlsph/strain/rate"_compute_smd_tlsph_strain_rate.html -
"smd/tlsph/stress"_compute_smd_tlsph_stress.html - per-particle Cauchy stress tensor for SPH particles
"smd/triangle/vertices"_compute_smd_triangle_vertices.html -
"smd/ulsph/num/neighs"_compute_smd_ulsph_num_neighs.html -
"smd/ulsph/strain"_compute_smd_ulsph_strain.html -
"smd/ulsph/strain/rate"_compute_smd_ulsph_strain_rate.html -
"smd/ulsph/stress"_compute_smd_ulsph_stress.html - per-particle Cauchy stress tensor and von Mises equivalent stress in Smooth Mach Dynamics
"smd/vol"_compute_smd_vol.html - per-particle volumes and their sum in Smooth Mach Dynamics
"sna/atom"_compute_sna_atom.html - calculate bispectrum coefficients for each atom
"snad/atom"_compute_sna_atom.html - derivative of bispectrum coefficients for each atom
"snav/atom"_compute_sna_atom.html - virial contribution from bispectrum coefficients for each atom
"spin"_compute_spin.html - magnetic quantities for a system of atoms having spins
"stress/atom"_compute_stress_atom.html - stress tensor for each atom
"stress/mop"_compute_stress_mop.html - normal components of the local stress tensor using the method of planes
"stress/mop/profile"_compute_stress_mop.html - profile of the normal components of the local stress tensor using the method of planes
"stress/tally"_compute_tally.html -
"tdpd/cc/atom"_compute_tdpd_cc_atom.html - per-atom chemical concentration of a specified species for each tDPD particle 
"temp"_compute_temp.html - temperature of group of atoms
"temp/asphere"_compute_temp_asphere.html - temperature of aspherical particles
"temp/body"_compute_temp_body.html - temperature of body particles
"temp/chunk"_compute_temp_chunk.html - temperature of each chunk
"temp/com"_compute_temp_com.html - temperature after subtracting center-of-mass velocity
"temp/cs"_compute_temp_cs.html - temperature based on the center-of-mass velocity of atom pairs that are bonded to each other
"temp/deform"_compute_temp_deform.html - temperature excluding box deformation velocity
"temp/deform/eff"_compute_temp_deform_eff.html - temperature excluding box deformation velocity in the electron force field model
"temp/drude"_compute_temp_drude.html - temperature of Core-Drude pairs
"temp/eff"_compute_temp_eff.html - temperature of a group of nuclei and electrons in the electron force field model
"temp/partial"_compute_temp_partial.html - temperature excluding one or more dimensions of velocity
"temp/profile"_compute_temp_profile.html - temperature excluding a binned velocity profile
"temp/ramp"_compute_temp_ramp.html - temperature excluding ramped velocity component
"temp/region"_compute_temp_region.html - temperature of a region of atoms
"temp/region/eff"_compute_temp_region_eff.html - temperature of a region of nuclei and electrons in the electron force field model
"temp/rotate"_compute_temp_rotate.html - temperature of a group of atoms after subtracting out their center-of-mass and angular velocities
"temp/sphere"_compute_temp_sphere.html - temperature of spherical particles
"temp/uef"_compute_temp_uef.html - kinetic energy tensor in the reference frame of an applied flow field
"ti"_compute_ti.html - thermodynamic integration free energy values
"torque/chunk"_compute_torque_chunk.html - torque applied on each chunk
"vacf"_compute_vacf.html - velocity auto-correlation function of group of atoms
"vcm/chunk"_compute_vcm_chunk.html - velocity of center-of-mass for each chunk
"voronoi/atom"_compute_voronoi_atom.html - Voronoi volume and neighbors for each atom
"xrd"_compute_xrd.html - x-ray diffraction intensity on a mesh of reciprocal lattice nodes :ul

[Restrictions:] none

[Related commands:]

"uncompute"_uncompute.html, "compute_modify"_compute_modify.html, "fix
ave/atom"_fix_ave_atom.html, "fix ave/time"_fix_ave_time.html, "fix
ave/histo"_fix_ave_histo.html

[Default:] none
