fix ave/histo command
fix ave/histo/weight command
Syntax
fix ID group-ID style Nevery Nrepeat Nfreq lo hi Nbin value1 value2 ... keyword args ...
ID, group-ID are documented in fix command
style = ave/histo or ave/histo/weight = style name of this fix command
Nevery = use input values every this many timesteps
Nrepeat = # of times to use input values for calculating histogram
Nfreq = calculate histogram every this many timesteps
lo,hi = lo/hi bounds within which to histogram
Nbin = # of histogram bins
one or more input values can be listed
value = x, y, z, vx, vy, vz, fx, fy, fz, c_ID, c_ID[N], f_ID, f_ID[N], v_name
x,y,z,vx,vy,vz,fx,fy,fz = atom attribute (position, velocity, force component) c_ID = scalar or vector calculated by a compute with ID c_ID[I] = Ith component of vector or Ith column of array calculated by a compute with ID, I can include wildcard (see below) f_ID = scalar or vector calculated by a fix with ID f_ID[I] = Ith component of vector or Ith column of array calculated by a fix with ID, I can include wildcard (see below) v_name = value(s) calculated by an equal-style or vector-style or atom-style variable with name v_name[I] = value calculated by a vector-style variable with name, I can include wildcard (see below)
zero or more keyword/arg pairs may be appended
keyword = mode or kind or file or ave or start or beyond or overwrite or title1 or title2 or title3
mode arg = scalar or vector scalar = all input values are scalars vector = all input values are vectors kind arg = global or peratom or local file arg = filename filename = name of file to output histogram(s) to ave args = one or running or window one = output a new average value every Nfreq steps running = output cumulative average of all previous Nfreq steps window M = output average of M most recent Nfreq steps start args = Nstart Nstart = start averaging on this timestep beyond arg = ignore or end or extra ignore = ignore values outside histogram lo/hi bounds end = count values outside histogram lo/hi bounds in end bins extra = create 2 extra bins for value outside histogram lo/hi bounds overwrite arg = none = overwrite output file with only latest output title1 arg = string string = text to print as 1st line of output file title2 arg = string string = text to print as 2nd line of output file title3 arg = string string = text to print as 3rd line of output file, only for vector mode
Examples
fix 1 all ave/histo 100 5 1000 0.5 1.5 50 c_myTemp file temp.histo ave running
fix 1 all ave/histo 100 5 1000 -5 5 100 c_thermo_press[2] c_thermo_press[3] title1 "My output values"
fix 1 all ave/histo 100 5 1000 -5 5 100 c_thermo_press[*]
fix 1 all ave/histo 1 100 1000 -2.0 2.0 18 vx vy vz mode vector ave running beyond extra
fix 1 all ave/histo/weight 1 1 1 10 100 2000 c_XRD[1] c_XRD[2]
Description
Use one or more values as inputs every few timesteps to create a single histogram. The histogram can then be averaged over longer timescales. The resulting histogram can be used by other output commands, and can also be written to a file. The fix ave/histo/weight command has identical syntax to fix ave/histo, except that exactly two values must be specified. See details below.
The group specified with this command is ignored for global and local input values. For per-atom input values, only atoms in the group contribute to the histogram. Note that regardless of the specified group, specified values may represent calculations performed by computes and fixes which store their own “group” definition.
A histogram is simply a count of the number of values that fall within a histogram bin. Nbins are defined, with even spacing between lo and hi. Values that fall outside the lo/hi bounds can be treated in different ways; see the discussion of the beyond keyword below.
Each input value can be an atom attribute (position, velocity, force component) or can be the result of a compute or fix or the evaluation of an equal-style or vector-style or atom-style variable. The set of input values can be either all global, all per-atom, or all local quantities. Inputs of different kinds (e.g. global and per-atom) cannot be mixed. Atom attributes are per-atom vector values. See the page for individual “compute” and “fix” commands to see what kinds of quantities they generate. See the optional kind keyword below for how to force the fix ave/histo command to disambiguate if necessary.
Note that the output of this command is a single histogram for all input values combined together, not one histogram per input value. See below for details on the format of the output of this fix.
The input values must either be all scalars or all vectors (or arrays), depending on the setting of the mode keyword.
If mode = scalar, then the input values must be scalars, or vectors with a bracketed term appended, indicating the Ith value of the vector is used.
If mode = vector, then the input values must be vectors, or arrays with a bracketed term appended, indicating the Ith column of the array is used.
If the fix ave/histo/weight command is used, exactly two values must
be specified. If the values are vectors, they must be the same
length. The first value (a scalar or vector) is what is histogrammed
into bins, in the same manner the fix ave/histo command operates. The
second value (a scalar or vector) is used as a “weight”. This means
that instead of each value tallying a “1” to its bin, the
corresponding weight is tallied. For example, the
For input values from a compute or fix or variable, the bracketed
index I can be specified using a wildcard asterisk with the index to
effectively specify multiple values. This takes the form “*” or
“*n” or “m*” or “m*n”. If
Using a wildcard is the same as if the individual elements of the vector or columns of the array had been listed one by one. For example, the following two fix ave/histo commands are equivalent, since the compute com/chunk command creates a global array with three columns:
compute myCOM all com/chunk
fix 1 all ave/histo 100 1 100 -10.0 10.0 100 c_myCOM[*] file tmp1.com mode vector
fix 2 all ave/histo 100 1 100 -10.0 10.0 100 c_myCOM[1] c_myCOM[2] c_myCOM[3] file tmp2.com mode vector
Note
For a vector-style variable, only the wildcard forms “*n” or “m*n” are allowed. You must specify the upper bound, because vector-style variable lengths are not determined until the variable is evaluated. If n is specified larger than the vector length turns out to be, zeroes are output for missing vector values.
The
For example, if
The atom attribute values (x, y, z, vx, vy, vz, fx, fy, and fz) are self-explanatory. Note that other atom attributes can be used as inputs to this fix by using the compute property/atom command and then specifying an input value from that compute.
If a value begins with “c_”, a compute ID must follow which has been previously defined in the input script. If mode = scalar, then if no bracketed term is appended, the global scalar calculated by the compute is used. If a bracketed term is appended, the Ith element of the global vector calculated by the compute is used. If mode = vector, then if no bracketed term is appended, the global or per-atom or local vector calculated by the compute is used. If a bracketed term is appended, the Ith column of the global or per-atom or local array calculated by the compute is used. See the discussion above for how I can be specified with a wildcard asterisk to effectively specify multiple values.
Note that there is a compute reduce command that can sum per-atom quantities into a global scalar or vector, which can then be accessed by fix ave/histo. It can also be a compute defined not in your input script, but by thermodynamic output or other fixes such as fix nvt or fix temp/rescale. See the doc pages for these commands which give the IDs of these computes. Users can also write code for their own compute styles and add them to LAMMPS.
If a value begins with “f_”, a fix ID must follow which has been
previously defined in the input script. If mode = scalar, then if
no bracketed term is appended, the global scalar calculated by the fix
is used. If a bracketed term is appended, the Ith element of the
global vector calculated by the fix is used. If mode = vector, then
if no bracketed term is appended, the global or per-atom or local
vector calculated by the fix is used. If a bracketed term is
appended, the
Note that some fixes only produce their values on certain timesteps,
which must be compatible with
If a value begins with “v_”, a variable name must follow which has
been previously defined in the input script. If mode = scalar, then
only equal-style or vector-style variables can be used, which both
produce global values. In this mode, a vector-style variable requires
a bracketed term to specify the
Note that variables of style equal, vector, and atom define a formula which can reference individual atom properties or thermodynamic keywords, or they can invoke other computes, fixes, or variables when they are evaluated, so this is a very general means of specifying quantities to histogram.
Additional optional keywords also affect the operation of this fix.
If the mode keyword is set to scalar, then all input values must be global scalars, or elements of global vectors. If the mode keyword is set to vector, then all input values must be global or per-atom or local vectors, or columns of global or per-atom or local arrays.
The kind keyword only needs to be set if a compute or fix produces more than one kind of output (global, per-atom, local). If this is not the case, then LAMMPS will determine what kind of input is provided and whether all the input arguments are consistent. If a compute or fix produces more than one kind of output, the kind keyword should be used to specify which output will be used. The remaining input arguments must still be consistent.
The beyond keyword determines how input values that fall outside the
lo to hi bounds are treated. Values such that lo
The ave keyword determines how the histogram produced every
If the ave setting is one, then the histograms produced on
timesteps that are multiples of
If the ave setting is running, then the histograms produced on
timesteps that are multiples of
If the ave setting is window, then the histograms produced on
timesteps that are multiples of
The start keyword specifies what timestep histogramming will begin on. The default is step 0. Often input values can be 0.0 at time 0, so setting start to a larger value can avoid including a 0.0 in a running or windowed histogram.
The file keyword allows a filename to be specified. Every Nfreq steps, one histogram is written to the file. This includes a leading line that contains the timestep, number of bins, the total count of values contributing to the histogram, the count of values that were not histogrammed (see the beyond keyword), the minimum value encountered, and the maximum value encountered. The min/max values include values that were not histogrammed. Following the leading line, one line per bin is written into the file. Each line contains the bin #, the coordinate for the center of the bin (between lo and hi), the count of values in the bin, and the normalized count. The normalized count is the bin count divided by the total count (not including values not histogrammed), so that the normalized values sum to 1.0 across all bins.
The overwrite keyword will continuously overwrite the output file with the latest output, so that it only contains one timestep worth of output. This option can only be used with the ave running setting.
The title1, title2, and title3 keywords allow specification of the strings that will be printed as the first three lines of the output file, assuming the file keyword was used. LAMMPS uses default values for each of these, so they do not need to be specified.
By default, these header lines are as follows:
# Histogram for fix ID
# TimeStep Number-of-bins Total-counts Missing-counts Min-value Max-value
# Bin Coord Count Count/Total
In the first line, ID is replaced with the fix-ID. The second line describes the six values that are printed at the first of each section of output. The third describes the four values printed for each bin in the histogram.
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.
This fix produces a global vector and global array which can be
accessed by various output commands. The values
can only be accessed on timesteps that are multiples of
1 = total counts in the histogram
2 = values that were not histogrammed (see beyond keyword)
3 = min value of all input values, including ones not histogrammed
4 = max value of all input values, including ones not histogrammed
The global array has
The vector and array values calculated by this fix are all treated as intensive. If this is not the case (e.g., due to histogramming per-atom input values), then you will need to account for that when interpreting the values produced by this fix.
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
none
Default
none
The option defaults are mode = scalar, kind = figured out from input arguments, ave = one, start = 0, no file output, beyond = ignore, and title 1,2,3 = strings as described above.