atom ID

Hi, all, I confront an issue: I have the cpp code to compute the displacement of each single atom and its equilibrium position every timestep inside the lammps. When I compute that, the output is error. I guess it is because my atom ID is not continuous since I delete some atoms previously. I calculated one sample before, due to the ID of atoms are continuous, so it works. I am not sure which part I should modify for my cpp code. How can I make the cpp code work while the ID of atoms are not continuous? I think it is relevant to nlocal, is that correct? Thanks.

Best,
Haoxiang Huang

Hi, all, I confront an issue: I have the cpp code to compute the displacement of each single atom and its equilibrium position every timestep inside the lammps. When I compute that, the output is error. I guess it is because my atom ID is not continuous since I delete some atoms previously. I calculated one sample before, due to the ID of atoms are continuous, so it works. I am not sure which part I should modify for my cpp code. How can I make the cpp code work while the ID of atoms are not continuous? I think it is relevant to nlocal, is that correct? Thanks.

no, the atom id and nlocal are two unrelated properties. nlocal is the
number of "owned" atoms within the domain decomposition and the atom
id is a global atom identifier.

what you need to do is to construct a map, similar to what the Atom
class in LAMMPS does. that can be either based on a simple array or a
hash table (available as <map> or <vector> templates in the STL
library) and would map the atom id to a consecutive index in your
local storage of your C++ code. for the second to be efficient, you
should first identify the largest atom id and then dimension the array
accordingly (using the vector::reserve() method). this is
straightforward C++ stuff.

axel.

Hi, Axel, how the lammps code matches the global ID of each atom? which variable in the cpp source code generally? Thanks.

Hi, Axel, how the lammps code matches the global ID of each atom? which variable in the cpp source code generally? Thanks.

Please re-read my previous email and study the lammps source code as indicated. If that doesn’t help, I don’t know how else to help you. What you are asking for is a conceptually simple thing (a map).
If you don’t get that, you may first need to work on your general programming skills.

Axel

Hi, I define the command to restore the global ID for the atoms below :

int natomALL = atom-> natoms;
memory-> create(id_global2subsystem,natomALL,"id_global2subsystem:natomALL");

I have a question, if I define an array of number to substitute the original global ID like

id_global2subsystem[k]= i, where k is the specific number of atom and i is specified number I wanted to subs the original global ID, is that working?

if it does, I call tag[k] to match the global ID like id_global2subsystem[tag[k]], will it get the value of i? Thanks.

Best,

Hi, I define the command to restore the global ID for the atoms below :

int natomALL = atom-> natoms;
memory-> create(id_global2subsystem,natomALL,“id_global2subsystem:natomALL”);

I have a question, if I define an array of number to substitute the original global ID like

id_global2subsystem[k]= i, where k is the specific number of atom and i is specified number I wanted to subs the original global ID, is that working?

if it does, I call tag[k] to match the global ID like id_global2subsystem[tag[k]], will it get the value of i? Thanks.

It is not that simple.

Why program a feature, that lammps already provides?

Study the atom class and other parts of the code, that require the same feature…