From 28e986c266580f87d1f100f22e309ea7f2d60c1e Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Tue, 16 Mar 2021 23:25:46 -0400 Subject: [PATCH] add python module support for plugins --- python/lammps/core.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/python/lammps/core.py b/python/lammps/core.py index eaf78dfa0c..e75647fe44 100644 --- a/python/lammps/core.py +++ b/python/lammps/core.py @@ -264,6 +264,9 @@ class lammps(object): self.lib.lammps_id_name.argtypes = [c_void_p, c_char_p, c_int, c_char_p, c_int] + self.lib.lammps_plugin_count.argtypes = [ ] + self.lib.lammps_plugin_name.argtypes = [c_int, c_char_p, c_char_p, c_int] + self.lib.lammps_version.argtypes = [c_void_p] self.lib.lammps_get_os_info.argtypes = [c_char_p, c_int] @@ -1594,6 +1597,29 @@ class lammps(object): # ------------------------------------------------------------------------- + def available_plugins(self, category): + """Returns a list of plugins available for a given category + + This is a wrapper around the functions :cpp:func:`lammps_plugin_count()` + and :cpp:func:`lammps_plugin_name()` of the library interface. + + .. versionadded:: 10Mar2021 + + :return: list of style/name pairs of loaded plugins + :rtype: list + """ + + available_plugins = [] + num = self.lib.lammps_plugin_count(self.lmp) + sty = create_string_buffer(100) + nam = create_string_buffer(100) + for idx in range(num): + self.lib.lammps_plugin_name(idx, sty, nam, 100) + available_plugins.append([sty.value.decode(), nam.value.decode()]) + return available_plugins + + # ------------------------------------------------------------------------- + def set_fix_external_callback(self, fix_name, callback, caller=None): import numpy as np