Miscellaneous Utilities

openmmtools.utils provides a number of useful utilities for working with OpenMM.

Timing functions

time_it Context manager to log execution time of a block of code.
with_timer Decorator that logs the execution time of a function.
Timer A class with stopwatch-style timing functions.

Temporary directories

temporary_directory Context for safe creation of temporary directories.

Symbolic mathematics

sanitize_expression Sanitize variables with an illegal Python name.
math_eval Evaluate a mathematical expression with variables.

Quantity functions

is_quantity_close Check if the quantities are equal up to floating-point precision errors.

OpenMM Platform utilities

get_available_platforms Return a list of the available OpenMM Platforms.
get_fastest_platform Return the fastest available platform.

Serialization utilities

serialize Serialize an object.
deserialize Deserialize an object.

Metaclass utilities

with_metaclass Create a base class with a metaclass.
SubhookedABCMeta Abstract class with an implementation of __subclasshook__.
find_all_subclasses Return a set of all the classes inheriting from parent_cls.
find_subclass Return the class called subcls_name inheriting from parent_cls.

OpenMM custom object utilities

RestorableOpenMMObject Base class for restorable custom integrators and forces.