def setup(self):
        # As a test system, let's use 1D motion on a flat potential. If the
        # velocity is positive, you right the state on the right. If it is
        # negative, you hit the state on the left.
        pes = toys.LinearSlope(m=[0.0], c=[0.0]) # flat line
        topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
        integrator = toys.LeapfrogVerletIntegrator(0.1)
        options = {
            'integ': integrator,
            'n_frames_max': 100000,
            'n_steps_per_frame': 5
        }
        self.engine = toys.Engine(options=options, topology=topology)
        self.snap0 = toys.Snapshot(coordinates=np.array([[0.0]]),
                                   velocities=np.array([[1.0]]),
                                   engine=self.engine)
        cv = paths.FunctionCV("Id", lambda snap : snap.coordinates[0][0])
        self.left = paths.CVDefinedVolume(cv, float("-inf"), -1.0)
        self.right = paths.CVDefinedVolume(cv, 1.0, float("inf"))
        self.state_labels = {"Left" : self.left,
                             "Right" : self.right,
                             "None" : ~(self.left | self.right)}

        randomizer = paths.NoModification()

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

        self.simulation = CommittorSimulation(storage=self.storage,
                                              engine=self.engine,
                                              states=[self.left, self.right],
                                              randomizer=randomizer,
                                              initial_snapshots=self.snap0)
        self.simulation.output_stream = open(os.devnull, 'w')
    def setup(self):
        pes = linear
        integ = toy.LeapfrogVerletIntegrator(dt=0.002)
        topology = toy.Topology(
            n_spatial=2,
            masses=sys_mass,
            pes=pes
        )
        options = {
            'integ': integ,
            'n_frames_max': 5
        }
        sim = toy.Engine(options=options,
                         topology=topology)

        template = toy.Snapshot(
            coordinates=init_pos.copy(),
            velocities=init_pos.copy(),
            engine=sim
        )

        sim.positions = init_pos.copy()
        sim.velocities = init_vel.copy()

        sim.n_steps_per_frame = 10
        self.sim = sim
Esempio n. 3
0
def make_1d_traj(coordinates, velocities=None, engine=None):
    if velocities is None:
        velocities = [1.0]*len(coordinates)
    try:
        _ = len(velocities)
    except TypeError:
        velocities = [velocities] * len(coordinates)

    if engine is None:
        engine = toys.Engine(
            {},
            toys.Topology(
                n_spatial=3,
                masses=[1.0, 1.0, 1.0], pes=None
            )
        )
    traj = []
    for (pos, vel) in zip(coordinates, velocities):
        snap = toys.Snapshot(
            coordinates=np.array([[pos, 0, 0]]),
            velocities=np.array([[vel, 0, 0]]),
            engine=engine
        )
        traj.append(snap)
    return paths.Trajectory(traj)
Esempio n. 4
0
    def setUp(self):
        pes = linear
        integ = toy.LangevinBAOABIntegrator(dt=0.002, temperature=0.5,
                                        gamma=1.0)
        topology=toy.Topology(
            n_spatial = 2,
            masses = sys_mass,
            pes = pes
        )
        options={
            'integ' : integ,
            'n_frames_max' : 5}
        sim = toy.Engine(options=options,
                        topology=topology
                       )

        template = toy.Snapshot(
            coordinates=init_pos.copy(),
            velocities=init_pos.copy(),
            engine=sim
        )

        sim.positions = init_pos.copy()
        sim.velocities = init_vel.copy()

        sim.n_steps_per_frame = 10
        self.sim = sim
Esempio n. 5
0
    def setup(self):
        import openpathsampling.engines.toy as toys
        self.toy_modifier = SingleAtomVelocityDirectionModifier(
            delta_v=[1.0, 2.0],
            subset_mask=[1, 2],
            remove_linear_momentum=False)
        self.toy_engine = toys.Engine(
            topology=toys.Topology(n_spatial=2,
                                   n_atoms=3,
                                   pes=None,
                                   masses=np.array([1.0, 1.5, 4.0])),
            options={})
        self.toy_snapshot = toys.Snapshot(coordinates=np.array([[0.0, 0.0],
                                                                [0.0, 0.0],
                                                                [0.0, 0.0]]),
                                          velocities=np.array([[1.0, 1.0],
                                                               [2.0, 2.0],
                                                               [3.0, 3.0]]),
                                          engine=self.toy_engine)

        u_vel = old_div(u.nanometer, u.picosecond)
        self.openmm_modifier = SingleAtomVelocityDirectionModifier(
            delta_v=1.2 * u_vel, remove_linear_momentum=False)
        ad_vacuum = omt.testsystems.AlanineDipeptideVacuum(constraints=None)
        self.test_snap = omm_engine.snapshot_from_testsystem(ad_vacuum)
        self.openmm_engine = omm_engine.Engine(
            topology=self.test_snap.topology,
            system=ad_vacuum.system,
            integrator=omt.integrators.VVVRIntegrator())

        self.openmm_snap = self.test_snap.copy_with_replacement(
            engine=self.openmm_engine,
            velocities=np.ones(shape=self.test_snap.velocities.shape) * u_vel)
    def test_storage(self):
        import os
        fname = data_filename("tps_network_storage_test.nc")
        if os.path.isfile(fname):
            os.remove(fname)

        topol = peng.Topology(n_spatial=1, masses=[1.0], pes=None)
        engine = peng.Engine({}, topol)
        self.template = peng.Snapshot(coordinates=np.array([[0.0]]),
                                      velocities=np.array([[0.0]]),
                                      engine=engine)

        states = [self.stateA, self.stateB, self.stateC]
        network_a = self.NetworkType(initial_states=states,
                                     final_states=states,
                                     **self.std_kwargs)
        assert_equal(len(network_a.sampling_transitions), 1)
        assert_equal(len(network_a.transitions), 6)
        storage_w = paths.storage.Storage(fname, "w")
        storage_w.snapshots.save(self.template)
        storage_w.save(network_a)
        storage_w.sync_all()

        storage_r = paths.storage.AnalysisStorage(fname)
        network_b = storage_r.networks[0]
        assert_equal(len(network_b.sampling_transitions), 1)
        assert_equal(len(network_b.transitions), 6)

        if os.path.isfile(fname):
            os.remove(fname)
Esempio n. 7
0
    def setup(self):
        import openpathsampling.engines.toy as toys
        # applies one delta_v to all atoms
        self.toy_modifier_all = GeneralizedDirectionModifier(1.5)
        # defines delta_v per atom, including those not in the mask
        self.toy_modifier_long_dv = GeneralizedDirectionModifier(
            delta_v=[0.5, 1.0, 2.0], subset_mask=[1, 2])
        # defines delta_v per atom in the subset mask
        self.toy_modifier = GeneralizedDirectionModifier(delta_v=[1.0, 2.0],
                                                         subset_mask=[1, 2])
        self.toy_engine = toys.Engine(topology=toys.Topology(
            n_spatial=2, n_atoms=3, pes=None, masses=[1.0, 1.5, 4.0]),
                                      options={})
        self.toy_snapshot = toys.Snapshot(coordinates=np.array([[0.0, 0.0],
                                                                [0.0, 0.0],
                                                                [0.0, 0.0]]),
                                          velocities=np.array([[1.0, 1.0],
                                                               [2.0, 2.0],
                                                               [3.0, 3.0]]),
                                          engine=self.toy_engine)

        # create the OpenMM versions
        u_vel = old_div(u.nanometer, u.picosecond)
        self.openmm_modifier = GeneralizedDirectionModifier(1.2 * u_vel)
        ad_vacuum = omt.testsystems.AlanineDipeptideVacuum(constraints=None)
        self.test_snap = omm_engine.snapshot_from_testsystem(ad_vacuum)
        self.openmm_engine = omm_engine.Engine(
            topology=self.test_snap.topology,
            system=ad_vacuum.system,
            integrator=omt.integrators.VVVRIntegrator())
        self.openmm_snap = self.test_snap.copy_with_replacement(
            engine=self.openmm_engine)
def make_mstis_engine():
    pes = (
        toys.OuterWalls([1.0, 1.0], [0.0, 0.0])
        + toys.Gaussian(-0.7, [12.0, 12.0], [0.0, 0.4])
        + toys.Gaussian(-0.7, [12.0, 12.0], [-0.5, -0.5])
        + toys.Gaussian(-0.7, [12.0, 12.0], [0.5, -0.5])
    )

    topology=toys.Topology(
        n_spatial=2,
        masses=[1.0, 1.0],
        pes=pes
    )

    integ = toys.LangevinBAOABIntegrator(dt=0.02, temperature=0.1, gamma=2.5)

    options={
        'integ': integ,
        'n_frames_max': 5000,
        'n_steps_per_frame': 1
    }

    toy_eng = toys.Engine(
        options=options,
        topology=topology
    ).named('toy_engine')

    template = toys.Snapshot(
        coordinates=np.array([[-0.5, -0.5]]),
        velocities=np.array([[0.0,0.0]]),
        engine=toy_eng
    )

    toy_eng.current_snapshot = template
    return toy_eng
 def setup(self):
     pes = toys.HarmonicOscillator(A=[1.0], omega=[1.0], x0=[0.0])
     topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
     integrator = toys.LeapfrogVerletIntegrator(0.1)
     options = {
         'integ': integrator,
         'n_frames_max': 100000,
         'n_steps_per_frame': 2
     }
     self.engine = toys.Engine(options=options, topology=topology)
     self.snap0 = toys.Snapshot(coordinates=np.array([[0.0]]),
                                velocities=np.array([[1.0]]),
                                engine=self.engine)
     cv = paths.FunctionCV("Id", lambda snap : snap.coordinates[0][0])
     self.cv = cv
     self.center = paths.CVDefinedVolume(cv, -0.2, 0.2)
     self.interface = paths.CVDefinedVolume(cv, -0.3, 0.3)
     self.outside = paths.CVDefinedVolume(cv, 0.6, 0.9)
     self.extra = paths.CVDefinedVolume(cv, -1.5, -0.9)
     self.flux_pairs = [(self.center, self.interface)]
     self.sim = DirectSimulation(storage=None,
                                 engine=self.engine,
                                 states=[self.center, self.outside],
                                 flux_pairs=self.flux_pairs,
                                 initial_snapshot=self.snap0)
Esempio n. 10
0
def make_engine():
    pes = toys.LinearSlope([0, 0], 0)
    topology = toys.Topology(n_spatial=2, masses=[1.0, 1.0], pes=pes)
    integ = toys.LeapfrogVerletIntegrator(dt=0.1)
    options = {'integ': integ, 'n_frames_max': 1000, 'n_steps_per_frame': 1}
    engine = toys.Engine(options=options, topology=topology)
    return engine
def make_mistis_engine():
    pes = (
        toys.OuterWalls([1.0, 1.0], [0.0, 0.0])
        + toys.Gaussian(-1.0, [12.0, 12.0], [-0.5, 0.5])
        + toys.Gaussian(-1.0, [12.0, 12.0], [-0.5, -0.5])
        + toys.Gaussian(-1.0, [12.0, 12.0], [0.5, -0.5])
    )

    topology=toys.Topology(n_spatial=2,
                           masses=[1.0, 1.0],
                           pes=pes)

    integ = toys.LangevinBAOABIntegrator(dt=0.02, temperature=0.1, gamma=2.5)

    options = {
        'integ': integ,
        'n_frames_max': 5000,
        'n_steps_per_frame': 1
    }

    toy_eng = toys.Engine(
        options=options,
        topology=topology
    ).named('engine')
    return toy_eng
    def setup(self):
        # As a test system, let's use 1D motion on a flat potential. If the
        # velocity is positive, you right the state on the right. If it is
        # negative, you hit the state on the left.
        pes = toys.LinearSlope(m=[0.0], c=[0.0])  # flat line
        topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
        integrator = toys.LeapfrogVerletIntegrator(0.1)
        options = {
            'integ': integrator,
            'n_frames_max': 100000,
            'n_steps_per_frame': 5
        }
        self.engine = toys.Engine(options=options, topology=topology)
        self.snap0 = toys.Snapshot(coordinates=np.array([[0.0]]),
                                   velocities=np.array([[1.0]]),
                                   engine=self.engine)
        cv = paths.FunctionCV("Id", lambda snap: snap.coordinates[0][0])
        starting_volume = paths.CVDefinedVolume(cv, -0.01, 0.01)
        forward_ensemble = paths.LengthEnsemble(5)
        backward_ensemble = paths.LengthEnsemble(3)
        randomizer = paths.NoModification()

        self.filename = data_filename("shoot_from_snaps.nc")
        self.storage = paths.Storage(self.filename, 'w')
        self.simulation = ShootFromSnapshotsSimulation(
            storage=self.storage,
            engine=self.engine,
            starting_volume=starting_volume,
            forward_ensemble=forward_ensemble,
            backward_ensemble=backward_ensemble,
            randomizer=randomizer,
            initial_snapshots=self.snap0)
        self.simulation.output_stream = open(os.devnull, "w")
    def setup(self):
        self.mdtraj = md.load(data_filename("ala_small_traj.pdb"))
        self.traj = peng.trajectory_from_mdtraj(
            self.mdtraj, simple_topology=True)

        self.filename = data_filename("storage_test.nc")
        self.filename_clone = data_filename("storage_test_clone.nc")

        self.simplifier = ObjectJSON()
        self.template_snapshot = self.traj[0]
        self.solute_indices = list(range(22))

        self.toy_topology = toys.Topology(
            n_spatial=2,
            masses=[1.0, 1.0],
            pes=None
        )

        self.engine = toys.Engine({}, self.toy_topology)

        self.toy_template = toys.Snapshot(
            coordinates=np.array([[-0.5, -0.5]]),
            velocities=np.array([[0.0,0.0]]),
            engine=self.engine
        )
Esempio n. 14
0
    def setup(self):
        # PES is one-dimensional linear slope (y(x) = x)
        pes = toys.LinearSlope(m=[-1.0], c=[0.0])
        # one particle with mass 1.0
        topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
        integrator = toys.LeapfrogVerletIntegrator(0.02)
        options = {
            'integ': integrator,
            'n_frames_max': 1000,
            'n_steps_per_frame': 5
        }
        self.engine = toys.Engine(options=options, topology=topology)
        # test uses three snapshots with different velocities
        # 0: direction ok, velocity too low => falls back to dividing surface
        # 1: wrong direction => backward shot towards B
        # 2: direction ok, velocity high enough => successfull new trajectory
        self.initial_snapshots = [
            toys.Snapshot(coordinates=np.array([[0.0]]),
                          velocities=np.array([[1.0]]),
                          engine=self.engine),
            toys.Snapshot(coordinates=np.array([[0.0]]),
                          velocities=np.array([[-1.0]]),
                          engine=self.engine),
            toys.Snapshot(coordinates=np.array([[0.0]]),
                          velocities=np.array([[2.0]]),
                          engine=self.engine)
        ]
        # reaction coordinate is just x coordinate
        rc = paths.FunctionCV("Id", lambda snap: snap.coordinates[0][0])
        # state A: [-inf, -1]
        self.state_A = paths.CVDefinedVolume(rc, float("-inf"), -1.0)
        # area between A and dividing surface: [-1, 0]
        self.towards_A = paths.CVDefinedVolume(rc, -1.0, 0.0)
        # state B: [1, inf]
        self.state_B = paths.CVDefinedVolume(rc, 1.0, float("inf"))
        # define state labels
        self.state_labels = {
            "A": self.state_A,
            "B": self.state_B,
            "ToA": self.towards_A,
            "None": ~(self.state_A | self.state_B | self.towards_A)
        }

        # velocities are not randomized
        randomizer = paths.NoModification()

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

        self.simulation = ReactiveFluxSimulation(
            storage=self.storage,
            engine=self.engine,
            states=[self.state_A, self.state_B],
            randomizer=randomizer,
            initial_snapshots=self.initial_snapshots,
            rc=rc)
        self.simulation.output_stream = open(os.devnull, 'w')
Esempio n. 15
0
    def setup(self):
        integ = toys.LangevinBAOABIntegrator(dt=0.002,
                                             temperature=1.0,
                                             gamma=2.5)
        options = {'integ': integ, 'n_frames_max': 5}
        topology_2D = toys.Topology(n_spatial=2, masses=[1.0], pes=None)
        engine_2D = toys.Engine(options=options, topology=topology_2D)
        self.snap_2D = toys.Snapshot(coordinates=np.array([[0.0, 0.0]]),
                                     velocities=np.array([[2.0, 4.0]]),
                                     engine=engine_2D)

        topology_6D = toys.Topology(n_spatial=3,
                                    n_atoms=2,
                                    masses=[1.0, 2.0],
                                    pes=None)
        engine_6D = toys.Engine(options=options, topology=topology_6D)
        self.snap_6D = toys.Snapshot(coordinates=np.array([[0.0, 0.0, 0.0],
                                                           [0.0, 0.0, 0.0]]),
                                     velocities=np.array([[1.0, 0.0, 0.0],
                                                          [1.0, 0.0, 0.0]]),
                                     engine=engine_6D)
    def setup(self):
        # PES is one-dimensional zero function (y(x) = 0)
        pes = toys.LinearSlope(m=[0.0], c=[0.0])
        topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
        integrator = toys.LeapfrogVerletIntegrator(0.02)
        options = {
            'integ' : integrator,
            'n_frames_max' : 1000,
            'n_steps_per_frame' : 1
        }
        self.engine = toys.Engine(options=options, topology=topology)
        # test uses snapshots with different velocities
        self.initial_snapshots = [toys.Snapshot(
                                      coordinates=np.array([[0.0]]),
                                      velocities=np.array([[1.0]]),
                                      engine=self.engine),
                                  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,
            trajectory_length=self.l
        )
        self.simulation.output_stream = open(os.devnull, 'w')
    def setup(self):
        self.HAS_TQDM = paths.progress.HAS_TQDM
        paths.progress.HAS_TQDM = False
        # taken from the TestCommittorSimulation
        import openpathsampling.engines.toy as toys
        pes = toys.LinearSlope(m=[0.0], c=[0.0])  # flat line
        topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
        descriptor = peng.SnapshotDescriptor.construct(
            toys.Snapshot,
            {
                'n_atoms': 1,
                'n_spatial': 1
            }
        )
        engine = peng.NoEngine(descriptor)
        self.snap0 = toys.Snapshot(coordinates=np.array([[0.0]]),
                                   velocities=np.array([[1.0]]),
                                   engine=engine)
        self.snap1 = toys.Snapshot(coordinates=np.array([[0.1]]),
                                   velocities=np.array([[1.0]]),
                                   engine=engine)
        integrator = toys.LeapfrogVerletIntegrator(0.1)
        options = {
            'integ': integrator,
            'n_frames_max': 10000,
            'n_steps_per_frame': 5
        }
        self.engine = toys.Engine(options=options, topology=topology)
        self.cv = paths.FunctionCV("Id", lambda snap: snap.coordinates[0][0])
        self.left = paths.CVDefinedVolume(self.cv, float("-inf"), -1.0)
        self.right = paths.CVDefinedVolume(self.cv, 1.0, float("inf"))

        randomizer = paths.NoModification()
        self.filename = data_filename("shooting_analysis.nc")
        self.storage = paths.Storage(self.filename, mode="w")

        self.simulation = paths.CommittorSimulation(
            storage=self.storage,
            engine=self.engine,
            states=[self.left, self.right],
            randomizer=randomizer,
            initial_snapshots=[self.snap0, self.snap1]
        )
        self.simulation.output_stream = open(os.devnull, 'w')
        self.simulation.run(20)
        # set up the analysis object
        self.analyzer = ShootingPointAnalysis(self.storage.steps,
                                              [self.left, self.right])
Esempio n. 18
0
    def setup(self):
        # PES is one-dimensional negative slope (y(x) = -x)
        pes = toys.LinearSlope(m=[-1.0], c=[0.0])
        topology = toys.Topology(n_spatial=1, masses=[1.0], pes=pes)
        integrator = toys.LeapfrogVerletIntegrator(0.02)
        options = {
            'integ': integrator,
            'n_frames_max': 1000,
            'n_steps_per_frame': 1
        }
        self.engine = toys.Engine(options=options, topology=topology)
        # test uses snapshots with different velocities
        # (1) does not ever reach A
        # (2) goes form A to S to B
        # (3) goes from B to S to A
        self.initial_snapshots = [
            toys.Snapshot(coordinates=np.array([[0.0]]),
                          velocities=np.array([[1.0]]),
                          engine=self.engine),
            toys.Snapshot(coordinates=np.array([[0.1]]),
                          velocities=np.array([[2.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 A: [-inf, -1]
        self.state_A = paths.CVDefinedVolume(rc, float("-inf"), -1.0)
        # state B: [1, inf]
        self.state_B = paths.CVDefinedVolume(rc, 1.0, float("inf"))
        # state S: [-0.5, 0.5]
        self.state_S = paths.CVDefinedVolume(rc, -0.5, 0.5)
        # define state labels
        self.state_labels = {
            "A": self.state_A,
            "B": self.state_B,
            "S": self.state_S,
            "None": ~(self.state_A | self.state_B | 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,
            trajectory_length=self.l)
        self.simulation.output_stream = open(os.devnull, 'w')
        self.simulation.run(n_per_snapshot=1)
        self.analysis = SShootingAnalysis(
            steps=self.storage.steps,
            states=[self.state_A, self.state_B, self.state_S])
Esempio n. 19
0
import argparse

def make_parser():
    parser = argparse.ArgumentParser()
    parser.add_argument('--nsteps', type=int, default=10000)
    return parser

parser = make_parser()
opts = parser.parse_args()
n_steps = opts.nsteps

pes = (toys.OuterWalls([1.0,1.0], [0.0,0.0])
       + toys.Gaussian(-0.7, [30.0, 0.5], [-0.6, 0.0])
       + toys.Gaussian(-0.7, [30.0, 0.5], [0.6, 0.0])
       + toys.Gaussian(0.5, [85.0, 70.0], [0.1, 0.0]))
topology = toys.Topology(n_spatial=2, masses=[1.0, 1.0], pes=pes)
engine = toys.Engine(
    {'integ': toys.LangevinBAOABIntegrator(dt=0.02,
                                           temperature=0.1,
                                           gamma=2.5),
     'n_frames_max': 5000,
     'n_steps_per_frame': 10}, topology)
template = toys.Snapshot(coordinates=np.array([[0.0, 0.0]]),
                         velocities=np.array([[0.0, 0.0]]),
                         engine=engine)

def val(snapshot, index):
    return snapshot.xyz[0][index]

cv_x = paths.FunctionCV("xval", val, index=0)
cv_y = paths.FunctionCV("yval", val, index=1)