You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When two pylammps objects are initialized and each of them executes plugin load, the second one still gets Exception: ERROR: Unrecognized pair style error.
The stable version in 2022 doesn't have this problem.
LAMMPS Version and Platform
stable_2Aug2023, linux
Expected Behavior
Each of the multiple pylammps objects can load plugins.
Actual Behavior
If the first pylammps object is not closed, the second one does not actually load the plugin though the message says it does.
This is not easy to resolve. The plugin interface is not set up for this kind of use case.
When importing a plugin, it is added to the global address space. The data structure that knows about styles and how to create them, however, is a per-class instance data structure. so when you create the second LAMMPS instance and try to load the same plugin, LAMMPS will refuse, because the handle for the plugin is already open and the code loaded. However, the factory function has not been registered with that LAMMPS instance, hence the error.
Plugins have to be managed in a static global data structure (see the file src/PLUGIN/plugin.cpp). There are two possible strategies:
add reference counting to the global data structure so that the same plugin can be loaded multiple times but always the same factory function is registered and then the plugin is only unloaded after all references are gone
move the map holds the factory function pointer and connects them to the style name also to a static global data structure.
In the first case, each plugin must be loaded with each instance, but the second and further loads are "fake". In the second case, each plugin can only be loaded once, but is accessible from all LAMMPS instances.
This is independent from whether you use PyLammps, the plain python module or the LAMMPS executable.
Summary
When two pylammps objects are initialized and each of them executes
plugin load
, the second one still getsException: ERROR: Unrecognized pair style
error.The stable version in 2022 doesn't have this problem.
LAMMPS Version and Platform
stable_2Aug2023, linux
Expected Behavior
Each of the multiple pylammps objects can load plugins.
Actual Behavior
If the first pylammps object is not closed, the second one does not actually load the plugin though the message says it does.
Steps to Reproduce
Got
Exception: ERROR: Unrecognized pair style
.However, it works when the first pylammps is closed before the second one is initialized:
Using
LAMMPS_PLUGIN_PATH
will observe the same behavior.Further Information, Files, and Links
The text was updated successfully, but these errors were encountered: