def do_check(self, **kwargs): self.pot.nfev = 0 opt = FindTransitionState(self.x, self.pot, **kwargs) ret = opt.run() self.assertEqual(ret.nfev, self.pot.nfev) self.assertTrue(ret.success) self.assertGreater(ret.nfev, 0)
def test(): # pragma: no cover from pele.systems import LJCluster from pele.transition_states import GeneralizedDimer from pele.transition_states import FindTransitionState from pele.utils.xyz import read_xyz system = LJCluster(13) x = system.get_random_configuration() x = read_xyz(open("tests/lj18_ts.xyz", "r")).coords.flatten() dimer = GeneralizedDimer(x.copy(), system.get_potential(), rotational_steps=40, dimer=False, leig_kwargs=dict(iprint=10, maxstep=2., tol=.1, ), translator_kwargs=dict(iprint=1, verbosity=10, ), ) ret = dimer.run() print(ret) print("\n\nnow the same with the old version") searcher = FindTransitionState(x.copy(), system.get_potential(), iprint=1, verbosity=10) # print ret ret = searcher.run() print(ret)
def test1(self): print("\n\ntesting find ts with harmonic potential") pot = HarmonicPot() x0 = np.array([.2, 0]) opt = FindTransitionState(x0, pot, orthogZeroEigs=None, iprint=1, verbosity=10, # event=print_event, hessian_diagonalization=True ) ret = opt.run() self.assertFalse(ret.success) print(ret)
def test_2(self): self.called = False def event(**kwargs): self.called = True opt = FindTransitionState(self.x0, self.pot, orthogZeroEigs=None, tangentSpaceQuenchParams=dict(maxstep=1.), event=event) ret = opt.run() self.assertTrue(ret.success) self.assertTrue(self.called)
def test1(self): print "\n\ntesting find ts with harmonic potential" pot = HarmonicPot() x0 = np.array([.2, 0]) opt = FindTransitionState(x0, pot, orthogZeroEigs=None, iprint=1, verbosity=10, # event=print_event, hessian_diagonalization=True ) ret = opt.run() self.assertFalse(ret.success) print ret
def test1(self): # plot_pot() opt = FindTransitionState(self.x0, self.pot, orthogZeroEigs=None, # iprint=1, # verbosity=10, event=print_event, # tol=1e-3, # lowestEigenvectorQuenchParams=dict(iprint=1, events=[print_event]) ) ret = opt.run() self.assertTrue(ret.success) assert_arrays_almost_equal(self, ret.coords, self.xts, places=3) self.assertAlmostEqual(ret.energy, self.ets, delta=1e-3) self.assertLess(ret.rms, 1e-3) self.assertEqual(ret.nfev + 1, self.pot.nfev)
def test_from_near_minimum(self): print "\n\nstarting from a minimum" x0 = np.array([.6, .1]) opt = FindTransitionState(x0, self.pot, orthogZeroEigs=None, iprint=1, verbosity=10, # event=print_event, # tol=1e-3, # lowestEigenvectorQuenchParams=dict(iprint=1, events=[print_event]) ) ret = opt.run() print ret self.assertTrue(ret.success) assert_arrays_almost_equal(self, ret.coords, self.xts, places=3)
def test_from_near_minimum(self): print("\n\nstarting from a minimum") x0 = np.array([.6, .1]) opt = FindTransitionState(x0, self.pot, orthogZeroEigs=None, iprint=1, verbosity=10, # event=print_event, # tol=1e-3, # lowestEigenvectorQuenchParams=dict(iprint=1, events=[print_event]) ) ret = opt.run() print(ret) self.assertTrue(ret.success) assert_arrays_almost_equal(self, ret.coords, self.xts, places=3)
def test_from_near_minimum_demand_negative_eigenvalue(self): print "\n\nstarting from a minimum demand" # demand that the eigenvalue is negative initially. # this should fail right away x0 = np.array([.6, .1]) opt = FindTransitionState(x0, self.pot, orthogZeroEigs=None, demand_initial_negative_vec=True, iprint=1, verbosity=10, # event=print_event, # tol=1e-3, # lowestEigenvectorQuenchParams=dict(iprint=1, events=[print_event]) ) ret = opt.run() print ret self.assertFalse(ret.success) self.assertEqual(ret.nsteps, 0)
def test_from_near_minimum_demand_negative_eigenvalue(self): print("\n\nstarting from a minimum demand") # demand that the eigenvalue is negative initially. # this should fail right away x0 = np.array([.6, .1]) opt = FindTransitionState(x0, self.pot, orthogZeroEigs=None, demand_initial_negative_vec=True, iprint=1, verbosity=10, # event=print_event, # tol=1e-3, # lowestEigenvectorQuenchParams=dict(iprint=1, events=[print_event]) ) ret = opt.run() print(ret) self.assertFalse(ret.success) self.assertEqual(ret.nsteps, 0)
def make_dimer(self, x, **kwargs): return FindTransitionState( x, self.pot, orthogZeroEigs=self.system.get_orthogonalize_to_zero_eigenvectors( ), invert_gradient=True, )
def make_dimer(self, x, **kwargs): return FindTransitionState( x, self.pot, orthogZeroEigs=self.system.get_orthogonalize_to_zero_eigenvectors( ), **kwargs # verbosity=10 )
def test(): # pragma: no cover from pele.systems import LJCluster from pele.transition_states import GeneralizedDimer from pele.transition_states import FindTransitionState from pele.utils.xyz import read_xyz system = LJCluster(13) x = system.get_random_configuration() x = read_xyz(open("tests/lj18_ts.xyz", "r")).coords.flatten() dimer = GeneralizedDimer( x.copy(), system.get_potential(), rotational_steps=40, dimer=False, leig_kwargs=dict( iprint=10, maxstep=2., tol=.1, ), translator_kwargs=dict( iprint=1, verbosity=10, ), ) ret = dimer.run() print(ret) print("\n\nnow the same with the old version") searcher = FindTransitionState(x.copy(), system.get_potential(), iprint=1, verbosity=10) # print ret ret = searcher.run() print(ret)
def __init__(self): self["database"] = BaseParameters() self["basinhopping"] = BaseParameters() self["takestep"] = BaseParameters() self.structural_quench_params = BaseParameters() self.gui = BaseParameters() self.double_ended_connect = BaseParameters() self.double_ended_connect.local_connect_params = BaseParameters() self.double_ended_connect.local_connect_params.pushoff_params = BaseParameters( ) self.double_ended_connect.local_connect_params.tsSearchParams = BaseParameters( FindTransitionState.params()) self.double_ended_connect.local_connect_params.NEBparams = BaseParameters( NEBDriver.params())
def __init__(self): self["database"] = BaseParameters() self["basinhopping"] = BaseParameters() self["takestep"] = BaseParameters() self.structural_quench_params = BaseParameters() self.gui = BaseParameters() self.double_ended_connect = BaseParameters() self.double_ended_connect.local_connect_params = BaseParameters() self.double_ended_connect.local_connect_params.pushoff_params = BaseParameters() self.double_ended_connect.local_connect_params.tsSearchParams = BaseParameters(FindTransitionState.params()) self.double_ended_connect.local_connect_params.NEBparams = BaseParameters(NEBDriver.params())
def test_params(self): params = FindTransitionState.params()