openpathsampling.pathsimulator.PathSampling

class openpathsampling.pathsimulator.PathSampling(storage, move_scheme=None, sample_set=None, initialize=True)[source]

General path sampling code.

Takes a single move_scheme and generates samples from that, keeping one per replica after each move.

__init__(storage, move_scheme=None, sample_set=None, initialize=True)[source]
Parameters:
  • storage (openpathsampling.storage.Storage) – the storage where all results should be stored in
  • move_scheme (openpathsampling.MoveScheme) – the move scheme used for the pathsampling cycle
  • sample_set (openpathsampling.SampleSet) – the initial SampleSet for the Simulator
  • initialize (bool) – if False the new PathSimulator will continue at the step and not create a new SampleSet object to cut the connection to previous steps

Methods

__init__(storage[, move_scheme, sample_set, …])
param storage:the storage where all results should be stored in :type storage: openpathsampling.storage.Storage :param move_scheme: the move scheme used for the pathsampling cycle :type move_scheme: openpathsampling.MoveScheme :param sample_set: the initial SampleSet for the Simulator :type sample_set: openpathsampling.SampleSet :param initialize: if False the new PathSimulator will continue at the step and not create a new SampleSet object to cut the connection to previous steps :type initialize: bool
args() Return a list of args of the __init__ function of a class
base() Return the most parent class actually derived from StorableObject
count_weaks() Return number of objects subclassed from StorableObject 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
from_step(storage, step[, initialize])
param storage:the storage to be used to hold the simulation results :type storage: openpathsampling.storage.Storage :param step: the step used to fill the initial parameters :type step: openpathsampling.MCStep :param initialize: if False the new PathSimulator will continue at the given step and not create a new SampleSet object to cut the connection to previous steps.
get_uuid()
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
restart_at_step(step[, storage]) Continue with a loaded pathsampling at a given step
reverse_uuid()
run(n_steps) Run the simulator for a number of steps
run_until(n_steps)
ruuid(uid)
save_current_step() Save the current step to the storage
save_initial_step() Save the initial state as an MCStep to the storage
set_observer(active) (De-)Activate observing creation of storable objects
sync_storage() Will sync all collective variables and the storage to disk
to_dict() Convert object into a dictionary representation

Attributes

ACTIVE_LONG
CREATION_COUNT
INSTANCE_UUID
base_cls Return the base class
base_cls_name Return the name of the base class
calc_name
cls Return the class name as a string
current_step
default_name Return the default name.
is_named True if this object has a custom name.
name Return the current name of the object.
observe_objects
__delattr__

x.__delattr__(‘name’) <==> del x.name

__format__()

default object formatter

__getattribute__

x.__getattribute__(‘name’) <==> x.name

__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__
classmethod 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
classmethod base()

Return the most parent class actually derived from StorableObject

Important to determine which store should be used for storage

Returns:the base class
Return type:type
base_cls

Return the base class

Returns:the base class
Return type:type

See also

base()

base_cls_name

Return the name of the base class

Returns:the string representation of the base class
Return type:str
cls

Return the class name as a string

Returns:the class name
Return type:str
static count_weaks()

Return number of objects subclassed from StorableObject 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
classmethod 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.

classmethod from_dict(dct)[source]

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
classmethod from_step(storage, step, initialize=True)[source]
Parameters:
  • storage (openpathsampling.storage.Storage) – the storage to be used to hold the simulation results
  • step (openpathsampling.MCStep) – the step used to fill the initial parameters
  • initialize (bool) – if False the new PathSimulator will continue at the given step and not create a new SampleSet object to cut the connection to previous steps.
Returns:

the new simulator object

Return type:

openpathsampling.PathSampling

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.ObjectStore) – the store in which to ask for the index
Returns: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.

Parameters:name (str) – the name to be used for the object. Can only be set once

Examples

>>> import openpathsampling as p
>>> full = p.FullVolume().named('myFullVolume')
static 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
restart_at_step(step, storage=None)[source]

Continue with a loaded pathsampling at a given step

Notes

You can only continue from a step that is compatible in the sense that it was previously generated from the pathsampling instance.

If you want to switch the move scheme you need to create a new pathsampling instance. You can do so with the constructor or using the classmethod from_step which simplifies the setup process

Parameters:
  • step (MCStep) – the step to be continued from. You are always free to chose any step which can be used to fork a simulation but for analysis you may only use one path of steps.
  • storage (Storage) – If given this will change the storage used to store the generated steps
run(n_steps)[source]

Run the simulator for a number of steps

Parameters:n_steps (int) – number of step to be run
save_current_step()[source]

Save the current step to the storage

save_initial_step()

Save the initial state as an MCStep to the storage

static 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 objects

Parameters:active (bool) – if True then observing is enabled. False disables observing. Per default observing is disabled.
sync_storage()

Will sync all collective variables and the storage to disk

to_dict()[source]

Convert object into a dictionary representation

Used to convert the dictionary into JSON string for serialization

Returns:the dictionary representing the (immutable) state of the object
Return type:dict