add lammps_add_molecule API to the C-library interface and python/fortran module

This commit is contained in:
Axel Kohlmeyer
2025-06-14 12:46:36 -04:00
parent faa1dbc19d
commit 2d5f02a398
9 changed files with 122 additions and 5 deletions

View File

@ -325,6 +325,8 @@ class lammps(object):
POINTER(c_double), POINTER(c_double), POINTER(self.c_imageint), c_int]
self.lib.lammps_create_atoms.retype = c_int
self.lib.lammps_create_molecule.argtypes = [c_void_p, c_char_p, c_char_p]
self.lib.lammps_create_molecule.restype = None
self.lib.lammps_find_pair_neighlist.argtypes = [c_void_p, c_char_p, c_int, c_int, c_int]
self.lib.lammps_find_pair_neighlist.restype = c_int
@ -2101,6 +2103,28 @@ class lammps(object):
# -------------------------------------------------------------------------
def create_molecule(self, id, jsonstr):
""" Create new molecule template from string with JSON data
.. versionadded:: TBD
This is a wrapper around the :cpp:func:`lammps_create_molecule` function
of the library interface.
:param id: molecule-id of the new molecule template
:type name: string
:param jsonstr: JSON data defining a new molecule template
:type jsonstr: string
"""
if id: newid = id.encode()
else: newid = None
if id: newjsonstr = jsonstr.encode()
else: newjsonstr = None
with ExceptionCheck(self):
self.lib.lammps_create_molecule(self.lmp, newid, newjsonstr)
# -------------------------------------------------------------------------
@property
def has_mpi_support(self):
""" Report whether the LAMMPS shared library was compiled with a