[lammps-users] Using Variables to check on a value in running an 'if' loop

Hi,

I have a defined velocity:

velocity particle set 0 0 -3001.405 units box

I need to give the velocity a variable so that I can track its value. ie. I need to assign a place to hold the current velocity value.

Can I do that using the line:

variable pvel equal v_particle[i] ?

Or should I use vx[i] ?

I have defined a second group of atoms.

I need to average the velocity values of that group of atoms as my simulation proceeds. How is that done?

When that average value becomes equal to the velocity of the first particle group, I need to switch the fix to a different type.

It would be great if someone could elaborate on: assigning a variable for the velocity, averaging velocities for a group of atoms, using the if command to equate/compare two variables.

I did go through the documentation for variables and the if command. I tried out a command like:

if {pvel}=={rem} then “unfix 2”

It doesn’t work though. Look forward to inputs.

Thanks!
Harish

The variable doc page explains:

velocity of a particular atom = vx[N], etc
ave velocity of a group of atoms = vcm(group,1)
the if command can compare two equal-style variables
  and you could use "unfix" or "set" if the
  if test is successful

Steve