accept PyLammps() and lammps() objects for ptr argument and initialize as needed

This commit is contained in:
Axel Kohlmeyer
2016-07-18 23:14:29 -04:00
parent 0aebb2eabe
commit 899c5401ab

View File

@ -392,7 +392,13 @@ class PyLammps(object):
def __init__(self,name="",cmdargs=None,ptr=None,comm=None):
if ptr:
self.lmp = ptr
if isinstance(ptr,PyLammps):
self.lmp = ptr.lmp
elif isinstance(ptr,lammps):
self.lmp = ptr
else:
self.lmp = None
raise TypeError('Unsupported type passed as "ptr"')
else:
self.lmp = lammps(name=name,cmdargs=cmdargs,ptr=None,comm=comm)
print("LAMMPS output is captured by PyLammps wrapper")