[lammps-users] how to use math operations in variable command

Hello,

I would like to change some parameters during my simulation, therefore I need to use rariable command in my input script.

variable sig index 2.5 3 3.5 4 4.5 5 5.5 6.0
label index
variable flag equal 2*v_sig
print "flag = " ${flag}
next sig
jump in.gel index

This always give me flag = 2

variable sig index 2.5 3 3.5 4 4.5 5 5.5 6.0
label index
variable flag equal 2.5*v_sig
print "flag = " ${flag}
next sig
jump in.gel index

This always give me flag = 2.5

variable sig index 2.5 3 3.5 4 4.5 5 5.5 6.0
label index
variable flag equal v_sig
print "flag = " ${flag}
next sig
jump in.gel index

This gives me different value of flag as supposed to do.

For the first two cases, they seem to ignore the math operation. Could anyone tell me how to use math operation inside the variable command? Thanks!

Dongsheng

If I run this script with the most current LAMMPS (fully patched):

variable sig index 2.5 3 3.5 4 4.5 5 5.5 6.0
variable flag equal 2*v_sig
print "flag = ${flag}"
next sig

variable flag equal 2*v_sig
print "flag = ${flag}"
next sig

variable flag equal 2*v_sig
print "flag = ${flag}"
next sig

I get:

flag = 5
flag = 6
flag = 7

which looks right to me. I don't think you're running the current
version, b/c your form of the print statement is no longer valid.

Steve