From 5f3efd5aa49a76cea878e554e301da0fcbd6d806 Mon Sep 17 00:00:00 2001 From: Gerardo Tauriello <gerardo.tauriello@unibas.ch> Date: Thu, 3 Nov 2016 15:48:37 +0100 Subject: [PATCH] Use new ost.mol.mm functionality to check for CPU platform. --- modelling/pymod/_pipeline.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/modelling/pymod/_pipeline.py b/modelling/pymod/_pipeline.py index f7c3e2ec..9871d1a5 100644 --- a/modelling/pymod/_pipeline.py +++ b/modelling/pymod/_pipeline.py @@ -121,23 +121,22 @@ def _SetupMmSimulation(model, force_fields): if lig_ent.residue_count > 0: _AddLigands(ent, top, lig_ent, settings, force_fields) - # finally set up the simulation - try: - # use fast CPU platform by default - # NOTE: settings.platform only relevant for mm.Simulation! - settings.platform = mm.Platform.CPU + # use fast CPU platform by default + # NOTE: settings.platform only relevant for mm.Simulation! + settings.platform = mm.Platform.CPU + if mm.Simulation.IsPlatformAvailable(settings): num_cpu_threads = os.getenv('PM3_OPENMM_CPU_THREADS') if num_cpu_threads is None: settings.cpu_properties["CpuThreads"] = "1" else: settings.cpu_properties["CpuThreads"] = num_cpu_threads - sim = mm.Simulation(top, ent, settings) - except RuntimeError as ex: - ost.LogWarning("OpenMM failed to initialize with error: %s" % str(ex)) + else: # switch to "mm.Platform.Reference" as fallback settings.platform = mm.Platform.Reference - sim = mm.Simulation(top, ent, settings) ost.LogWarning("Switched to slower reference platform of OpenMM!") + # finally set up the simulation + sim = mm.Simulation(top, ent, settings) + return sim def _GetSimEntity(sim): -- GitLab