Question about velocity zero and fix momentum

If one were to use the following commands:

   velocity [groupname] zero linear
OR
   fix [id] [groupname] momentum linear 10 10 10

during a simulation, does LAMMPS adjust the velocity of ALL entities in
the system, or just those entities that belong to [groupname]? The
documentation doesn't say, but it appears from the source code that the
velocity of the center of mass of the entities in [groupname] is computed,
and that velocity is subtracted only from the entities in [groupname], not
the entire system. As such, this fix actually applies a force to the
atoms (in a manner of speaking).

Is there a way to simply make sure a group of atoms is always in the same
location in the box? That is, subtract the velocity of the center of mass
of [groupname] from ALL entities in the simulation box? Or is this what
fix/momentum and velocity/zero are supposed to do?

Obviously this issue does not apply when [groupname] is "all."

Karl

If one were to use the following commands:

velocity [groupname] zero linear
OR
fix [id] [groupname] momentum linear 10 10 10

during a simulation, does LAMMPS adjust the velocity of ALL entities in
the system, or just those entities that belong to [groupname]? The

only the group.

anything that operates on a group affects only that group unless
explicitly specified differently.

documentation doesn't say, but it appears from the source code that the
velocity of the center of mass of the entities in [groupname] is computed,
and that velocity is subtracted only from the entities in [groupname], not
the entire system. As such, this fix actually applies a force to the
atoms (in a manner of speaking).

i would not call it a force. it is an arbitrary manipulation.
it is usually done to remove momentum buildup due to
random initialization or floating point number truncation
error accumulation.

Is there a way to simply make sure a group of atoms is always in the same
location in the box? That is, subtract the velocity of the center of mass
of [groupname] from ALL entities in the simulation box? Or is this what
fix/momentum and velocity/zero are supposed to do?

the best way to do this depends on "how fixed" you want those
atoms to be. if you don't want those atoms to not move at all,
you can either exclude them from time integration or set velocities
to zero and then forces as well (with fix setforce). if you just want
to retain the center of mass, but have the atoms move around,
i would say, fix spring in "tether" mode would be a good option.

cheers,
    axel.

It occurred to me after reading your reply that the following commands
might do it as well:

   variable xcom equal xcm([groupid],x)
   variable ycom equal xcm([groupid],y)
   variable zcom equal xcm([groupid],z)
   fix [id] [groupid] recenter \{xcom\} {ycom} ${zcom} shift all units box

This means the center of mass of [groupid] stays put, but ALL entities get
shifted every timestep so that none of the forces or velocities is
disrupted. Also, my previous post had an incorrect fix/momentum command;
the 10's should be 1's, of course. Combining these two commands would get
rid of both velocity drift AND position drift, for those interesting in
doing so.

Thank you!

Karl