add python interface with optional numpy support for lammps_gather_bonds()
unit tests are included
This commit is contained in:
@ -248,6 +248,24 @@ class numpy_wrapper:
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def gather_bonds(self):
|
||||
"""Retrieve global list of bonds as NumPy array
|
||||
|
||||
This is a wrapper around :py:meth:`lammps.gather_bonds() <lammps.lammps.gather_bonds()>`
|
||||
It behaves the same as the original method, but returns a NumPy array instead
|
||||
of a ``ctypes`` list.
|
||||
|
||||
.. versionadded:: 28Jul2021
|
||||
|
||||
:return: the requested data as a 2d-integer numpy array
|
||||
:rtype: numpy.array(nbonds,3)
|
||||
"""
|
||||
import numpy as np
|
||||
nbonds, value = self.lmp.gather_bonds()
|
||||
return np.ctypeslib.as_array(value).reshape(nbonds,3)
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
def fix_external_get_force(self, fix_id):
|
||||
"""Get access to the array with per-atom forces of a fix external instance with a given fix ID.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user