openpathsampling.openmm_engine.OpenMMEngine¶
-
class
openpathsampling.openmm_engine.
OpenMMEngine
(template, system, integrator, options=None)[source]¶ OpenMM dynamics engine based on using an simtk.openmm system and integrator object.
The engine will create a
simtk.openmm.app.Simulation
instance and uses this to generate new frames.-
__init__
(template, system, integrator, options=None)[source]¶ Parameters: - template (openpathsampling.Snapshot) – a template snapshots which provides the topology object to be used to create the openmm engine
- system (simtk.openmm.app.System) – the openmm system object
- integrator (simtk.openmm.Integrator) – the openmm integrator object
- options (dict) – a dictionary that provides additional settings for the OPS engine. Allowed are ‘n_steps_per_frame’ : int, default: 10, the number of integration steps per returned snapshot ‘n_frames_max’ : int or None, default: 5000, the maximal number of frames allowed for a returned trajectory object platform : str, default: fastest, the openmm specification for the platform to be used, also ‘fastest’ is allowed which will pick the currently fastest one available
Notes
the n_frames_max does not limit Trajectory objects in length. It only limits the maximal lenght of returned trajectory objects when this engine is used. picking fasted as platform will not save fastest as the platform but rather replace the platform with the currently fastest one (usually OpenCL or CUDA for GPU and CPU otherwise). If you load this engine it will assume the same engine and not the currently fastest one, so you might have to create a replacement that uses another engine.
Methods
__init__
(template, system, integrator[, options])param template: a template snapshots which provides the topology object to be used to create the openmm engine args
()Return a list of args of the __init__ function of a class base
()Return the most parent class that is actually derived from Storable(Named)Object check_snapshot_type
(snapshot)count_weaks
()Return the counts of how many objects of storable type are still in memory descendants
()Return a list of all subclassed objects fix_name
()Set the objects name to be immutable. from_dict
(dct)from_new_options
([integrator, options])Create a new engine with the same system, but different options and/or integrator generate
(snapshot[, running, direction])Generate a trajectory consisting of ntau segments of tau_steps in between storage of Snapshots. generate_backward
(snapshot, ensemble)Generate a potential trajectory in ensemble simulating forward in time generate_forward
(snapshot, ensemble)Generate a potential trajectory in ensemble simulating forward in time generate_n_frames
([n_frames])Generates n_frames, from but not including the current snapshot. generate_next_frame
()idx
(store)Return the index which is used for the object in the given store. initialize
()Create the final OpenMMEngine named
(name)Name an unnamed object. objects
()Returns a dictionary of all storable objects save
(store)Save the object in the given store (or storage) set_as_default
()set_observer
(active)(De-)Activate observing creation of storable objects start
([snapshot])stop
(trajectory)Nothing special needs to be done for direct-control simulations when you hit a stop condition. stop_conditions
(trajectory[, ...])Test whether we can continue; called by generate a couple of times, so the logic is separated here. to_dict
()Attributes
BACKWARD
FORWARD
base_cls
Return the base class base_cls_name
Return the name of the base class cls
Return the class name as a string current_snapshot
default_name
Return the default name. default_options
is_named
True if this object has a custom name. n_atoms
n_spatial
name
Return the current name of the object. observe_objects
platform
simulation
snapshot_timestep
topology
units
-
__delattr__
¶ x.__delattr__(‘name’) <==> del x.name
-
__format__
()¶ default object formatter
-
__getattribute__
¶ x.__getattribute__(‘name’) <==> x.name
-
__hash__
¶
-
__reduce__
()¶ helper for pickle
-
__reduce_ex__
()¶ helper for pickle
-
__repr__
¶
-
__setattr__
¶ x.__setattr__(‘name’, value) <==> x.name = value
-
__sizeof__
() → int¶ size of object in memory, in bytes
-
__str__
¶
-
args
()¶ Return a list of args of the __init__ function of a class
Returns: the list of argument names. No information about defaults is included. Return type: list of str
-
base
()¶ Return the most parent class that is actually derived from Storable(Named)Object
Important to determine which store should be used for storage
Returns: the base class Return type: type
-
base_cls_name
¶ Return the name of the base class
Returns: the string representation of the base class Return type: str
-
base_snapshot_type
¶ alias of
Snapshot
-
cls
¶ Return the class name as a string
Returns: the class name Return type: str
-
count_weaks
()¶ Return the counts of how many objects of storable type are still in memory
This includes objects not yet recycled by the garbage collector.
Returns: dict of str – the dictionary which assigns the base class name of each references objects the integer number of objects still present Return type: int
-
default_name
¶ Return the default name.
Usually derived from the objects class
Returns: the default name Return type: str
-
descendants
()¶ Return a list of all subclassed objects
Returns: list of subclasses of a storable object Return type: list of type
-
fix_name
()¶ Set the objects name to be immutable.
Usually called after load and save to fix the stored state.
-
from_new_options
(integrator=None, options=None)[source]¶ Create a new engine with the same system, but different options and/or integrator
Notes
This can be used to quickly set up simulations at various temperatures or change the step sizes, etc...
-
generate
(snapshot, running=None, direction=1)¶ Generate a trajectory consisting of ntau segments of tau_steps in between storage of Snapshots.
Parameters: - snapshot (
openpathsampling.snapshot.Snapshot
) – initial coordinates and velocities in form of a Snapshot object - running ((list of) function(
openpathsampling.trajectory.Trajectory
)) – callable function of a ‘Trajectory’ that returns True or False. If one of these returns False the simulation is stopped. - direction (-1 or +1 (DynamicsEngine.FORWARD or DynamicsEngine.BACKWARD)) – If +1 then this will integrate forward, if -1 it will reversed the momenta of the given snapshot and then prepending generated snapshots with reversed momenta. This will generate a _reversed_ trajectory that effectively ends in the initial snapshot
Returns: trajectory – generated trajectory of initial conditions, including initial coordinate set
Return type: Notes
If the returned trajectory has length n_frames_max it can still happen that it stopped because of the stopping criterion. You need to check in that case.
- snapshot (
-
generate_backward
(snapshot, ensemble)¶ Generate a potential trajectory in ensemble simulating forward in time
-
generate_forward
(snapshot, ensemble)¶ Generate a potential trajectory in ensemble simulating forward in time
-
generate_n_frames
(n_frames=1)¶ Generates n_frames, from but not including the current snapshot.
This generates a fixed number of frames at once. If you desire the reversed trajectory, you can reverse the returned trajectory.
Parameters: n_frames (integer) – number of frames to generate Returns: the n_frames of the trajectory following (and not including) the initial current_snapshot Return type: paths.Trajectory()
-
idx
(store)¶ Return the index which is used for the object in the given store.
Once you store a storable object in a store it gets assigned a unique number that can be used to retrieve the object back from the store. This function will ask the given store if the object is stored if so what the used index is.
Parameters: store ( openpathsampling.netcdfplus.objects.ObjectStore
) – the store in which to ask for the indexReturns: the integer index for the object of it exists or None else Return type: int or None
-
initialize
()[source]¶ Create the final OpenMMEngine
Notes
This step is OpenMM specific and will actually create the openmm.Simulation object used to run the simulations. The object will be created automatically the first time the engine is used. This way we will not create unnecessay Engines in memory during analysis.
-
is_named
¶ True if this object has a custom name.
This distinguishes default algorithmic names from assigned names.
-
name
¶ Return the current name of the object.
If no name has been set a default generated name is returned.
Returns: the name of the object Return type: str
-
named
(name)¶ Name an unnamed object.
This only renames the object if it does not yet have a name. It can be used to chain the naming onto the object creation. It should also be used when naming things algorithmically: directly setting the .name attribute could override a user-defined name.
Examples
>>> import openpathsampling as p >>> full = p.FullVolume().named('myFullVolume')
-
objects
()¶ Returns a dictionary of all storable objects
Returns: dict of str – a dictionary of all subclassed objects from StorableObject. The name points to the class. Return type: type
-
save
(store)¶ Save the object in the given store (or storage)
Parameters: store ( openpathsampling.netcdfplus.objects.ObjectStore
oropenpathsampling.netcdfplus.netcdfplus.NetCDFStorage
) – the store or storage to be saved in. if a storage is given then the default store for the given object base type is determined and the appropriate store is used.Returns: the integer index used to save the object or None if the object has already been saved. Return type: int or None
-
set_observer
(active)¶ (De-)Activate observing creation of storable objects
This can be used to track which storable objects are still alive and hence look for memory leaks and inspect caching. Use
openpathsampling.netcdfplus.base.StorableObject.count_weaks()
to get the current summary of created objectsParameters: active (bool) – if True then observing is enabled. False disables observing. Per default observing is disabled.
-
stop
(trajectory)¶ Nothing special needs to be done for direct-control simulations when you hit a stop condition.
-
stop_conditions
(trajectory, continue_conditions=None, trusted=True)¶ Test whether we can continue; called by generate a couple of times, so the logic is separated here.
Parameters: - trajectory (
openpathsampling.trajectory.Trajectory
) – the trajectory we’ve generated so far - continue_conditions (list of function(Trajectory)) – callable function of a ‘Trajectory’ that returns True or False. If one of these returns False the simulation is stopped.
Returns: true if the dynamics should be stopped; false otherwise
Return type: boolean
- trajectory (
-