Skip to content
Snippets Groups Projects
Commit 2f3a3a68 authored by Gerardo Tauriello's avatar Gerardo Tauriello
Browse files

Added static Simulation::IsPlatformAvailable method to check OpenMM platforms.

parent 8835ca8d
Branches
Tags
No related merge requests found
......@@ -60,7 +60,7 @@ mapped back to the attached structure at any time.
:param filename: Filename
:type filename: :class:`str`
.. method:: Load(filename)
.. staticmethod:: Load(filename)
Loads a dumped simulation from disk. You have to make sure, that the provided
settings are consistent with those from the saved simulation. Undefined
......@@ -72,6 +72,18 @@ mapped back to the attached structure at any time.
:type filename: :class:`str`
:type settings: :class:`Settings`
.. staticmethod:: IsPlatformAvailable(settings)
:return: True, if platform defined in *settings* is available. Otherwise,
construction of a simulation object will fail with these settings.
:rtype: :class:`bool`
:param settings: Controls the parametrization of this class.
Only :attr:`Settings.openmm_plugin_directory`,
:attr:`Settings.custom_plugin_directory` and
:attr:`Settings.platform` are relevant.
:type settings: :class:`Settings`
.. method:: ApplyLBFGS([tolerance=1.0,max_iterations=1000])
Run minimization using the Limited-memory Broyden–Fletcher–Goldfarb–Shanno
......
......@@ -52,7 +52,11 @@ void export_Simulation()
.def(init<const ost::mol::EntityHandle, const ost::mol::mm::SettingsPtr>())
.def(init<const ost::mol::mm::TopologyPtr,const ost::mol::EntityHandle&,const ost::mol::mm::SettingsPtr>())
.def("Save",&ost::mol::mm::Simulation::Save,(arg("filename")))
.def("Load",&ost::mol::mm::Simulation::Load,(arg("filename"))).staticmethod("Load")
.def("Load",&ost::mol::mm::Simulation::Load,(arg("filename")))
.staticmethod("Load")
.def("IsPlatformAvailable",&ost::mol::mm::Simulation::IsPlatformAvailable,
(arg("settings")))
.staticmethod("IsPlatformAvailable")
.def("Steps",&ost::mol::mm::Simulation::Steps,(arg("steps")))
.def("GetPositions",&ost::mol::mm::Simulation::GetPositions,(arg("enforce_periodic_box")=false, arg("in_angstrom")=true))
.def("GetVelocities",&ost::mol::mm::Simulation::GetVelocities)
......
......@@ -267,6 +267,24 @@ SimulationPtr Simulation::Load(const String& filename, SettingsPtr settings){
}
bool Simulation::IsPlatformAvailable(const SettingsPtr settings) {
// load settings-dependent plugin directories
EnsurePluginsLoaded(settings->openmm_plugin_directory);
EnsurePluginsLoaded(settings->custom_plugin_directory);
// check if OpenMM platform exists by checking all (this is fast..)
const Platform platform_id = settings->platform;
for (int i = 0; i < OpenMM::Platform::getNumPlatforms(); ++i) {
OpenMM::Platform& platform = OpenMM::Platform::getPlatform(i);
if ( (platform_id == Reference && platform.getName() == "Reference")
|| (platform_id == OpenCL && platform.getName() == "OpenCL")
|| (platform_id == CUDA && platform.getName() == "CUDA")
|| (platform_id == CPU && platform.getName() == "CPU")) {
return true;
}
}
return false;
}
void Simulation::EnsurePluginsLoaded(const String& plugin_path) {
// note: this is guaranteed to be constructed on first use only
static std::set<String> already_loaded;
......
......@@ -67,6 +67,8 @@ public:
static SimulationPtr Load(const String& filename, SettingsPtr settings);
static bool IsPlatformAvailable(const SettingsPtr settings);
ost::mol::EntityHandle GetEntity() { return ent_; }
geom::Vec3List GetPositions(bool enforce_periodic_box = false, bool in_angstrom = true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment