diff --git a/modules/mol/mm/src/simulation.cc b/modules/mol/mm/src/simulation.cc index 570bbaf80832d0f35b2bdbc74b8e34fb1088c3e9..7a3d4d2d31adf15ffb8bf8358a8ba3f04cd46510 100644 --- a/modules/mol/mm/src/simulation.cc +++ b/modules/mol/mm/src/simulation.cc @@ -267,6 +267,16 @@ SimulationPtr Simulation::Load(const String& filename, SettingsPtr settings){ } +void Simulation::EnsurePluginsLoaded(const String& plugin_path) { + // note: this is guaranteed to be constructed on first use only + static std::set<String> already_loaded; + if (already_loaded.find(plugin_path) == already_loaded.end()) { + // not loaded yet: load directory, but only once! + OpenMM::Platform::loadPluginsFromDirectory(plugin_path); + already_loaded.insert(plugin_path); + } +} + void Simulation::Init(const TopologyPtr top, const SettingsPtr settings){ diff --git a/modules/mol/mm/src/simulation.hh b/modules/mol/mm/src/simulation.hh index 9abe038bdf533ffcf788210198f18edf094617a1..4b9a8f8aa355f813b9e6651eb1f5670ab797a44b 100644 --- a/modules/mol/mm/src/simulation.hh +++ b/modules/mol/mm/src/simulation.hh @@ -145,6 +145,9 @@ private: int TimeToNextNotification(); + // loads plugins from directory for OpenMM BUT only once per unique path! + static void EnsurePluginsLoaded(const String& plugin_path); + SystemPtr system_; IntegratorPtr integrator_; ContextPtr context_;