# How to group atoms by logical operator

Dear Lammpser,

I am trying to do this in Lammps:

Support I have a group of atoms defined by this

group

Dear Lammpser,

I am trying to do this in Lammps:

Support I have a group of atoms defined by this

“group G1 type 1”

At each time step, I want to selected the atoms from group ‘G1’ whose X and Y coordinates satisfy the following two conditions:

X_min < X < X_max

Y_min < Y < Y_max

Here “X-min”, “X_max”, “Y_min” and “Y_max” are also variables, depending on other “compute” command results.

I was trying to have this two variables in the input control:

variable XL1 atom "x <> v_X_min v_X_max "

variable YL1 atom "y <> v_Y_min v_Y_max "

but then I get lost and do know how to combine two logical operator.

Any idea?

Thank you in advance!

Liangliang

CHE, NC State University

Dear Lammpser,

I am trying to do this in Lammps:

Support I have a group of atoms defined by this

"group G1 type 1"

At each time step, I want to selected the atoms from group 'G1' whose X and
Y coordinates satisfy the following two conditions:

it has been discussed many times on this list that these kinds of
things are a bad idea, starting from the fact that each group command
will *add* atoms to the group and not redefine it. it also is
extremely inefficient. and is unlikely to work the way you want.

X_min < X < X_max

Y_min < Y < Y_max

Here "X-min", "X_max", "Y_min" and "Y_max" are also variables, depending on
other "compute" command results.

I was trying to have this two variables in the input control:

variable XL1 atom "x <> v_X_min v_X_max "

variable YL1 atom "y <> v_Y_min v_Y_max "

but then I get lost and do know how to combine two logical operator.

Any idea?

what do you need these dynamically changing groups for?

no way to make any suggestions on this very incomplete information.

axel.

Hi Axel,

Thanks for the reply. You are right that a post analysis is more efficient.

I was trying to do some AFM modeling, and thus am curious to know the relative deformation of the substrate when the tip is moving along a certain direction of the surface. Any suggestion on this type of calculation & analysis?

I guess I will export the mobile part of the simulation box into DCD file and do the analysis there.

Best regards,

Liangliang

Hi Axel,

Thanks for the reply. You are right that a post analysis is more efficient.

I was trying to do some AFM modeling, and thus am curious to know the
relative deformation of the substrate when the tip is moving along a certain
direction of the surface. Any suggestion on this type of calculation &
analysis?

how about using fix store/state and an atom style variable that
computes the delta on a per atom basis?

axel.

There is a variable function grmask() that can be used
in an atom-style variable to return a 1 if an atom is in
both a group and region and 0 otherwise. There are also
several other functions like count() and xcm() that will

only operation on atoms in the group and region.

Steve