lammps/doc/fix_ave_spatial.html

217 lines
11 KiB
HTML

<HTML>
<CENTER><A HREF = "http://lammps.sandia.gov">LAMMPS WWW Site</A> - <A HREF = "Manual.html">LAMMPS Documentation</A> - <A HREF = "Section_commands.html#comm">LAMMPS Commands</A>
</CENTER>
<HR>
<H3>fix ave/spatial command
</H3>
<P><B>Syntax:</B>
</P>
<PRE>fix ID group-ID ave/spatial Nevery Nrepeat Nfreq dim origin delta file style args keyword value ...
</PRE>
<UL><LI>ID, group-ID are documented in <A HREF = "fix.html">fix</A> command
<LI>ave/spatial = style name of this fix command
<LI>Nevery = calculate property every this many timesteps
<LI>Nrepeat = # of times to repeat the Nevery calculation before averaging
<LI>Nfreq = timestep frequency at which the average value is written to file
<LI>dim = <I>x</I> or <I>y</I> or <I>z</I>
<LI>origin = <I>lower</I> or <I>center</I> or <I>upper</I> or coordinate value (distance units)
<LI>delta = thickness of spatial layers in dim (distance units)
<LI>file = filename to write results to
<LI>style = <I>density</I> or <I>compute</I> or <I>fix</I>
<PRE> <I>density</I> arg = <I>mass</I> or <I>number</I>
<I>mass</I> = compute mass density
<I>number</I> = compute number density
<I>compute</I> arg = compute-ID that stores or calculates per-atom quantities
<I>fix</I> arg = fix-ID that stores or calculates per-atom quantities
</PRE>
<PRE>
</PRE>
<LI>zero or more keyword/value pairs may be appended
<PRE>keyword = <I>norm</I> or <I>units</I>
<I>norm</I> value = <I>all</I> or <I>sample</I>
<I>units</I> value = <I>box</I> or <I>lattice</I> or <I>reduced</I>
</PRE>
</UL>
<P><B>Examples:</B>
</P>
<PRE>fix 1 all ave/spatial 10000 1 10000 z lower 2.0 centro.profile compute myCentro
fix 1 flow ave/spatial 100 10 1000 y 0.0 1.0 vel.profile compute Vx norm sample
fix 1 flow ave/spatial 100 5 1000 y 0.0 2.5 dens.profile density mass
</PRE>
<P><B>Description:</B>
</P>
<P>Calculate one or more instantaneous per-atom quantities every few
timesteps, average them by layer in a chosen dimension and over a
longer timescale, and print the results to a file. This can be used
to spatially average per-atom properties (velocity, force) or per-atom
quantities calculated by a <A HREF = "compute.html">compute</A> (energy, stress) or
by another fix (see the <A HREF = "fix_ave_atom.html">fix ave/atom</A> command) or
by a variable via an equation you define (see the <A HREF = "compute_variable_atom.html">compute
variable/atom</A> command).
</P>
<P>The <I>density</I> styles means to simply count the number of atoms in each
layer, either by mass or number. The <I>compute</I> style allows
specification of a <A HREF = "compute.html">compute</A> which will be invoked to
calculate the desired property. The compute can be previously defined
in the input script or it can be a compute defined by a <A HREF = "dump.html">dump
custom</A> command.
</P>
<P>For the <I>compute</I> style, the fix ave/spatial command accesses the
per-atom scalar or vector values stored by the compute. Thus it must
be a "per-atom" compute with the word "atom" in its style name, rather
than a "global" compute. See the <A HREF = "fix_ave_time.html">fix ave/time</A>
command if you wish to time-average a global quantity calculated by a
compute without the word atom in its style name, e.g. a compute that
calculates a temperature or pressure.
</P>
<P>See the <A HREF = "compute.html">compute</A> command for a list of pre-defined
per-atom computes. Two special computes are as follows. The <A HREF = "compute_attribute_atom.html">compute
attribute/atom</A> command selects one or
more atom attributes like vx or fz. The "compute variable/atom" style
can calculate a value for an atom that can be specified by a <A HREF = "variable.html">variable
atom</A> equation. Users can also write code for their own
per-atom compute styles and <A HREF = "Section_modify.html">add them to LAMMPS</A>.
Note that the <A HREF = "dump.html">dump custom</A> command can also be used to
directly output per-atom quantities calculated by a per-atom compute.
</P>
<P>For the <I>fix</I> style, the fix ave/spatial command accesses the per-atom
scalar or vector values stored by another fix. The <A HREF = "fix_ave_atom.html">fix
ave/atom</A> command is an example of such a fix.
</P>
<P>In all cases, the calculated property is averaged over atoms in each
layer, where the layers are in a particular <I>dim</I> and have a thickness
given by <I>delta</I>. Every Nfreq steps, when a property is calculated
for the first time (after a previous write), the number of layers and
the layer boundaries are computed. Thus if the simlation box changes
size during a simulation, the number of layers and their boundaries
may also change. Layers are defined relative to a specified <I>origin</I>,
which may be the lower/upper edge of the box (in <I>dim</I>) or its center
point, or a specified coordinate value. Starting at the origin,
sufficient layers are created in both directions to completely cover
the box. On subsequent timesteps every atom is mapped to one of the
layers. Atoms beyond the lowermost/uppermost layer are counted in the
first/last layer.
</P>
<P>For orthogonal simulation boxes, the layers are "slices" aligned with
the xyz coordinate axes. For non-orthogonal (triclinic) simulation
boxes, the layers are "tilted slices" that align with the tilted faces
of the box. See the <A HREF = "region.html">region prism</A> command for a
discussion of the geometry of tilted boxes in LAMMPS. As described
there, a tilted simulation box has edge vectors a,b,c. In that
nomenclature, layers in the x dimension have faces with normals in the
"b" cross "c" direction. Layers in y have faces normal to the "a"
cross "c" direction. And layers in z have faces normal to the "a"
cross "b" direction. Note that in order to define the thickness and
position of these tilted layers in an unambiguous fashion, the <I>units</I>
option must be set to <I>reduced</I>.
</P>
<P>The <I>units</I> keyword determines the meaning of the distance units used
for the layer thickness <I>delta</I> and for <I>origin</I> if it is a coordinate
value. For orthogonal simulation boxes, any of the 3 options may be
used. For non-orthongal (triclinic) simulation boxes, only the
<I>reduced</I> option may be used.
</P>
<P>A <I>box</I> value selects standard distance units as defined by the
<A HREF = "units.html">units</A> command, e.g. Angstroms for units = real or metal.
A <I>lattice</I> value means the distance units are in lattice spacings.
The <A HREF = "lattice.html">lattice</A> command must have been previously used to
define the lattice spacing. A <I>reduced</I> value means normalized
unitless values between 0 and 1, which represent the lower and upper
faces of the simulation box respectively. Thus an <I>origin</I> value of
0.5 means the center of the box in any dimension. A <I>delta</I> value of
0.1 means 10 layers span the box in any dimension.
</P>
<P>Consider a non-orthogonal box, with layers in the x dimension. No
matter how the box is tilted, an <I>origin</I> of 0.0 means start layers at
the lower "b" cross "c" plane of the simulation box and an <I>origin</I> of
1.0 means to start layers at the upper "b" cross "c" face of the box.
A <I>delta</I> value of 0.1 means there will be 10 layers from 0.0 to 1.0,
regardless of the current size or shape of the simulation box.
</P>
<P>The <I>Nevery</I>, <I>Nrepeat</I>, and <I>Nfreq</I> arguments specify how the
property will be time-averaged. The final averaged value(s) are
computed every <I>Nfreq</I> timesteps. The average is over <I>Nrepeat</I>
values, computed in the preceeding portion of the simulation every
<I>Nevery</I> timesteps. Thus 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 written to the file on timestep 100. Similary for
timesteps 190,192,194,196,198,200 on timestep 200, etc.
</P>
<P>The <I>norm</I> keyword also affects how time-averaging is done. For an
<I>all</I> setting, a layer quantity is summed over all atoms in all
Nfreq/Nevery samples, as is the count of atoms in the layer. The
printed value for the layer is Total-quantity / Total-count.
In other words it is an average over the entire Nfreq timescale.
</P>
<P>For a <I>sample</I> setting, the quantity is summed over atoms for only a
single sample, as is the count, and a "average sample value" is
computed, i.e. Sample-quantity / Sample-count. The printed value for
the layer is the average of the M "average sample values", where M =
Nfreq/Nevery. In other words it is an average of an average.
</P>
<P>Each time info is written to the file, it is in the following format.
A line with the timestep and number of layers is written. Then one
line per layer is written, containing the layer ID (1-N), the
coordinate of the center of the layer, the number of atoms in the
layer, and one or more calculated values. The number of atoms and the
value(s) are average quantities. If the value of the <I>units</I> keyword
is <I>box</I> or <I>lattice</I>, the "coord" is printed in box units. If the
value of the <I>units</I> keyword is <I>reduced</I>, the "coord" is printed in
reduced units (0-1).
</P>
<P>If the <I>density</I> keyword is used, or the <I>compute</I> or <I>fix</I> keyword
with a compute/fix that calculates a single quantity per atom, then a
single value will be printed for each layer. If the <I>compute</I> or
<I>fix</I> keyword is used with a compute/fix that calculates N quantities
per atom, then N values per line will be written, each of them
averaged independently.
</P>
<P>For the <I>compute</I> and <I>fix</I> keywords, the calculation performed by the
compute or fix is on the group defined by the that command. However,
only atoms in the fix group are included in the layer averaging.
</P>
<P>Note that some computes perform costly calculations, involving use of
or creation of neighbor lists. If the compute is invoked too often by
fix ave/spatial, it can slow down a simulation.
</P>
<P><B>Restart, fix_modify, thermo output, run start/stop, minimize info:</B>
</P>
<P>No information about this fix is written to <A HREF = "restart.html">binary restart
files</A>. None of the <A HREF = "fix_modify.html">fix_modify</A> options
are relevant to this fix. No quantities calculated by this fix can be
output by the <A HREF = "thermo_style.html">thermo_style custom</A> command. No
parameter of this fix can be used with the <I>start/stop</I> keywords of
the <A HREF = "run.html">run</A> command. This fix is not invoked during <A HREF = "minimize.html">energy
minimization</A>.
</P>
<P><B>Restrictions:</B> none
</P>
<P><B>Related commands:</B>
</P>
<P><A HREF = "compute.html">compute</A>, <A HREF = "fix_ave_time.html">fix ave/time</A>
</P>
<P><B>Default:</B>
</P>
<P>The option defaults are norm = all and units = lattice.
</P>
</HTML>