LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Commands

### fix ave/time command

Syntax:

    fix ID group-ID ave/time Nevery Nrepeat Nfreq style ID keyword args ...

- ID, group-ID are documented in fix command
- ave/time = style name of this fix command
- Nevery = calculate property every this many timesteps
- Nrepeat = # of times to repeat the Nevery calculation before averaging
- Nfreq = timestep frequency at which the average value is computed
- style = compute or fix
- ID = ID of compute or fix that performs the calculation
- zero or more keyword/arg pairs may be appended
- keyword = type or file or ave

        type arg = scalar or vector or both
          scalar = single scalar value from fix or compute
          vector = vector of values from fix or compute
          both = both a single value and vector of values from fix or compute
        file arg = filename
          filename = name of file to output time averages to
        ave args = one or running or window M
          one = output new average value every Nfreq steps
          running = output cummulative average of all previous Nfreq steps
          window M = output average of M most recent Nfreq steps

Examples:

    fix 1 all ave/time 100 5 1000 compute myTemp
    fix 1 all ave/time 100 5 1000 compute myTemp ave window 20
    fix 1 all ave/time 1 100 1000 fix indenter value both file temp.indent

Description:

Calculate one or more instantaneous quantities every few timesteps, and average them over a longer timescale. The resulting averages can be used by other output commands such as thermo_style custom, and also written to a file.

This fix can be used to time-average a compute which calculates a global quantity such as a temperature or pressure or a fix which calculates a global quantity. Note that per-atom quantities cannot be averaged with this fix; their values can be averaged by the fix ave/spatial or fix ave/atom commands.

Since the calculation is performed by the compute or fix which stores its own "group" definition, the group specified as part of the fix ave/time command is ignored.

For style compute the ID specifies a compute which calculates the desired property. The compute must be a "global" compute that calculates one or more global properties rather than a "per-atom" compute. However, there is a compute sum command which sums per-atom quantities into a global scalar or vector which can be accessed by fix ave/time.

The compute must be previously defined in the input script. Or it can be a compute defined by thermodynamic output or other fixes such as fix nvt or fix temp/rescale. Users can write code for their own compute styles and add them to LAMMPS.

For style fix the ID specifies a fix which calculates the desired property. The fix must calculate a global scalar or vector quantity, which only a few fixes do. See the doc page for individual fix commands for details. The fix must be previously defined in the input script. Users can write code for their own fix styles and add them to LAMMPS.

The Nevery, Nrepeat, and Nfreq arguments specify on what timesteps the property will be evaluated in order to contribute to the average. The final averaged value(s) are computed every Nfreq timesteps. The average is over Nrepeat values, computed in the preceeding portion of the simulation every Nevery timesteps. Nfreq must be a multiple of Nevery and Nevery must be non-zero even if Nrepeat is 1.

For example, if Nevery=2, Nrepeat=6, and Nfreq=100, then values on timesteps 90,92,94,96,98,100 will be used to compute the final average on timestep 100. Similary for timesteps 190,192,194,196,198,200 on timestep 200, etc.

Additional optional keywords also affect the operation of this fix.

The type keyword chooses whether the scalar and/or vector quantities produced by the compute or fix are used. For a setting of scalar a single global value is used. For a setting of vector N global values are used, where N is defined by the compute or fix, e.g. 6 pressure tensor components. For a setting of both, both a scalar the vector values are used. When vectors are used, each of the N values is averaged independently.

The file keyword allows a filename to be specified. The scalar and/or N vector quantities are written to the file in a self-explanatory text format.

The ave keyword determines how the scalar and/or vector values produced every Nfreq steps are averaged with values produced on previous steps that were multiples of Nfreq, before they are accessed by another output command or written to a file.

If the ave setting is one, then the values produced on timesteps that are multiples of Nfreq are independent of each other; they are output as-is without further averaging.

If the ave setting is running, then the values produced on timesteps that are multiples of Nfreq are summed and averaged in a cummulative sense before being output. Each output value is thus the average of the value produced on that timestep with all preceeding values. This running average begins when the fix is defined; it can only be restarted by deleting the fix via the unfix command, or re-defining the fix by re-specifying it.

If the ave setting is window, then the values produced on timesteps that are multiples of Nfreq are summed and averaged within a moving "window" of time, so that the last M values are used to produce the output. E.g. if M = 3 and Nfreq = 1000, then the output on step 10000 will be the average of the individual values on steps 8000,9000,10000. Outputs on early steps will average over less than M values if they are not available.

Restart, fix_modify, output, run start/stop, minimize info:

No information about this fix is written to binary restart files. None of the fix_modify options are relevant to this fix.

Depending on the setting of the type parameter, this fix computes a scalar and/or a vector of quantities which can be accessed by various output commands. The values should only be accessed on timesteps that are multiples of Nfreq since that is when averaging is performed.

No parameter of this fix can be used with the start/stop keywords of the run command. This fix is not invoked during energy minimization.

Restrictions:

If the style is compute and the specified compute calculates pressure, it will cause the force computations performed by LAMMPS (pair, bond, angle, etc) to calculate virial terms each Nevery timesteps. If this is more frequent than thermodynamic output, this adds extra cost to a simulation. However, if a constant pressure simulation is being run (fix npt or fix nph), LAMMPS is already calculating virial terms for the pressure every timestep.

Related commands:

compute, fix ave/atom, fix ave/spatial

Default: none

The option defaults are type = scalar, no file output, and ave = one.