LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands

compute sum command

Syntax:

compute ID group-ID sum value1 value2 ... 

Examples:

compute 1 all sum c_force
compute 2 all sum c_press2 f_ave v_myKE 

Description:

Define a calculation that sums the results of one or more per-atom quantities across all atoms in the group to yield a global scalar or vector quantity. The resulting value(s) can be accessed by any command that uses global computes, e.g. the thermo custom command or fix ave/time command or by a variable command. See this section of the documentation for an overview of output options.

Each listed value is summed independently. The group specified with the command means only atoms within the group contribute to the sum. Note that the value that produces the per-atom quantities may define its own group which affects the values it returns. For example, if a per-atom compute is used as a value, it will generate values of 0.0 for atoms that are not in the group specified for that compute.

Each listed value can be an atom attribute (position, velocity, force component) or can be the result of a compute or fix or the evaluation of an atom-style variable. In the latter cases, the compute, fix, or variable must produce a per-atom quantity, not a global quantity.

Computes that produce per-atom quantities are those which have the word atom in their style name. See the doc pages for individual fixes to determine which ones produce per-atom quantities. Variables of style atom are the only ones that can be used with this compute since all other variable styles produce global quantities.

If a single value is specified this compute produces a global scalar value. If multiple values are specified, this compute produces a vector of global values, the length of which is equal to the number of values specified.

The value(s) produced by this compute are all "extensive", meaning their value scales linearly with the number of atoms involved. If normalized values are desired, this compute can be accessed by the thermo_style custom command with thermo_modify norm yes set as an option. Or it can be accessed by a variable that divides by the appropriate atom count.

Output info:

The scalar and vector values calculated by this compute are "extensive", meaning they scale with the number of atoms in the simulation.

Restrictions: none

Related commands:

compute, fix, variable

Default: none