diff --git a/python/lammps.py b/python/lammps.py index 80d1a87159e287d507a97141d740bc228b0415a9..0581b475a4b241decdd6d959d0301e6c3a58e34b 100644 --- a/python/lammps.py +++ b/python/lammps.py @@ -362,14 +362,22 @@ class lammps(object): # e.g. for Python list or NumPy, etc # ditto for gather_atoms() above - def create_atoms(self,n,id,type,x,v): + def create_atoms(self,n,id,type,x,v,image=None,shrinkexceed=False): if id: id_lmp = (c_int * n)() id_lmp[:] = id - else: id_lmp = id + else: + id_lmp = id + + if image: + image_lmp = (c_int * n)() + image_lmp[:] = image + else: + image_lmp = image + type_lmp = (c_int * n)() type_lmp[:] = type - self.lib.lammps_create_atoms(self.lmp,n,id_lmp,type_lmp,x,v) + self.lib.lammps_create_atoms(self.lmp,n,id_lmp,type_lmp,x,v,image_lmp,shrinkexceed) # document this? diff --git a/src/library.cpp b/src/library.cpp index 5980b135eb1bd8ee00f417b662e63339a9f9b0c2..da491f71528a319a69a2e28f822ac72e6ad14399 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -971,11 +971,9 @@ void lammps_create_atoms(void *ptr, int n, tagint *id, int *type, xdata[0] = x[3*i]; xdata[1] = x[3*i+1]; xdata[2] = x[3*i+2]; - if (image) { - if (!domain->ownatom(id[i],xdata,&image[i],shrinkexceed)) continue; - } else { - if (!domain->ownatom(id[i],xdata,NULL,shrinkexceed)) continue; - } + imageint * img = image ? &image[i] : NULL; + tagint tag = id ? id[i] : -1; + if (!domain->ownatom(tag, xdata, img, shrinkexceed)) continue; atom->avec->create_atom(type[i],xdata); if (id) atom->tag[nlocal] = id[i];