From 98f408427d0e14fbe08ab2a56465871963baa1c2 Mon Sep 17 00:00:00 2001
From: sjplimp
Date: Wed, 6 Oct 2010 18:12:34 +0000
Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@4983
f3b2605a-c512-4ea7-a41b-209d697bcdaa
---
doc/variable.html | 35 ++++++++++++++++++++++++++---------
doc/variable.txt | 35 ++++++++++++++++++++++++++---------
2 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/doc/variable.html b/doc/variable.html
index fbb3d47f47..387d8e408a 100644
--- a/doc/variable.html
+++ b/doc/variable.html
@@ -46,7 +46,7 @@
x==y, x!=y, xy, x>=y, x&&y, x||y
math functions = sqrt(x), exp(x), ln(x), log(x),
sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x),
- ceil(x), floor(x), round(x)
+ random(lo,hi,seed), normal(mu,sigma,seed), ceil(x), floor(x), round(x)
group functions = count(group), mass(group), charge(group),
xcm(group,dim), vcm(group,dim), fcm(group,dim),
bound(group,xmin), gyration(group), ke(group),
@@ -270,7 +270,7 @@ references to other variables.
Number | 0.2, 100, 1.0e20, -15.4, etc |
Thermo keywords | vol, pe, ebond, etc |
Math operators | (), -x, x+y, x-y, x*y, x/y, x^y, x==y, x!=y, xy, x>=y, x&&y, x||y |
-Math functions | sqrt(x), exp(x), ln(x), log(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x), ceil(x), floor(x), round(x) |
+Math functions | sqrt(x), exp(x), ln(x), log(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x), random(lo,hi,seed), normal(mu,sigma,seed), ceil(x), floor(x), round(x) |
Group functions | count(ID), mass(ID), charge(ID), xcm(ID,dim), vcm(ID,dim), fcm(ID,dim), bound(ID,dir), gyration(ID), ke(ID), angmom(ID,dim), inertia(ID,dimdim), omega(ID,dim) |
Region functions | count(ID,IDR), mass(ID,IDR), charge(ID,IDR), xcm(ID,dim,IDR), vcm(ID,dim,IDR), fcm(ID,dim,IDR), bound(ID,dir,IDR), gyration(ID,IDR), ke(ID,IDR), angmom(ID,dim,IDR), inertia(ID,dimdim,IDR), omega(ID,dim,IDR) |
Special functions | ramp(x,y), stagger(x,y), logfreq(x,y,z), sum(x), min(x), max(x), ave(x), trap(x) |
@@ -316,8 +316,8 @@ discussion below about "Variable Accuracy".
the examples can themselves be arbitrarily complex formulas, as in the
examples above. In this syntax, "x" and "y" can be scalar values or
per-atom vectors. For example, "ke/natoms" is the division of two
-scalars, where "y+z" is the element-by-element sum of two per-atom
-vectors of y- and z-coordinates.
+scalars, where "vy+vz" is the element-by-element sum of two per-atom
+vectors of y and z velocities.
Operators are evaluated left to right and have the usual C-style
precedence: unary minus before exponentiation ("^"); exponentiation
@@ -354,11 +354,28 @@ yields a per-atom vector with each element being the sqrt() of the
product of one atom's y and z coordinates.
Most of the math functions perform obvious operations. The ln() is
-the natural log; log() is the base 10 log. The ceil(), floor(), and
-round() operations are those in the C math library. Ceil() is the
-smallest integer not less than its argument. Floor() if the largest
-integer not greater than its argument. Round() is the nearest integer
-to its argument.
+the natural log; log() is the base 10 log.
+
+The random() function generates a uniform random number between lo and
+hi. The normal() function generates a Gaussian variate centered on mu
+with variance sigma. In both cases the seed is used the first time
+the internal random number generator is invoked, to initialize it.
+For equal-style variables, every processor uses the same seed. For
+atom-style variables, a new unique seed is created for each processor,
+based on the specified seed. This effectively generates a different
+random number for each atom being looped over.
+
+The ceil(), floor(), and round() functions are those in the C math
+library. Ceil() is the smallest integer not less than its argument.
+Floor() if the largest integer not greater than its argument. Round()
+is the nearest integer to its argument.
+
+IMPORTANT NOTE: Internally, there is just one random number generator
+for equal-style variables and one for atom-style variables. If you
+define multiple variables (of each style) which use the random() or
+normal() math functions, then the internal random number generators
+will only be initialized once, which means only one of the specified
+seeds will determine the sequence of generated random numbers.
diff --git a/doc/variable.txt b/doc/variable.txt
index 578ac99a2f..714919a96f 100644
--- a/doc/variable.txt
+++ b/doc/variable.txt
@@ -41,7 +41,7 @@ style = {delete} or {index} or {loop} or {world} or {universe} or {uloop} or {st
x==y, x!=y, xy, x>=y, x&&y, x||y
math functions = sqrt(x), exp(x), ln(x), log(x),
sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x),
- ceil(x), floor(x), round(x)
+ random(lo,hi,seed), normal(mu,sigma,seed), ceil(x), floor(x), round(x)
group functions = count(group), mass(group), charge(group),
xcm(group,dim), vcm(group,dim), fcm(group,dim),
bound(group,xmin), gyration(group), ke(group),
@@ -263,7 +263,7 @@ references to other variables.
Number: 0.2, 100, 1.0e20, -15.4, etc
Thermo keywords: vol, pe, ebond, etc
Math operators: (), -x, x+y, x-y, x*y, x/y, x^y, x==y, x!=y, xy, x>=y, x&&y, x||y
-Math functions: sqrt(x), exp(x), ln(x), log(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x), ceil(x), floor(x), round(x)
+Math functions: sqrt(x), exp(x), ln(x), log(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x), random(lo,hi,seed), normal(mu,sigma,seed), ceil(x), floor(x), round(x)
Group functions: count(ID), mass(ID), charge(ID), xcm(ID,dim), \
vcm(ID,dim), fcm(ID,dim), bound(ID,dir), \
gyration(ID), ke(ID), angmom(ID,dim), \
@@ -316,8 +316,8 @@ Math operators are written in the usual way, where the "x" and "y" in
the examples can themselves be arbitrarily complex formulas, as in the
examples above. In this syntax, "x" and "y" can be scalar values or
per-atom vectors. For example, "ke/natoms" is the division of two
-scalars, where "y+z" is the element-by-element sum of two per-atom
-vectors of y- and z-coordinates.
+scalars, where "vy+vz" is the element-by-element sum of two per-atom
+vectors of y and z velocities.
Operators are evaluated left to right and have the usual C-style
precedence: unary minus before exponentiation ("^"); exponentiation
@@ -354,11 +354,28 @@ yields a per-atom vector with each element being the sqrt() of the
product of one atom's y and z coordinates.
Most of the math functions perform obvious operations. The ln() is
-the natural log; log() is the base 10 log. The ceil(), floor(), and
-round() operations are those in the C math library. Ceil() is the
-smallest integer not less than its argument. Floor() if the largest
-integer not greater than its argument. Round() is the nearest integer
-to its argument.
+the natural log; log() is the base 10 log.
+
+The random() function generates a uniform random number between lo and
+hi. The normal() function generates a Gaussian variate centered on mu
+with variance sigma. In both cases the seed is used the first time
+the internal random number generator is invoked, to initialize it.
+For equal-style variables, every processor uses the same seed. For
+atom-style variables, a new unique seed is created for each processor,
+based on the specified seed. This effectively generates a different
+random number for each atom being looped over.
+
+The ceil(), floor(), and round() functions are those in the C math
+library. Ceil() is the smallest integer not less than its argument.
+Floor() if the largest integer not greater than its argument. Round()
+is the nearest integer to its argument.
+
+IMPORTANT NOTE: Internally, there is just one random number generator
+for equal-style variables and one for atom-style variables. If you
+define multiple variables (of each style) which use the random() or
+normal() math functions, then the internal random number generators
+will only be initialized once, which means only one of the specified
+seeds will determine the sequence of generated random numbers.
:line