LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands

fix ave/spatial command

Syntax:

fix ID group-ID ave/spatial Nevery Nfreq dim origin delta file keyword value ... 
  density value = none
  atom value = vx or vy or vz or fx or fy or fz
  compute value = compute-ID that calculates per-atom quantities 

Examples:

fix 1 all ave/time 10000 10000 z lower 2.0 centro.profile compute myCentro
fix 1 flow ave/time 100 1000 y 0.0 1.0 vel.profile atom vx 

Description:

Calculate one or more instantaneous per-atom quantities every few timesteps, average them by layer in a chosen dimension and over a longer timescale, and print the results to a file. This can be used to spatially average per-atom properties such as velocity or energy or a quantity calculated by an equation you define; see the variable atom command.

The density keyword means to simply count the number of atoms in each layer. The atom keyword allows an atom property such as x-velocity to be specified. The compute keyword allows specification of a compute which will be invoked to calculate the desired property. The compute can be previously defined in the input script. Note that the "compute variable/atom" style allows you to calculate any quantity for an atom that can be specified by a variable atom equation. Users can also write code for their own compute styles and add them to LAMMPS. Note that the dump custom command can also be used to output per-atom quantities calculated by a compute.

For the compute keyword, the fix ave/spatial style uses the per-atom scalar or vector calculated by the compute. See the fix ave/time command if you wish to time-average a global quantity, e.g. via a compute that temperature or pressure.

In all cases, the calculated property is averaged over atoms in each layer, where the layers are in a particular dim and have a thickness given by delta. Every Nfreq steps, when a property is calculated for the first time (after a previous write), the number of layers and the layer boundaries are computed. Thus if the simlation box changes size during a simulation, the number of layers and their boundaries may also change. Layers are defined relative to a specified origin, which may be the lower/upper edge of the box (in dim) or its center point, or a specified coordinate value. Starting at the origin, sufficient layers are created in both directions to completely cover the box. On subsequent timesteps every atom is mapped to one of the layers. Atoms beyond the lowermost/uppermost layer are counted in the first/last layer.

The Nevery and Nfreq arguments specify how the property calculated for each layer is time-averaged. The property is calculated once each Nevery timesteps. It is averaged and output every Nfreq timesteps. Nfreq must be a multiple of Nevery. In the 2nd example above, the property is calculated every 100 steps. After 10 calculations, the average result is written to the file, once every 1000 steps.

Each time info is written to the file, it is in the following format. A line with the timestep and number of layers is written. Then one line per layer is written, containing the layer ID (1-N), the coordinate of the center of the layer, the number of atoms in the layer, and one or more calculated values. The number of atoms and the value(s) are average quantities.

If the density or atom keyword is used, or the compute keyword with a compute that calculates a single quantity per atom, then a single value will be printed for each layer. If the compute keyword is used with a compute that calculates N quantities per atom, then N values per line will be written, each of them averaged independently.

Note that for the density keyword, the printed count of atoms in the layer is actually what you should use to infer a density. The calculated value is always 1.0, since it is normalized by the number of atoms in the layer.

For the compute keyword, the calculation performed by the compute in on the group defined by the compute. However, only atoms in the fix group are included in the layer averaging. LAMMPS prints a warning if the fix group and compute group do not match.

Note that some computes perform costly calculations, involving use of or creation of neighbor lists. If the compute is invoked too often by fix ave/spatial, it can slow down a simulation.

Restrictions: none

Related commands:

compute, fix ave/time

Default: none