python interface for per-atom data for fix external

This commit is contained in:
Axel Kohlmeyer
2021-07-22 15:27:51 -04:00
parent bb46dd7d1f
commit 324ae3181b
3 changed files with 109 additions and 4 deletions

View File

@ -246,6 +246,26 @@ class numpy_wrapper:
return np.ctypeslib.as_array(value)
return value
# -------------------------------------------------------------------------
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.
This function is a wrapper around the
:py:meth:`lammps.fix_external_get_force() <lammps.lammps.fix_external_get_force()>`
method. It behaves the same as the original method, but returns a NumPy array instead
of a ``ctypes`` pointer.
:param fix_id: Fix-ID of a fix external instance
:type: string
:return: requested data
:rtype: numpy.array
"""
import numpy as np
nlocal = self.lmp.extract_setting('nlocal')
value = self.lmp.fix_external_get_force(fix_id)
return self.darray(value,nlocal,3)
# -------------------------------------------------------------------------
def get_neighlist(self, idx):