From c3091aeaaca79ea2e873e3e68200b24ceaca30c7 Mon Sep 17 00:00:00 2001 From: sjplimp Date: Mon, 18 Feb 2013 17:23:22 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@9525 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- doc/Section_commands.html | 44 +++++++++++++++++++++++++++---------- doc/Section_commands.txt | 46 +++++++++++++++++++++++++++++---------- doc/read_data.html | 4 ++-- doc/read_data.txt | 4 ++-- doc/variable.html | 19 +++++++++++----- doc/variable.txt | 19 +++++++++++----- 6 files changed, 97 insertions(+), 39 deletions(-) diff --git a/doc/Section_commands.html b/doc/Section_commands.html index ddd9a4f6ad..eda9fe6886 100644 --- a/doc/Section_commands.html +++ b/doc/Section_commands.html @@ -100,13 +100,34 @@ single leading "#" will comment out the entire command.

(3) The line is searched repeatedly for $ characters, which indicate variables that are replaced with a text string. See an exception in -(6). 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 single character immediately -following the $. Thus ${myTemp} and $x refer to variable names -"myTemp" and "x". See the variable command for -details of how strings are assigned to variables and how they are -substituted for in input script commands. +(6). +

+

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 single character immediately following +the $. Thus ${myTemp} and $x refer to variable names "myTemp" and +"x". +

+

If the $ is followed by parenthesis, then the text inside the +parenthesis is treated as an "immediate" variable and evaluated as an +equal-style variable. This is a way to use numeric +formulas in an input script without having to assign them to variable +names. For example, these 3 input script lines: +

+
variable X equal (xlo+xhi)/2+sqrt(v_area)
+region 1 block $X 2 INF INF EDGE EDGE
+variable X delete 
+
+

can be replaced by +

+
region 1 block $((xlo+xhi)/2+sqrt(v_area)) 2 INF INF EDGE EDGE 
+
+

The latter produces an identical result, without having to define and +discard a temporary variable X. +

+

See the variable command for more details of how +strings are assigned to variables and evaluated, and how they can be +used in input script commands.

(4) The line is broken into "words" separated by whitespace (tabs, spaces). Note that words can thus contain letters, digits, @@ -120,12 +141,13 @@ it can be enclosed in either double or single quotes. E.g.

print "Volume = $v"
 print 'Volume = $v' 
+if "$steps > 1000" then quit 
 

The quotes are removed when the single argument is stored internally. -See the dump modify format or if commands -for examples. A "#" or "$" character that is between quotes will not -be treated as a comment indicator in (2) or substituted for as a -variable in (3). +See the dump modify format or print or +if commands for examples. A "#" or "$" character that is +between quotes will not be treated as a comment indicator in (2) or +substituted for as a variable in (3).

IMPORTANT NOTE: If the argument is itself a command that requires a quoted argument (e.g. using a print command as part of an diff --git a/doc/Section_commands.txt b/doc/Section_commands.txt index 319d50e9fb..af990f3f6e 100644 --- a/doc/Section_commands.txt +++ b/doc/Section_commands.txt @@ -96,13 +96,34 @@ single leading "#" will comment out the entire command. (3) The line is searched repeatedly for $ characters, which indicate variables that are replaced with a text string. See an exception in -(6). 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 single 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 strings are assigned to variables and how they are -substituted for in input script commands. +(6). + +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 single character immediately following +the $. Thus $\{myTemp\} and $x refer to variable names "myTemp" and +"x". + +If the $ is followed by parenthesis, then the text inside the +parenthesis is treated as an "immediate" variable and evaluated as an +"equal-style variable"_variable.html. This is a way to use numeric +formulas in an input script without having to assign them to variable +names. For example, these 3 input script lines: + +variable X equal (xlo+xhi)/2+sqrt(v_area) +region 1 block $X 2 INF INF EDGE EDGE +variable X delete :pre + +can be replaced by + +region 1 block $((xlo+xhi)/2+sqrt(v_area)) 2 INF INF EDGE EDGE :pre + +The latter produces an identical result, without having to define and +discard a temporary variable X. + +See the "variable"_variable.html command for more details of how +strings are assigned to variables and evaluated, and how they can be +used in input script commands. (4) The line is broken into "words" separated by whitespace (tabs, spaces). Note that words can thus contain letters, digits, @@ -115,13 +136,14 @@ line are arguments. it can be enclosed in either double or single quotes. E.g. print "Volume = $v" -print 'Volume = $v' :pre +print 'Volume = $v' +if "${steps} > 1000" then quit :pre The quotes are removed when the single argument is stored internally. -See the "dump modify format"_dump_modify.html or "if"_if.html commands -for examples. A "#" or "$" character that is between quotes will not -be treated as a comment indicator in (2) or substituted for as a -variable in (3). +See the "dump modify format"_dump_modify.html or "print"_print.html or +"if"_if.html commands for examples. A "#" or "$" character that is +between quotes will not be treated as a comment indicator in (2) or +substituted for as a variable in (3). IMPORTANT NOTE: If the argument is itself a command that requires a quoted argument (e.g. using a "print"_print.html command as part of an diff --git a/doc/read_data.html b/doc/read_data.html index 2688cc9762..17f96a2539 100644 --- a/doc/read_data.html +++ b/doc/read_data.html @@ -74,8 +74,8 @@ header line(s) and section(s) that it reads from the data file. spacing between words and numbers) is not important except that header and section keywords (e.g. atoms, xlo xhi, Masses, Bond Coeffs) must be capitalized as shown and can't have extra white space between their -words - e.g. two spaces or a tab between "Bond" and "Coeffs" is not -valid. +words - e.g. two spaces or a tab between the 2 words in "xlo xhi" or +the 2 words in "Bond Coeffs", is not valid.


diff --git a/doc/read_data.txt b/doc/read_data.txt index c250a73e48..55db36af93 100644 --- a/doc/read_data.txt +++ b/doc/read_data.txt @@ -68,8 +68,8 @@ The formatting of individual lines in the data file (indentation, spacing between words and numbers) is not important except that header and section keywords (e.g. atoms, xlo xhi, Masses, Bond Coeffs) must be capitalized as shown and can't have extra white space between their -words - e.g. two spaces or a tab between "Bond" and "Coeffs" is not -valid. +words - e.g. two spaces or a tab between the 2 words in "xlo xhi" or +the 2 words in "Bond Coeffs", is not valid. :line diff --git a/doc/variable.html b/doc/variable.html index 021ee60aea..a212a3f0df 100644 --- a/doc/variable.html +++ b/doc/variable.html @@ -119,8 +119,8 @@ evaluation of the string. Note that the same string can generate different values when it is evaluated at different times during a simulation.

-

IMPORTANT NOTE: When the input script line that defines a variable of -style equal or atom that contain a formula is encountered, the +

IMPORTANT NOTE: When the input script line is encountered that defines +a variable of style equal or atom 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. @@ -724,10 +724,17 @@ produce only a global scalar or a per-atom vector, never both.

There is a difference between referencing a variable with a leading $ sign (e.g. $x or ${abc}) versus with a leading "v_" (e.g. v_x or -v_abc). The former can be used in any command, including a variable -command, to force the immediate evaluation of the referenced variable -and the substitution of its value into the command. The latter is a -required kind of argument to some commands (e.g. the fix +v_abc). The former can be used in any input script command, including +a variable command. The input script parser evaluates the reference +variable immediately and substitutes its value into the command. As +explained in Section commands 3.2 for +"Parsing rules", you can also use un-named "immediate" variables for +this purpose. An variable reference such as +$((xlo+xhi)/2+sqrt(v_area)) evaluates the string between the +parenthesis as an equal-style variable. +

+

Referencing a variable with a leading "v_" is an optional or required +kind of argument for some commands (e.g. the fix ave/spatial or dump custom or thermo_style commands) if you wish it to evaluate a variable periodically during a run. It can also be used in a diff --git a/doc/variable.txt b/doc/variable.txt index bb64f4e067..86e3aac43f 100644 --- a/doc/variable.txt +++ b/doc/variable.txt @@ -113,8 +113,8 @@ evaluation of the string. Note that the same string can generate different values when it is evaluated at different times during a simulation. -IMPORTANT NOTE: When the input script line that defines a variable of -style {equal} or {atom} that contain a formula is encountered, the +IMPORTANT NOTE: When the input script line is encountered that defines +a variable of style {equal} or {atom} 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. @@ -718,10 +718,17 @@ v_name\[I\]: atom I's value in per-atom vector :tb(s=:) There is a difference between referencing a variable with a leading $ sign (e.g. $x or $\{abc\}) versus with a leading "v_" (e.g. v_x or -v_abc). The former can be used in any command, including a variable -command, to force the immediate evaluation of the referenced variable -and the substitution of its value into the command. The latter is a -required kind of argument to some commands (e.g. the "fix +v_abc). The former can be used in any input script command, including +a variable command. The input script parser evaluates the reference +variable immediately and substitutes its value into the command. As +explained in "Section commands 3.2"_Section_commands.html#3_2 for +"Parsing rules", you can also use un-named "immediate" variables for +this purpose. An variable reference such as +$((xlo+xhi)/2+sqrt(v_area)) evaluates the string between the +parenthesis as an equal-style variable. + +Referencing a variable with a leading "v_" is an optional or required +kind of argument for some commands (e.g. the "fix ave/spatial"_fix_ave_spatial.html or "dump custom"_dump.html or "thermo_style"_thermo_style.html commands) if you wish it to evaluate a variable periodically during a run. It can also be used in a