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/correlate command :h3
13 fix ID group-ID ave/correlate Nevery Nrepeat Nfreq value1 value2 ... keyword args ... :pre
15 ID, group-ID are documented in "fix"_fix.html command :ulb,l
16 ave/correlate = style name of this fix command :l
17 Nevery = use input values every this many timesteps :l
18 Nrepeat = # of correlation time windows to accumulate :l
19 Nfreq = calculate time window 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 calculated by a compute with ID
23 c_ID\[I\] = Ith component of global vector calculated by a compute with ID, I can include wildcard (see below)
24 f_ID = global scalar calculated by a fix with ID
25 f_ID\[I\] = Ith component of global vector calculated by a fix with ID, I can include wildcard (see below)
26 v_name = global value calculated by an equal-style variable with name
27 v_name\[I\] = Ith component of a vector-style variable with name :pre
29 zero or more keyword/arg pairs may be appended :l
30 keyword = {type} or {ave} or {start} or {prefactor} or {file} or {overwrite} or {title1} or {title2} or {title3} :l
31 {type} arg = {auto} or {upper} or {lower} or {auto/upper} or {auto/lower} or {full}
32 auto = correlate each value with itself
33 upper = correlate each value with each succeeding value
34 lower = correlate each value with each preceding value
35 auto/upper = auto + upper
36 auto/lower = auto + lower
37 full = correlate each value with every other value, including itself = auto + upper + lower
38 {ave} args = {one} or {running}
39 one = zero the correlation accumulation every Nfreq steps
40 running = accumulate correlations continuously
42 Nstart = start accumulating correlations on this timestep
43 {prefactor} args = value
44 value = prefactor to scale all the correlation data by
46 filename = name of file to output correlation data to
47 {overwrite} arg = none = overwrite output file with only latest output
49 string = text to print as 1st line of output file
51 string = text to print as 2nd line of output file
53 string = text to print as 3rd line of output file :pre
58 fix 1 all ave/correlate 5 100 1000 c_myTemp file temp.correlate
59 fix 1 all ave/correlate 1 50 10000 &
60 c_thermo_press\[1\] c_thermo_press\[2\] c_thermo_press\[3\] &
61 type upper ave running title1 "My correlation data" :pre
62 fix 1 all ave/correlate 1 50 10000 c_thermo_press\[*\]
66 Use one or more global scalar values as inputs every few timesteps,
67 calculate time correlations bewteen them at varying time intervals,
68 and average the correlation data over longer timescales. The
69 resulting correlation values can be time integrated by
70 "variables"_variable.html or used by other "output
71 commands"_Section_howto.html#howto_15 such as "thermo_style
72 custom"_thermo_style.html, and can also be written to a file. See the
73 "fix ave/correlate/long"_fix_ave_correlate_long.html command for an
74 alternate method for computing correlation functions efficiently over
75 very long time windows.
77 The group specified with this command is ignored. However, note that
78 specified values may represent calculations performed by computes and
79 fixes which store their own "group" definitions.
81 Each listed value can be the result of a "compute"_compute.html or
82 "fix"_fix.html or the evaluation of an equal-style or vector-style
83 "variable"_variable.html. In each case, the compute, fix, or variable
84 must produce a global quantity, not a per-atom or local quantity. If
85 you wish to spatial- or time-average or histogram per-atom quantities
86 from a compute, fix, or variable, then see the "fix
87 ave/chunk"_fix_ave_chunk.html, "fix ave/atom"_fix_ave_atom.html, or
88 "fix ave/histo"_fix_ave_histo.html commands. If you wish to convert a
89 per-atom quantity into a single global value, see the "compute
90 reduce"_compute_reduce.html command.
92 The input values must either be all scalars. What kinds of
93 correlations between input values are calculated is determined by the
94 {type} keyword as discussed below.
96 "Computes"_compute.html that produce global quantities are those which
97 do not have the word {atom} in their style name. Only a few
98 "fixes"_fix.html produce global quantities. See the doc pages for
99 individual fixes for info on which ones produce such values.
100 "Variables"_variable.html of style {equal} and {vector} are the only
101 ones that can be used with this fix. Variables of style {atom} cannot
102 be used, since they produce per-atom values.
104 Note that for values from a compute or fix, the bracketed index I can
105 be specified using a wildcard asterisk with the index to effectively
106 specify multiple values. This takes the form "*" or "*n" or "n*" or
107 "m*n". If N = the size of the vector (for {mode} = scalar) or the
108 number of columns in the array (for {mode} = vector), then an asterisk
109 with no numeric values means all indices from 1 to N. A leading
110 asterisk means all indices from 1 to n (inclusive). A trailing
111 asterisk means all indices from n to N (inclusive). A middle asterisk
112 means all indices from m to n (inclusive).
114 Using a wildcard is the same as if the individual elements of the
115 vector had been listed one by one. E.g. these 2 fix ave/correlate
116 commands are equivalent, since the "compute
117 pressure"_compute_pressure.html command creates a global vector with 6
120 compute myPress all pressure NULL
121 fix 1 all ave/correlate 1 50 10000 c_myPress\[*\]
122 fix 1 all ave/correlate 1 50 10000 &
123 c_myPress\[1\] c_myPress\[2\] c_myPress\[3\] &
124 c_myPress\[4\] c_myPress\[5\] c_myPress\[6\] :pre
128 The {Nevery}, {Nrepeat}, and {Nfreq} arguments specify on what
129 timesteps the input values will be used to calculate correlation data.
130 The input values are sampled every {Nevery} timesteps. The
131 correlation data for the preceding samples is computed on timesteps
132 that are a multiple of {Nfreq}. Consider a set of samples from some
133 initial time up to an output timestep. The initial time could be the
134 beginning of the simulation or the last output time; see the {ave}
135 keyword for options. For the set of samples, the correlation value
136 Cij is calculated as:
138 Cij(delta) = ave(Vi(t)*Vj(t+delta)) :pre
140 which is the correlation value between input values Vi and Vj,
141 separated by time delta. Note that the second value Vj in the pair is
142 always the one sampled at the later time. The ave() represents an
143 average over every pair of samples in the set that are separated by
144 time delta. The maximum delta used is of size ({Nrepeat}-1)*{Nevery}.
145 Thus the correlation between a pair of input values yields {Nrepeat}
148 Cij(0), Cij(Nevery), Cij(2*Nevery), ..., Cij((Nrepeat-1)*Nevery) :pre
150 For example, if Nevery=5, Nrepeat=6, and Nfreq=100, then values on
151 timesteps 0,5,10,15,...,100 will be used to compute the final averages
152 on timestep 100. Six averages will be computed: Cij(0), Cij(5),
153 Cij(10), Cij(15), Cij(20), and Cij(25). Cij(10) on timestep 100 will
154 be the average of 19 samples, namely Vi(0)*Vj(10), Vi(5)*Vj(15),
155 Vi(10)*V j20), Vi(15)*Vj(25), ..., Vi(85)*Vj(95), Vi(90)*Vj(100).
157 {Nfreq} must be a multiple of {Nevery}; {Nevery} and {Nrepeat} must be
158 non-zero. Also, if the {ave} keyword is set to {one} which is the
159 default, then {Nfreq} >= ({Nrepeat}-1)*{Nevery} is required.
163 If a value begins with "c_", a compute ID must follow which has been
164 previously defined in the input script. If no bracketed term is
165 appended, the global scalar calculated by the compute is used. If a
166 bracketed term is appended, the Ith element of the global vector
167 calculated by the compute is used. See the discussion above for how I
168 can be specified with a wildcard asterisk to effectively specify
171 Note that there is a "compute reduce"_compute_reduce.html command
172 which can sum per-atom quantities into a global scalar or vector which
173 can thus be accessed by fix ave/correlate. Or it can be a compute
174 defined not in your input script, but by "thermodynamic
175 output"_thermo_style.html or other fixes such as "fix nvt"_fix_nh.html
176 or "fix temp/rescale"_fix_temp_rescale.html. See the doc pages for
177 these commands which give the IDs of these computes. Users can also
178 write code for their own compute styles and "add them to
179 LAMMPS"_Section_modify.html.
181 If a value begins with "f_", a fix ID must follow which has been
182 previously defined in the input script. If no bracketed term is
183 appended, the global scalar calculated by the fix is used. If a
184 bracketed term is appended, the Ith element of the global vector
185 calculated by the fix is used. See the discussion above for how I can
186 be specified with a wildcard asterisk to effectively specify multiple
189 Note that some fixes only produce their values on certain timesteps,
190 which must be compatible with {Nevery}, else an error will result.
191 Users can also write code for their own fix styles and "add them to
192 LAMMPS"_Section_modify.html.
194 If a value begins with "v_", a variable name must follow which has
195 been previously defined in the input script. Only equal-style or
196 vector-style variables can be referenced; the latter requires a
197 bracketed term to specify the Ith element of the vector calculated by
198 the variable. See the "variable"_variable.html command for details.
199 Note that variables of style {equal} or {vector} define a formula
200 which can reference individual atom properties or thermodynamic
201 keywords, or they can invoke other computes, fixes, or variables when
202 they are evaluated, so this is a very general means of specifying
203 quantities to time correlate.
207 Additional optional keywords also affect the operation of this fix.
209 The {type} keyword determines which pairs of input values are
210 correlated with each other. For N input values Vi, for i = 1 to N,
211 let the number of pairs = Npair. Note that the second value in the
212 pair Vi(t)*Vj(t+delta) is always the one sampled at the later time.
214 If {type} is set to {auto} then each input value is correlated with
215 itself. I.e. Cii = Vi*Vi, for i = 1 to N, so Npair = N. :ulb,l
218 to {upper} then each input value is correlated with every succeeding
219 value. I.e. Cij = Vi*Vj, for i < j, so Npair = N*(N-1)/2. :l
222 to {lower} then each input value is correlated with every preceeding
223 value. I.e. Cij = Vi*Vj, for i > j, so Npair = N*(N-1)/2. :l
225 If {type} is set to {auto/upper} then each input value is correlated
226 with itself and every succeeding value. I.e. Cij = Vi*Vj, for i >= j,
227 so Npair = N*(N+1)/2. :l
229 If {type} is set to {auto/lower} then each input value is correlated
230 with itself and every preceding value. I.e. Cij = Vi*Vj, for i <= j,
231 so Npair = N*(N+1)/2. :l
233 If {type} is set to {full} then each input value is correlated with
234 itself and every other value. I.e. Cij = Vi*Vj, for i,j = 1,N so
238 The {ave} keyword determines what happens to the accumulation of
239 correlation samples every {Nfreq} timesteps. If the {ave} setting is
240 {one}, then the accumulation is restarted or zeroed every {Nfreq}
241 timesteps. Thus the outputs on successive {Nfreq} timesteps are
242 essentially independent of each other. The exception is that the
243 Cij(0) = Vi(T)*Vj(T) value at a timestep T, where T is a multiple of
244 {Nfreq}, contributes to the correlation output both at time T and at
247 If the {ave} setting is {running}, then the accumulation is never
248 zeroed. Thus the output of correlation data at any timestep is the
249 average over samples accumulated every {Nevery} steps since the fix
250 was defined. it can only be restarted by deleting the fix via the
251 "unfix"_unfix.html command, or by re-defining the fix by re-specifying
254 The {start} keyword specifies what timestep the accumulation of
255 correlation samples will begin on. The default is step 0. Setting it
256 to a larger value can avoid adding non-equilibrated data to the
257 correlation averages.
259 The {prefactor} keyword specifies a constant which will be used as a
260 multiplier on the correlation data after it is averaged. It is
261 effectively a scale factor on Vi*Vj, which can be used to account for
262 the size of the time window or other unit conversions.
264 The {file} keyword allows a filename to be specified. Every {Nfreq}
265 steps, an array of correlation data is written to the file. The
266 number of rows is {Nrepeat}, as described above. The number of
267 columns is the Npair+2, also as described above. Thus the file ends
268 up to be a series of these array sections.
270 The {overwrite} keyword will continuously overwrite the output file
271 with the latest output, so that it only contains one timestep worth of
272 output. This option can only be used with the {ave running} setting.
274 The {title1} and {title2} and {title3} keywords allow specification of
275 the strings that will be printed as the first 3 lines of the output
276 file, assuming the {file} keyword was used. LAMMPS uses default
277 values for each of these, so they do not need to be specified.
279 By default, these header lines are as follows:
281 # Time-correlated data for fix ID
282 # TimeStep Number-of-time-windows
283 # Index TimeDelta Ncount valueI*valueJ valueI*valueJ ... :pre
285 In the first line, ID is replaced with the fix-ID. The second line
286 describes the two values that are printed at the first of each section
287 of output. In the third line the value pairs are replaced with the
288 appropriate fields from the fix ave/correlate command.
292 Let Sij = a set of time correlation data for input values I and J,
293 namely the {Nrepeat} values:
295 Sij = Cij(0), Cij(Nevery), Cij(2*Nevery), ..., Cij(*Nrepeat-1)*Nevery) :pre
297 As explained below, these datums are output as one column of a global
298 array, which is effectively the correlation matrix.
300 The {trap} function defined for "equal-style variables"_variable.html
301 can be used to perform a time integration of this vector of datums,
302 using a trapezoidal rule. This is useful for calculating various
303 quantities which can be derived from time correlation data. If a
304 normalization factor is needed for the time integration, it can be
305 included in the variable formula or via the {prefactor} keyword.
309 [Restart, fix_modify, output, run start/stop, minimize info:]
311 No information about this fix is written to "binary restart
312 files"_restart.html. None of the "fix_modify"_fix_modify.html options
313 are relevant to this fix.
315 This fix computes a global array of values which can be accessed by
316 various "output commands"_Section_howto.html#howto_15. The values can
317 only be accessed on timesteps that are multiples of {Nfreq} since that
318 is when averaging is performed. The global array has # of rows =
319 {Nrepeat} and # of columns = Npair+2. The first column has the time
320 delta (in timesteps) between the pairs of input values used to
321 calculate the correlation, as described above. The 2nd column has the
322 number of samples contributing to the correlation average, as
323 described above. The remaining Npair columns are for I,J pairs of the
324 N input values, as determined by the {type} keyword, as described
327 For {type} = {auto}, the Npair = N columns are ordered: C11, C22, ...,
330 For {type} = {upper}, the Npair = N*(N-1)/2 columns are ordered: C12,
331 C13, ..., C1N, C23, ..., C2N, C34, ..., CN-1N. :l
333 For {type} = {lower}, the Npair = N*(N-1)/2 columns are ordered: C21,
334 C31, C32, C41, C42, C43, ..., CN1, CN2, ..., CNN-1. :l
336 For {type} = {auto/upper}, the Npair = N*(N+1)/2 columns are ordered:
337 C11, C12, C13, ..., C1N, C22, C23, ..., C2N, C33, C34, ..., CN-1N,
340 For {type} = {auto/lower}, the Npair = N*(N+1)/2 columns are ordered:
341 C11, C21, C22, C31, C32, C33, C41, ..., C44, CN1, CN2, ..., CNN-1,
344 For {type} = {full}, the Npair = N^2 columns are ordered: C11, C12,
345 ..., C1N, C21, C22, ..., C2N, C31, ..., C3N, ..., CN1, ..., CNN-1,
349 The array values calculated by this fix are treated as intensive. If
350 you need to divide them by the number of atoms, you must do this in a
351 later processing step, e.g. when using them in a
352 "variable"_variable.html.
354 No parameter of this fix can be used with the {start/stop} keywords of
355 the "run"_run.html command. This fix is not invoked during "energy
356 minimization"_minimize.html.
362 "fix ave/correlate/long"_fix_ave_correlate_long.html,
363 "compute"_compute.html, "fix ave/time"_fix_ave_time.html, "fix
364 ave/atom"_fix_ave_atom.html, "fix ave/chunk"_fix_ave_chunk.html,
365 "fix ave/histo"_fix_ave_histo.html, "variable"_variable.html
369 The option defaults are ave = one, type = auto, start = 0, no file
370 output, title 1,2,3 = strings as described above, and prefactor = 1.0.