diff --git a/python/lammps/core.py b/python/lammps/core.py index 9bf1f913a7..2f253c6333 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -269,6 +269,9 @@ class lammps(object): self.lib.lammps_extract_global_datatype.restype = c_int self.lib.lammps_extract_compute.argtypes = [c_void_p, c_char_p, c_int, c_int] + self.lib.lammps_map_atom.argtypes = [c_void_p, c_void_p] + self.lib.lammps_map_atom.restype = c_int + self.lib.lammps_get_thermo.argtypes = [c_void_p, c_char_p] self.lib.lammps_get_thermo.restype = c_double @@ -928,6 +931,24 @@ class lammps(object): else: return target_type(ptr[0]) return None + # ------------------------------------------------------------------------- + # map global atom ID to local atom index + + def map_atom(self, id): + """Map a global atom ID (aka tag) to the local atom indx + + This is a wrapper around the :cpp:func:`lammps_map_atom` + function of the C-library interface. + + :param id: atom ID + :type id: int + :return: local index + :rtype: int + """ + + tag = self.c_tagint(id) + return self.lib.lammps_map_atom(self.lmp, pointer(tag)) + # ------------------------------------------------------------------------- # extract per-atom info datatype