1 "LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
3 :link(lws,http://lammps.sandia.gov)
5 :link(lc,Section_commands.html#comm)
9 fix ave/time command :h3
13 fix ID group-ID ave/time Nevery Nrepeat Nfreq value1 value2 ... keyword args ... :pre
15 ID, group-ID are documented in "fix"_fix.html command :ulb,l
16 ave/time = style name of this fix command :l
17 Nevery = use input values every this many timesteps :l
18 Nrepeat = # of times to use input values for calculating averages :l
19 Nfreq = calculate averages every this many timesteps :l
20 one or more input values can be listed :l
21 value = c_ID, c_ID\[N\], f_ID, f_ID\[N\], v_name :l
22 c_ID = global scalar or vector calculated by a compute with ID
23 c_ID\[I\] = Ith component of global vector or Ith column of global array calculated by a compute with ID, I can include wildcard (see below)
24 f_ID = global scalar or vector calculated by a fix with ID
25 f_ID\[I\] = Ith component of global vector or Ith column of global array calculated by a fix with ID, I can include wildcard (see below)
26 v_name = value(s) calculated by an equal-style or vector-style variable with name
27 v_name\[I\] = value calculated by a vector-style variable with name :pre
29 zero or more keyword/arg pairs may be appended :l
30 keyword = {mode} or {file} or {ave} or {start} or {off} or {overwrite} or {title1} or {title2} or {title3} :l
31 {mode} arg = {scalar} or {vector}
32 scalar = all input values are global scalars
33 vector = all input values are global vectors or global arrays
34 {ave} args = {one} or {running} or {window M}
35 one = output a new average value every Nfreq steps
36 running = output cummulative average of all previous Nfreq steps
37 window M = output average of M most recent Nfreq steps
39 Nstart = start averaging on this timestep
40 {off} arg = M = do not average this value
41 M = value # from 1 to Nvalues
43 filename = name of file to output time averages to
44 {overwrite} arg = none = overwrite output file with only latest output
46 string = C-style format string
48 string = text to print as 1st line of output file
50 string = text to print as 2nd line of output file
52 string = text to print as 3rd line of output file, only for vector mode :pre
57 fix 1 all ave/time 100 5 1000 c_myTemp c_thermo_temp file temp.profile
58 fix 1 all ave/time 100 5 1000 c_thermo_press\[2\] ave window 20 &
59 title1 "My output values"
60 fix 1 all ave/time 100 5 1000 c_thermo_press\[*\]
61 fix 1 all ave/time 1 100 1000 f_indent f_indent\[1\] file temp.indent off 1 :pre
65 Use one or more global values as inputs every few timesteps, and
66 average them over longer timescales. The resulting averages can be
67 used by other "output commands"_Section_howto.html#howto_15 such as
68 "thermo_style custom"_thermo_style.html, and can also be written to a
69 file. Note that if no time averaging is done, this command can be
70 used as a convenient way to simply output one or more global values to
73 The group specified with this command is ignored. However, note that
74 specified values may represent calculations performed by computes and
75 fixes which store their own "group" definitions.
77 Each listed value can be the result of a "compute"_compute.html or
78 "fix"_fix.html or the evaluation of an equal-style or vector-style
79 "variable"_variable.html. In each case, the compute, fix, or variable
80 must produce a global quantity, not a per-atom or local quantity. If
81 you wish to spatial- or time-average or histogram per-atom quantities
82 from a compute, fix, or variable, then see the "fix
83 ave/chunk"_fix_ave_chunk.html, "fix ave/atom"_fix_ave_atom.html,
84 or "fix ave/histo"_fix_ave_histo.html commands. If you wish to sum a
85 per-atom quantity into a single global quantity, see the "compute
86 reduce"_compute_reduce.html command.
88 "Computes"_compute.html that produce global quantities are those which
89 do not have the word {atom} in their style name. Only a few
90 "fixes"_fix.html produce global quantities. See the doc pages for
91 individual fixes for info on which ones produce such values.
92 "Variables"_variable.html of style {equal} and {vector} are the only
93 ones that can be used with this fix. Variables of style {atom} cannot
94 be used, since they produce per-atom values.
96 The input values must either be all scalars or all vectors depending
97 on the setting of the {mode} keyword. In both cases, the averaging is
98 performed independently on each input value. I.e. each input scalar
99 is averaged independently or each element of each input vector is
100 averaged independently.
102 If {mode} = scalar, then the input values must be scalars, or vectors
103 with a bracketed term appended, indicating the Ith value of the vector
106 If {mode} = vector, then the input values must be vectors, or arrays
107 with a bracketed term appended, indicating the Ith column of the array
108 is used. All vectors must be the same length, which is the length of
109 the vector or number of rows in the array.
111 Note that for values from a compute or fix, the bracketed index I can
112 be specified using a wildcard asterisk with the index to effectively
113 specify multiple values. This takes the form "*" or "*n" or "n*" or
114 "m*n". If N = the size of the vector (for {mode} = scalar) or the
115 number of columns in the array (for {mode} = vector), then an asterisk
116 with no numeric values means all indices from 1 to N. A leading
117 asterisk means all indices from 1 to n (inclusive). A trailing
118 asterisk means all indices from n to N (inclusive). A middle asterisk
119 means all indices from m to n (inclusive).
121 Using a wildcard is the same as if the individual elements of the
122 vector or columns of the array had been listed one by one. E.g. these
123 2 fix ave/time commands are equivalent, since the "compute
124 rdf"_compute_rdf.html command creates, in this case, a global array
125 with 3 columns, each of length 50:
127 compute myRDF all rdf 50 1 2
128 fix 1 all ave/time 100 1 100 c_myRDF\[*\] file tmp1.rdf mode vector
129 fix 2 all ave/time 100 1 100 c_myRDF\[1\] c_myRDF\[2\] c_myRDF\[3\] file tmp2.rdf mode vector :pre
133 The {Nevery}, {Nrepeat}, and {Nfreq} arguments specify on what
134 timesteps the input values will be used in order to contribute to the
135 average. The final averaged quantities are generated on timesteps
136 that are a mlutiple of {Nfreq}. The average is over {Nrepeat}
137 quantities, computed in the preceding portion of the simulation every
138 {Nevery} timesteps. {Nfreq} must be a multiple of {Nevery} and
139 {Nevery} must be non-zero even if {Nrepeat} is 1. Also, the timesteps
140 contributing to the average value cannot overlap,
141 i.e. Nrepeat*Nevery can not exceed Nfreq.
143 For example, if Nevery=2, Nrepeat=6, and Nfreq=100, then values on
144 timesteps 90,92,94,96,98,100 will be used to compute the final average
145 on timestep 100. Similarly for timesteps 190,192,194,196,198,200 on
146 timestep 200, etc. If Nrepeat=1 and Nfreq = 100, then no time
147 averaging is done; values are simply generated on timesteps
152 If a value begins with "c_", a compute ID must follow which has been
153 previously defined in the input script. If {mode} = scalar, then if
154 no bracketed term is appended, the global scalar calculated by the
155 compute is used. If a bracketed term is appended, the Ith element of
156 the global vector calculated by the compute is used. If {mode} =
157 vector, then if no bracketed term is appended, the global vector
158 calculated by the compute is used. If a bracketed term is appended,
159 the Ith column of the global array calculated by the compute is used.
160 See the discussion above for how I can be specified with a wildcard
161 asterisk to effectively specify multiple values.
163 Note that there is a "compute reduce"_compute_reduce.html command
164 which can sum per-atom quantities into a global scalar or vector which
165 can thus be accessed by fix ave/time. Or it can be a compute defined
166 not in your input script, but by "thermodynamic
167 output"_thermo_style.html or other fixes such as "fix
168 nvt"_fix_nh.html or "fix temp/rescale"_fix_temp_rescale.html. See
169 the doc pages for these commands which give the IDs of these computes.
170 Users can also write code for their own compute styles and "add them
171 to LAMMPS"_Section_modify.html.
173 If a value begins with "f_", a fix ID must follow which has been
174 previously defined in the input script. If {mode} = scalar, then if
175 no bracketed term is appended, the global scalar calculated by the fix
176 is used. If a bracketed term is appended, the Ith element of the
177 global vector calculated by the fix is used. If {mode} = vector, then
178 if no bracketed term is appended, the global vector calculated by the
179 fix is used. If a bracketed term is appended, the Ith column of the
180 global array calculated by the fix is used. See the discussion above
181 for how I can be specified with a wildcard asterisk to effectively
182 specify multiple values.
184 Note that some fixes only produce their values on certain timesteps,
185 which must be compatible with {Nevery}, else an error will result.
186 Users can also write code for their own fix styles and "add them to
187 LAMMPS"_Section_modify.html.
189 If a value begins with "v_", a variable name must follow which has
190 been previously defined in the input script. If {mode} = scalar, then
191 only equal-style or vector-style variables can be used, which both
192 produce global values. In this mode, a vector-style variable requires
193 a bracketed term to specify the Ith element of the vector calculated
194 by the variable. If {mode} = vector, then only a vector-style
195 variable can be used, without a bracketed term. See the
196 "variable"_variable.html command for details.
198 Note that variables of style {equal} and {vector} define a formula
199 which can reference individual atom properties or thermodynamic
200 keywords, or they can invoke other computes, fixes, or variables when
201 they are evaluated, so this is a very general means of specifying
202 quantities to time average.
206 Additional optional keywords also affect the operation of this fix.
208 If the {mode} keyword is set to {scalar}, then all input values must
209 be global scalars, or elements of global vectors. If the {mode}
210 keyword is set to {vector}, then all input values must be global
211 vectors, or columns of global arrays. They can also be global arrays,
212 which are converted into a series of global vectors (one per column),
215 The {ave} keyword determines how the values produced every {Nfreq}
216 steps are averaged with values produced on previous steps that were
217 multiples of {Nfreq}, before they are accessed by another output
218 command or written to a file.
220 If the {ave} setting is {one}, then the values produced on timesteps
221 that are multiples of {Nfreq} are independent of each other; they are
222 output as-is without further averaging.
224 If the {ave} setting is {running}, then the values produced on
225 timesteps that are multiples of {Nfreq} are summed and averaged in a
226 cummulative sense before being output. Each output value is thus the
227 average of the value produced on that timestep with all preceding
228 values. This running average begins when the fix is defined; it can
229 only be restarted by deleting the fix via the "unfix"_unfix.html
230 command, or by re-defining the fix by re-specifying it.
232 If the {ave} setting is {window}, then the values produced on
233 timesteps that are multiples of {Nfreq} are summed and averaged within
234 a moving "window" of time, so that the last M values are used to
235 produce the output. E.g. if M = 3 and Nfreq = 1000, then the output
236 on step 10000 will be the average of the individual values on steps
237 8000,9000,10000. Outputs on early steps will average over less than M
238 values if they are not available.
240 The {start} keyword specifies what timestep averaging will begin on.
241 The default is step 0. Often input values can be 0.0 at time 0, so
242 setting {start} to a larger value can avoid including a 0.0 in a
243 running or windowed average.
245 The {off} keyword can be used to flag any of the input values. If a
246 value is flagged, it will not be time averaged. Instead the most
247 recent input value will always be stored and output. This is useful
248 if one of more of the inputs produced by a compute or fix or variable
249 are effectively constant or are simply current values. E.g. they are
250 being written to a file with other time-averaged values for purposes
251 of creating well-formatted output.
253 The {file} keyword allows a filename to be specified. Every {Nfreq}
254 steps, one quantity or vector of quantities is written to the file for
255 each input value specified in the fix ave/time command. For {mode} =
256 scalar, this means a single line is written each time output is
257 performed. Thus the file ends up to be a series of lines, i.e. one
258 column of numbers for each input value. For {mode} = vector, an array
259 of numbers is written each time output is performed. The number of
260 rows is the length of the input vectors, and the number of columns is
261 the number of values. Thus the file ends up to be a series of these
264 The {overwrite} keyword will continuously overwrite the output file
265 with the latest output, so that it only contains one timestep worth of
266 output. This option can only be used with the {ave running} setting.
268 The {format} keyword sets the numeric format of each value when it is
269 printed to a file via the {file} keyword. Note that all values are
270 floating point quantities. The default format is %g. You can specify
271 a higher precision if desired, e.g. %20.16g.
273 The {title1} and {title2} and {title3} keywords allow specification of
274 the strings that will be printed as the first 2 or 3 lines of the
275 output file, assuming the {file} keyword was used. LAMMPS uses
276 default values for each of these, so they do not need to be specified.
278 By default, these header lines are as follows for {mode} = scalar:
280 # Time-averaged data for fix ID
281 # TimeStep value1 value2 ... :pre
283 In the first line, ID is replaced with the fix-ID. In the second line
284 the values are replaced with the appropriate fields from the fix
285 ave/time command. There is no third line in the header of the file,
286 so the {title3} setting is ignored when {mode} = scalar.
288 By default, these header lines are as follows for {mode} = vector:
290 # Time-averaged data for fix ID
291 # TimeStep Number-of-rows
292 # Row value1 value2 ... :pre
294 In the first line, ID is replaced with the fix-ID. The second line
295 describes the two values that are printed at the first of each section
296 of output. In the third line the values are replaced with the
297 appropriate fields from the fix ave/time command.
301 [Restart, fix_modify, output, run start/stop, minimize info:]
303 No information about this fix is written to "binary restart
304 files"_restart.html. None of the "fix_modify"_fix_modify.html options
305 are relevant to this fix.
307 This fix produces a global scalar or global vector or global array
308 which can be accessed by various "output
309 commands"_Section_howto.html#howto_15. The values can only be
310 accessed on timesteps that are multiples of {Nfreq} since that is when
311 averaging is performed.
313 A scalar is produced if only a single input value is averaged and
314 {mode} = scalar. A vector is produced if multiple input values are
315 averaged for {mode} = scalar, or a single input value for {mode} =
316 vector. In the first case, the length of the vector is the number of
317 inputs. In the second case, the length of the vector is the same as
318 the length of the input vector. An array is produced if multiple
319 input values are averaged and {mode} = vector. The global array has #
320 of rows = length of the input vectors and # of columns = number of
323 If the fix prouduces a scalar or vector, then the scalar and each
324 element of the vector can be either "intensive" or "extensive",
325 depending on whether the values contributing to the scalar or vector
326 element are "intensive" or "extensive". If the fix produces an array,
327 then all elements in the array must be the same, either "intensive" or
328 "extensive". If a compute or fix provides the value being time
329 averaged, then the compute or fix determines whether the value is
330 intensive or extensive; see the doc page for that compute or fix for
331 further info. Values produced by a variable are treated as intensive.
333 No parameter of this fix can be used with the {start/stop} keywords of
334 the "run"_run.html command. This fix is not invoked during "energy
335 minimization"_minimize.html.
341 "compute"_compute.html, "fix ave/atom"_fix_ave_atom.html, "fix
342 ave/chunk"_fix_ave_chunk.html, "fix ave/histo"_fix_ave_histo.html,
343 "variable"_variable.html, "fix ave/correlate"_fix_ave_correlate.html,
347 The option defaults are mode = scalar, ave = one, start = 0, no file
348 output, format = %g, title 1,2,3 = strings as described above, and no
349 off settings for any input values.