compute ID group-ID atom/molecule input1 input2 ...
c_ID = per-atom vector calculated by a compute with ID c_ID[I] = Ith column of per-atom array calculated by a compute with ID f_ID = per-atom vector calculated by a fix with ID f_ID[I] = Ith column of per-atom array calculated by a fix with ID v_name = per-atom vector calculated by an atom-style variable with name
compute 1 all atom/molecule c_ke c_pe compute 1 top atom/molecule v_myFormula c_stress
Define a calculation that sums per-atom values on a per-molecule basis, one per listed input. The inputs can computes, fixes, or variables that generate per-atom quantities. Note that attributes stored by atoms, such as mass or force, can also be summed on a per-molecule basis, by accessing these quantities via the compute property/atom command.
Each listed input is operated on independently. Only atoms within the specified group contribute to the per-molecule sum. Note that compute or fix inputs define their own group which may affect the quantities they return. For example, if a compute is used as an input which generates a per-atom vector, it will generate values of 0.0 for atoms that are not in the group specified for that compute.
The ordering of per-molecule quantities produced by this compute is consistent with the ordering produced by other compute commands that generate per-molecule datums. Conceptually, them molecule IDs will be in ascending order for any molecule with one or more of its atoms in the specified group.
If an input begins with "c_", a compute ID must follow which has been previously defined in the input script and which generates per-atom quantities. See the individual compute doc page for details. If no bracketed integer is appended, the vector calculated by the compute is used. If a bracketed integer is appended, the Ith column of the array calculated by the compute is used. Users can also write code for their own compute styles and add them to LAMMPS.
If an input begins with "f_", a fix ID must follow which has been previously defined in the input script and which generates per-atom quantities. See the individual fix doc page for details. Note that some fixes only produce their values on certain timesteps, which must be compatible with when compute atom/molecule references the values, else an error results. If no bracketed integer is appended, the vector calculated by the fix is used. If a bracketed integer is appended, the Ith column of the array calculated by the fix is used. Users can also write code for their own fix style and add them to LAMMPS.
If an input begins with "v_", a variable name must follow which has been previously defined in the input script. It must be an atom-style variable. Atom-style variables can reference thermodynamic keywords and various per-atom attributes, or invoke other computes, fixes, or variables when they are evaluated, so this is a very general means of generating per-atom quantities to sum on a per-molecule basis.
Here is an example of using this command to sum up the components of total force on each molecule and print them to a file every 1000 timesteps. The printed values could also be time-averaged by the fix ave/time command if desired, by changing "1000 1 1000" to "10 100 1000" (for example):
compute 1 all property/atom fx fy fz compute 2 all atom/molecule c_1 c_1 c_1 fix 1 all ave/time 1000 1 1000 c_2 mode vector file tmp.molecule.force
This compute calculates a global vector or global array depending on the number of input values. The length of the vector or number of rows in the array is the number of molecules. If a single input is specified, a global vector is produced. If two or more inputs are specified, a global array is produced where the number of columns = the number of inputs. The vector or array can be accessed by any command that uses global values from a compute as input. See this section for an overview of LAMMPS output options.
All the vector or array values calculated by this compute are "extensive".
The vector or array values will be in whatever units the input quantities are in.
compute, fix, variable