query on random() function

Dear lammps users,

Did you use rand(x,y,z) function and store the number as a variable?
I have found that the value of stored variable (rnx) is changed during calls, contrary with those (cnt) obtained from simple math functions. (see below results.)
I just guess the reason. Could you clarify this?
Thank you.

Joe

My input script

processors 8 4 1

variable movex equal 111.1
variable i equal 1
variable cnt equal floor(i/10) variable rnx equal random(0,{movex},i) variable rnxx equal {rnx}

print “movex = {movex}" print "movex = {movex}”
print “cnt = {cnt}" print "cnt = {cnt}”
print “rnx = {rnx}" print "rnx = {rnx}”
print “rnxx = {rnxx}" print "rnxx = {rnxx}”

Output

LAMMPS (17 Sep 2011)
movex = 111.1
movex = 111.1
cnt = 0
cnt = 0
rnx = 19.80290119
rnx = 73.44809413
rnxx = 8.903851396
rnxx = 8.903851396

Dear lammps users,

Did you use rand(x,y,z) function and store the number as a variable?
I have found that the value of stored variable (rnx) is changed during calls, contrary with those (cnt) obtained from simple math functions. (see below results.)
I just guess the reason. Could you clarify this?

Yes. The equal statement is evaluated every time you expand a variable. An equal style variable is more like a function than a variable. If you assign it’s value via a expansion to another variable then it will remain constant since the expansion is immediate.

Axel