Commit a2108670 authored by Richard Berger's avatar Richard Berger
Browse files

Fixes lammps_create_atoms library function and its Python interface variant

The interface of that function has changed and includes two additional
parameters, which haven't been added to the Python interface either.
This showed up by trying to run the simple.py example.
parent 0262a54e
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -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?
    
+3 −5
Original line number Diff line number Diff line
@@ -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];