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/chunk command :h3
13
fix ID group-ID ave/chunk Nevery Nrepeat Nfreq chunkID value1 value2 ... keyword args ... :pre
15
ID, group-ID are documented in "fix"_fix.html command :ulb,l
16
ave/chunk = 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
chunkID = ID of "compute chunk/atom"_compute_chunk_atom.html command :l
21
one or more input values can be listed :l
22
value = vx, vy, vz, fx, fy, fz, density/mass, density/number, temp, c_ID, c_ID\[I\], f_ID, f_ID\[I\], v_name :l
23
vx,vy,vz,fx,fy,fz = atom attribute (velocity, force component)
24
density/number, density/mass = number or mass density
26
c_ID = per-atom vector calculated by a compute with ID
27
c_ID\[I\] = Ith column of per-atom array calculated by a compute with ID
28
f_ID = per-atom vector calculated by a fix with ID
29
f_ID\[I\] = Ith column of per-atom array calculated by a fix with ID
30
v_name = per-atom vector calculated by an atom-style variable with name :pre
32
zero or more keyword/arg pairs may be appended :l
33
keyword = {norm} or {ave} or {bias} or {adof} or {cdof} or {file} or {overwrite} or {title1} or {title2} or {title3} :l
34
{norm} arg = {all} or {sample} or {none} = how output on {Nfreq} steps is normalized
35
all = output is sum of atoms across all {Nrepeat} samples, divided by atom count
36
sample = output is sum of {Nrepeat} sample averages, divided by {Nrepeat}
37
none = output is sum of {Nrepeat} sums, divided by {Nrepeat}
38
{ave} args = {one} or {running} or {window M}
39
one = output new average value every Nfreq steps
40
running = output cumulative average of all previous Nfreq steps
41
window M = output average of M most recent Nfreq steps
43
bias-ID = ID of a temperature compute that removes a velocity bias for temperature calculation
44
{adof} value = dof_per_atom
45
dof_per_atom = define this many degrees-of-freedom per atom for temperature calculation
46
{cdof} value = dof_per_chunk
47
dof_per_chunk = define this many degrees-of-freedom per chunk for temperature calculation
49
filename = file to write results to
50
{overwrite} arg = none = overwrite output file with only latest output
52
string = text to print as 1st line of output file
54
string = text to print as 2nd line of output file
56
string = text to print as 3rd line of output file :pre
61
fix 1 all ave/chunk 10000 1 10000 binchunk c_myCentro title1 "My output values"
62
fix 1 flow ave/chunk 100 10 1000 molchunk vx vz norm sample file vel.profile
63
fix 1 flow ave/chunk 100 5 1000 binchunk density/mass ave running
64
fix 1 flow ave/chunk 100 5 1000 binchunk density/mass ave running :pre
68
If you are trying to replace an older fix ave/spatial command with the
69
newer, more flexible fix ave/chunk and "compute
70
chunk/atom"_compute_chunk_atom.html commands, you simply need to split
71
the fix ave/spatial arguments across the two new commands. For
72
example, this command:
74
fix 1 flow ave/spatial 100 10 1000 y 0.0 1.0 vx vz norm sample file vel.profile :pre
78
compute cc1 flow chunk/atom bin/1d y 0.0 1.0
79
fix 1 flow ave/chunk 100 10 1000 cc1 vx vz norm sample file vel.profile :pre
83
Use one or more per-atom vectors as inputs every few timesteps, sum
84
the values over the atoms in each chunk at each timestep, then average
85
the per-chunk values over longer timescales. The resulting chunk
86
averages can be used by other "output
87
commands"_Section_howto.html#howto_15 such as "thermo_style
88
custom"_thermo_style.html, and can also be written to a file.
90
In LAMMPS, chunks are collections of atoms defined by a "compute
91
chunk/atom"_compute_chunk_atom.html command, which assigns each atom
92
to a single chunk (or no chunk). The ID for this command is specified
93
as chunkID. For example, a single chunk could be the atoms in a
94
molecule or atoms in a spatial bin. See the "compute
95
chunk/atom"_compute_chunk_atom.html doc page and ""Section_howto
96
23"_Section_howto.html#howto_23 for details of how chunks can be
97
defined and examples of how they can be used to measure properties of
100
Note that only atoms in the specified group contribute to the summing
101
and averaging calculations. The "compute
102
chunk/atom"_compute_chunk_atom.html command defines its own group as
103
well as an optional region. Atoms will have a chunk ID = 0, meaning
104
they belong to no chunk, if they are not in that group or region.
105
Thus you can specify the "all" group for this command if you simply
106
want to use the chunk definitions provided by chunkID.
108
Each specified per-atom value can be an atom attribute (position,
109
velocity, force component), a mass or number density, or the result of
110
a "compute"_compute.html or "fix"_fix.html or the evaluation of an
111
atom-style "variable"_variable.html. In the latter cases, the
112
compute, fix, or variable must produce a per-atom quantity, not a
113
global quantity. Note that the "compute
114
property/atom"_compute_property_atom.html command provides access to
115
any attribute defined and stored by atoms. If you wish to
116
time-average global quantities from a compute, fix, or variable, then
117
see the "fix ave/time"_fix_ave_time.html command.
119
"Computes"_compute.html that produce per-atom quantities are those
120
which have the word {atom} in their style name. See the doc pages for
121
individual "fixes"_fix.html to determine which ones produce per-atom
122
quantities. "Variables"_variable.html of style {atom} are the only
123
ones that can be used with this fix since all other styles of variable
124
produce global quantities.
126
The per-atom values of each input vector are summed and averaged
127
independently of the per-atom values in other input vectors.
129
IMPORTANT NOTE: This fix works by creating an array of size {Nchunk}
130
by Nvalues on each processor. {Nchunk} is the number of chunks which
131
is defined by the "compute chunk/atom"_doc/compute_chunk_atom.html
132
command. Nvalues is the number of input values specified. Each
133
processor loops over its atoms, tallying its values to the appropriate
134
chunk. Then the entire array is summed across all processors. This
135
means that using a large number of chunks will incur an overhead in
136
memory and computational cost (summing across processors), so be
137
careful to define a reasonable number of chunks.
141
The {Nevery}, {Nrepeat}, and {Nfreq} arguments specify on what
142
timesteps the input values will be accessed and contribute to the
143
average. The final averaged quantities are generated on timesteps
144
that are a multiples of {Nfreq}. The average is over {Nrepeat}
145
quantities, computed in the preceding portion of the simulation every
146
{Nevery} timesteps. {Nfreq} must be a multiple of {Nevery} and
147
{Nevery} must be non-zero even if {Nrepeat} is 1. Also, the timesteps
148
contributing to the average value cannot overlap, i.e. Nfreq >
149
(Nrepeat-1)*Nevery is required.
151
For example, if Nevery=2, Nrepeat=6, and Nfreq=100, then values on
152
timesteps 90,92,94,96,98,100 will be used to compute the final average
153
on timestep 100. Similarly for timesteps 190,192,194,196,198,200 on
154
timestep 200, etc. If Nrepeat=1 and Nfreq = 100, then no time
155
averaging is done; values are simply generated on timesteps
158
Each input value can also be averaged over the atoms in each chunk.
159
The way the averaging is done across the {Nrepeat} timesteps to
160
produce output on the {Nfreq} timesteps, and across multiple {Nfreq}
161
outputs, is determined by the {norm} and {ave} keyword settings, as
164
IMPORTANT NOTE: To perform per-chunk averaging within a {Nfreq} time
165
window, the number of chunks {Nchunk} defined by the "compute
166
chunk/atom"_compute_chunk_atom.html command must remain constant. If
167
the {ave} keyword is set to {running} or {window} then {Nchunk} must
168
remain constant for the duration of the simulation. This fix forces
169
the chunk/atom compute specified by chunkID to hold {Nchunk} constant
170
for the appropriate time windows, by not allowing it to re-calcualte
171
{Nchunk}, which can also affect how it assigns chunk IDs to atoms.
172
More details are given on the "compute
173
chunk/atom"_compute_chunk_atom.html doc page.
177
The atom attribute values (vx,vy,vz,fx,fy,fz) are self-explanatory.
178
As noted above, any other atom attributes can be used as input values
179
to this fix by using the "compute
180
property/atom"_compute_property_atom.html command and then specifying
181
an input value from that compute.
183
The {density/number} value means the number density is computed for
184
each chunk, i.e. number/volume. The {density/mass} value means the
185
mass density is computed for each chunk, i.e. total-mass/volume. The
186
output values are in units of 1/volume or density (mass/volume). See
187
the "units"_units.html command doc page for the definition of density
188
for each choice of units, e.g. gram/cm^3. If the chunks defined by
189
the "compute chunk/atom"_compute_chunk_atom.html command are spatial
190
bins, the volume is the bin volume. Otherwise it is the volume of the
191
entire simulation box.
193
The {temp} value means the temperature is computed for each chunk, by
194
the formula KE = DOF/2 k T, where KE = total kinetic energy of the
195
chunk of atoms (sum of 1/2 m v^2), DOF = the total number of degrees
196
of freedom for all atoms in the chunk, k = Boltzmann constant, and T =
199
The DOF is calculated as N*adof + cdof, where N = number of atoms in
200
the chunk, adof = degrees of freedom per atom, and cdof = degrees of
201
freedom per chunk. By default adof = 2 or 3 = dimensionality of
202
system, as set via the "dimension"_dimension.html command, and cdof =
203
0.0. This gives the usual formula for temperature.
205
Note that currently this temperature only includes translational
206
degrees of freedom for each atom. No rotational degrees of freedom
207
are included for finite-size particles. Also no degrees of freedom
208
are subtracted for any velocity bias or constraints that are applied,
209
such as "compute temp/partial"_compute_temp_partial.html, or "fix
210
shake"_fix_shake.html or "fix rigid"_fix_rigid.html. This is because
211
those degrees of freedom (e.g. a constrained bond) could apply to sets
212
of atoms that are both included and excluded from a specific chunk,
213
and hence the concept is somewhat ill-defined. In some cases, you can
214
use the {adof} and {cdof} keywords to adjust the calculated degress of
215
freedom appropriately, as explained below.
217
Also note that a bias can be subtracted from atom velocities before
218
they are used in the above formula for KE, by using the {bias}
219
keyword. This allows, for example, a thermal temperature to be
220
computed after removal of a flow velocity profile.
222
Note that the per-chunk temperature calculated by this fix and the
223
"compute temp/chunk"_compute_temp_chunk.html command can be different.
224
The compute calculates the temperature for each chunk for a single
225
snapshot. This fix can do that but can also time average those values
226
over many snapshots, or it can compute a temperature as if the atoms
227
in the chunk on different timesteps were collected together as one set
228
of atoms to calculate their temperature. The compute allows the
229
center-of-mass velocity of each chunk to be subtracted before
230
calculating the temperature; this fix does not.
232
If a value begins with "c_", a compute ID must follow which has been
233
previously defined in the input script. If no bracketed integer is
234
appended, the per-atom vector calculated by the compute is used. If a
235
bracketed integer is appended, the Ith column of the per-atom array
236
calculated by the compute is used. Users can also write code for
237
their own compute styles and "add them to LAMMPS"_Section_modify.html.
239
If a value begins with "f_", a fix ID must follow which has been
240
previously defined in the input script. If no bracketed integer is
241
appended, the per-atom vector calculated by the fix is used. If a
242
bracketed integer is appended, the Ith column of the per-atom array
243
calculated by the fix is used. Note that some fixes only produce
244
their values on certain timesteps, which must be compatible with
245
{Nevery}, else an error results. Users can also write code for their
246
own fix styles and "add them to LAMMPS"_Section_modify.html.
248
If a value begins with "v_", a variable name must follow which has
249
been previously defined in the input script. Variables of style
250
{atom} can reference thermodynamic keywords and various per-atom
251
attributes, or invoke other computes, fixes, or variables when they
252
are evaluated, so this is a very general means of generating per-atom
253
quantities to average within chunks.
257
Additional optional keywords also affect the operation of this fix
260
The {norm} keyword affects how averaging is done for the per-chunk
261
values that are output every {Nfreq} timesteps.
263
It the {norm} setting is {all}, which is the default, a chunk value is
264
summed over all atoms in all {Nrepeat} samples, as is the count of
265
atoms in the chunk. The averaged output value for the chunk on the
266
{Nfreq} timesteps is Total-sum / Total-count. In other words it is an
267
average over atoms across the entire {Nfreq} timescale.
269
If the {norm} setting is {sample}, the chunk value is summed over atoms
270
for each sample, as is the count, and an "average sample value" is
271
computed for each sample, i.e. Sample-sum / Sample-count. The outuput
272
value for the chunk on the {Nfreq} timesteps is the average of the
273
{Nrepeat} "average sample values", i.e. the sum of {Nrepeat} "average
274
sample values" divided by {Nrepeat}. In other words it is an average
277
If the {norm} setting is {none}, a similar computation as for the
278
{sample} seting is done, except the individual "average sample values"
279
are "summed sample values". A summed sample value is simply the chunk
280
value summed over atoms in the sample, without dividing by the number
281
of atoms in the sample. The outuput value for the chunk on the
282
{Nfreq} timesteps is the average of the {Nrepeat} "summed sample
283
values", i.e. the sum of {Nrepeat} "summed sample values" divided by
286
The {ave} keyword determines how the per-chunk values produced every
287
{Nfreq} steps are averaged with values produced on previous steps that
288
were multiples of {Nfreq}, before they are accessed by another output
289
command or written to a file.
291
If the {ave} setting is {one}, which is the default, then the chunk
292
values produced on timesteps that are multiples of {Nfreq} are
293
independent of each other; they are output as-is without further
296
If the {ave} setting is {running}, then the chunk values produced on
297
timesteps that are multiples of {Nfreq} are summed and averaged in a
298
cumulative sense before being output. Each output chunk value is thus
299
the average of the chunk value produced on that timestep with all
300
preceding values for the same chunk. This running average begins when
301
the fix is defined; it can only be restarted by deleting the fix via
302
the "unfix"_unfix.html command, or re-defining the fix by
305
If the {ave} setting is {window}, then the chunk values produced on
306
timesteps that are multiples of {Nfreq} are summed and averaged within
307
a moving "window" of time, so that the last M values for the same
308
chunk are used to produce the output. E.g. if M = 3 and Nfreq = 1000,
309
then the output on step 10000 will be the average of the individual
310
chunk values on steps 8000,9000,10000. Outputs on early steps will
311
average over less than M values if they are not available.
313
The {bias} keyword specifies the ID of a temperature compute that
314
removes a "bias" velocity from each atom, specified as {bias-ID}. It
315
is only used when the {temp} value is calculated, to compute the
316
thermal temperature of each chunk after the translational kinetic
317
energy components have been altered in a prescribed way, e.g. to
318
remove a flow velocity profile. See the doc pages for individual
319
computes that calculate a temperature to see which ones implement a
322
The {adof} and {cdof} keywords define the values used in the degree of
323
freedom (DOF) formula described above for for temperature calculation
324
for each chunk. They are only used when the {temp} value is
325
calculated. They can be used to calculate a more appropriate
326
temperature for some kinds of chunks. Here are 3 examples.
328
If spatially binned chunks contain some number of water molecules and
329
"fix shake"_fix_shake.html is used to make each molecule rigid, then
330
you could calculate a temperature with 6 degrees of freedom (DOF) (3
331
translational, 3 rotational) per molecule by setting {adof} to 2.0.
332
If "compute temp/partial"_compute_temp_partial.html is used with the
333
{bias} keyword to only allow the x component of velocity to contribute
334
to the temperature, then {adof} = 1.0 would be appropriate. If each
335
chunk consists of a large molecule, with some number of its bonds
336
constrained by "fix shake"_fix_shake.html or the entire molecule by
337
"fix rigid/small"_fix_rigid.html, then {cdof} could be set to the
338
remaining degrees of freedom for the entire molecule (entire chunk in
341
The {file} keyword allows a filename to be specified. Every {Nfreq}
342
timesteps, a section of chunk info will be written to a text file in
343
the following format. A line with the timestep and number of chunks
344
is written. Then one line per chunk is written, containing the chunk
345
ID (1-Nchunk), an optional original ID value, optional coordinate
346
values for chunks that represent spatial bins, the number of atoms in
347
the chunk, and one or more calculated values. More explanation of the
348
optional values is given below. The number of values in each line
349
corresponds to the number of values specified in the fix ave/chunk
350
command. The number of atoms and the value(s) are summed or average
351
quantities, as explained above.
353
The {overwrite} keyword will continuously overwrite the output file
354
with the latest output, so that it only contains one timestep worth of
355
output. This option can only be used with the {ave running} setting.
357
The {title1} and {title2} and {title3} keywords allow specification of
358
the strings that will be printed as the first 3 lines of the output
359
file, assuming the {file} keyword was used. LAMMPS uses default
360
values for each of these, so they do not need to be specified.
362
By default, these header lines are as follows:
364
# Chunk-averaged data for fix ID and group name
365
# Timestep Number-of-chunks
366
# Chunk (OrigID) (Coord1) (Coord2) (Coord3) Ncount value1 value2 ... :pre
368
In the first line, ID and name are replaced with the fix-ID and group
369
name. The second line describes the two values that are printed at
370
the first of each section of output. In the third line the values are
371
replaced with the appropriate value names, e.g. fx or c_myCompute[2].
373
The words in parenthesis only appear with corresponding columns if the
374
chunk style specified for the "compute
375
chunk/atom"_compute_chunk_atom.html command supports them. The OrigID
376
column is only used if the {compress} keyword was set to {yes} for the
377
"compute chunk/atom"_compute_chunk_atom.html command. This means that
378
the original chunk IDs (e.g. molecule IDs) will have been compressed
379
to remove chunk IDs with no atoms assigned to them. Thus a compresed
380
chunk ID of 3 may correspond to an original chunk ID or molecule ID of
381
415. The OrigID column will list 415 for the 3rd chunk.
383
The CoordN columns only appear if a {binning} style was used in the
384
"compute chunk/atom"_compute_chunk_atom.html command. For {bin/1d},
385
{bin/2d}, and {bin/3d} styles the column values are the center point
386
of the bin in the corresponding dimension. Just Coord1 is used for
387
{bin/1d}, Coord2 is added for {bin/2d}, Coord3 is added for {bin/3d}.
389
Note that if the value of the {units} keyword used in the "compute
390
chunk/atom command"_compute_chunk_atom.html is {box} or {lattice}, the
391
coordinate values will be in distance "units"_units.html. If the
392
value of the {units} keyword is {reduced}, the coordinate values will
393
be in unitless reduced units (0-1).
397
[Restart, fix_modify, output, run start/stop, minimize info:]
399
No information about this fix is written to "binary restart
400
files"_restart.html. None of the "fix_modify"_fix_modify.html options
401
are relevant to this fix.
403
This fix computes a global array of values which can be accessed by
404
various "output commands"_Section_howto.html#howto_15. The values can
405
only be accessed on timesteps that are multiples of {Nfreq} since that
406
is when averaging is performed. The global array has # of rows =
407
the number of chunks {Nchunk} as calculated by the specified "compute
408
chunk/atom"_compute_chunk_atom.html command. The # of columns =
409
M+1+Nvalues, where M = 1 to 4, depending on whether the optional
410
columns for OrigID and CoordN are used, as explained above.
411
Following the optional columns, the next column contains the count of
412
atoms in the chunk, and the remaining columns are the Nvalue
413
quantities. When the array is accessed with a row I that exceeds the
414
current number of chunks, than a 0.0 is returned by the fix instead of
415
an error, since the number of chunks can vary as a simulation runs
416
depending on how that value is computed by the compute chunk/atom
419
The array values calculated by this fix are treated as "intensive",
420
since they are typically already normalized by the count of atoms in
423
No parameter of this fix can be used with the {start/stop} keywords of
424
the "run"_run.html command. This fix is not invoked during "energy
425
minimization"_minimize.html.
431
"compute"_compute.html, "fix ave/atom"_fix_ave_atom.html, "fix
432
ave/histo"_fix_ave_histo.html, "fix ave/time"_fix_ave_time.html,
433
"variable"_variable.html, "fix ave/correlate"_fix_ave_correlate.html
437
The option defaults are norm = all, ave = one, bias = none, no file output, and
438
title 1,2,3 = strings as described above.