Merge branch 'lammps:develop' into mliappy_unified
This commit is contained in:
@ -188,20 +188,17 @@ class lammps(object):
|
||||
[c_void_p,POINTER(c_double),POINTER(c_double),c_double,c_double,c_double]
|
||||
self.lib.lammps_reset_box.restype = None
|
||||
|
||||
self.lib.lammps_gather_atoms.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_gather_atoms.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_gather_atoms.restype = None
|
||||
|
||||
self.lib.lammps_gather_atoms_concat.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_gather_atoms_concat.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_gather_atoms_concat.restype = None
|
||||
|
||||
self.lib.lammps_gather_atoms_subset.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p]
|
||||
self.lib.lammps_gather_atoms_subset.restype = None
|
||||
|
||||
self.lib.lammps_scatter_atoms.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_scatter_atoms.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_scatter_atoms.restype = None
|
||||
|
||||
self.lib.lammps_scatter_atoms_subset.argtypes = \
|
||||
@ -211,20 +208,17 @@ class lammps(object):
|
||||
self.lib.lammps_gather_bonds.argtypes = [c_void_p,c_void_p]
|
||||
self.lib.lammps_gather_bonds.restype = None
|
||||
|
||||
self.lib.lammps_gather.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_gather.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_gather.restype = None
|
||||
|
||||
self.lib.lammps_gather_concat.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_gather_concat.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_gather_concat.restype = None
|
||||
|
||||
self.lib.lammps_gather_subset.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_int,POINTER(c_int),c_void_p]
|
||||
self.lib.lammps_gather_subset.restype = None
|
||||
|
||||
self.lib.lammps_scatter.argtypes = \
|
||||
[c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_scatter.argtypes = [c_void_p,c_char_p,c_int,c_int,c_void_p]
|
||||
self.lib.lammps_scatter.restype = None
|
||||
|
||||
self.lib.lammps_scatter_subset.argtypes = \
|
||||
@ -244,7 +238,8 @@ class lammps(object):
|
||||
self.lib.lammps_neighlist_num_elements.argtypes = [c_void_p, c_int]
|
||||
self.lib.lammps_neighlist_num_elements.restype = c_int
|
||||
|
||||
self.lib.lammps_neighlist_element_neighbors.argtypes = [c_void_p, c_int, c_int, POINTER(c_int), POINTER(c_int), POINTER(POINTER(c_int))]
|
||||
self.lib.lammps_neighlist_element_neighbors.argtypes = \
|
||||
[c_void_p, c_int, c_int, POINTER(c_int), POINTER(c_int), POINTER(POINTER(c_int))]
|
||||
self.lib.lammps_neighlist_element_neighbors.restype = None
|
||||
|
||||
self.lib.lammps_is_running.argtypes = [c_void_p]
|
||||
@ -368,11 +363,9 @@ class lammps(object):
|
||||
if type(cmdargs[i]) is str:
|
||||
cmdargs[i] = cmdargs[i].encode()
|
||||
cargs = (c_char_p*narg)(*cmdargs)
|
||||
self.lib.lammps_open.argtypes = [c_int, c_char_p*narg, \
|
||||
MPI_Comm, c_void_p]
|
||||
self.lib.lammps_open.argtypes = [c_int, c_char_p*narg, MPI_Comm, c_void_p]
|
||||
else:
|
||||
self.lib.lammps_open.argtypes = [c_int, c_char_p, \
|
||||
MPI_Comm, c_void_p]
|
||||
self.lib.lammps_open.argtypes = [c_int, c_char_p, MPI_Comm, c_void_p]
|
||||
|
||||
self.opened = 1
|
||||
comm_ptr = self.MPI._addressof(comm)
|
||||
@ -390,8 +383,7 @@ class lammps(object):
|
||||
if type(cmdargs[i]) is str:
|
||||
cmdargs[i] = cmdargs[i].encode()
|
||||
cargs = (c_char_p*narg)(*cmdargs)
|
||||
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*narg, \
|
||||
c_void_p]
|
||||
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p*narg, c_void_p]
|
||||
self.lmp = c_void_p(self.lib.lammps_open_no_mpi(narg,cargs,None))
|
||||
else:
|
||||
self.lib.lammps_open_no_mpi.argtypes = [c_int, c_char_p, c_void_p]
|
||||
@ -963,17 +955,14 @@ class lammps(object):
|
||||
return ptr
|
||||
|
||||
elif ctype == LMP_SIZE_COLS:
|
||||
if cstyle == LMP_STYLE_GLOBAL \
|
||||
or cstyle == LMP_STYLE_ATOM \
|
||||
or cstyle == LMP_STYLE_LOCAL:
|
||||
if cstyle == LMP_STYLE_GLOBAL or cstyle == LMP_STYLE_ATOM or cstyle == LMP_STYLE_LOCAL:
|
||||
self.lib.lammps_extract_compute.restype = POINTER(c_int)
|
||||
with ExceptionCheck(self):
|
||||
ptr = self.lib.lammps_extract_compute(self.lmp,cid,cstyle,ctype)
|
||||
return ptr[0]
|
||||
|
||||
elif ctype == LMP_SIZE_VECTOR or ctype == LMP_SIZE_ROWS:
|
||||
if cstyle == LMP_STYLE_GLOBAL \
|
||||
or cstyle == LMP_STYLE_LOCAL:
|
||||
if cstyle == LMP_STYLE_GLOBAL or cstyle == LMP_STYLE_LOCAL:
|
||||
self.lib.lammps_extract_compute.restype = POINTER(c_int)
|
||||
with ExceptionCheck(self):
|
||||
ptr = self.lib.lammps_extract_compute(self.lmp,cid,cstyle,ctype)
|
||||
|
||||
@ -165,7 +165,7 @@ class numpy_wrapper:
|
||||
"""
|
||||
value = self.lmp.extract_compute(cid, cstyle, ctype)
|
||||
|
||||
if cstyle in (LMP_STYLE_GLOBAL, LMP_STYLE_LOCAL):
|
||||
if cstyle == LMP_STYLE_GLOBAL:
|
||||
if ctype == LMP_TYPE_VECTOR:
|
||||
nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_VECTOR)
|
||||
return self.darray(value, nrows)
|
||||
@ -173,6 +173,13 @@ class numpy_wrapper:
|
||||
nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_ROWS)
|
||||
ncols = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_COLS)
|
||||
return self.darray(value, nrows, ncols)
|
||||
elif cstyle == LMP_STYLE_LOCAL:
|
||||
nrows = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_ROWS)
|
||||
ncols = self.lmp.extract_compute(cid, cstyle, LMP_SIZE_COLS)
|
||||
if ncols == 0:
|
||||
return self.darray(value, nrows)
|
||||
else:
|
||||
return self.darray(value, nrows, ncols)
|
||||
elif cstyle == LMP_STYLE_ATOM:
|
||||
if ctype == LMP_TYPE_VECTOR:
|
||||
nlocal = self.lmp.extract_global("nlocal")
|
||||
|
||||
@ -449,6 +449,8 @@ class PyLammps(object):
|
||||
:type ptr: pointer
|
||||
:param comm: MPI communicator (as provided by `mpi4py <mpi4py_docs_>`_). ``None`` means use ``MPI_COMM_WORLD`` implicitly.
|
||||
:type comm: MPI_Comm
|
||||
:param verbose: print all LAMMPS output to stdout
|
||||
:type verbose: bool
|
||||
|
||||
:ivar lmp: instance of original LAMMPS Python interface
|
||||
:vartype lmp: :py:class:`lammps`
|
||||
@ -457,8 +459,9 @@ class PyLammps(object):
|
||||
:vartype run: list
|
||||
"""
|
||||
|
||||
def __init__(self, name="", cmdargs=None, ptr=None, comm=None):
|
||||
def __init__(self, name="", cmdargs=None, ptr=None, comm=None, verbose=False):
|
||||
self.has_echo = False
|
||||
self.verbose = verbose
|
||||
|
||||
if cmdargs:
|
||||
if '-echo' in cmdargs:
|
||||
@ -869,8 +872,8 @@ class PyLammps(object):
|
||||
if comm:
|
||||
output = self.lmp.comm.bcast(output, root=0)
|
||||
|
||||
if 'verbose' in kwargs and kwargs['verbose']:
|
||||
print(output)
|
||||
if self.verbose or ('verbose' in kwargs and kwargs['verbose']):
|
||||
print(output, end = '')
|
||||
|
||||
lines = output.splitlines()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user