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

This commit is contained in:
sjplimp
2015-03-17 16:05:28 +00:00
parent fb2a894e03
commit 220bb4df5e
16 changed files with 1685 additions and 305 deletions

View File

@ -17,7 +17,8 @@
</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>format</I> or <I>getenv</I> or <I>file</I> or <I>atomfile</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>format</I> or <I>getenv</I> or <I>file</I> or <I>atomfile</I> or <I>python</I> or <I>equal</I> or <I>atom</I>
<PRE> <I>delete</I> = no args
<I>index</I> args = one or more strings
@ -45,6 +46,7 @@
<I>getenv</I> arg = one string
<I>file</I> arg = filename
<I>atomfile</I> arg = filename
<I>python</I> arg = function
<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
@ -87,6 +89,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 myPy python increase
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
@ -116,7 +119,9 @@ command) or used as input to an averaging fix (see the <A HREF = "fix_ave_spatia
ave/spatial</A> and <A HREF = "fix_ave_atom.html">fix ave/atom</A>
commands). Variables of style <I>atomfile</I> can be used anywhere in an
input script that atom-style variables are used; they get their
per-atom values from a file rather than from a formula.
per-atom values from a file rather than from a formula. Variables can
be hooked to Python functions using code you provide, so that the
variable gets its value from the evaluation of the Python code.
</P>
<P>IMPORTANT NOTE: As discussed in <A HREF = "Section_commands.html#cmd_2">Section
3.2</A> of the manual, an input script can
@ -138,11 +143,31 @@ different values when it is evaluated at different times during a
simulation.
</P>
<P>IMPORTANT NOTE: When the input script line is encountered that defines
a variable of style <I>equal</I> or <I>atom</I> that contains a formula, the
formula is NOT immediately evaluated and the result stored. See the
discussion below about "Immediate Evaluation of Variables" if you want
to do this. This is also true of the <I>format</I> style variable
since it evaluates another variable when it is invoked.
a variable of style <I>equal</I> or <I>atom</I> or <I>python</I> that contains a
formula or Python code, the formula is NOT immediately evaluated and
the result stored. See the discussion below about "Immediate
Evaluation of Variables" if you want to do this. This is also true of
the <I>format</I> style variable since it evaluates another variable when
it is invoked.
</P>
<P>IMPORTANT NOTE: Variables of style <I>equal</I> and <I>atom</I> can be used as
inputs to various other LAMMPS commands which evaluate their formulas
as needed, e.g. at different timesteps during a <A HREF = "run.html">run</A>.
Variables of style <I>python</I> can be used in place of an equal-style
variable so long as the associated Python function, as defined by the
<A HREF = "python.html">python</A> command, returns a numeric value. Thus any
command that states it can use an equal-style variable as an argument,
can also use such a python-style variable. This means that when the
LAMMPS command evaluates the variable, the Python function will be
executed.
</P>
<P>When the input script line is encountered that defines
a variable of style <I>equal</I> or <I>atom</I> or <I>python</I> that contains a
formula or Python code, the formula is NOT immediately evaluated and
the result stored. See the discussion below about "Immediate
Evaluation of Variables" if you want to do this. This is also true of
the <I>format</I> style variable since it evaluates another variable when
it is invoked.
</P>
<P>IMPORTANT NOTE: When a variable command is encountered in the input
script and the variable name has already been specified, the command
@ -155,12 +180,12 @@ means that using the <A HREF = "Section_start.html#start_7">command-line switch<
script.
</P>
<P>There are two exceptions to this rule. First, variables of style
<I>string</I>, <I>getenv</I>, <I>equal</I> and <I>atom</I> ARE redefined each time the
command is encountered. This allows these style of variables to be
redefined multiple times in an input script. In a loop, this means
the formula associated with an <I>equal</I> or <I>atom</I> style variable can
change if it contains a substitution for another variable, e.g. $x or
v_x.
<I>string</I>, <I>getenv</I>, <I>equal</I>, <I>atom</I>, and <I>python</I> ARE redefined each
time the command is encountered. This allows these style of variables
to be redefined multiple times in an input script. In a loop, this
means the formula associated with an <I>equal</I> or <I>atom</I> style variable
can change if it contains a substitution for another variable, e.g. $x
or v_x.
</P>
<P>Second, as described below, if a variable is iterated on to the end of
its list of strings via the <A HREF = "next.html">next</A> command, it is removed
@ -202,13 +227,15 @@ variable a delete
</PRE>
<HR>
<P>This section describes how various variable styles are defined and
what they store. Many of the styles store one or more strings. Note
that a single string can contain spaces (multiple words), if it is
enclosed in quotes in the variable command. When the variable is
substituted for in another input script command, its returned string
will then be interpreted as multiple arguments in the expanded
command.
<P>This section describes how all the various variable styles are defined
and what they store. Except for the <I>equal</I> and <I>atom</I> styles,
which are explaine in the next section.
</P>
<P>Many of the styles store one or more strings. Note that a single
string can contain spaces (multiple words), if it is enclosed in
quotes in the variable command. When the variable is substituted for
in another input script command, its returned string will then be
interpreted as multiple arguments in the expanded command.
</P>
<P>For the <I>index</I> style, one or more strings are specified. Initially,
the 1st string is assigned to the variable. Each time a
@ -338,6 +365,31 @@ will be assigned to that atom. IDs can be listed in any order.
for all atoms is first set to 0.0. Thus values for atoms whose ID
does not appear in the set, will remain 0.0.
</P>
<P>For the <I>python</I> style a Python function name is provided. This needs
to match a function name specified in a <A HREF = "python.html">python</A> command
which returns a value to this variable as defined by its <I>return</I>
keyword. For exampe these two commands would be self-consistent:
</P>
<PRE>variable foo python myMultiply
python myMultiply return v_foo format f file funcs.py
</PRE>
<P>The two commands can appear in either order so long as both are
specified before the Python function is invoked for the first time.
</P>
<P>Each time the variable is evaluated, the associated Python function is
invoked, and the value it returns is also returned by the variable.
Since the Python function can use other LAMMPS variables as input, or
query interal LAMMPS quantities to perform its computation, this means
the variable can return a different value each time it is evaluated.
</P>
<P>The type of value stored in the variable is determined by the <I>format</I>
keyword of the <A HREF = "python.html">python</A> command. It can be an integer
(i), floating point (f), or string (s) value. As mentioned above, if
it is a numeric value (integer or floating point), then the
python-style variable can be used in place of an equal-style variable
anywhere in an input script, e.g. as an argument to another command
that allows for equal-style variables.
</P>
<HR>
<P>For the <I>equal</I> and <I>atom</I> styles, a single string is specified which