simulation hangs with velocity set command and mixed variable styles

Hi All,

I am finding that my simulation “hangs” when I try to implement the “velocity set” command using mixed variable styles. For example, when I define an “equal” style variable such as:
variable COM1x equal xcm(1,x)

There is no problem when I set velocities using this equal style variable, ie:
velocity all set v_COM1x NULL NULL sum yes units box

and the alternative also works the same:
velocity all set ${COM1x} NULL NULL sum yes units box

In addition, when I define an “atom” style variable, such as:

variable Xnow atom x

There is no problem when I set velocities using this atom style variable, ie:

velocity all set v_Xnow NULL NULL sum yes units box

However, when I define a variable that references “equal” style and “atom” style variables, such as:
variable COM1x equal xcm(1,x)
variable Xrel atom x-v_COM1x

and use this variable to set velocities, I get the error “Substitution for illegal variable” for this syntax:

velocity all set ${Xrel} NULL NULL sum yes units box

And although I do not get an error for the following syntax:

velocity all set v_Xrel NULL NULL sum yes units box

The simulation hangs-up and does not progress past this step. My test system is very simple; 2 bonded atoms. I have let the simulation take up to 3,000 times longer than the analogous simulations that employ the velocity commands that work. Still, the simulation does not complete the step and the simulation only ends when it is killed by the queue administrator.

Could anyone catch a mistake I am making? Is there some reason LAMMPS has difficulty referencing variables with mixed styles?

As a final note, I have found that:

variable COM1x equal xcm(1,x)
variable Xrel atom x-${COM1x} (note the forced evaluation)
velocity all set v_Xrel NULL NULL sum yes units box

will work, but of course, COM1x is not evaluated dynamically in the velocity set command. I suppose it is possible to always precede the “velocity set” command with the two variable definitions (both “atom” and “equal” style variables can be redefined I believe) however this might prove cumbersome in the future, and since I am not receiving an error message prohibiting the syntax I want to use, I thought I would try to understand it more.

Thanks in advance for any comments or suggestions.

-Rich

However, when I define a variable that references "equal" style and "atom" style variables, such as:
variable COM1x equal xcm(1,x)
variable Xrel atom x-v_COM1x
and use this variable to set velocities, I get the error "Substitution for illegal variable" for this syntax:
velocity all set ${Xrel} NULL NULL sum yes units box

This is clearly not allowed. You can't evaluate an atom-style
variable (produces N quantities, one per atom)
and substitute the result into a command. You can only substittute
for a variable that produces a single value, e.g. an equal-style variable.
Substitution is simply as if you had taken the number (or string) that came
from evaluating the variable, and typed it in the input script yourself
as an argument of the command.

And although I do not get an error for the following syntax:
velocity all set v_Xrel NULL NULL sum yes units box
The simulation hangs-up and does not progress past this step.

If I put these 3 lines into bench/in.lj in place of the velocity command
that is already there, it works fine, in serial or parallel. Also no memory
issues. Can you
try your script with the most current version of LAMMPS. I think
it should work.

Steve