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 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)
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
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): # 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 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')
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])
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])