diff --git a/doc/Section_commands.html b/doc/Section_commands.html index beddd7c494..b059e9df53 100644 --- a/doc/Section_commands.html +++ b/doc/Section_commands.html @@ -94,12 +94,12 @@ across two or more lines. comment and discarded.

(3) The line is searched repeatedly for $ characters which indicate -variables that are replaced with text. If the $ is followed by curly -brackets, then the variable name is the text inside the curly +variables that are replaced with a text string. If the $ is followed +by curly brackets, then the variable name is the text inside the curly brackets. If no curly brackets follow the $, then the variable name is the character immediately following the $. Thus ${myTemp} and $x refer to variable names "myTemp" and "x". See the -variable command for details of how values are +variable command for details of how strings are assigned to variables and how they are substituted for in input scripts.

@@ -315,12 +315,12 @@ descriptions of each style or click on the style itself for a full description:

- - - - - - + + + + +
addforceaveforcecomdepositdragefieldenforce2dfreeze
gran/diaggravitygyrationindentlangevinlineforcemsdmomentum
nphnptnvenve/grannvtorient/fccplaneforcepoems
pourprintrdfrecenterrigidsetforceshakespring
spring/rgspring/selftemp/rescaletmduniaxialvcmviscousvolume/rescale
wall/granwall/lj93wall/lj126wall/reflectwiggle +
addforceaveforceave/spatialave/timebox/relaxcomdepositdrag
efieldenforce2dfreezegran/diaggravitygyrationindentlangevin
lineforcemsdmomentumnphnptnvenve/grannvt
orient/fccplaneforcepoemspourprintrdfrecenterrigid
setforceshakespringspring/rgspring/selftemp/rescaletmduniaxial
vcmviscousvolume/rescalewall/granwall/lj93wall/lj126wall/reflectwiggle

@@ -331,7 +331,7 @@ description:

-
centro/atomepair/atometotal/atomke/atompressurerotate/dipole
rotate/granstress/atomtemptemp/partialtemp/ramptemp/region +
rotate/granstress/atomtemptemp/partialtemp/ramptemp/regionvariable/atom

diff --git a/doc/Section_commands.txt b/doc/Section_commands.txt index 7c2028efcd..4910d9dadc 100644 --- a/doc/Section_commands.txt +++ b/doc/Section_commands.txt @@ -91,12 +91,12 @@ across two or more lines. comment and discarded. (3) The line is searched repeatedly for $ characters which indicate -variables that are replaced with text. If the $ is followed by curly -brackets, then the variable name is the text inside the curly +variables that are replaced with a text string. If the $ is followed +by curly brackets, then the variable name is the text inside the curly brackets. If no curly brackets follow the $, then the variable name is the character immediately following the $. Thus $\{myTemp\} and $x refer to variable names "myTemp" and "x". See the -"variable"_variable.html command for details of how values are +"variable"_variable.html command for details of how strings are assigned to variables and how they are substituted for in input scripts. @@ -371,6 +371,9 @@ description: "addforce"_fix_addforce.html, "aveforce"_fix_aveforce.html, +"ave/spatial"_fix_ave_spatial.html, +"ave/time"_fix_ave_time.html, +"box/relax"_fix_box_relax.html, "com"_fix_com.html, "deposit"_fix_deposit.html, "drag"_fix_drag.html, @@ -432,7 +435,8 @@ description: "temp"_compute_temp.html, "temp/partial"_compute_temp_partial.html, "temp/ramp"_compute_temp_ramp.html, -"temp/region"_compute_temp_region.html :tb(c=6,ea=c) +"temp/region"_compute_temp_region.html +"variable/atom"_compute_variable_atom.html :tb(c=6,ea=c) :line diff --git a/doc/Section_start.html b/doc/Section_start.html index 93a186dccc..50d60cc0a5 100644 --- a/doc/Section_start.html +++ b/doc/Section_start.html @@ -513,10 +513,10 @@ the input script is read. "Name" is the variable name which can be a single character (referenced as $x in the input script) or a full string (referenced as ${abc}). The value can be any string. Using this command-line option is equivalent to putting the line "variable -name index value" at the beginning of the input script. See the +name equal value" at the beginning of the input script. See the variable command for more info on defining variables and this section for more info on using -variables in scripts. +variables in input scripts.


diff --git a/doc/Section_start.txt b/doc/Section_start.txt index a3a98e508b..3c30daacc7 100644 --- a/doc/Section_start.txt +++ b/doc/Section_start.txt @@ -506,10 +506,10 @@ the input script is read. "Name" is the variable name which can be a single character (referenced as $x in the input script) or a full string (referenced as $\{abc\}). The value can be any string. Using this command-line option is equivalent to putting the line "variable -name index value" at the beginning of the input script. See the +name equal value" at the beginning of the input script. See the "variable"_variable.html command for more info on defining variables and "this section"_Section_commands.html#3_2 for more info on using -variables in scripts. +variables in input scripts. :line diff --git a/doc/compute.html b/doc/compute.html index bc19ff7606..1ced3d2f53 100644 --- a/doc/compute.html +++ b/doc/compute.html @@ -32,13 +32,14 @@ compute 3 all ke/atom

In LAMMPS, a "compute" is used in several ways. Computes that calculate one or more values for the entire group of atoms can output -those values via the thermo_style custom command. -Or the values can be referenced in a variable equal -command. Computes that calculate a temperature or pressure are used -by fixes that do thermostatting or barostatting and when atom -velocities are created. Computes that calculate one or more values -for each atom in the group can output those values via the dump -custom command. +those values via the thermo_style custom or fix +ave/time command. Or the values can be referenced +in a variable equal command. Computes that calculate +a temperature or pressure are used by fixes that do thermostatting or +barostatting and when atom velocities are created. Computes that +calculate one or more values for each atom in the group can output +those values via the dump custom command or the fix +ave/spatial command.

LAMMPS creates its own computes for thermodynamic output and dumping atom snapshots. Likewise fixes that compute temperature or pressure @@ -73,7 +74,8 @@ defined in LAMMPS:

  • temp - temperature of group of atoms
  • temp/partial - temperature excluding one or more dimensions of velocity
  • temp/ramp - temperature after subtracting a ramped velocity component -
  • temp/region - temperature of a region of atoms +
  • temp/region - temperature of a region of atoms +
  • variable/atom - calculate a formula for each atom

    Restrictions: none

    diff --git a/doc/compute.txt b/doc/compute.txt index 1af41aa58e..7d624a7b4c 100644 --- a/doc/compute.txt +++ b/doc/compute.txt @@ -29,13 +29,14 @@ Create a computation that will be performed on a group of atoms. In LAMMPS, a "compute" is used in several ways. Computes that calculate one or more values for the entire group of atoms can output -those values via the "thermo_style custom"_thermo_style.html command. -Or the values can be referenced in a "variable equal"_variable.html -command. Computes that calculate a temperature or pressure are used -by fixes that do thermostatting or barostatting and when atom -velocities are created. Computes that calculate one or more values -for each atom in the group can output those values via the "dump -custom"_dump.html command. +those values via the "thermo_style custom"_thermo_style.html or "fix +ave/time"_fix_ave_time.html command. Or the values can be referenced +in a "variable equal"_variable.html command. Computes that calculate +a temperature or pressure are used by fixes that do thermostatting or +barostatting and when atom velocities are created. Computes that +calculate one or more values for each atom in the group can output +those values via the "dump custom"_dump.html command or the "fix +ave/spatial"_fix_ave_spatial.html command. LAMMPS creates its own computes for thermodynamic output and dumping atom snapshots. Likewise fixes that compute temperature or pressure @@ -70,7 +71,8 @@ defined in LAMMPS: "temp"_compute_temp.html - temperature of group of atoms "temp/partial"_compute_temp_partial.html - temperature excluding one or more dimensions of velocity "temp/ramp"_compute_temp_ramp.html - temperature after subtracting a ramped velocity component -"temp/region"_compute_temp_region.html - temperature of a region of atoms :ul +"temp/region"_compute_temp_region.html - temperature of a region of atoms +"variable/atom"_compute_variable_atom.html - calculate a formula for each atom :ul [Restrictions:] none diff --git a/doc/compute_centro_atom.html b/doc/compute_centro_atom.html index 95444f9184..3571f19d70 100644 --- a/doc/compute_centro_atom.html +++ b/doc/compute_centro_atom.html @@ -9,18 +9,18 @@
    -

    compute ke/atom command +

    compute centro/atom command

    Syntax:

    -
    compute ID group-ID ke/atom 
    +
    compute ID group-ID centro/atom 
     

    Examples:

    -
    compute 1 all ke/atom 
    +
    compute 1 all centro/atom 
     

    Description:

    diff --git a/doc/compute_centro_atom.txt b/doc/compute_centro_atom.txt index 39bab91c4d..ef1dddce5e 100644 --- a/doc/compute_centro_atom.txt +++ b/doc/compute_centro_atom.txt @@ -6,18 +6,18 @@ :line -compute ke/atom command :h3 +compute centro/atom command :h3 [Syntax:] -compute ID group-ID ke/atom :pre +compute ID group-ID centro/atom :pre ID, group-ID are documented in "compute"_compute.html command -ke/atom = style name of this compute command :ul +centro/atom = style name of this compute command :ul [Examples:] -compute 1 all ke/atom :pre +compute 1 all centro/atom :pre [Description:] diff --git a/doc/dump.html b/doc/dump.html index 1d84665788..5f0a707f60 100644 --- a/doc/dump.html +++ b/doc/dump.html @@ -263,16 +263,15 @@ quantities calculated by a compute to be output. The ID in the keyword should be replaced by the actual ID of the compute that has been defined elsewhere in the input script. See the compute command for details. Note that scalar and -vector quantities that are not calculated on a per-atoms basis +vector quantities that are not calculated on a per-atom basis (e.g. global temperature or pressure) cannot be output in a dump. Rather, these quantities are output by the thermo_style custom command.

    -

    If c_ID is used as a keyword, then the a single per-atom quantity -calculated by the compute is printed. If c_ID[N] is used, then N in -the range from 1-M will print a specific component of the per-atom -vector calculated by the compute. A value of N=0 will output the -single per-atom quantity. +

    If c_ID is used as a keyword, then the scalar per-atom quantity +calculated by the compute is printed. If c_ID[N] is used, then N +in the range from 1-M will print the Nth component of the M-length +per-atom vector calculated by the compute.

    See this section for information on how to add new compute styles to LAMMPS that calculate per-atom quantities which diff --git a/doc/dump.txt b/doc/dump.txt index d706f41a63..03c1a29572 100644 --- a/doc/dump.txt +++ b/doc/dump.txt @@ -253,16 +253,15 @@ quantities calculated by a compute to be output. The ID in the keyword should be replaced by the actual ID of the compute that has been defined elsewhere in the input script. See the "compute"_compute.html command for details. Note that scalar and -vector quantities that are not calculated on a per-atoms basis +vector quantities that are not calculated on a per-atom basis (e.g. global temperature or pressure) cannot be output in a dump. Rather, these quantities are output by the "thermo_style custom"_thermo_style.html command. -If {c_ID} is used as a keyword, then the a single per-atom quantity -calculated by the compute is printed. If {c_ID\[N\]} is used, then N in -the range from 1-M will print a specific component of the per-atom -vector calculated by the compute. A value of N=0 will output the -single per-atom quantity. +If {c_ID} is used as a keyword, then the scalar per-atom quantity +calculated by the compute is printed. If {c_ID\[N\]} is used, then N +in the range from 1-M will print the Nth component of the M-length +per-atom vector calculated by the compute. See "this section"_Section_modify.html for information on how to add new compute styles to LAMMPS that calculate per-atom quantities which diff --git a/doc/fix.html b/doc/fix.html index f2b6ce6de4..bb2f0485ec 100644 --- a/doc/fix.html +++ b/doc/fix.html @@ -65,6 +65,9 @@ made to the old fix via the fix_modify command.

    • fix addforce - add a force to each atom
    • fix aveforce - add an averaged force to each atom +
    • fix ave/spatial - output per-atom quantities by layer +
    • fix ave/time - output time-averaged compute quantities +
    • fix box/relax - relax box size during a minimization
    • fix com - compute a center-of-mass
    • fix deposit - add new atoms above a surface
    • fix drag - drag atoms towards a defined coordinate diff --git a/doc/fix.txt b/doc/fix.txt index da8fa0490f..acef1f1bcf 100644 --- a/doc/fix.txt +++ b/doc/fix.txt @@ -62,6 +62,9 @@ Here is an alphabetic list of fix styles defined in LAMMPS: "fix addforce"_fix_addforce.html - add a force to each atom "fix aveforce"_fix_aveforce.html - add an averaged force to each atom +"fix ave/spatial"_fix_ave_spatial.html - output per-atom quantities by layer +"fix ave/time"_fix_ave_time.html - output time-averaged compute quantities +"fix box/relax"_fix_box_relax.html - relax box size during a minimization "fix com"_fix_com.html - compute a center-of-mass "fix deposit"_fix_desosit.html - add new atoms above a surface "fix drag"_fix_drag.html - drag atoms towards a defined coordinate diff --git a/doc/thermo_style.html b/doc/thermo_style.html index 4ca783d4e0..6ce38536f2 100644 --- a/doc/thermo_style.html +++ b/doc/thermo_style.html @@ -204,8 +204,8 @@ are output by the dump custom command.

      If c_ID is used as a keyword, then the scalar quantity calculated by the compute is printed. If c_ID[N] is used, then N in the range -from 1-M will print a specific component of the vector calculated by -the compute. A value of N=0 will output the scalar quantity. +from 1-M will print the Nth component of the M-length vector +calculated by the compute.

      The f_ID and f_ID[N] keywords allow scalar or vector quantities calculated by a fix to be output. The ID in the keyword should be @@ -214,8 +214,8 @@ in the input script. See the fix command for details.

      If f_ID is used as a keyword, then the scalar quantity calculated by the fix is printed. If f_ID[N] is used, then N in the range from -1-M will print a specific component of the vector calculated by the -fix. A value of N=0 will output the scalar quantity. +1-M will print the Nth component of the M-length vector calculated by +the fix.

      The v_name keyword allow the current value of a variable to be output. The name in the keyword should be replaced by the actual namd diff --git a/doc/thermo_style.txt b/doc/thermo_style.txt index 5c39f4d8cf..90b9ba7ced 100644 --- a/doc/thermo_style.txt +++ b/doc/thermo_style.txt @@ -198,8 +198,8 @@ are output by the "dump custom"_dump.html command. If {c_ID} is used as a keyword, then the scalar quantity calculated by the compute is printed. If {c_ID\[N\]} is used, then N in the range -from 1-M will print a specific component of the vector calculated by -the compute. A value of N=0 will output the scalar quantity. +from 1-M will print the Nth component of the M-length vector +calculated by the compute. The {f_ID} and {f_ID\[N\]} keywords allow scalar or vector quantities calculated by a fix to be output. The ID in the keyword should be @@ -208,8 +208,8 @@ in the input script. See the "fix"_fix.html command for details. If {f_ID} is used as a keyword, then the scalar quantity calculated by the fix is printed. If {f_ID\[N\]} is used, then N in the range from -1-M will print a specific component of the vector calculated by the -fix. A value of N=0 will output the scalar quantity. +1-M will print the Nth component of the M-length vector calculated by +the fix. The {v_name} keyword allow the current value of a variable to be output. The name in the keyword should be replaced by the actual namd diff --git a/doc/variable.html b/doc/variable.html index d7fc682d9a..a31ce16919 100644 --- a/doc/variable.html +++ b/doc/variable.html @@ -17,22 +17,26 @@

    Specifically, an equation can contain numbers, thermo keywords, math functions, group functions, atom vectors, compute references, and -other variables: +other variables. There is one difference between equal and atom +variables; the syntax of Atom vector references is different.

    - + +
    Number 0.2, 1.0e20, -15.4, etc
    Thermo keywords vol, pe, ebond, etc
    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(ID), charge(ID), xcm(ID,dim), vcm(ID,dim), bound(ID,dir), gyration(ID)
    Atom vectors x[N], y[N], z[N], vx[N], vy[N], vz[N], fx[N], fy[N], fz[N]
    Atom vectors for equal mass[N], x[N], y[N], z[N], vx[N], vy[N], vz[N], fx[N], fy[N], fz[N]
    Atom vectors for atom mass[], x[], y[], z[], vx[], vy[], vz[], fx[], fy[], fz[]
    Compute references c_ID[0], c_ID[N]
    Other variables v_abc, v_x, etc
    @@ -197,20 +225,24 @@ 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 command for the formula.

    -

    The atom vectors take a single integer argument from 1-N, which -is the desired atom-ID, e.g. x[243]. +

    For equal style variables, atom vectors take a single integer +argument from 1-N, which is the desired atom-ID, e.g. x[243]. For +atom style variables, atom vectors take no argument. Since atom +style variables compute one value per atom, a reference like x[] +means the x-coord of each atom will be used when evaluating the +variable.

    -

    Compute references access allow access to scalar or vector quantities -calculated by a compute. The ID in the reference should be replaced -by the actual ID of the compute that has been defined elsewhere in the -input script. See the compute command for details. -Note that per-atom quantities calcalated by a compute cannot be -accessed this way, but only global scalar or vector quantities. +

    Compute references access scalar or vector quantities calculated by a +compute. The ID in the reference should be replaced by +the actual ID of the compute defined elsewhere in the input script. +See the compute command for details. Note that +per-atom quantities calculated by a compute cannot be accessed this +way, but only global scalar or vector quantities.

    If c_ID[0] is used as a keyword, then the scalar quantity calculated by the compute is printed. If c_ID[N] is used, then N -in the range from 1-M will print a specific component of the vector -calculated by the compute. +in the range from 1-M will print the Mth component of the N-length +vector calculated by the compute.

    The current values of other variables can be accessed by prepending a "v_" to the variable name. This will cause the other variable to be @@ -222,8 +254,8 @@ print $a

    then LAMMPS will run for a while when the print statement is invoked.

    -

    Note that there is a subtle difference between using a variable -in a equal-style equation in the form $x versus v_x. +

    Note that there is a subtle difference between using a variable in a +equal or atom style equation in the form $x versus v_x.

    In the former case, as with any other input script command, the variable's value is substituted for immediately when the line is read @@ -243,7 +275,7 @@ variable y equal mult(v_x,2)

    would associate the equation string "mult(v_x,2)" with variable y.

    Thus if the variable y were evaluated periodically during a run where -the box volume changed, the resulting value would always be 500.0 for +the box volume changed, the resulting value would always be 2000.0 for the first case, but would change dynamically for the second case.


    diff --git a/doc/variable.txt b/doc/variable.txt index a0d089dfe2..6c2afb2b14 100644 --- a/doc/variable.txt +++ b/doc/variable.txt @@ -13,21 +13,25 @@ variable command :h3 variable name style args ... :pre name = name of variable to define :ulb,l -style = {index} or {loop} or {world} or {universe} or {uloop} or {equal} :l +style = {index} or {loop} or {world} or {universe} or {uloop} or {equal} or {atom} :l {index} args = one or more strings {loop} args = N = integer size of loop {world} args = one string for each partition of processors {universe} args = one or more strings {uloop} args = N = integer size of loop - {equal} args = one equation containing numbers, thermo keywords, math functions, group functions, atom vectors, compute references, other variables + {equal} or {atom} args = one equation containing numbers, thermo keywords, math functions, group functions, atom vectors, compute references, other variables numbers = 0.0, -5.4, 2.8e-4, etc thermo keywords = vol, ke, press, etc from "thermo_style"_thermo_style.html 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), bound(group,xmin), gyration(group) - atom vectors = x\[N\], y\[N\], z\[N\], vx\[N\], vy\[N\], vz\[N\], - fx\[N\], fy\[N\], fz\[N\] + atom vectors for {equal} = mass\[N\], x\[N\], y\[N\], z\[N\], + vx\[N\], vy\[N\], vz\[N\], + fx\[N\], fy\[N\], fz\[N\] + atom vectors for {atom} = mass\[\], x\[\], y\[\], z\[\], + vx\[\], vy\[\], vz\[\], + fx\[\], fy\[\], fz\[\] compute references = c_ID\[0\], c_ID\[N\] other variables = v_abc, v_x, etc :pre :ule @@ -37,68 +41,78 @@ style = {index} or {loop} or {world} or {universe} or {uloop} or {equal} :l 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,col)) +variable b1 equal add(x\[234\],mult(0.5,vol)) variable b equal div(xcm(mol1,x),2.0) variable b equal c_myTemp\[0\] +variable b atom div(mult(x[],y[]),vol) 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 variable x uloop 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 or its value -output during a simulation. 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. +This command assigns one or more strings to a variable name. +Variables can be used in several ways in LAMMPS. A variable can be +referenced elsewhere in an input script. For variable styles that +store multiple strings, the "next"_next.html command can be used to +increment which string is assigned to the variable. Variables can be +evaluated to produce a numeric value which can be output either +directly (see the "print"_print.html, "fix print"_fix_print.html, and +"run every"_run.html commands) or as part of thermodynamic output (see +the "thermo_style"_thermo_style.html command), fix output (see the +"fix ave/spatial"_fix_ave_spatial.html and "compute +variable/atom"_compute_variable_atom.html commands), or dump output +(see the "dump custom"_dump.html and "compute +variable/atom"_compute_variable_atom.html commands). -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. +In the discussion that follows, the "name" of the variable is the +arbitrary string that is the 1st argument in the variable command. +The "string" is one of the subsequent arguments. The "value" is the +numeric quantity resulting from evaluation of the string. Note that +the same string can generate different values when it is evaluated at +different times during a simulation. -Variable values can also be accessed for output once or periodically -during a simulation by the "print"_print.html command, "fix -print"_fix_print.html command, "run every"_run.html command, and the -"thermo_style"_thermo_style.html command. +IMPORTANT NOTE: When a variable command is encountered in the input +script and the variable name has already been specified, the command +is ignored. This means variables can NOT be re-defined in an input +script. This is to allow an input script with variable commands to be +processed multiple times without resetting the variables; see the +"jump"_jump.html or "include"_include.html commands. It also means +that using a command-line switch -var will override a corresponding +variable setting in the input script. + +There is one exception to this rule. As described below, if a +variable is iterated on to the end of its list of strings via the +"next"_next.html command, it is available to be re-defined in a +subsequent variable command. :line +"This section"_Section_commands.html#3_2 explains how occurrences of a +variable name in an input script line are replaced by 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}, the value assigned to a variable can be incremented via -the "next"_next.html command. When there are no more values to +and {uloop}, the string 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 exited from. -When a variable command is encountered for a variable that has already -been specified, the command is ignored. This 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. - -There are two exceptions to this rule. The first is for {equal} style -variables. They are re-defined each time a variable command using an -equal-style variable is encountered. Also, if a variable is iterated -on to the end of its list via the "next"_next.html command, it is -available to be re-defined in a subsequent variable command. - :line 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_6 for details. +variable. The {loop} style is identical to the {index} style except that the -strings are the integers from 1 to N. This allows you to generate a -long list of runs (e.g. 1000) without having to list N values in your +strings are the integers from 1 to N. This allows generation of a +long list of runs (e.g. 1000) without having to list N strings in the input script. 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 @@ -110,7 +124,7 @@ section"_Section_start.html#2_6 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 +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 @@ -124,31 +138,43 @@ 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 +assigned the next available string. This continues until all the +variable strings 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 +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. The {uloop} style is identical to the {universe} style except that the -strings are the integers from 1 to N. This allows you to generate a -long list of runs (e.g. 1000) without having to list N values in your -input script. +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. :line -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, different values could be printed -each timestep it was invoked. The next command cannot be used with -{equal}-style variables, since there is only one value. +For the {equal} and {atom} styles, a single string is specified which +represents an equation that will be evaluated afresh each time the +variable is used. For {equal} style variables this equation computes +a scalar quantity, which becomes the value of the variable whenever it +is evaluated. For {atom} style variables it computes a quantity for +each atom, which is used by the "compute variable/atom" command and +its associated output. -The equation for an {equal}-style variable can contain a variety of -quantities. The syntax for each kind of quantity is simple, but +Note that {equal} and {atom} variables can produce different values at +different stages of the input script or at different times during a +run. For example, if an {equal} variable is used in a "fix +print"_fix_print.html command, different values could be printed each +timestep it was invoked. + +{Equal} style variables can also be set by using the command-line +switch -var; see "this section"_Section_start.html#2_6 for details. + +The next command cannot be used with {equal} or {atom} style +variables, since there is only one string. + +The equation for an {equal} or {atom} variable can contain a variety +of quantities. The syntax for each kind of quantity is simple, but multiple quantities can be nested and combined in various ways to build up formulas of arbitrary complexity. For example, this is a valid (though strange) variable equation: @@ -157,7 +183,8 @@ variable x equal div(add(pe,c_MyTemp\[0\]),pow(vol,div(1,3))) :pre Specifically, an equation can contain numbers, thermo keywords, math functions, group functions, atom vectors, compute references, and -other variables: +other variables. There is one difference between {equal} and {atom} +variables; the syntax of Atom vector references is different. Number: 0.2, 1.0e20, -15.4, etc Thermo keywords: vol, pe, ebond, etc @@ -165,8 +192,12 @@ 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(ID), charge(ID), xcm(ID,dim), vcm(ID,dim), \ bound(ID,dir), gyration(ID) -Atom vectors: x\[N\], y\[N\], z\[N\], vx\[N\], vy\[N\], vz\[N\], \ - fx\[N\], fy\[N\], fz\[N\] +Atom vectors for {equal}: mass\[N\], x\[N\], y\[N\], z\[N\], \ + vx\[N\], vy\[N\], vz\[N\], \ + fx\[N\], fy\[N\], fz\[N\] +Atom vectors for {atom}: mass\[\], x\[\], y\[\], z\[\], \ + vx\[\], vy\[\], vz\[\], \ + fx\[\], fy\[\], fz\[\] Compute references: c_ID\[0\], c_ID\[N\] Other variables: v_abc, v_x, etc :tb(s=:) @@ -192,20 +223,24 @@ 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. -The atom vectors take a single integer argument from 1-N, which -is the desired atom-ID, e.g. x\[243\]. +For {equal} style variables, atom vectors take a single integer +argument from 1-N, which is the desired atom-ID, e.g. x\[243\]. For +{atom} style variables, atom vectors take no argument. Since {atom} +style variables compute one value per atom, a reference like x\[\] +means the x-coord of each atom will be used when evaluating the +variable. -Compute references access allow access to scalar or vector quantities -calculated by a compute. The ID in the reference should be replaced -by the actual ID of the compute that has been defined elsewhere in the -input script. See the "compute"_compute.html command for details. -Note that per-atom quantities calcalated by a compute cannot be -accessed this way, but only global scalar or vector quantities. +Compute references access scalar or vector quantities calculated by a +"compute"_compute.html. The ID in the reference should be replaced by +the actual ID of the compute defined elsewhere in the input script. +See the "compute"_compute.html command for details. Note that +per-atom quantities calculated by a compute cannot be accessed this +way, but only global scalar or vector quantities. If {c_ID\[0\]} is used as a keyword, then the scalar quantity calculated by the compute is printed. If {c_ID\[N\]} is used, then N -in the range from 1-M will print a specific component of the vector -calculated by the compute. +in the range from 1-M will print the Mth component of the N-length +vector calculated by the compute. The current values of other variables can be accessed by prepending a "v_" to the variable name. This will cause the other variable to be @@ -217,8 +252,8 @@ print $a :pre then LAMMPS will run for a while when the print statement is invoked. -Note that there is a subtle difference between using a variable -in a {equal}-style equation in the form $x versus v_x. +Note that there is a subtle difference between using a variable in a +{equal} or {atom} style equation in the form $x versus v_x. In the former case, as with any other input script command, the variable's value is substituted for immediately when the line is read @@ -238,7 +273,7 @@ variable y equal mult(v_x,2) :pre would associate the equation string "mult(v_x,2)" with variable y. Thus if the variable y were evaluated periodically during a run where -the box volume changed, the resulting value would always be 500.0 for +the box volume changed, the resulting value would always be 2000.0 for the first case, but would change dynamically for the second case. :line