The boundary between two types: create a group which contain only boundary atoms

Dear LAMMPS community,

I have two types of atoms, say 1 and 2, unmixed, i.e. they have an undiffused boundary. I want to create a LAMMPS group from atoms of both types, located exactly at the boundary (i.e. atoms of type 1 have at least one neighbor of type 2 and vice versa) so I could perform Metropolis MC for atoms only at the boundary.

I tried to use coord/atom compute to calculate type 1 neighbors of type 2 and vice versa as

compute type2neigh groupoftype2atoms coord/atom cutoff 5.5 1
run 0
variable iftype2 atom “c_ type2neigh > 0”

compute type1neigh groupoftype1atoms coord/atom cutoff 5.5 2
run 0
variable iftype1 atom “c_ type1neigh > 0”

But the problem is when I try to combine variables iftype1 and iftype2 to create a variable like

variable ifswap atom “c_lneigh > 0 || c_alneigh > 0”

and then plug it into the dynamic group

group swpgr variable ifswap dynamic all

to create a group of atoms to swap, LAMMPS probably considers that the variable iftype2 is changed in between the runs.

I also tried creating dynamic groups of type 1 and 2 atoms having type 2 and 1 neighbors separately and then uniting them to obtain the desired swpgr but LAMMPS, as I understand, requires the parent groups to be static.

Has anyone encountered a problem like that before? Is there any good strategy to solve it within LAMMPS?

Thank you!

Best regards,
Mikhail Arefev

This statement cannot work:
group swpgr variable ifswap dynamic all

It’s not valid syntax for the group command.

I suggest you first try to define a static group
that has the atoms you want. Count them, dump them, viz them.
Verify it is the atoms you want. Then worry
about a dynamic group.