openpathsampling.dynamics_engine.DynamicsEngine¶
-
class
openpathsampling.dynamics_engine.
DynamicsEngine
(options=None, template=None)[source]¶ Wraps simulation tool (parameters, storage, etc.)
Notes
Should be considered an abstract class: only its subclasses can be instantiated.
-
__init__
(options=None, template=None)[source]¶ Create an empty DynamicsEngine object
Notes
The purpose of an engine is to create trajectories and keep track of the results. The main method is ‘generate’ to create a trajectory, which is a list of snapshots and then can store the in the associated storage. In the initialization this storage is created as well as the related Trajectory and Snapshot classes are initialized.
Methods
__init__
([options, template])Create an empty DynamicsEngine object 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)Reconstruct an object from a dictionary representaiton 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. 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 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
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
BaseSnapshot
-
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_dict
(dct)¶ Reconstruct an object from a dictionary representaiton
Parameters: dct (dict) – the dictionary containing a state representaion of the class. Returns: the reconstructed storable object Return type: openpathsampling.netcdfplus.StorableObject
-
generate
(snapshot, running=None, direction=1)[source]¶ 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)[source]¶ Generate a potential trajectory in ensemble simulating forward in time
-
generate_forward
(snapshot, ensemble)[source]¶ Generate a potential trajectory in ensemble simulating forward in time
-
generate_n_frames
(n_frames=1)[source]¶ 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
-
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)[source]¶ Nothing special needs to be done for direct-control simulations when you hit a stop condition.
-
stop_conditions
(trajectory, continue_conditions=None, trusted=True)[source]¶ 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 (
-