.. index:: compute rigid/local

compute rigid/local command
===========================

Syntax
""""""

.. parsed-literal::

   compute ID group-ID rigid/local rigidID input1 input2 ...

* ID, group-ID are documented in :doc:`compute <compute>` command
* rigid/local = style name of this compute command
* rigidID = ID of fix rigid/small command or one of its variants
* input = one or more rigid body attributes

  .. parsed-literal::

       possible attributes = id, mol, mass,
                             x, y, z, xu, yu, zu, ix, iy, iz
                             vx, vy, vz, fx, fy, fz,
                             omegax, omegay, omegaz,
                             angmomx, angmomy, angmomz,
                             quatw, quati, quatj, quatk,
                             tqx, tqy, tqz,
                             inertiax, inertiay, inertiaz
           id = atom ID of atom within body which owns body properties
           mol = molecule ID used to define body in :doc:`fix rigid/small <fix_rigid>` command
           mass = total mass of body
           x,y,z = center of mass coords of body
           xu,yu,zu = unwrapped center of mass coords of body
           ix,iy,iz = box image that the center of mass is in
           vx,vy,vz = center of mass velocities
           fx,fy,fz = force of center of mass
           omegax,omegay,omegaz = angular velocity of body
           angmomx,angmomy,angmomz = angular momentum of body
           quatw,quati,quatj,quatk = quaternion components for body
           tqx,tqy,tqz = torque on body
           inertiax,inertiay,inertiaz = diagonalized moments of inertia of body

Examples
""""""""

.. code-block:: LAMMPS

   compute 1 all rigid/local myRigid mol x y z

Description
"""""""""""

Define a computation that simply stores rigid body attributes for
rigid bodies defined by the :doc:`fix rigid/small <fix_rigid>` command
or one of its NVE, NVT, NPT, NPH variants.  The data is stored as
local data so it can be accessed by other :doc:`output commands <Howto_output>` that process local data, such as the
:doc:`compute reduce <compute_reduce>` or :doc:`dump local <dump>`
commands.

Note that this command only works with the :doc:`fix rigid/small <fix_rigid>` command or its variants, not the fix rigid
command and its variants.  The ID of the :doc:`fix rigid/small <fix_rigid>` command used to define rigid bodies must
be specified as *rigidID*\ .  The :doc:`fix rigid <fix_rigid>` command is
typically used to define a handful of (potentially very large) rigid
bodies.  It outputs similar per-body information as this command
directly from the fix as global data; see the :doc:`fix rigid <fix_rigid>` doc page for details

The local data stored by this command is generated by looping over all
the atoms owned on a processor.  If the atom is not in the specified
*group-ID* or is not part of a rigid body it is skipped.  If it is not
the atom within a body that is assigned to store the body information
it is skipped (only one atom per body is so assigned).  If it is the
assigned atom, then the info for that body is output.  This means that
information for N bodies is generated.  N may be less than the # of
bodies defined by the fix rigid command, if the atoms in some bodies
are not in the *group-ID*\ .

.. note::

   Which atom in a body owns the body info is determined internal
   to LAMMPS; it's the one nearest the geometric center of the body.
   Typically you should avoid this complication, by defining the group
   associated with this fix to include/exclude entire bodies.

Note that as atoms and bodies migrate from processor to processor,
there will be no consistent ordering of the entries within the local
vector or array from one timestep to the next.

Here is an example of how to use this compute to dump rigid body info
to a file:

.. code-block:: LAMMPS

   compute 1 all rigid/local myRigid mol x y z fx fy fz
   dump 1 all local 1000 tmp.dump index c_1[1] c_1[2] c_1[3] c_1[4] c_1[5] c_1[6] c_1[7]

----------

This section explains the rigid body attributes that can be specified.

The *id* attribute is the atom-ID of the atom which owns the rigid body, which is
assigned by the :doc:`fix rigid/small <fix_rigid>` command.

The *mol* attribute is the molecule ID of the rigid body.  It should
be the molecule ID which all of the atoms in the body belong to, since
that is how the :doc:`fix rigid/small <fix_rigid>` command defines its
rigid bodies.

The *mass* attribute is the total mass of the rigid body.

There are two options for outputting the coordinates of the center of
mass (COM) of the body.  The *x*\ , *y*\ , *z* attributes write the COM
"unscaled", in the appropriate distance :doc:`units <units>` (Angstroms,
sigma, etc).  Use *xu*\ , *yu*\ , *zu* if you want the COM "unwrapped" by
the image flags for each body.  Unwrapped means that if the body
COM has passed through a periodic boundary one or more times, the value
is generated what the COM coordinate would be if it had not been
wrapped back into the periodic box.

The image flags for the body can be generated directly using the *ix*\ ,
*iy*\ , *iz* attributes.  For periodic dimensions, they specify which
image of the simulation box the COM is considered to be in.  An image
of 0 means it is inside the box as defined.  A value of 2 means add 2
box lengths to get the true value.  A value of -1 means subtract 1 box
length to get the true value.  LAMMPS updates these flags as the rigid
body COMs cross periodic boundaries during the simulation.

The *vx*\ , *vy*\ , *vz*\ , *fx*\ , *fy*\ , *fz* attributes are components of
the COM velocity and force on the COM of the body.

The *omegax*\ , *omegay*\ , and *omegaz* attributes are the angular
velocity components of the body around its COM.

The *angmomx*\ , *angmomy*\ , and *angmomz* attributes are the angular
momentum components of the body around its COM.

The *quatw*\ , *quati*\ , *quatj*\ , and *quatk* attributes are the
components of the 4-vector quaternion representing the orientation of
the rigid body.  See the :doc:`set <set>` command for an explanation of
the quaternion vector.

The *angmomx*\ , *angmomy*\ , and *angmomz* attributes are the angular
momentum components of the body around its COM.

The *tqx*\ , *tqy*\ , *tqz* attributes are components of the torque acting
on the body around its COM.

The *inertiax*\ , *inertiay*\ , *inertiaz* attributes are components of
diagonalized inertia tensor for the body, i.e the 3 moments of inertia
for the body around its principal axes, as computed internally by
LAMMPS.

----------

**Output info:**

This compute calculates a local vector or local array depending on the
number of keywords.  The length of the vector or number of rows in the
array is the number of rigid bodies.  If a single keyword is
specified, a local vector is produced.  If two or more keywords are
specified, a local array is produced where the number of columns = the
number of keywords.  The vector or array can be accessed by any
command that uses local values from a compute as input.  See the
:doc:`Howto output <Howto_output>` doc page for an overview of LAMMPS
output options.

The vector or array values will be in whatever :doc:`units <units>` the
corresponding attribute is in:

* id,mol = unitless
* mass = mass units
* x,y,z and xy,yu,zu = distance units
* vx,vy,vz = velocity units
* fx,fy,fz = force units
* omegax,omegay,omegaz = radians/time units
* angmomx,angmomy,angmomz = mass\*distance\^2/time units
* quatw,quati,quatj,quatk = unitless
* tqx,tqy,tqz = torque units
* inertiax,inertiay,inertiaz = mass\*distance\^2 units

Restrictions
""""""""""""

This compute is part of the RIGID package.  It is only enabled if
LAMMPS was built with that package.  See the :doc:`Build package <Build_package>` doc page for more info.

Related commands
""""""""""""""""

:doc:`dump local <dump>`, :doc:`compute reduce <compute_reduce>`

**Default:** none
