git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9049 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2012-11-10 01:17:45 +00:00
parent 25db2bbb13
commit 75e9a2e218
8 changed files with 240 additions and 86 deletions

View File

@ -308,12 +308,14 @@ minimization converges. Note that this means a dump will not be
performed on the initial timestep after the dump command is invoked,
if the current timestep is not a multiple of N. This behavior can be
changed via the <A HREF = "dump_modify.html">dump_modify first</A> command, which
can be useful if the dump command is invoked after a minimization
can also be useful if the dump command is invoked after a minimization
ended on an arbitrary timestep. N can be changed between runs by
using the <A HREF = "dump_modify.html">dump_modify every</A> command (not allowed
for <I>dcd</I> style). The <A HREF = "dump_modify.html">dump_modify every</A> command
also allows a variable to be used to determine the sequence of
timesteps on which dump files are written.
timesteps on which dump files are written. In this mode a dump on the
first timestep of a run will also not be written unless the
<A HREF = "dump_modify.html">dump_modify first</A> command is used.
</P>
<P>The specified filename determines how the dump file(s) is written.
The default is to write one large text file, which is opened when the

View File

@ -296,12 +296,14 @@ minimization converges. Note that this means a dump will not be
performed on the initial timestep after the dump command is invoked,
if the current timestep is not a multiple of N. This behavior can be
changed via the "dump_modify first"_dump_modify.html command, which
can be useful if the dump command is invoked after a minimization
can also be useful if the dump command is invoked after a minimization
ended on an arbitrary timestep. N can be changed between runs by
using the "dump_modify every"_dump_modify.html command (not allowed
for {dcd} style). The "dump_modify every"_dump_modify.html command
also allows a variable to be used to determine the sequence of
timesteps on which dump files are written.
timesteps on which dump files are written. In this mode a dump on the
first timestep of a run will also not be written unless the
"dump_modify first"_dump_modify.html command is used.
The specified filename determines how the dump file(s) is written.
The default is to write one large text file, which is opened when the

View File

@ -365,16 +365,22 @@ which should be specified as v_name, where name is the variable name.
</P>
<P>In this case, the variable is evaluated at the beginning of a run to
determine the next timestep at which a dump snapshot will be written
out. On that timestep, the variable will be evaluated again to
out. On that timestep the variable will be evaluated again to
determine the next timestep, etc. Thus the variable should return
timestep values. See the stagger() and logfreq() and stride() math
functions for <A HREF = "variable.html">equal-style variables</A>, as examples of
useful functions to use in this context. Other similar math functions
could easily be added as options for <A HREF = "variable.html">equal-style
variables</A>. When using the variable option with the
<I>every</I> keyword, you also need to use the <I>first</I> option if you want
an initial snapshot written to the dump file. The <I>every</I> keyword
cannot be used with the dump <I>dcd</I> style.
variables</A>. Also see the next() function, which allows
use of a file-style variable which reads successive values from a
file, each time the variable is evaluated. Used with the <I>every</I>
keyword, if the file contains a list of ascending timesteps, you can
output snapshots whenever you wish.
</P>
<P>Note that when using the variable option with the <I>every</I> keyword, you
need to use the <I>first</I> option if you want an initial snapshot written
to the dump file. The <I>every</I> keyword cannot be used with the dump
<I>dcd</I> style.
</P>
<P>For example, the following commands will
write snapshots at timesteps 0,10,20,30,100,200,300,1000,2000,etc:
@ -383,6 +389,25 @@ write snapshots at timesteps 0,10,20,30,100,200,300,1000,2000,etc:
dump 1 all atom 100 tmp.dump
dump_modify 1 every v_s first yes
</PRE>
<P>The following commands would write snapshots at the timesteps listed
in file tmp.times:
</P>
<PRE>variable f file tmp.times
variable s equal next(f)
dump 1 all atom 100 tmp.dump
dump_modify 1 every v_s
</PRE>
<P>IMPORTANT NOTE: When using a file-style variable with the <I>every</I>
keyword, the file of timesteps must list a first timestep that is
beyond the current timestep (e.g. it cannot be 0). And it must list
one or more timesteps beyond the length of the run you perform. This
is because the dump command will generate an error if the next
timestep it reads from the file is not a value greater than the
current timestep. Thus if you wanted output on steps 0,15,100 of a
100-timestep run, the file should contain the values 15,100,101 and
you should also use the dump_modify first command. Any final value >
100 could be used in place of 101.
</P>
<HR>
<P>The <I>first</I> keyword determines whether a dump snapshot is written on

View File

@ -358,16 +358,22 @@ which should be specified as v_name, where name is the variable name.
In this case, the variable is evaluated at the beginning of a run to
determine the next timestep at which a dump snapshot will be written
out. On that timestep, the variable will be evaluated again to
out. On that timestep the variable will be evaluated again to
determine the next timestep, etc. Thus the variable should return
timestep values. See the stagger() and logfreq() and stride() math
functions for "equal-style variables"_variable.html, as examples of
useful functions to use in this context. Other similar math functions
could easily be added as options for "equal-style
variables"_variable.html. When using the variable option with the
{every} keyword, you also need to use the {first} option if you want
an initial snapshot written to the dump file. The {every} keyword
cannot be used with the dump {dcd} style.
variables"_variable.html. Also see the next() function, which allows
use of a file-style variable which reads successive values from a
file, each time the variable is evaluated. Used with the {every}
keyword, if the file contains a list of ascending timesteps, you can
output snapshots whenever you wish.
Note that when using the variable option with the {every} keyword, you
need to use the {first} option if you want an initial snapshot written
to the dump file. The {every} keyword cannot be used with the dump
{dcd} style.
For example, the following commands will
write snapshots at timesteps 0,10,20,30,100,200,300,1000,2000,etc:
@ -376,6 +382,25 @@ variable s equal logfreq(10,3,10)
dump 1 all atom 100 tmp.dump
dump_modify 1 every v_s first yes :pre
The following commands would write snapshots at the timesteps listed
in file tmp.times:
variable f file tmp.times
variable s equal next(f)
dump 1 all atom 100 tmp.dump
dump_modify 1 every v_s :pre
IMPORTANT NOTE: When using a file-style variable with the {every}
keyword, the file of timesteps must list a first timestep that is
beyond the current timestep (e.g. it cannot be 0). And it must list
one or more timesteps beyond the length of the run you perform. This
is because the dump command will generate an error if the next
timestep it reads from the file is not a value greater than the
current timestep. Thus if you wanted output on steps 0,15,100 of a
100-timestep run, the file should contain the values 15,100,101 and
you should also use the dump_modify first command. Any final value >
100 could be used in place of 101.
:line
The {first} keyword determines whether a dump snapshot is written on

View File

@ -38,14 +38,15 @@ be used in an input script command as $a or $z. If it is multiple
letters, it can be used as ${myTemp}.
</P>
<P>If multiple variables are used as arguments to the <I>next</I> command,
then all must be of the same variable style: <I>index</I>, <I>loop</I>,
then all must be of the same variable style: <I>index</I>, <I>loop</I>, <I>file</I>,
<I>universe</I>, or <I>uloop</I>. An exception is that <I>universe</I>- and
<I>uloop</I>-style variables can be mixed in the same <I>next</I> command.
</P>
<P>All the variables specified with the next command are incremented by
one value from their respective list or values. <I>String-</I> or <I>atom</I>-
or <I>equal</I>- or <I>world</I>-style variables cannot be used with the the
next command, since they only store a single value.
one value from their respective list of values. A <I>file</I>-style variable
reads the next line from its associated file. <I>String-</I> or <I>atom</I>- or
<I>equal</I>- or <I>world</I>-style variables cannot be used with the the next
command, since they only store a single value.
</P>
<P>When any of the variables in the next command has no more values, a
flag is set that causes the input script to skip the next
@ -53,18 +54,19 @@ flag is set that causes the input script to skip the next
a next command to exit. As explained in the <A HREF = "variable.html">variable</A>
command, the variable that has exhausted its values is also deleted.
This allows it to be used and re-defined later in the input script.
<I>File</I>-style variables are exhausted when the end-of-file is reached.
</P>
<P>When the next command is used with <I>index</I>- or <I>loop</I>-style variables,
the next value is assigned to the variable for all processors. When
the next command is used with <I>universe</I>- or <I>uloop</I>-style variables,
the next value is assigned to whichever processor partition executes
the command first. All processors in the partition are assigned the
same value. Running LAMMPS on multiple partitions of processors via
the "-partition" command-line switch is described in <A HREF = "Section_start.html#start_7">this
section</A> of the manual. <I>Universe</I>- and
<I>uloop</I>-style variables are incremented using the files
"tmp.lammps.variable" and "tmp.lammps.variable.lock" which you will
see in your directory during such a LAMMPS run.
<P>When the next command is used with <I>index</I>- or <I>loop</I>-style or
<I>file</I>-style variables, the next value is assigned to the variable for
all processors. When the next command is used with <I>universe</I>- or
<I>uloop</I>-style variables, the next value is assigned to whichever
processor partition executes the command first. All processors in the
partition are assigned the same value. Running LAMMPS on multiple
partitions of processors via the "-partition" command-line switch is
described in <A HREF = "Section_start.html#start_7">this section</A> of the manual.
<I>Universe</I>- and <I>uloop</I>-style variables are incremented using the
files "tmp.lammps.variable" and "tmp.lammps.variable.lock" which you
will see in your directory during such a LAMMPS run.
</P>
<P>Here is an example of running a series of simulations using the next
command with an <I>index</I>-style variable. If this input script is named

View File

@ -35,14 +35,15 @@ be used in an input script command as $a or $z. If it is multiple
letters, it can be used as $\{myTemp\}.
If multiple variables are used as arguments to the {next} command,
then all must be of the same variable style: {index}, {loop},
then all must be of the same variable style: {index}, {loop}, {file},
{universe}, or {uloop}. An exception is that {universe}- and
{uloop}-style variables can be mixed in the same {next} command.
All the variables specified with the next command are incremented by
one value from their respective list or values. {String-} or {atom}-
or {equal}- or {world}-style variables cannot be used with the the
next command, since they only store a single value.
one value from their respective list of values. A {file}-style variable
reads the next line from its associated file. {String-} or {atom}- or
{equal}- or {world}-style variables cannot be used with the the next
command, since they only store a single value.
When any of the variables in the next command has no more values, a
flag is set that causes the input script to skip the next
@ -50,18 +51,19 @@ flag is set that causes the input script to skip the next
a next command to exit. As explained in the "variable"_variable.html
command, the variable that has exhausted its values is also deleted.
This allows it to be used and re-defined later in the input script.
{File}-style variables are exhausted when the end-of-file is reached.
When the next command is used with {index}- or {loop}-style variables,
the next value is assigned to the variable for all processors. When
the next command is used with {universe}- or {uloop}-style variables,
the next value is assigned to whichever processor partition executes
the command first. All processors in the partition are assigned the
same value. Running LAMMPS on multiple partitions of processors via
the "-partition" command-line switch is described in "this
section"_Section_start.html#start_7 of the manual. {Universe}- and
{uloop}-style variables are incremented using the files
"tmp.lammps.variable" and "tmp.lammps.variable.lock" which you will
see in your directory during such a LAMMPS run.
When the next command is used with {index}- or {loop}-style or
{file}-style variables, the next value is assigned to the variable for
all processors. When the next command is used with {universe}- or
{uloop}-style variables, the next value is assigned to whichever
processor partition executes the command first. All processors in the
partition are assigned the same value. Running LAMMPS on multiple
partitions of processors via the "-partition" command-line switch is
described in "this section"_Section_start.html#start_7 of the manual.
{Universe}- and {uloop}-style variables are incremented using the
files "tmp.lammps.variable" and "tmp.lammps.variable.lock" which you
will see in your directory during such a LAMMPS run.
Here is an example of running a series of simulations using the next
command with an {index}-style variable. If this input script is named

View File

@ -17,7 +17,7 @@
</PRE>
<UL><LI>name = name of variable to define
<LI>style = <I>delete</I> or <I>index</I> or <I>loop</I> or <I>world</I> or <I>universe</I> or <I>uloop</I> or <I>string</I> or <I>equal</I> or <I>atom</I>
<LI>style = <I>delete</I> or <I>index</I> or <I>loop</I> or <I>world</I> or <I>universe</I> or <I>uloop</I> or <I>string</I> or <I>file</I> or <I>equal</I> or <I>atom</I>
<PRE> <I>delete</I> = no args
<I>index</I> args = one or more strings
@ -39,6 +39,7 @@
N = integer size of loop
pad = all values will be same length, e.g. 001, 002, ..., 100
<I>string</I> arg = one string
<I>file</I> arg = filename
<I>equal</I> or <I>atom</I> args = one formula containing numbers, thermo keywords, math operations, group functions, atom values and vectors, compute/fix/variable references
numbers = 0.0, 100, -5.4, 2.8e-4, etc
constants = PI
@ -59,7 +60,7 @@
bound(group,xmin,region), gyration(group,region), ke(group,reigon),
angmom(group,dim,region), torque(group,dim,region),
inertia(group,dimdim,region), omega(group,dim,region)
special functions = sum(x), min(x), max(x), ave(x), trap(x), gmask(x), rmask(x), grmask(x,y)
special functions = sum(x), min(x), max(x), ave(x), trap(x), gmask(x), rmask(x), grmask(x,y), next(x)
atom value = mass[i], type[i], x[i], y[i], z[i], vx[i], vy[i], vz[i], fx[i], fy[i], fz[i]
atom vector = mass, type, x, y, z, vx, vy, vz, fx, fy, fz
compute references = c_ID, c_ID[i], c_ID[i][j]
@ -79,6 +80,7 @@ variable b equal xcm(mol1,x)/2.0
variable b equal c_myTemp
variable b atom x*y/vol
variable foo string myfile
variable f file values.txt
variable temp world 300.0 310.0 320.0 ${Tfinal}
variable x universe 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
variable x uloop 15 pad
@ -154,13 +156,13 @@ the variable's string. The variable name can be referenced as $x if
the name "x" is a single character, or as ${LoopVar} if the name
"LoopVar" is one or more characters.
</P>
<P>As described below, for variable styles <I>index</I>, <I>loop</I>, <I>universe</I>,
and <I>uloop</I>, which string is assigned to a variable can be incremented
via the <A HREF = "next.html">next</A> command. When there are no more strings to
assign, the variable is exhausted and a flag is set that causes the
next <A HREF = "jump.html">jump</A> command encountered in the input script to be
skipped. This enables the construction of simple loops in the input
script that are iterated over and then exited from.
<P>As described below, for variable styles <I>index</I>, <I>loop</I>, <I>file</I>,
<I>universe</I>, and <I>uloop</I>, which string is assigned to a variable can be
incremented via the <A HREF = "next.html">next</A> command. When there are no more
strings to assign, the variable is exhausted and a flag is set that
causes the next <A HREF = "jump.html">jump</A> command encountered in the input
script to be skipped. This enables the construction of simple loops
in the input script that are iterated over and then exited from.
</P>
<P>As explained above, an exhausted variable can be re-used in an input
script. The <I>delete</I> style also removes the variable, the same as if
@ -235,6 +237,32 @@ strings are the integers from 1 to N. This allows generation of long
list of runs (e.g. 1000) without having to list N strings in the input
script.
</P>
<P>For the <I>string</I> style, a single string is assigned to the variable.
The only difference between this and using the <I>index</I> style with a
single string is that a variable with <I>string</I> style can be redefined.
E.g. by another command later in the input script, or if the script is
read again in a loop.
</P>
<P>For the <I>file</I> style, a filename is provided which contains a list of
strings to assign to the variable, one per line. The strings can be
numeric values if desired; see the discussion of the next() function
below for equal-style variables, which will convert the string of a
file-style variable into a numeric value in a formula.
</P>
<P>When a file-style variable is defined, the file is opened and the
string on the first line is read and stored with the variable. This
means the variable can then be evaluated as many times as desired and
will return that string. There are two ways to cause the next string
from the file to be read: use the <A HREF = "next.html">next</A> command or the
next() function in an equal- or atom-style variable, as discussed
below.
</P>
<P>The rules for formatting the file are as follows. A comment character
"#" can be used anywhere on a line; text starting with the comment
character is stripped. Blank lines are skipped. The first "word" of
a non-blank line, delimited by white space, is the "string" assigned
to the variable.
</P>
<HR>
<P>For the <I>equal</I> and <I>atom</I> styles, a single string is specified which
@ -279,7 +307,7 @@ references to other variables.
<TR><TD >Math functions</TD><TD > sqrt(x), exp(x), ln(x), log(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x), random(x,y,z), normal(x,y,z), ceil(x), floor(x), round(x), ramp(x,y), stagger(x,y), logfreq(x,y,z), stride(x,y,z), vdisplace(x,y), swiggle(x,y,z), cwiggle(x,y,z)</TD></TR>
<TR><TD >Group functions</TD><TD > count(ID), mass(ID), charge(ID), xcm(ID,dim), vcm(ID,dim), fcm(ID,dim), bound(ID,dir), gyration(ID), ke(ID), angmom(ID,dim), torque(ID,dim), inertia(ID,dimdim), omega(ID,dim)</TD></TR>
<TR><TD >Region functions</TD><TD > count(ID,IDR), mass(ID,IDR), charge(ID,IDR), xcm(ID,dim,IDR), vcm(ID,dim,IDR), fcm(ID,dim,IDR), bound(ID,dir,IDR), gyration(ID,IDR), ke(ID,IDR), angmom(ID,dim,IDR), torque(ID,dim,IDR), inertia(ID,dimdim,IDR), omega(ID,dim,IDR)</TD></TR>
<TR><TD >Special functions</TD><TD > sum(x), min(x), max(x), ave(x), trap(x), gmask(x), rmask(x), grmask(x,y)</TD></TR>
<TR><TD >Special functions</TD><TD > sum(x), min(x), max(x), ave(x), trap(x), gmask(x), rmask(x), grmask(x,y), next(x)</TD></TR>
<TR><TD >Atom values</TD><TD > mass[i], type[i], x[i], y[i], z[i], vx[i], vy[i], vz[i], fx[i], fy[i], fz[i]</TD></TR>
<TR><TD >Atom vectors</TD><TD > mass, type, x, y, z, vx, vy, vz, fx, fy, fz</TD></TR>
<TR><TD >Compute references</TD><TD > c_ID, c_ID[i], c_ID[i][j]</TD></TR>
@ -559,6 +587,20 @@ and the second is a region ID. It can only be used in atom-style
variables. It returns a 1 for atoms that are in both the group and
region, and a 0 for atoms that are not in both.
</P>
<P>The next(x) function takes 1 argument which is a variable ID (not
"v_foo", just "foo"). It must be for a file-style variable. Each
time the next() function is invoked (i.e. each time the equal-style or
atom-style variable is evaluated), the current string value stored by
the file-style variable is converted to a numeric value returned by
the function, and the next value from the file is read and stored.
Note that if the line previously read from the file was not a numeric
string, then it will typically evaluate to 0.0, which is likely not
what you want. Since the file-style variable reads and stores the
first line of the file when it is defined in the input script, this is
the value that will be returned the first time the next() function is
invoked. If next() is invoked more times than there are lines in the
file, the value for the last line is repeatedly returned.
</P>
<HR>
<H4>Atom Values and Vectors
@ -649,20 +691,26 @@ the doc pages for individual fix commands for details.
<H4>Variable References
</H4>
<P>Variable references access quantities calulated by other variables,
which will cause those variables to be evaluated. The name in the
reference should be replaced by the name of a variable defined
elsewhere in the input script. As discussed on this doc page,
atom-style variables generate a per-atom vector of values; all other
variable styles generate a global scalar value. An equal-style
variable can only use scalar values, which means another equal-style
variable or an element of an atom-style variable. Atom-style
variables can use the same scalar values. They can also use other
atom-style variables.
<P>Variable references access quantities stored or calculated by other
variables, which will cause those variables to be evaluated. The name
in the reference should be replaced by the name of a variable defined
elsewhere in the input script.
</P>
<P>As discussed on this doc page, equal-style variables generate a global
scalar numeric value; atom-style variables generate a per-atom vector
of numeric values; all other variables store a string. The formula
for an equal-style variable can use any style of variable except an
atom-style (unless only a single value from the atom-style variable is
accessed via a subscript). If a string-storing variable is used,
the string is converted to a numeric value. Note that this
will typically produce a 0.0 if the string is not a numeric string,
which is likely not what you want. The formula for an atom-style
variable can use any style of variable, including other atom-style
variables.
</P>
<P>Examples of different kinds of variable references are as follows.
There is no ambiguity as to what a reference means, since variables
produce only a global scalar or a per-atom vectors, never both.
produce only a global scalar or a per-atom vector, never both.
</P>
<DIV ALIGN=center><TABLE BORDER=1 >
<TR><TD >v_name</TD><TD > scalar, or per-atom vector</TD></TR>

View File

@ -13,7 +13,7 @@ variable command :h3
variable name style args ... :pre
name = name of variable to define :ulb,l
style = {delete} or {index} or {loop} or {world} or {universe} or {uloop} or {string} or {equal} or {atom} :l
style = {delete} or {index} or {loop} or {world} or {universe} or {uloop} or {string} or {file} or {equal} or {atom} :l
{delete} = no args
{index} args = one or more strings
{loop} args = N
@ -34,6 +34,7 @@ style = {delete} or {index} or {loop} or {world} or {universe} or {uloop} or {st
N = integer size of loop
pad = all values will be same length, e.g. 001, 002, ..., 100
{string} arg = one string
{file} arg = filename
{equal} or {atom} args = one formula containing numbers, thermo keywords, math operations, group functions, atom values and vectors, compute/fix/variable references
numbers = 0.0, 100, -5.4, 2.8e-4, etc
constants = PI
@ -54,7 +55,7 @@ style = {delete} or {index} or {loop} or {world} or {universe} or {uloop} or {st
bound(group,xmin,region), gyration(group,region), ke(group,reigon),
angmom(group,dim,region), torque(group,dim,region),
inertia(group,dimdim,region), omega(group,dim,region)
special functions = sum(x), min(x), max(x), ave(x), trap(x), gmask(x), rmask(x), grmask(x,y)
special functions = sum(x), min(x), max(x), ave(x), trap(x), gmask(x), rmask(x), grmask(x,y), next(x)
atom value = mass\[i\], type\[i\], x\[i\], y\[i\], z\[i\], vx\[i\], vy\[i\], vz\[i\], fx\[i\], fy\[i\], fz\[i\]
atom vector = mass, type, x, y, z, vx, vy, vz, fx, fy, fz
compute references = c_ID, c_ID\[i\], c_ID\[i\]\[j\]
@ -73,6 +74,7 @@ variable b equal xcm(mol1,x)/2.0
variable b equal c_myTemp
variable b atom x*y/vol
variable foo string myfile
variable f file values.txt
variable temp world 300.0 310.0 320.0 $\{Tfinal\}
variable x universe 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
variable x uloop 15 pad
@ -148,13 +150,13 @@ the variable's string. The variable name can be referenced as $x if
the name "x" is a single character, or as $\{LoopVar\} if the name
"LoopVar" is one or more characters.
As described below, for variable styles {index}, {loop}, {universe},
and {uloop}, which string is assigned to a variable can be incremented
via the "next"_next.html command. When there are no more strings to
assign, the variable is exhausted and a flag is set that causes the
next "jump"_jump.html command encountered in the input script to be
skipped. This enables the construction of simple loops in the input
script that are iterated over and then exited from.
As described below, for variable styles {index}, {loop}, {file},
{universe}, and {uloop}, which string is assigned to a variable can be
incremented via the "next"_next.html command. When there are no more
strings to assign, the variable is exhausted and a flag is set that
causes the next "jump"_jump.html command encountered in the input
script to be skipped. This enables the construction of simple loops
in the input script that are iterated over and then exited from.
As explained above, an exhausted variable can be re-used in an input
script. The {delete} style also removes the variable, the same as if
@ -229,6 +231,32 @@ strings are the integers from 1 to N. This allows generation of long
list of runs (e.g. 1000) without having to list N strings in the input
script.
For the {string} style, a single string is assigned to the variable.
The only difference between this and using the {index} style with a
single string is that a variable with {string} style can be redefined.
E.g. by another command later in the input script, or if the script is
read again in a loop.
For the {file} style, a filename is provided which contains a list of
strings to assign to the variable, one per line. The strings can be
numeric values if desired; see the discussion of the next() function
below for equal-style variables, which will convert the string of a
file-style variable into a numeric value in a formula.
When a file-style variable is defined, the file is opened and the
string on the first line is read and stored with the variable. This
means the variable can then be evaluated as many times as desired and
will return that string. There are two ways to cause the next string
from the file to be read: use the "next"_next.html command or the
next() function in an equal- or atom-style variable, as discussed
below.
The rules for formatting the file are as follows. A comment character
"#" can be used anywhere on a line; text starting with the comment
character is stripped. Blank lines are skipped. The first "word" of
a non-blank line, delimited by white space, is the "string" assigned
to the variable.
:line
For the {equal} and {atom} styles, a single string is specified which
@ -279,7 +307,7 @@ Region functions: count(ID,IDR), mass(ID,IDR), charge(ID,IDR), \
bound(ID,dir,IDR), gyration(ID,IDR), ke(ID,IDR), \
angmom(ID,dim,IDR), torque(ID,dim,IDR), \
inertia(ID,dimdim,IDR), omega(ID,dim,IDR)
Special functions: sum(x), min(x), max(x), ave(x), trap(x), gmask(x), rmask(x), grmask(x,y)
Special functions: sum(x), min(x), max(x), ave(x), trap(x), gmask(x), rmask(x), grmask(x,y), next(x)
Atom values: mass\[i\], type\[i\], x\[i\], y\[i\], z\[i\], \
vx\[i\], vy\[i\], vz\[i\], fx\[i\], fy\[i\], fz\[i\]
Atom vectors: mass, type, x, y, z, vx, vy, vz, fx, fy, fz
@ -559,6 +587,20 @@ and the second is a region ID. It can only be used in atom-style
variables. It returns a 1 for atoms that are in both the group and
region, and a 0 for atoms that are not in both.
The next(x) function takes 1 argument which is a variable ID (not
"v_foo", just "foo"). It must be for a file-style variable. Each
time the next() function is invoked (i.e. each time the equal-style or
atom-style variable is evaluated), the current string value stored by
the file-style variable is converted to a numeric value returned by
the function, and the next value from the file is read and stored.
Note that if the line previously read from the file was not a numeric
string, then it will typically evaluate to 0.0, which is likely not
what you want. Since the file-style variable reads and stores the
first line of the file when it is defined in the input script, this is
the value that will be returned the first time the next() function is
invoked. If next() is invoked more times than there are lines in the
file, the value for the last line is repeatedly returned.
:line
Atom Values and Vectors :h4
@ -645,20 +687,26 @@ the doc pages for individual fix commands for details.
Variable References :h4
Variable references access quantities calulated by other variables,
which will cause those variables to be evaluated. The name in the
reference should be replaced by the name of a variable defined
elsewhere in the input script. As discussed on this doc page,
atom-style variables generate a per-atom vector of values; all other
variable styles generate a global scalar value. An equal-style
variable can only use scalar values, which means another equal-style
variable or an element of an atom-style variable. Atom-style
variables can use the same scalar values. They can also use other
atom-style variables.
Variable references access quantities stored or calculated by other
variables, which will cause those variables to be evaluated. The name
in the reference should be replaced by the name of a variable defined
elsewhere in the input script.
As discussed on this doc page, equal-style variables generate a global
scalar numeric value; atom-style variables generate a per-atom vector
of numeric values; all other variables store a string. The formula
for an equal-style variable can use any style of variable except an
atom-style (unless only a single value from the atom-style variable is
accessed via a subscript). If a string-storing variable is used,
the string is converted to a numeric value. Note that this
will typically produce a 0.0 if the string is not a numeric string,
which is likely not what you want. The formula for an atom-style
variable can use any style of variable, including other atom-style
variables.
Examples of different kinds of variable references are as follows.
There is no ambiguity as to what a reference means, since variables
produce only a global scalar or a per-atom vectors, never both.
produce only a global scalar or a per-atom vector, never both.
v_name: scalar, or per-atom vector
v_name\[I\]: atom I's value in per-atom vector :tb(s=:)