How to map the id of a ghost atom back to the original actual atom ID when adding a new potential function

I’m writing a machine learning potential for ghost atoms usually mapped to his original id in order to join a neural network for force delivery. But in lammps ghost atoms usually have new ids, how can I map their ids to their original ids after getting the distance to the ghost atom?

Sorry, but it is not clear what you are asking about. What is a “mirror atom”?
LAMMPS does not use that nomenclature. Please see the latest LAMMPS paper or the 4. Information for Developers — LAMMPS documentation to see what nomenclature the LAMMPS developers use and reformulate your question accordingly.

I am sorry! I’ve changed the expression, he should be ghost atom

1 Like

You have to understand the indexing in LAMMPS.
There is a global index, the atom ID, that is unique across the whole system, but the same atom ID may be present in multiple sub-domains, once as local atom and the remaining as ghost atoms. The atom ID can be obtained by accessing atom->tag[i].
Then there is the local index, that is the list of atoms stored on each subdomain. That ranges from 0 to nlocal-1 (inclusively) for “local” atoms and from nlocal to nlocal + nghost - 1 for ghost atoms.

If you have the global atom ID, you can get the corresponding local index with the atom->map() function, but for that you have to have set up an atom map. That is automatic for molecular systems, but must be requested with an atom_modify command if it is not set up.

See also here: 4.5. Accessing per-atom data — LAMMPS documentation