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

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

:line

compute variable/atom command :h3

[Syntax:]

compute ID group-ID variable/atom name :pre

ID, group-ID are documented in "compute"_compute.html command
variable/atom = style name of this compute command
name = variable name to invoke for each atom :ul

[Examples:]

compute 1 flow variable/atom myVar :pre

[Description:]

Define a computation that calculates a formula for each atom in the
group.  The resulting values can be accessed by any command that uses
per-atom computes, e.g. the "dump custom"_dump.html command or "fix
ave/spatial"_fix_ave_spatial.html command or "fix
ave/atom"_fix_ave_atom.html command.

The value of the variable evaluation will be 0.0 for atoms not in the
specified compute group.

The formula is defined by the "variable atom"_variable.html command.
A variable of style {atom} can access properties of the system, such
as volume or temperature, and also reference individual atom
attributes, such as its coordinates or velocity.

For example, these 3 commands would compute the xy kinectic energy of
atoms in the flow group and include the values in dumped snapshots of
the system.

variable xy atom mult(0.5,add(mult(vx\[\],vx\[\]),mult(vy\[\],vy\[\])))
compute ke flow variable/atom xy
dump 1 flow custom 1000 dump.flow tag type x y z c_ke :pre

If the dump line were replaced by

fix 1 flow ave/spatial 100 1000 z lower 2.0 ke.profile compute ke :pre

then the xy kinetic energy values would be averaged by z layer and the
layer averages written periodically to the file ke.profile.

[Restrictions:] none

[Related commands:]

"dump custom"_dump.html, "fix ave/spatial"_fix_ave_spatial.html

[Default:] none
