Extract Atom IDs from group

Hi,

Is there any way to get the “IDs of atoms in a group” in a variable vector?

Dhritiman

Hi,

Is there any way to get the "IDs of atoms in a group" in a variable vector?

what is a "variable vector"?

what do you need this for?

you can access atom ids via compute property/atom. for atoms that are
not in the group, the corresponding property is set to zero.

axel.

Axel is correct, there is no vector-style variable

currently implemented in LAMMPS.

There are atom-style variables, which can use the gmask()

function defied for variables. Thus

variable g atom gmask(groupID)

will store a 1 for each atom in groupID, and a 0 for the others.

Steve

Hi,

Sorry about the “variable vector” I meant array x[i].

I need it for the same task mentioned in the mail sent by me titled “Assign formal charges to atoms in lammps data file”

the ID’s of atoms with which bonds are created can be changed to a certain type.
the atoms can be taken in a group and their ID’s can be dumped in an file…
but if the ids could be in a array stored in a variable in lammps, one could add a constant to the variable and hance derive the IDs of the bonded neighbours of the bond created atoms.
this is possible because packmol packed the molecules in a systematic way hence the arrangement of atoms in the atoms section is very orderly…
By orderly I mean see in the following example:

1 1 9 -0.8100 6.675000 7.420000 13.250000 # N3 UNK
2 1 5 0.2700 7.044000 8.381000 14.290000 # C32n UNK
3 1 5 0.2700 7.592000 9.661000 13.642000 # C32n UNK
4 1 10 -0.8100 7.985000 10.617000 14.695000 # N3o UNK
5 1 5 0.2700 8.203000 11.962000 14.126000 # C32n UNK
6 1 5 0.2700 9.454000 12.020000 13.229000 # C32n UNK
7 1 9 -0.8100 9.671000 13.403000 12.797000 # N3 UNK
8 2 9 -0.8100 6.611000 6.520000 16.593000 # N3 UNK
9 2 5 0.2700 5.211000 6.442000 17.013000 # C32n UNK
10 2 5 0.2700 4.473000 7.722000 16.596001 # C32n UNK
11 2 10 -0.8100 3.069000 7.649000 17.042999 # N3o UNK
12 2 5 0.2700 2.256000 8.693000 16.386999 # C32n UNK
13 2 5 0.2700 2.619000 10.107000 16.874001 # C32n UNK
14 2 9 -0.8100 1.699000 11.074000 16.271000 # N3 UNK
15 3 9 -0.8100 8.025000 17.532000 9.754000 # N3 UNK
16 3 5 0.2700 8.516000 18.892000 9.986000 # C32n UNK
17 3 5 0.2700 7.483000 19.684000 10.800000 # C32n UNK
18 3 10 -0.8100 7.972000 21.059999 11.010000 # N3o UNK
19 3 5 0.2700 7.177000 21.745001 12.049000 # C32n UNK
20 3 5 0.2700 5.738000 22.039000 11.584000 # C32n UNK
21

The N3 C32n C32n N3o C32n C32n N3 pattern is repeating.

I am able to get the IDs in a dump file but cant get it in a variable…

Hi,

Sorry about the "variable vector" I meant array x[i].

I need it for the same task mentioned in the mail sent by me titled "Assign
formal charges to atoms in lammps data file"

the ID's of atoms with which bonds are created can be changed to a certain
type.
the atoms can be taken in a group and their ID's can be dumped in an file..
but if the ids could be in a array stored in a variable in lammps, one could
add a constant to the variable and hance derive the IDs of the bonded
neighbours of the bond created atoms.
this is possible because packmol packed the molecules in a systematic way
hence the arrangement of atoms in the atoms section is very orderly..
By orderly I mean see in the following example:

why on earth do you try to make LAMMPS go through hoops to do things
that it isn't really designed for.
this same thing can be done elegantly and conveniently in VMD with a
little bit of scripting. there are (simple) examples on my homepage.
it is easy to gradually build this to do extremely complex things.
specifically selecting atoms or processing patterns of atom sequences
is *extremely* simple.

axel.

You can dump a subset of atoms, i.e. the ones with
the IDs you want. By either defining a group with
those atoms, or using the dump_modify thresh command.

Once you have them in a dump file, you can write a simple
Python script that converts it into the format of a variable
input (list of IDs). Then you can read it back into a
LAMMPS script.

Steve

Hi,
I have successfully dumped the atom IDs… Then I manually copy it into a LAMMPS input script like this:
variable Cc index xx xx xxx xx xxx xx …

Is there any way to read a modified(by python script) dump file from a LAMMPS script???

Dhritiman

Hi,
I have successfully dumped the atom IDs.. Then I manually copy it into a
LAMMPS input script like this:
variable Cc index xx xx xxx xx xxx xx ...

Is there any way to read a modified(by python script) dump file from a
LAMMPS script???

the read_dump command will read any dump file that is correctly formatted.

http://lammps.sandia.gov/doc/read_dump.html

axel.

Hi,
I am sorry… what I meant to ask was:How to read a file containing a list of IDs into a index style variable from a LAMMPS script?

I have read the read_dump’s documentation. I don’t think it is of use for the problem in hand.

Dhritiman

Hi,
I am sorry… what I meant to ask was:How to read a file containing a list of IDs into a index style variable from a LAMMPS script?

Read the variable documentation about file style variables.

I have read the read_dump’s documentation. I don’t think it is of use for the problem in hand.

Why not? It can read and set the charge property from custom dump files.

If you would have spent a little time learning vmd scripting, you would have solved your problem long ago.

Or you can use an atomfile variable and just one set command. Or write a script that outputs all individual lammps commands rather than making lammps do a loop. Post-process a data file. There are so many ways to skin this cat…

All it requires is a little creative thinking.