コード例 #1
0
ファイル: profile_otp.py プロジェクト: Mahdisadjadi/pele
def do_connect(nmol=20):
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    m1 = db.minima()[0]
    for m2 in db.minima()[1:5]:
        connect = system.get_double_ended_connect(m1, m2, db, fresh_connect=True)
        connect.connect()
コード例 #2
0
ファイル: profile_otp.py プロジェクト: Mahdisadjadi/pele
def do_mindist(nmol=20):
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    mindist = system.get_mindist()
    m0 = db.minima()[0]
    for m1 in db.minima()[1:6]:
        d, x1, x2 = mindist(m0.coords, m1.coords)
        print d
コード例 #3
0
def do_mindist(nmol=20):
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    mindist = system.get_mindist()
    m0 = db.minima()[0]
    for m1 in db.minima()[1:6]:
        d, x1, x2 = mindist(m0.coords, m1.coords)
        print d
コード例 #4
0
 def setUp(self):
     np.random.seed(0)
     self.nmol = 4
     self.system = OTPCluster(self.nmol)
     pot = self.system.get_potential()
     self.db = self.system.create_database()
     self.m1 = self.db.addMinimum(pot.getEnergy(_x1), _x1)
     self.m2 = self.db.addMinimum(pot.getEnergy(_x2), _x2)
コード例 #5
0
def do_NEB(nmol=20):
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    mindist = system.get_mindist()
    pot = system.get_potential()
    m1 = db.minima()[0]
    for m2 in db.minima()[1:3]:
        neb = NEBDriver(pot, m1.coords, m2.coords)
        neb.run()
コード例 #6
0
ファイル: profile_otp.py プロジェクト: Mahdisadjadi/pele
def do_NEB(nmol=20):
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    mindist = system.get_mindist()
    pot = system.get_potential()
    m1 = db.minima()[0]
    for m2 in db.minima()[1:3]:
        neb = NEBDriver(pot, m1.coords, m2.coords)
        neb.run()
コード例 #7
0
def do_connect(nmol=20):
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    m1 = db.minima()[0]
    for m2 in db.minima()[1:5]:
        connect = system.get_double_ended_connect(m1,
                                                  m2,
                                                  db,
                                                  fresh_connect=True)
        connect.connect()
コード例 #8
0
ファイル: profile_otp.py プロジェクト: Mahdisadjadi/pele
def do_ts_search(nmol=20):
    from pele.transition_states import findTransitionState
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    orthogopt = system.get_orthogonalize_to_zero_eigenvectors()
    for ts in db.transition_states():
        coords = db.transition_states()[0].coords.copy() 
        coords += np.random.uniform(-.5,.5, coords.size)
    
        print system.params.double_ended_connect.local_connect_params.tsSearchParams
        findTransitionState(coords, system.get_potential(), orthogZeroEigs=orthogopt, 
                            **system.params.double_ended_connect.local_connect_params.tsSearchParams)
コード例 #9
0
def do_ts_search(nmol=20):
    from pele.transition_states import findTransitionState
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    orthogopt = system.get_orthogonalize_to_zero_eigenvectors()
    for ts in db.transition_states():
        coords = db.transition_states()[0].coords.copy()
        coords += np.random.uniform(-.5, .5, coords.size)

        print system.params.double_ended_connect.local_connect_params.tsSearchParams
        findTransitionState(coords,
                            system.get_potential(),
                            orthogZeroEigs=orthogopt,
                            **system.params.double_ended_connect.
                            local_connect_params.tsSearchParams)
コード例 #10
0
ファイル: test_otp.py プロジェクト: pele-python/pele
 def setUp(self):
     np.random.seed(0)
     self.nmol = 4
     self.system = OTPCluster(self.nmol)
     pot = self.system.get_potential()
     self.db = self.system.create_database()
     self.m1 = self.db.addMinimum(pot.getEnergy(_x1), _x1)
     self.m2 = self.db.addMinimum(pot.getEnergy(_x2), _x2)
コード例 #11
0
ファイル: test_otp.py プロジェクト: cjforman/pele
    def setUp(self):
        np.random.seed(0)
        self.nmol = 3
        self.system = OTPCluster(self.nmol)
        #        pot = self.system.get_potential()
        #        self.db = self.system.create_database()
        #        self.m1 = self.db.addMinimum(pot.getEnergy(_x1), _x1)
        #        self.m2 = self.db.addMinimum(pot.getEnergy(_x2), _x2)

        self.x0 = np.array([
            0, 1, 2, 3, 4, 5, 6, 7, 8, 0.517892, 0.575435, 0.632979, 0.531891,
            0.576215, 0.620539, 0.540562, 0.5766, 0.612637
        ])

        from pele.angleaxis.aamindist import TransformAngleAxisCluster
        self.topology = self.system.aatopology
        self.transform = TransformAngleAxisCluster(self.topology)

        self.p0 = np.array(range(1, 4), dtype=float)
        self.p0 /= np.linalg.norm(self.p0)
コード例 #12
0
ファイル: test_otp.py プロジェクト: cjforman/pele
    def setUp(self):
        np.random.seed(0)
        self.nmol = 3
        self.system = OTPCluster(self.nmol)
#        pot = self.system.get_potential()
#        self.db = self.system.create_database()
#        self.m1 = self.db.addMinimum(pot.getEnergy(_x1), _x1)
#        self.m2 = self.db.addMinimum(pot.getEnergy(_x2), _x2)

        self.x0 = np.array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 
                             0.517892, 0.575435, 0.632979, 
                             0.531891, 0.576215, 0.620539, 
                             0.540562, 0.5766, 0.612637 ])
        
        from pele.angleaxis.aamindist import TransformAngleAxisCluster
        self.topology = self.system.aatopology
        self.transform = TransformAngleAxisCluster(self.topology)
        
        self.p0 = np.array(range(1,4), dtype=float)
        self.p0 /= np.linalg.norm(self.p0)
コード例 #13
0
class TestOTPCluster(unittest.TestCase):
    def setUp(self):
        np.random.seed(0)
        self.nmol = 4
        self.system = OTPCluster(self.nmol)
        pot = self.system.get_potential()
        self.db = self.system.create_database()
        self.m1 = self.db.addMinimum(pot.getEnergy(_x1), _x1)
        self.m2 = self.db.addMinimum(pot.getEnergy(_x2), _x2)

    def test1(self):
        pot = self.system.get_potential()
        self.assertLess(np.linalg.norm(pot.getGradient(self.m1.coords)), .1)
        self.assertLess(np.linalg.norm(pot.getGradient(self.m2.coords)), .1)

    def test_basinhopping(self):
        db = self.system.create_database()
        bh = self.system.get_basinhopping(db)
        bh.setPrinting(ostream=None)
        bh.run(5)
        self.assertGreaterEqual(db.number_of_minima(), 1)

    def test_double_ended_connect(self):
        connect = self.system.get_double_ended_connect(self.m1, self.m2,
                                                       self.db)
        connect.connect()
        self.assertTrue(connect.success())

        path = connect.returnPath()

    def test_thermodynamics(self):
        get_thermodynamic_information(self.system,
                                      self.db,
                                      nproc=None,
                                      recalculate=True)
        self.assertIsNotNone(self.m1.fvib)

        mt = self.system.get_metric_tensor(self.m1.coords)
        print("metric tensor")
        print(mt)
コード例 #14
0
ファイル: test_otp.py プロジェクト: pele-python/pele
class TestOTPCluster(unittest.TestCase):
    def setUp(self):
        np.random.seed(0)
        self.nmol = 4
        self.system = OTPCluster(self.nmol)
        pot = self.system.get_potential()
        self.db = self.system.create_database()
        self.m1 = self.db.addMinimum(pot.getEnergy(_x1), _x1)
        self.m2 = self.db.addMinimum(pot.getEnergy(_x2), _x2)
    
    def test1(self):
        pot = self.system.get_potential()
        self.assertLess(np.linalg.norm(pot.getGradient(self.m1.coords)), .1)
        self.assertLess(np.linalg.norm(pot.getGradient(self.m2.coords)), .1)
    
    def test_basinhopping(self):
        db = self.system.create_database()
        bh = self.system.get_basinhopping(db)
        bh.setPrinting(ostream=None)
        bh.run(5)
        self.assertGreaterEqual(db.number_of_minima(), 1)

    def test_double_ended_connect(self):
        connect = self.system.get_double_ended_connect(self.m1, self.m2, self.db)
        connect.connect()
        self.assertTrue(connect.success())
        
        path = connect.returnPath()
    
    def test_thermodynamics(self):
        get_thermodynamic_information(self.system, self.db, nproc=None, recalculate=True)
        self.assertIsNotNone(self.m1.fvib)
        
        mt = self.system.get_metric_tensor(self.m1.coords)
        print("metric tensor")
        print(mt)
コード例 #15
0
ファイル: test_otp.py プロジェクト: cjforman/pele
class TestRBTopologyOTP(unittest.TestCase):
    def setUp(self):
        np.random.seed(0)
        self.nmol = 3
        self.system = OTPCluster(self.nmol)
        #        pot = self.system.get_potential()
        #        self.db = self.system.create_database()
        #        self.m1 = self.db.addMinimum(pot.getEnergy(_x1), _x1)
        #        self.m2 = self.db.addMinimum(pot.getEnergy(_x2), _x2)

        self.x0 = np.array([
            0, 1, 2, 3, 4, 5, 6, 7, 8, 0.517892, 0.575435, 0.632979, 0.531891,
            0.576215, 0.620539, 0.540562, 0.5766, 0.612637
        ])

        from pele.angleaxis.aamindist import TransformAngleAxisCluster
        self.topology = self.system.aatopology
        self.transform = TransformAngleAxisCluster(self.topology)

        self.p0 = np.array(range(1, 4), dtype=float)
        self.p0 /= np.linalg.norm(self.p0)

    def test_transform_rotate(self):
        print "\ntest rotate"
        x = self.x0.copy()
        p = np.array(range(1, 4), dtype=float)
        p /= np.linalg.norm(p)
        self.transform.rotate(x, rotations.aa2mx(p))

        xnewtrue = np.array([
            0.48757698, 0.61588594, 2.09355038, 2.02484605, 4.76822812,
            4.81289924, 3.56211511, 8.92057031, 7.53224809, 0.71469473,
            1.23875927, 1.36136748, 0.72426504, 1.24674367, 1.34426835,
            0.73015833, 1.25159032, 1.33345003
        ])
        for v1, v2 in izip(x, xnewtrue):
            self.assertAlmostEqual(v1, v2, 5)

    def test_align_path(self):
        print "\ntest align_path"
        x1 = self.x0.copy()
        x2 = self.x0 + 5

        self.topology.align_path([x1, x2])

        x2true = np.array([
            5., 6., 7., 8., 9., 10., 11., 12., 13., 1.92786071, 1.94796529,
            1.96807021, 1.93320298, 1.94869267, 1.96418236, 1.93645608,
            1.94905155, 1.96164668
        ])

        for v1, v2 in izip(x1, self.x0):
            self.assertAlmostEqual(v1, v2, 5)
        for v1, v2 in izip(x2, x2true):
            self.assertAlmostEqual(v1, v2, 5)

    def test_cpp_zero_ev(self):
        print "\ntest zeroEV cpp"
        x = self.x0.copy()
        zev = self.topology._zeroEV_python(x)
        czev = self.topology.cpp_topology.get_zero_modes(x)
        self.assertEqual(len(czev), 6)
        for ev, cev in izip(zev, czev):
            for v1, v2 in izip(ev, cev):
                self.assertAlmostEqual(v1, v2, 5)

    def test_site_distance_squared(self):
        print "\ntest site distance squared"
        c0 = np.zeros(3)
        c1 = np.ones(3)
        p0 = self.p0.copy()
        p1 = p0 + 1
        site = self.system.make_otp()
        d2 = site.distance_squared(c0, p0, c1, p1)
        d2p = _sitedist(c1 - c0, p0, p1, site.S, site.W, site.cog)
        self.assertAlmostEqual(d2, 10.9548367929, 5)

    def test_distance_squared(self):
        print "\ntest distance squared"
        x1 = self.x0.copy()
        x2 = self.x0 + 1.1
        d2 = self.topology.distance_squared(x1, x2)
        d3 = self.topology._distance_squared_python(x1, x2)
        self.assertAlmostEqual(d2, 38.9401810973, 5)
        self.assertAlmostEqual(d2, d3, 5)

    def test_distance_squared_grad(self):
        print "\ntest distance squared grad"
        x1 = self.x0.copy()
        x2 = self.x0 + 1.1
        grad = self.topology.distance_squared_grad(x1, x2)
        g2 = self.topology._distance_squared_grad_python(x1, x2)

        gtrue = np.array([
            -6.6, -6.6, -6.6, -6.6, -6.6, -6.6, -6.6, -6.6, -6.6, -1.21579025,
            -0.07013805, -1.2988823, -1.21331786, -0.06984532, -1.28945301,
            -1.2116105, -0.06975828, -1.28362943
        ])
        for v1, v2 in izip(grad, gtrue):
            self.assertAlmostEqual(v1, v2, 5)
        for v1, v2 in izip(grad, g2):
            self.assertAlmostEqual(v1, v2, 5)

    def test_measure_align(self):
        print "\ntest measure align"
        x1 = self.x0.copy()
        x2 = self.x0 + 5.1
        x2[-1] = x1[-1] + .1
        x20 = x2.copy()
        measure = MeasureRigidBodyCluster(self.topology)
        measure.align(x1, x2)
コード例 #16
0
 def get_random_rbcoords(self):
     otp = OTPCluster(self.nrigid)
     ret = otp.get_random_minimized_configuration(tol=100.)
     return ret.coords
コード例 #17
0
ファイル: test_otp.py プロジェクト: cjforman/pele
class TestRBTopologyOTP(unittest.TestCase):
    def setUp(self):
        np.random.seed(0)
        self.nmol = 3
        self.system = OTPCluster(self.nmol)
#        pot = self.system.get_potential()
#        self.db = self.system.create_database()
#        self.m1 = self.db.addMinimum(pot.getEnergy(_x1), _x1)
#        self.m2 = self.db.addMinimum(pot.getEnergy(_x2), _x2)

        self.x0 = np.array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 
                             0.517892, 0.575435, 0.632979, 
                             0.531891, 0.576215, 0.620539, 
                             0.540562, 0.5766, 0.612637 ])
        
        from pele.angleaxis.aamindist import TransformAngleAxisCluster
        self.topology = self.system.aatopology
        self.transform = TransformAngleAxisCluster(self.topology)
        
        self.p0 = np.array(range(1,4), dtype=float)
        self.p0 /= np.linalg.norm(self.p0)

    
    def test_transform_rotate(self):
        print "\ntest rotate"
        x = self.x0.copy()
        p = np.array(range(1,4), dtype=float)
        p /= np.linalg.norm(p)
        self.transform.rotate(x, rotations.aa2mx(p))
        
        xnewtrue = np.array([ 0.48757698,  0.61588594,  2.09355038,  2.02484605,  4.76822812,
                            4.81289924,  3.56211511,  8.92057031,  7.53224809,  0.71469473,
                            1.23875927,  1.36136748,  0.72426504,  1.24674367,  1.34426835,
                            0.73015833,  1.25159032,  1.33345003])
        for v1, v2 in izip(x, xnewtrue):
            self.assertAlmostEqual(v1, v2, 5)
    
    def test_align_path(self):
        print "\ntest align_path"
        x1 = self.x0.copy()
        x2 = self.x0 + 5
        
        self.topology.align_path([x1, x2])
        
        x2true = np.array([  5.        ,   6.        ,   7.        ,   8.        ,
                             9.        ,  10.        ,  11.        ,  12.        ,
                            13.        ,   1.92786071,   1.94796529,   1.96807021,
                             1.93320298,   1.94869267,   1.96418236,   1.93645608,
                             1.94905155,   1.96164668])
        
        for v1, v2 in izip(x1, self.x0):
            self.assertAlmostEqual(v1, v2, 5)
        for v1, v2 in izip(x2, x2true):
            self.assertAlmostEqual(v1, v2, 5)
    
    def test_cpp_zero_ev(self):
        print "\ntest zeroEV cpp"
        x = self.x0.copy()
        zev = self.topology._zeroEV_python(x)
        czev = self.topology.cpp_topology.get_zero_modes(x)
        self.assertEqual(len(czev), 6)
        for ev, cev in izip(zev, czev):
            for v1, v2 in izip(ev, cev):
                self.assertAlmostEqual(v1, v2, 5)     
    
    def test_site_distance_squared(self):
        print "\ntest site distance squared"
        c0 = np.zeros(3)
        c1 = np.ones(3)
        p0 = self.p0.copy()
        p1 = p0 + 1
        site = self.system.make_otp()
        d2 = site.distance_squared(c0, p0, c1, p1)
        d2p = _sitedist(c1-c0, p0, p1, site.S, site.W, site.cog)
        self.assertAlmostEqual(d2, 10.9548367929, 5)


    def test_distance_squared(self):
        print "\ntest distance squared"
        x1 = self.x0.copy()
        x2 = self.x0 + 1.1
        d2 = self.topology.distance_squared(x1, x2)
        d3 = self.topology._distance_squared_python(x1, x2)
        self.assertAlmostEqual(d2, 38.9401810973, 5)
        self.assertAlmostEqual(d2, d3, 5)
        


    def test_distance_squared_grad(self):
        print "\ntest distance squared grad"
        x1 = self.x0.copy()
        x2 = self.x0 + 1.1
        grad = self.topology.distance_squared_grad(x1, x2)
        g2 = self.topology._distance_squared_grad_python(x1, x2)
        
        gtrue = np.array([-6.6       , -6.6       , -6.6       , -6.6       , -6.6       ,
                       -6.6       , -6.6       , -6.6       , -6.6       , -1.21579025,
                       -0.07013805, -1.2988823 , -1.21331786, -0.06984532, -1.28945301,
                       -1.2116105 , -0.06975828, -1.28362943])
        for v1, v2 in izip(grad, gtrue):
            self.assertAlmostEqual(v1, v2, 5)
        for v1, v2 in izip(grad, g2):
            self.assertAlmostEqual(v1, v2, 5)
    
    def test_measure_align(self):
        print "\ntest measure align"
        x1 = self.x0.copy()
        x2 = self.x0 + 5.1
        x2[-1] = x1[-1] + .1
        x20 = x2.copy()
        measure = MeasureRigidBodyCluster(self.topology)
        measure.align(x1, x2)
コード例 #18
0
def getdb(nmol=20):
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    bh = system.get_basinhopping(db)
    bh.run(20)
コード例 #19
0
ファイル: profile_otp.py プロジェクト: Mahdisadjadi/pele
def getdb(nmol=20):
    system = OTPCluster(nmol)
    db = system.create_database("test.sqlte")
    bh = system.get_basinhopping(db)
    bh.run(20)
コード例 #20
0
 def get_random_rbcoords(self):
     otp = OTPCluster(self.nrigid)
     ret = otp.get_random_minimized_configuration(tol=100.)
     return ret.coords