add lammps_expand() method and make available in python

This commit is contained in:
Axel Kohlmeyer
2024-09-20 00:17:06 -04:00
parent 11838801d6
commit 5e15eb6949
3 changed files with 72 additions and 0 deletions

View File

@ -178,6 +178,9 @@ class lammps(object):
self.lib.lammps_error.argtypes = [c_void_p, c_int, c_char_p]
self.lib.lammps_expand.argtypes = [c_void_p, c_char_p]
self.lib.lammps_expand.restype = c_char_p
self.lib.lammps_file.argtypes = [c_void_p, c_char_p]
self.lib.lammps_file.restype = None
@ -613,6 +616,28 @@ class lammps(object):
# -------------------------------------------------------------------------
def expand(self,line):
"""Expand a single LAMMPS string like an input line
This is a wrapper around the :cpp:func:`lammps_expand`
function of the C-library interface.
:param cmd: a single lammps line
:type cmd: string
:return: expanded string
:rtype: string
"""
if line: newline = line.encode()
else: return None
with ExceptionCheck(self):
strptr = self.lib.lammps_expand(self.lmp, newline)
rval = strptr.decode()
return rval
return None
# -------------------------------------------------------------------------
def file(self, path):
"""Read LAMMPS commands from a file.