Re: [lammps-users] if command for grouping molecules

I assume you mean you want to create a group that contains all the
atoms that are in molecules where any atom in that molecule has type N.

You can do that with the compute reduce/chunk and compute chunk/spread/atom commands,
something like this:

variable flag atom type[i]==7 # e.g. N = 7, each atom is now flagged 0 or 1
compute mol all chunk/atom molecule # one chunk per molecule
compute label all reduce/chunk mol max v_flag # each molecule label = 1 or 0

if it contains a type=7 atom or not

compute flag all chunk/spread/atom mol c_label # assign each atom a flag = its molecule label
variable flag atom c_flag[i] # create a variable with the flag for each atom
group type7mols variable v_flag # group the atoms which have their flag set