Two Way Shooting Pathmovers#

class aimmd.distributed.pathmovers.TwoWayShootingPathMover#

Produce new trials by propagating two trajectories from the selected shooting point, one forward and one backward in time, until the given states have been reached. To modify the shooting point selection you can pass different SPSelector classes as sp_selector (see module aimmd.distributed.spselectors).

Initialize a TwoWayShootingPathMover.

Parameters:
  • states (list[asyncmd.trajectory.functionwrapper.TrajectoryFunctionWrapper]) – State functions (stopping conditions) to use, passed to Propagator.

  • md_engine_spec (MDEngineSpec) – Description/Specification of the MD engine (including parameters) used in the trial propagation. See MDEngineSpec for what is included.

  • temperature (float) – Temperature in degree K (used for velocity randomization).

  • sp_selector_cls (type[SPSelector]) – The class of the shooting point selector to use for providing the (forward) SPs. Note that an uninitialized class is required.

  • sp_selector_kwargs (dict | None) – Dictionary with keyword arguments used to initialize the shooting point selector. Can be None, in which case no arguments will be used when initializing the SP selector.

  • path_weight_func (asyncmd.trajectory.functionwrapper.TrajectoryFunctionWrapper) – Weight function for paths. Can be used to enhance the sampling of low probability transition mechanisms. Only makes sense when the shooting points are chosen from the last accepted path (as opposed to shooting from points with known equilibrium weight).

build_frame_extractors() tuple[FrameExtractor, FrameExtractor]#

Initialize and return the forward and backward frame extractors.

Returns:

RandomVelocitiesFrameExtractor and InvertedVelocitiesFrameExtractor

Return type:

tuple[FrameExtractor, FrameExtractor]

build_propagators() list[ConditionalTrajectoryPropagator]#

Initialize and return the trajectory propagators for this PathMover.

Returns:

List of forward and (optionally) backward propagators. In this order.

Return type:

list[_TrajectoryPropagator]

delete_model(step_num: int) None#

Delete the stored model for a given step_num.

Parameters:

step_num (int) – The step number in the MC chain to delete the model for.

Raises:

RuntimeError – If modelstore is None.

async generate_move(instep: MCstep, simstate_info: PathSamplingSimStateInfo, *, model: RCModelAsyncMixin) MCstep#

Perform flexible length two way shooting trial move.

Parameters:
  • instep (MCstep) – The input MC step.

  • simstate_info (PathSamplingSimStateInfo) – Dataclass carrying the current state of the pathsampling simulation and information about the current step, e.g. the step_num, workdir.

  • model (RCModelAsyncMixin) – The reaction coordinate model to use during this MC step.

Returns:

The newly generated MC step.

Return type:

MCstep

get_model(step_num: int) RCModelAsyncMixin#

Load the stored model for given step_num.

Parameters:

step_num (int) – The step number in the MC chain.

Returns:

The loaded model used for the given step_num.

Return type:

RCModelAsyncMixin

Raises:

RuntimeError – If modelstore is None.

async get_or_generate_sp_bw(workdir: str, fw_sp: Trajectory) tuple[Trajectory, bool]#

Generate or retrieve existing backward shooting point.

Parameters:
  • workdir (str) – The working directory to which the shooting point will be written or from which it will be retrieved.

  • fw_sp (Trajectory) – The forward shooting point from which the backward shooting point will be generated.

Returns:

bw_sp, file_exists: The shooting point and whether it existed.

Return type:

tuple[Trajectory, bool]

Raises:

RuntimeError – If no backward frame extractor is defined, i.e., if self._frame_extractor_bw is None.

async get_or_generate_sp_fw(*, instep: MCstep, simstate_info: PathSamplingSimStateInfo, model: RCModelAsyncMixin) tuple[Trajectory, bool]#

Generate or retrieve existing forward shooting point.

Parameters:
  • instep (MCstep) – The input MC step.

  • simstate_info (PathSamplingSimStateInfo) – Dataclass carrying the current state of the pathsampling simulation and information about the current step, e.g. the step_num, workdir.

  • model (RCModelAsyncMixin) – The reaction coordinate model to use to select the shooting point.

Returns:

fw_sp, file_exists: The shooting point and whether it existed.

Return type:

tuple[Trajectory, bool]

async get_or_generate_sps(*, instep: MCstep, simstate_info: PathSamplingSimStateInfo, model: RCModelAsyncMixin) tuple[Trajectory, Trajectory] | Trajectory#

Generate or retrieve shooting points for both directions.

Returns a tuple (fw_sp, bw_sp) if both forward and backward frame extractor are defined, otherwise, if only the forward frame extractor is defined only the forward shooting point is returned.

Warn if continuation is True but the shooting point(s) do not exist.

Parameters:
  • instep (MCstep) – The input MC step.

  • simstate_info (PathSamplingSimStateInfo) – Dataclass carrying the current state of the pathsampling simulation and information about the current step, e.g. the step_num, workdir.

  • model (RCModelAsyncMixin) – The reaction coordinate model to use to select the shooting point.

Returns:

Either a tuple of (forward shooting point, backward shooting point) or the forward shooting point, depending on if frame extractors for both directions are defined or not.

Return type:

tuple[Trajectory, Trajectory] | Trajectory

async move(instep: MCstep, simstate_info: PathSamplingSimStateInfo, *, model: RCModelAsyncMixin) MCstep#

Perform a move in the MC chain, i.e. generate a new MCstep.

Note: Subclasses should overwrite the generate_move() method, to enable reuse of the same save/delete logic for every (model-dependant) pathmover.

Parameters:
  • instep (MCstep) – The input MCstep, i.e. the previous step in the MC chain.

  • simstate_info (PathSamplingSimStateInfo) – Dataclass carrying the current state of the pathsampling simulation and information about the current step, e.g. the step_num, workdir.

  • model (RCModelAsyncMixin) – The reaction coordinate model to use during the step.

Returns:

The newly generated MCstep.

Return type:

MCstep

store_model(model: RCModelAsyncMixin, step_num: int) None#

Store the given model for step_num.

Parameters:
  • model (RCModelAsyncMixin) – The model to store.

  • step_num (int) – The step number in the MC chain, i.e. the number of steps performed in the sampler performing this step.

Raises:

RuntimeError – If modelstore is None.

class aimmd.distributed.pathmovers.FixedLengthTwoWayShootingPathMover#

Produce new trials by propagating two trajectories from the selected shooting point, one forward and one backward in time, for a fixed number of frames in total. We draw the number of frames for forward and backward at random, essentially making this move is a combination of a shooting and a shifting move at the same time. To modify the shooting point selection you can pass different SPSelector classes as sp_selector (see module aimmd.distributed.spselectors).

Initialize a FixedLengthTwoWayShootingPathMover.

Parameters:
  • n_steps (int) – Number of integration steps to perform in total (over both forward and backward combined).

  • states (list[asyncmd.trajectory.functionwrapper.TrajectoryFunctionWrapper]) – State functions to use to decide if a trial is valid.

  • md_engine_spec (MDEngineSpec) – Description/Specification of the MD engine (including parameters) used in the trial propagation. See MDEngineSpec for what is included.

  • temperature (float) – Temperature in degree K (used for velocity randomization).

  • sp_selector_cls (type[SPSelector]) – The class of the shooting point selector to use for providing the (forward) SPs. Note that an uninitialized class is required.

  • sp_selector_kwargs (dict | None) – Dictionary with keyword arguments used to initialize the shooting point selector. Can be None, in which case no arguments will be used when initializing the SP selector.

  • path_weight_func (asyncmd.trajectory.functionwrapper.TrajectoryFunctionWrapper) – Weight function for paths. Can be used to enhance the sampling of low probability transition mechanisms. Only makes sense when the shooting points are choosen from the last accepted path (as opposed to shooting from points with known equilibrium weight).

build_frame_extractors() tuple[FrameExtractor, FrameExtractor]#

Initialize and return the forward and backward frame extractors.

Returns:

RandomVelocitiesFrameExtractor and InvertedVelocitiesFrameExtractor

Return type:

tuple[FrameExtractor, FrameExtractor]

build_propagators() list[InPartsTrajectoryPropagator]#

Initialize and return the trajectory propagators for this PathMover.

Returns:

List of forward and (optionally) backward propagators. In this order.

Return type:

list[_TrajectoryPropagator]

delete_model(step_num: int) None#

Delete the stored model for a given step_num.

Parameters:

step_num (int) – The step number in the MC chain to delete the model for.

Raises:

RuntimeError – If modelstore is None.

async generate_move(instep: MCstep, simstate_info: PathSamplingSimStateInfo, *, model: RCModelAsyncMixin) MCstep#

Perform fixed length two way shooting trial move.

Parameters:
  • instep (MCstep) – The input MC step.

  • simstate_info (PathSamplingSimStateInfo) – Dataclass carrying the current state of the pathsampling simulation and information about the current step, e.g. the step_num, workdir.

  • model (RCModelAsyncMixin) – The reaction coordinate model to use during this MC step.

Returns:

The newly generated MC step.

Return type:

MCstep

get_model(step_num: int) RCModelAsyncMixin#

Load the stored model for given step_num.

Parameters:

step_num (int) – The step number in the MC chain.

Returns:

The loaded model used for the given step_num.

Return type:

RCModelAsyncMixin

Raises:

RuntimeError – If modelstore is None.

async get_or_generate_sp_bw(workdir: str, fw_sp: Trajectory) tuple[Trajectory, bool]#

Generate or retrieve existing backward shooting point.

Parameters:
  • workdir (str) – The working directory to which the shooting point will be written or from which it will be retrieved.

  • fw_sp (Trajectory) – The forward shooting point from which the backward shooting point will be generated.

Returns:

bw_sp, file_exists: The shooting point and whether it existed.

Return type:

tuple[Trajectory, bool]

Raises:

RuntimeError – If no backward frame extractor is defined, i.e., if self._frame_extractor_bw is None.

async get_or_generate_sp_fw(*, instep: MCstep, simstate_info: PathSamplingSimStateInfo, model: RCModelAsyncMixin) tuple[Trajectory, bool]#

Generate or retrieve existing forward shooting point.

Parameters:
  • instep (MCstep) – The input MC step.

  • simstate_info (PathSamplingSimStateInfo) – Dataclass carrying the current state of the pathsampling simulation and information about the current step, e.g. the step_num, workdir.

  • model (RCModelAsyncMixin) – The reaction coordinate model to use to select the shooting point.

Returns:

fw_sp, file_exists: The shooting point and whether it existed.

Return type:

tuple[Trajectory, bool]

async get_or_generate_sps(*, instep: MCstep, simstate_info: PathSamplingSimStateInfo, model: RCModelAsyncMixin) tuple[Trajectory, Trajectory] | Trajectory#

Generate or retrieve shooting points for both directions.

Returns a tuple (fw_sp, bw_sp) if both forward and backward frame extractor are defined, otherwise, if only the forward frame extractor is defined only the forward shooting point is returned.

Warn if continuation is True but the shooting point(s) do not exist.

Parameters:
  • instep (MCstep) – The input MC step.

  • simstate_info (PathSamplingSimStateInfo) – Dataclass carrying the current state of the pathsampling simulation and information about the current step, e.g. the step_num, workdir.

  • model (RCModelAsyncMixin) – The reaction coordinate model to use to select the shooting point.

Returns:

Either a tuple of (forward shooting point, backward shooting point) or the forward shooting point, depending on if frame extractors for both directions are defined or not.

Return type:

tuple[Trajectory, Trajectory] | Trajectory

async move(instep: MCstep, simstate_info: PathSamplingSimStateInfo, *, model: RCModelAsyncMixin) MCstep#

Perform a move in the MC chain, i.e. generate a new MCstep.

Note: Subclasses should overwrite the generate_move() method, to enable reuse of the same save/delete logic for every (model-dependant) pathmover.

Parameters:
  • instep (MCstep) – The input MCstep, i.e. the previous step in the MC chain.

  • simstate_info (PathSamplingSimStateInfo) – Dataclass carrying the current state of the pathsampling simulation and information about the current step, e.g. the step_num, workdir.

  • model (RCModelAsyncMixin) – The reaction coordinate model to use during the step.

Returns:

The newly generated MCstep.

Return type:

MCstep

store_model(model: RCModelAsyncMixin, step_num: int) None#

Store the given model for step_num.

Parameters:
  • model (RCModelAsyncMixin) – The model to store.

  • step_num (int) – The step number in the MC chain, i.e. the number of steps performed in the sampler performing this step.

Raises:

RuntimeError – If modelstore is None.