LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands

### compute variable command

Syntax:

    compute ID group-ID variable name

- ID, group-ID are documented in compute command
- variable/atom = style name of this compute command
- name = variable name to invoke to compute a scalar quantity

Examples:

    compute 1 all variable myTemp

Description:

Define a computation that calculates a formula that returns a scalar quantity. This quantity can be time averaged and output via the fix ave/time command. It could also be output via the thermo_style custom command, although it makes more sense to access the variable directly in this case.

The formula is defined by the variable equal command. A variable of style equal 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 time average the system density (assuming the volume fluctuates) temperature and output the average value periodically to the file den.profile:

    variable den equal div(atoms,vol)
    compute density all variable den
    fix 1 all ave/time 1 1000 density 0 den.profile

Restrictions: none

Related commands:

fix ave/time, variable

Default: none