2006-09-22 00:22:34 +08:00
|
|
|
<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>next command
|
|
|
|
</H3>
|
|
|
|
<P><B>Syntax:</B>
|
|
|
|
</P>
|
|
|
|
<PRE>next variables
|
|
|
|
</PRE>
|
2006-09-28 03:12:31 +08:00
|
|
|
<UL><LI>variables = one or more variable names
|
2006-09-22 00:22:34 +08:00
|
|
|
</UL>
|
|
|
|
<P><B>Examples:</B>
|
|
|
|
</P>
|
|
|
|
<PRE>next x
|
2006-09-28 03:12:31 +08:00
|
|
|
next a t x myTemp
|
2006-09-22 00:22:34 +08:00
|
|
|
</PRE>
|
|
|
|
<P><B>Description:</B>
|
|
|
|
</P>
|
|
|
|
<P>This command is used with variables defined by the
|
|
|
|
<A HREF = "variable.html">variable</A> command. It assigns the next value to the
|
2007-06-20 20:56:17 +08:00
|
|
|
variable from the list of values defined for that variable by the
|
|
|
|
<A HREF = "variable.html">variable</A> command. Thus when that variable is
|
2006-09-28 03:12:31 +08:00
|
|
|
subsequently substituted for in an input script command, the new value
|
2007-06-20 20:56:17 +08:00
|
|
|
is used.
|
2006-09-22 00:22:34 +08:00
|
|
|
</P>
|
2007-06-20 20:56:17 +08:00
|
|
|
<P>See the <A HREF = "variable.html">variable</A> command for info on how to define and
|
|
|
|
use different kinds of variables in LAMMPS input scripts. If a
|
|
|
|
variable name is a single lower-case character from "a" to "z", it can
|
|
|
|
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,
|
2012-11-10 09:17:45 +08:00
|
|
|
then all must be of the same variable style: <I>index</I>, <I>loop</I>, <I>file</I>,
|
2007-06-20 20:56:17 +08:00
|
|
|
<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.
|
2010-05-12 04:04:33 +08:00
|
|
|
</P>
|
|
|
|
<P>All the variables specified with the next command are incremented by
|
2013-07-25 04:47:56 +08:00
|
|
|
one value from their respective list of values. A <I>file</I>-style
|
|
|
|
variable reads the next line from its associated file. An
|
|
|
|
<I>atomfile</I>-style variable reads the next set of lines (one per atom)
|
|
|
|
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.
|
2006-09-22 00:22:34 +08:00
|
|
|
</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
|
|
|
|
<A HREF = "jump.html">jump</A> command encountered. This enables a loop containing
|
2008-10-07 23:02:40 +08:00
|
|
|
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.
|
2013-07-25 04:47:56 +08:00
|
|
|
<I>File</I>-style and <I>atomfile</I>-style variables are exhausted when the
|
|
|
|
end-of-file is reached.
|
2006-09-22 00:22:34 +08:00
|
|
|
</P>
|
2013-07-25 04:47:56 +08:00
|
|
|
<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>file</I>-style variables, the next line is
|
|
|
|
read from its file and the string assigned to the variable. When the
|
|
|
|
next command is used with <I>atomfile</I>-style variables, the next set of
|
|
|
|
per-atom values is read from its file and assigned to the variable.
|
|
|
|
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.
|
2006-09-22 00:22:34 +08:00
|
|
|
</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
|
|
|
|
in.polymer, 8 simulations would be run using data files from
|
|
|
|
directories run1 thru run8.
|
|
|
|
</P>
|
|
|
|
<PRE>variable d index run1 run2 run3 run4 run5 run6 run7 run8
|
|
|
|
shell cd $d
|
|
|
|
read_data data.polymer
|
|
|
|
run 10000
|
|
|
|
shell cd ..
|
|
|
|
clear
|
|
|
|
next d
|
|
|
|
jump in.polymer
|
|
|
|
</PRE>
|
|
|
|
<P>If the variable "d" were of style <I>universe</I>, and the same in.polymer
|
|
|
|
input script were run on 3 partitions of processors, then the first 3
|
|
|
|
simulations would begin, one on each set of processors. Whichever
|
|
|
|
partition finished first, it would assign variable "d" the 4th value
|
|
|
|
and run another simulation, and so forth until all 8 simulations were
|
|
|
|
finished.
|
|
|
|
</P>
|
|
|
|
<P>Jump and next commands can also be nested to enable multi-level loops.
|
|
|
|
For example, this script will run 15 simulations in a double loop.
|
|
|
|
</P>
|
2007-04-20 07:25:27 +08:00
|
|
|
<PRE>variable i loop 3
|
2008-10-07 23:02:40 +08:00
|
|
|
variable j loop 5
|
|
|
|
clear
|
|
|
|
...
|
|
|
|
read_data data.polymer.$i$j
|
|
|
|
print Running simulation $i.$j
|
|
|
|
run 10000
|
|
|
|
next j
|
|
|
|
jump in.script
|
2006-09-22 00:22:34 +08:00
|
|
|
next i
|
2007-04-20 07:25:27 +08:00
|
|
|
jump in.script
|
|
|
|
</PRE>
|
2008-10-07 23:02:40 +08:00
|
|
|
<P>Here is an example of a double loop which uses the <A HREF = "if.html">if</A> and
|
|
|
|
<A HREF = "jump.html">jump</A> commands to break out of the inner loop when a
|
|
|
|
condition is met, then continues iterating thru the outer loop.
|
|
|
|
</P>
|
|
|
|
<PRE>label loopa
|
|
|
|
variable a loop 5
|
|
|
|
label loopb
|
|
|
|
variable b loop 5
|
|
|
|
print "A,B = $a,$b"
|
|
|
|
run 10000
|
|
|
|
if $b > 2 then "jump in.script break"
|
|
|
|
next b
|
|
|
|
jump in.script loopb
|
|
|
|
label break
|
|
|
|
variable b delete
|
|
|
|
</PRE>
|
|
|
|
<PRE>next a
|
|
|
|
jump in.script loopa
|
|
|
|
</PRE>
|
2006-09-22 00:22:34 +08:00
|
|
|
<P><B>Restrictions:</B> none
|
|
|
|
</P>
|
|
|
|
<P><B>Related commands:</B>
|
|
|
|
</P>
|
|
|
|
<P><A HREF = "jump.html">jump</A>, <A HREF = "include.html">include</A>, <A HREF = "shell.html">shell</A>,
|
|
|
|
<A HREF = "variable.html">variable</A>,
|
|
|
|
</P>
|
|
|
|
<P><B>Default:</B> none
|
|
|
|
</P>
|
|
|
|
</HTML>
|