# Path: openpathsampling/pathsimulators/sshooting_simulator.py
# class SShootingSimulation(ShootFromSnapshotsSimulation):
#     """ S-Shooting simulations.
# 
#     Parameters
#     ----------
#     storage : :class:`.Storage`
#         the file to store simulations in
#     engine : :class:`.DynamicsEngine`
#         the dynamics engine to use to run the simulation
#     state_S : :class:`.Volume`
#         the volume representing saddle region S.
#     randomizer : :class:`.SnapshotModifier`
#         the method used to modify the input snapshot before each shot
#     initial_snapshots : list of :class:`.Snapshot`
#         initial snapshots to use.
#     trajectory_length : int
#         Trajectory length l of backward/forward shot, total length of generated
#         trajectories is 2*l+1. The harvested subtrajectories have length l+1.
#     """
#     def __init__(self, storage, engine=None, state_S=None, randomizer=None,
#                  initial_snapshots=None, trajectory_length=None):
# 
#         # Defintion of state S (A and B are only required for analysis).
#         self.state_S = state_S
# 
#         # Set forward/backward shot length.
#         self.trajectory_length = trajectory_length
#         l = self.trajectory_length
# 
#         # Define backward ensemble:
#         # trajectory starts in S and has fixed length l.
#         backward_ensemble = paths.SequentialEnsemble([
#             paths.LengthEnsemble(l),
#             paths.AllInXEnsemble(state_S) & paths.LengthEnsemble(1)
#         ])
# 
#         # Define forward ensemble:
#         # CAUTION: first trajectory is in backward ensemble,
#         # then continues with fixed length l.
#         forward_ensemble = paths.SequentialEnsemble([
#             paths.LengthEnsemble(l),
#             paths.AllInXEnsemble(state_S) & paths.LengthEnsemble(1),
#             paths.LengthEnsemble(l)
#         ])
# 
#         super(SShootingSimulation, self).__init__(
#             storage=storage,
#             engine=engine,
#             starting_volume=state_S,
#             forward_ensemble=forward_ensemble,
#             backward_ensemble=backward_ensemble,
#             randomizer=randomizer,
#             initial_snapshots=initial_snapshots
#         )
# 
#         # Create backward mover (starting from single point).
#         self.backward_mover = paths.BackwardExtendMover(
#             ensemble=self.starting_ensemble,
#             target_ensemble=self.backward_ensemble
#         )
# 
#         # Create forward mover (starting from the backward ensemble).
#         self.forward_mover = paths.ForwardExtendMover(
#             ensemble=self.backward_ensemble,
#             target_ensemble=self.forward_ensemble
#         )
# 
#         # Create mover combining forward and backward shooting. No condition
#         # here, shots in both directions are executed in any case.
#         self.mover = paths.NonCanonicalConditionalSequentialMover([
#             self.backward_mover,
#             self.forward_mover
#         ])
# 
#     def to_dict(self):
#         ret_dict = {
#             'state_S' : self.state_S,
#             'trajectory_length' : self.trajectory_length
#         }
#         return ret_dict
# 
#     @classmethod
#     def from_dict(cls, dct):
#         sshooting = cls.__new__(cls)
# 
#         # replace automatically created attributes with stored ones
#         sshooting.state_S = dct['state_S']
#         sshooting.trajectory_length = dct['trajectory_length']
#         return sshooting


from openpathsampling.tests.test_helpers import (data_filename)
from openpathsampling.pathsimulators.sshooting_simulator import SShootingSimulation
import openpathsampling as paths
import openpathsampling.engines.toy as toys
import numpy as np
import os
                                  toys.Snapshot(
                                      coordinates=np.array([[0.1]]),
                                      velocities=np.array([[-1.0]]),
                                      engine=self.engine),
                                  toys.Snapshot(
                                      coordinates=np.array([[-0.2]]),
                                      velocities=np.array([[2.0]]),
                                      engine=self.engine)]
        # trajectory length is set to 100 steps
        self.l = 100
        # reaction coordinate is just x coordinate
        rc = paths.FunctionCV("Id", lambda snap : snap.coordinates[0][0])
        # state S: [-0.5, 0.5]
        self.state_S = paths.CVDefinedVolume(rc, -0.5, 0.5)
        # define state labels
        self.state_labels = {
            "S" : self.state_S,
            "NotS" :~self.state_S}
        # velocities are not randomized
        randomizer = paths.NoModification()

        self.filename = data_filename("sshooting_test.nc")
        self.storage = paths.Storage(self.filename, mode="w")
        self.storage.save(self.initial_snapshots)

        self.simulation = SShootingSimulation(
            storage=self.storage,
            engine=self.engine,
            state_S=self.state_S,
            randomizer=randomizer,

# Path: openpathsampling/pathsimulators/sshooting_simulator.py
# class SShootingSimulation(ShootFromSnapshotsSimulation):
#     """ S-Shooting simulations.
# 
#     Parameters
#     ----------
#     storage : :class:`.Storage`
#         the file to store simulations in
#     engine : :class:`.DynamicsEngine`
#         the dynamics engine to use to run the simulation
#     state_S : :class:`.Volume`
#         the volume representing saddle region S.
#     randomizer : :class:`.SnapshotModifier`
#         the method used to modify the input snapshot before each shot
#     initial_snapshots : list of :class:`.Snapshot`
#         initial snapshots to use.
#     trajectory_length : int
#         Trajectory length l of backward/forward shot, total length of generated
#         trajectories is 2*l+1. The harvested subtrajectories have length l+1.
#     """
#     def __init__(self, storage, engine=None, state_S=None, randomizer=None,
#                  initial_snapshots=None, trajectory_length=None):
# 
#         # Defintion of state S (A and B are only required for analysis).
#         self.state_S = state_S
# 
#         # Set forward/backward shot length.
#         self.trajectory_length = trajectory_length
#         l = self.trajectory_length
# 
#         # Define backward ensemble:
#         # trajectory starts in S and has fixed length l.
#         backward_ensemble = paths.SequentialEnsemble([
#             paths.LengthEnsemble(l),
#             paths.AllInXEnsemble(state_S) & paths.LengthEnsemble(1)
#         ])
# 
#         # Define forward ensemble:
#         # CAUTION: first trajectory is in backward ensemble,
#         # then continues with fixed length l.
#         forward_ensemble = paths.SequentialEnsemble([
#             paths.LengthEnsemble(l),
#             paths.AllInXEnsemble(state_S) & paths.LengthEnsemble(1),
#             paths.LengthEnsemble(l)
#         ])
# 
#         super(SShootingSimulation, self).__init__(
#             storage=storage,
#             engine=engine,
#             starting_volume=state_S,
#             forward_ensemble=forward_ensemble,
#             backward_ensemble=backward_ensemble,
#             randomizer=randomizer,
#             initial_snapshots=initial_snapshots
#         )
# 
#         # Create backward mover (starting from single point).
#         self.backward_mover = paths.BackwardExtendMover(
#             ensemble=self.starting_ensemble,
#             target_ensemble=self.backward_ensemble
#         )
# 
#         # Create forward mover (starting from the backward ensemble).
#         self.forward_mover = paths.ForwardExtendMover(
#             ensemble=self.backward_ensemble,
#             target_ensemble=self.forward_ensemble
#         )
# 
#         # Create mover combining forward and backward shooting. No condition
#         # here, shots in both directions are executed in any case.
#         self.mover = paths.NonCanonicalConditionalSequentialMover([
#             self.backward_mover,
#             self.forward_mover
#         ])
# 
#     def to_dict(self):
#         ret_dict = {
#             'state_S' : self.state_S,
#             'trajectory_length' : self.trajectory_length
#         }
#         return ret_dict
# 
#     @classmethod
#     def from_dict(cls, dct):
#         sshooting = cls.__new__(cls)
# 
#         # replace automatically created attributes with stored ones
#         sshooting.state_S = dct['state_S']
#         sshooting.trajectory_length = dct['trajectory_length']
#         return sshooting


# Path: openpathsampling/tests/test_sshooting_simulator.py
from openpathsampling.tests.test_helpers import (data_filename)
from openpathsampling.pathsimulators.sshooting_simulator import SShootingSimulation
import openpathsampling as paths
import openpathsampling.engines.toy as toys
import numpy as np
import os

                                  toys.Snapshot(
                                      coordinates=np.array([[0.1]]),
                                      velocities=np.array([[-1.0]]),
                                      engine=self.engine),
                                  toys.Snapshot(
                                      coordinates=np.array([[-0.2]]),
                                      velocities=np.array([[2.0]]),
                                      engine=self.engine)]
        # trajectory length is set to 100 steps
        self.l = 100
        # reaction coordinate is just x coordinate
        rc = paths.FunctionCV("Id", lambda snap : snap.coordinates[0][0])
        # state S: [-0.5, 0.5]
        self.state_S = paths.CVDefinedVolume(rc, -0.5, 0.5)
        # define state labels
        self.state_labels = {
            "S" : self.state_S,
            "NotS" :~self.state_S}
        # velocities are not randomized
        randomizer = paths.NoModification()

        self.filename = data_filename("sshooting_test.nc")
        self.storage = paths.Storage(self.filename, mode="w")
        self.storage.save(self.initial_snapshots)

        self.simulation = SShootingSimulation(
            storage=self.storage,
            engine=self.engine,
            state_S=self.state_S,
            randomizer=randomizer,

            initial_snapshots=self.initial_snapshots,