defining groups

Hello,

I have quite a large list of atom ID’s (>1000) in my model that I would like place in the same group. I cannot use the

group group_name id …

command, because the line becomes much too long with all the atom IDs. I have the list of atom ID’s in a text file, is there any way to import the list into LAMMPS directly?

I have been trying to find a work around, without much success…Thank you for any suggestions,

Regards,
-A

Hello Andrew,
below is a completely untested piece of code to be inserted in
group.cpp that _should_ do what you want (it compiles, that is all I
can vouch for).
The code goes into void Group::assign(int narg, char **arg) for
example after the if block that starts with if
(strcmp(arg[1],"region") == 0) {
You'll probably have to tweak it to read the data in correctly. It
builds an atom map (if non is defied) to look up the atoms according
to their id.
Cheers,
Daniel

  // select atoms from IDs given in a text file

  } else if (strcmp(arg[1],"file") == 0) {

    if (narg != 3) error->all(FLERR,"Illegal group command");

    // create an atom map if one doesn't exist already

    int mapflag = 0;
    if (atom->map_style == 0) {
      mapflag = 1;
      atom->map_style = 1;
      atom->nghost = 0;
      atom->map_init();
      atom->map_set();
    }

    FILE *in = fopen( arg[2], "rt" );
    int ii;
    while(!feof(in)) {
      if( fscanf( in, "%d", &ii ) == 1 ) {
        i = atom->map(ii);
        if ( i >= 0 && i < nlocal) mask[i] |= bit;
      }
    }
    fclose(in);

    // delete temporary atom map

    if (mapflag) {
      atom->map_delete();
      atom->map_style = 0;
    }

Hello,

I have quite a large list of atom ID's (>1000) in my model that I would like
place in the same group. I cannot use the

group group_name id ...

command, because the line becomes much too long with all the atom IDs. I
have the list of atom ID's in a text file, is there any way to import the
list into LAMMPS directly?

current lammps versions should not have a limit to the maximum length
of an input line
when using continuation markers (&). so you could probably write a
script that outputs the list you want and then using include to read
it into lammps.

axel.

Also, you can use as many group commands to add atoms to the group one
(or more) at a time.

From the docs:

"If the group ID already exists, the group command adds the specified
atoms to the group."

If you want to do this cleanly, you could create a file with
(potentially) thousands of lines containing a list of all the atoms in
your group (using one or more group commands), and insert this text
into your main script using the "include" command.

You could also use "&" characters to continue a single command, as
Axel suggested.

Cheers!
Andrew

http://lammps.sandia.gov/doc/include.html
http://lammps.sandia.gov/doc/group.html

Thank you all ! This was exactly what I was looking for. I was not aware of these solutions.

Regards,
-A