add function to dispatch LAMMPS errors to library interfaces

This commit is contained in:
Axel Kohlmeyer
2022-09-23 16:28:15 -04:00
parent 0f2a7d3f33
commit 86d1aacf7e
7 changed files with 197 additions and 45 deletions

View File

@ -167,6 +167,8 @@ class lammps(object):
self.lib.lammps_flush_buffers.argtypes = [c_void_p]
self.lib.lammps_free.argtypes = [c_void_p]
self.lib.lammps_error.argtypes = [c_void_p, c_int, c_char_p]
self.lib.lammps_file.argtypes = [c_void_p, c_char_p]
self.lib.lammps_file.restype = None
@ -486,6 +488,26 @@ class lammps(object):
# -------------------------------------------------------------------------
def error(self, error_type, error_text):
"""Forward error to the LAMMPS Error class.
This is a wrapper around the :cpp:func:`lammps_error` function of the C-library interface.
.. versionadded:: TBD
:param error_type:
:type error_type: int
:param error_text:
:type error_text: string
"""
if error_text: error_text = error_text.encode()
else: error_text = "(unknown error)".encode()
with ExceptionCheck(self):
self.lib.lammps_error(self.lmp, error_type, error_text)
# -------------------------------------------------------------------------
def version(self):
"""Return a numerical representation of the LAMMPS version in use.
@ -1622,8 +1644,8 @@ class lammps(object):
"""Return a string with detailed information about any devices that are
usable by the GPU package.
This is a wrapper around the :cpp:func:`lammps_get_gpu_device_info`
function of the C-library interface.
This is a wrapper around the :cpp:func:`lammps_get_gpu_device_info`
function of the C-library interface.
:return: GPU device info string
:rtype: string