add function to dispatch LAMMPS errors to library interfaces
This commit is contained in:
@ -13,29 +13,35 @@
|
||||
|
||||
# various symbolic constants to be used
|
||||
# in certain calls to select data formats
|
||||
LAMMPS_AUTODETECT = None
|
||||
LAMMPS_INT = 0
|
||||
LAMMPS_INT_2D = 1
|
||||
LAMMPS_DOUBLE = 2
|
||||
LAMMPS_DOUBLE_2D = 3
|
||||
LAMMPS_INT64 = 4
|
||||
LAMMPS_INT64_2D = 5
|
||||
LAMMPS_STRING = 6
|
||||
LAMMPS_AUTODETECT = None
|
||||
LAMMPS_INT = 0
|
||||
LAMMPS_INT_2D = 1
|
||||
LAMMPS_DOUBLE = 2
|
||||
LAMMPS_DOUBLE_2D = 3
|
||||
LAMMPS_INT64 = 4
|
||||
LAMMPS_INT64_2D = 5
|
||||
LAMMPS_STRING = 6
|
||||
|
||||
# these must be kept in sync with the enums in library.h
|
||||
LMP_STYLE_GLOBAL = 0
|
||||
LMP_STYLE_ATOM = 1
|
||||
LMP_STYLE_LOCAL = 2
|
||||
LMP_STYLE_GLOBAL = 0
|
||||
LMP_STYLE_ATOM = 1
|
||||
LMP_STYLE_LOCAL = 2
|
||||
|
||||
LMP_TYPE_SCALAR = 0
|
||||
LMP_TYPE_VECTOR = 1
|
||||
LMP_TYPE_ARRAY = 2
|
||||
LMP_SIZE_VECTOR = 3
|
||||
LMP_SIZE_ROWS = 4
|
||||
LMP_SIZE_COLS = 5
|
||||
LMP_TYPE_SCALAR = 0
|
||||
LMP_TYPE_VECTOR = 1
|
||||
LMP_TYPE_ARRAY = 2
|
||||
LMP_SIZE_VECTOR = 3
|
||||
LMP_SIZE_ROWS = 4
|
||||
LMP_SIZE_COLS = 5
|
||||
|
||||
LMP_VAR_EQUAL = 0
|
||||
LMP_VAR_ATOM = 1
|
||||
LMP_ERROR_WARNING = 0
|
||||
LMP_ERROR_ONE = 1
|
||||
LMP_ERROR_ALL = 2
|
||||
LMP_ERROR_WORLD = 4
|
||||
LMP_ERROR_UNIVERSE = 8
|
||||
|
||||
LMP_VAR_EQUAL = 0
|
||||
LMP_VAR_ATOM = 1
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Reference in New Issue
Block a user