forked from lijiext/lammps
190 lines
9.0 KiB
Plaintext
190 lines
9.0 KiB
Plaintext
"LAMMPS WWW Site"_lws - "LAMMPS Documentation"_ld - "LAMMPS Commands"_lc :c
|
|
|
|
:link(lws,http://lammps.sandia.gov)
|
|
:link(ld,Manual.html)
|
|
:link(lc,Section_commands.html#comm)
|
|
|
|
:line
|
|
|
|
variable command :h3
|
|
|
|
[Syntax:]
|
|
|
|
variable name style args ... :pre
|
|
|
|
name = name of variable to define :ulb,l
|
|
style = {index} or {loop} or {equal} or {world} or {universe} :l
|
|
{index} args = one or more strings
|
|
{loop} args = N = integer size of loop
|
|
{equal} args = one string containing functions, vectors, keywords, numbers
|
|
math functions = add(x,y), sub(x,y), mult(x,y), div(x,y),
|
|
neg(x), pow(x,y), exp(x), ln(x), sqrt(x)
|
|
group functions = mass(group), charge(group), xcm(group,dim),
|
|
vcm(group,dim), bounds(group,xmin), gyration(group)
|
|
vectors = x\[5\], y\[12\], z\[17\], vx\[88\], vy\[19\], vz\[2\],
|
|
fx\[1\], fy\[2005\], fz\[1\]
|
|
keywords = same keywords (mostly) as in "thermo_style custom"_thermo_style.html command
|
|
{world} args = one string for each partition of processors
|
|
{universe} args = one or more strings :pre
|
|
:ule
|
|
|
|
[Examples:]
|
|
|
|
variable x index run1 run2 run3 run4 run5 run6 run7 run8
|
|
variable LoopVar loop 20
|
|
variable beta equal div(temp,3.0)
|
|
variable b1 equal add(x\[234\],mult(0.5,lx))
|
|
variable b equal xcm(mol1,x)
|
|
variable temp world 300.0 310.0 320.0 330.0
|
|
variable x universe 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 :pre
|
|
|
|
[Description:]
|
|
|
|
This command assigns one or more values to a variable name so that the
|
|
variable can be used in subsequent input script commands. The "name"
|
|
of the variable is an arbitrary string. Each "value" is a string
|
|
which could be text or numbers, as in the examples above. As
|
|
explained in "this section"_Section_commands.html#3_2, occurrences of
|
|
the variable name in an input script line are replaced by the
|
|
variable's value. The variable name can be referenced in the input
|
|
script 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}, and
|
|
{universe}, the value assigned to a variable can be incremented via
|
|
the "next"_next.html command. When there are no more values 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 exited from.
|
|
|
|
When a variable command is encountered for a variable that has already
|
|
been specified, the command is skipped. This is the case for all
|
|
variable styles except {equal}, so that {equal}-style variable names
|
|
can be re-used and re-defined anytime. Skipping allows you to loop
|
|
over the same input script many times without re-defining your
|
|
variables. When a variable is exhausted via the "next"_next.html
|
|
command, it is then available to be re-defined in a subsequent
|
|
variable command.
|
|
|
|
For the {index} style, one or more strings are specified. Initially,
|
|
the 1st string is assigned to the variable. Each time a
|
|
"next"_next.html command is used with the variable name, the next
|
|
string is assigned. All processors assign the same string to the
|
|
variable. {Index}-style variables can also be set (with a single
|
|
value) by using the command-line switch -var; see "this
|
|
section"_Section_start.html#2_4 for details.
|
|
|
|
The {loop} style is identical to the {index} style except that the
|
|
strings are the integers from 1 to N. Initially, the string "1" is
|
|
assigned to the variable. Each time a "next"_next.html command is
|
|
used with the variable name, the next string ("2", "3", etc) is
|
|
assigned. All processors assign the same string to the variable.
|
|
|
|
For the {equal} style, a single string is specified which represents
|
|
an equation that will be evaluated afresh each time the variable is
|
|
used. Thus the variable can take on different values at different
|
|
stages of the input script. For example, if the variable is used in a
|
|
"fix print"_fix_print.html command, it could print different values
|
|
each timestep it was invoked. The next command cannot be used with
|
|
{equal}-style variables, since there is only one value. Note that, as
|
|
with any other input script command, it is feasible to use another
|
|
variable in the {equal} variable's string, e.g. variable y equal
|
|
mult($x,2). However, $x will be replaced immediately by it's current
|
|
value when the command is first parsed, not each time that $y is
|
|
substituted for.
|
|
|
|
The syntax of the equation assigned to {equal} variables is simple.
|
|
It can contain "functions", "vectors", "keywords", or "numbers" in any
|
|
combination.
|
|
|
|
Function = a keyword followed by parenthesis with one or two arguments
|
|
Supported arithmetic functions = add(x,y), sub(x,y), mult(x,y), div(x,y), \
|
|
neg(x), pow(x,y), exp(x), ln(x), sqrt(x)
|
|
Supported group functions = mass(ID), charge(ID), xcm(ID,dim), vcm(ID,dim), \
|
|
bound(ID,dir), gyration(ID)
|
|
Example function usage = div(1.0e20,3.0), neg(x\[34\]), pow(lx,3.0), \
|
|
xcm(mol,x), bound(lower,zmin)
|
|
Vector = a keyword followed by square brackets containing an atom ID
|
|
Supported vectors = x, y, z, vx, vy, vz, fx, fy, fz
|
|
Example vector usage = x\[123\], fz\[1000\]
|
|
Keyword = keywords supported by the \
|
|
"thermo_style custom"_thermo_style.html \
|
|
command except cpu and pressure tensor components (pxx, pyy, etc)
|
|
Supported keywords = step, atoms, temp, press, pe, ke, eng, evdwl, \
|
|
ecoul, epair, ebond, eangle, edihed, eimp, emol, elong, vol, lx, ly, lz, \
|
|
gke, grot, t_ID
|
|
Example keyword usage = atoms, pow(vol,0.333), mult(elong,0.5)
|
|
Number = 0.2, 1.0e20, -15.4, etc :ul
|
|
|
|
For the group functions, ID is a group-ID, dim is 'x' or 'y' or 'z',
|
|
and dir is one of 6 strings: "xmin", "xmax", "ymin", "ymax", "zmin",
|
|
or "zmax". The group functions mass() and charge() are the total mass
|
|
and charge of the group of atoms. Xcm() and vcm() return components
|
|
of the position and velocity of the center of mass of the group.
|
|
Bound() returns the min/max of a particular coordinate for all atoms
|
|
in the group. Gyration() computes the radius-of-gyration of the group
|
|
of atoms. See the "fix gyration"_fix_gyration.html command for the
|
|
formula.
|
|
|
|
Keywords have restrictions on when they can be assigned to variables.
|
|
For example, keywords that compute thermodynamic quantites can only be
|
|
invoked after the first simulation has begun. A warning is issued if
|
|
thermodyanmic keywords are invoked on timesteps when thermodynamic
|
|
information is not being printed to the screen, since the values
|
|
assigned to the variable may be out-of-date.
|
|
|
|
The variable {equal} equation can also be nested in that function
|
|
arguments can be functions, vectors, keywords, or numbers. For
|
|
example, this is a valid equation:
|
|
|
|
variable x equal div(add(pe,ke),pow(vol,div(1,3))) :pre
|
|
|
|
For the {world} style, one or more strings are specified. There must
|
|
be one string for each processor partition or "world". See "this
|
|
section"_Section_start.html#2_4 of the manual for information on
|
|
running LAMMPS with multiple partitions via the "-partition"
|
|
command-line switch. This variable command assigns one string to each
|
|
world. All processors in the world are assigned the same string. The
|
|
next command cannot be used with {equal}-style variables, since there
|
|
is only one value per world. This style of variable is useful when
|
|
you wish to run different simulations on different partitions, or when
|
|
performing a parallel tempering simulation (see the
|
|
"temper"_temper.html command), to assign different temperatures to
|
|
different partitions.
|
|
|
|
For the {universe} style, one or more strings are specified. There
|
|
must be at least as many strings as there are processor partitions or
|
|
"worlds". See "this page"_Section_start.html#2_4 for information on
|
|
running LAMMPS with multiple partitions via the "-partition"
|
|
command-line switch. This variable command initially assigns one
|
|
string to each world. When a "next"_next.html command is encountered
|
|
using this variable, the first processor partition to encounter it, is
|
|
assigned the next available value. This continues until all the
|
|
variable values are consumed. Thus, this command can be used to run
|
|
50 simulations on 8 processor partitions. The simulations will be run
|
|
one after the other on whatever partition becomes available, until
|
|
they are all finished. {Universe}-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.
|
|
|
|
If a variable command is encountered when the variable has already
|
|
been defined, the command is ignored. Thss allows an input script
|
|
with a variable command to be processed multiple times; see the
|
|
"jump"_jump.html or "include"_include.html commands. It also means
|
|
that the use of the command-line switch -var will override a
|
|
corresponding variable setting in the input script.
|
|
|
|
[Restrictions:]
|
|
|
|
The use of atom vectors in {equal} style variables requires the atom
|
|
style to use a global mapping in order to look up the vector indices.
|
|
Only atom styles with molecular information create global maps.
|
|
|
|
[Related commands:]
|
|
|
|
"next"_next.html, "jump"_jump.html, "include"_include.html,
|
|
"temper"_temper.html, "fix print"_fix_print.html, "print"_print.html
|
|
|
|
[Default:] none
|