예제 #1
0
    def setUp(self):
        nmin = 10
        natoms = 13

        sys = LJCluster(natoms)

        pot = sys.get_potential()
        mindist = sys.get_mindist()

        db = create_random_database(nmin=nmin,
                                    natoms=natoms,
                                    nts=old_div(nmin, 2))
        min1, min2 = list(db.minima())[:2]

        self.db = db
        self.natoms = natoms
        self.connect = DoubleEndedConnect(min1,
                                          min2,
                                          pot,
                                          mindist,
                                          db,
                                          merge_minima=True,
                                          max_dist_merge=1e100)
        #        for ts in db.transition_states():
        #            self.add_ts(ts.energy, ts.coords,
        #                        ts.minimum1.energy, ts.minimum1.coords,
        #                        ts.minimum2.energy, ts.minimum2.coords)
        for m in db.minima():
            self.connect.dist_graph.addMinimum(m)
def guessts(coords1, coords2, pot):
    from pele.optimize import lbfgs_py as quench
#    from pele.mindist.minpermdist_stochastic import minPermDistStochastic as mindist
    from pele.transition_states import NEB
    from pele.systems import LJCluster
    ret1 = quench(coords1, pot.getEnergyGradient)
    ret2 = quench(coords2, pot.getEnergyGradient)
    coords1 = ret1[0]
    coords2 = ret2[0]
    natoms = len(coords1)/3
    system = LJCluster(natoms)
    mindist = system.get_mindist()
    dist, coords1, coords2 = mindist(coords1, coords2) 
    print "dist", dist
    print "energy coords1", pot.getEnergy(coords1)
    print "energy coords2", pot.getEnergy(coords2)
    from pele.transition_states import InterpolatedPath
    neb = NEB(InterpolatedPath(coords1, coords2, 20), pot)
    #neb.optimize(quenchParams={"iprint" : 1})
    neb.optimize(iprint=-30, nsteps=100)
    neb.MakeAllMaximaClimbing()
    #neb.optimize(quenchParams={"iprint": 30, "nsteps":100})
    for i in xrange(len(neb.energies)):
        if(neb.isclimbing[i]):
            coords = neb.coords[i,:]
    return pot, coords, neb.coords[0,:], neb.coords[-1,:]
예제 #3
0
    def setUp(self):
#        from pele.mindist import minPermDistStochastic, MinDistWrapper
#        from pele.potentials import LJ
        
        nmin = 10
        natoms=13
        
        sys = LJCluster(natoms)
        
        pot = sys.get_potential()
        mindist = sys.get_mindist()
        
        db = create_random_database(nmin=nmin, natoms=natoms, nts=nmin/2)
        min1, min2 = list(db.minima())[:2]
        
        
        self.db = db
        self.natoms = natoms
        self.connect = DoubleEndedConnect(min1, min2, pot, mindist, db,
                                          merge_minima=True, max_dist_merge=1e100)
#        for ts in db.transition_states():
#            self.add_ts(ts.energy, ts.coords, 
#                        ts.minimum1.energy, ts.minimum1.coords,
#                        ts.minimum2.energy, ts.minimum2.coords)
        for m in db.minima():
            self.connect.dist_graph.addMinimum(m)
예제 #4
0
def test(Connect=DoubleEndedConnect, natoms=16):
#    from pele.landscape import TSGraph
#    from pele.storage.database import Database
    from pele.systems import LJCluster
    #get min1
    system = LJCluster(natoms)
    pot, database = getSetOfMinLJ(system)
#    from pele.potentials.lj import LJ
#    pot = LJ()
#    saveit = Database(db="test.db")
    minima = database.minima()
    min1 = minima[0]
    min2 = minima[1]
    print min1.energy, min2.energy
    
    
    mindist = system.get_mindist()
    
    if False:
        #test to see if min1 and min2 are already connected
        connected = graph.areConnected(min1, min2)
        print "at start are minima connected?", connected
        return
 
    connect = Connect(min1, min2, pot, mindist, database)
    connect.connect()
    
    graph = connect.graph
    if False:
        print graph
        for node in graph.graph.nodes():
            print node._id, node.energy
    for ts in graph.storage.transition_states():
        print ts.minimum1._id,ts.minimum2._id, "E", ts.minimum1.energy, ts.minimum2.energy, ts.energy
        
    ret = graph.getPath(min1, min2)
    if ret is None:
        print "no path found"
        return
    distances, path = ret
    with open("path.out", "w") as fout:
        for i in range(len(path)-1):
            m1 = path[i]
            m2 = path[i+1]
            n1 = m1._id
            m2 = m2._id
#            ts = graph._getTS(n1, n2)
#            print "path", n1, "->", n2, m1.E, "/->", ts.E, "\->", m2.E
            fout.write("%f\n" % m1.energy)
            fout.write("%f\n" % ts.energy)
        m2 = path[-1]
        n2 = m2._id
        fout.write("%f\n" % m2.energy)
예제 #5
0
def getPairLJ(natoms=38):
    from pele.systems import LJCluster
    system = LJCluster(natoms)
    ret1 = system.get_random_minimized_configuration()
    ret2 = system.get_random_minimized_configuration()
    coords1, coords2 = ret1[0], ret2[0]
    E1, E2 = ret1[1], ret2[1]
    
    mindist = system.get_mindist()
    mindist(coords1, coords2)
    
    return coords1, coords2, system.get_potential(), mindist, E1, E2
예제 #6
0
def getPairLJ(natoms=38):  # pragma: no cover
    from pele.systems import LJCluster

    system = LJCluster(natoms)
    ret1 = system.get_random_minimized_configuration()
    ret2 = system.get_random_minimized_configuration()
    coords1, coords2 = ret1[0], ret2[0]
    E1, E2 = ret1[1], ret2[1]

    mindist = system.get_mindist()
    mindist(coords1, coords2)

    return coords1, coords2, system.get_potential(), mindist, E1, E2
예제 #7
0
def get_x0():
    from pele.systems import LJCluster
    natoms = 31
    system = LJCluster(natoms)
    db = system.create_database()
    bh = system.get_basinhopping(db, outstream=None)
    while db.number_of_minima() < 2:
        bh.run(1)
    
    mindist = system.get_mindist()
    m1, m2 = db.minima()[:4]
    d, x1, x2 = mindist(m1.coords, m2.coords)
    
    x0 = (x1 + x2) / 2
    evec0 = x2 - x1
    
    return system, x0, evec0
예제 #8
0
def get_x0():  # pragma: no cover
    from pele.systems import LJCluster

    natoms = 31
    system = LJCluster(natoms)
    db = system.create_database()
    bh = system.get_basinhopping(db, outstream=None)
    while db.number_of_minima() < 2:
        bh.run(1)

    mindist = system.get_mindist()
    m1, m2 = db.minima()[:4]
    d, x1, x2 = mindist(m1.coords, m2.coords)

    x0 = (x1 + x2) / 2
    evec0 = x2 - x1

    return system, x0, evec0
예제 #9
0
def test(Connect=DoubleEndedConnect, natoms=16): # pragma: no cover
    from pele.systems import LJCluster
    #get min1
    system = LJCluster(natoms)
    pot, database = getSetOfMinLJ(system)
    minima = database.minima()
    min1 = minima[0]
    min2 = minima[1]
    print min1.energy, min2.energy
    
    
    mindist = system.get_mindist()
    
    connect = Connect(min1, min2, pot, mindist, database)
    connect.connect()
    
    graph = connect.graph
    if False:
        print graph
        for node in graph.graph.nodes():
            print node._id, node.energy
    for ts in graph.storage.transition_states():
        print ts.minimum1._id,ts.minimum2._id, "E", ts.minimum1.energy, ts.minimum2.energy, ts.energy
        
    ret = graph.getPath(min1, min2)
    if ret is None:
        print "no path found"
        return
    distances, path = ret
    with open("path.out", "w") as fout:
        for i in range(len(path)-1):
            m1 = path[i]
            m2 = path[i+1]
            n1 = m1._id
            m2 = m2._id
#            ts = graph._getTS(n1, n2)
#            print "path", n1, "->", n2, m1.E, "/->", ts.E, "\->", m2.E
            fout.write("%f\n" % m1.energy)
            fout.write("%f\n" % ts.energy)
        m2 = path[-1]
        n2 = m2._id
        fout.write("%f\n" % m2.energy)
예제 #10
0
def test(Connect=DoubleEndedConnect, natoms=16):  # pragma: no cover
    from pele.systems import LJCluster
    # get min1
    system = LJCluster(natoms)
    pot, database = getSetOfMinLJ(system)
    minima = database.minima()
    min1 = minima[0]
    min2 = minima[1]
    print min1.energy, min2.energy

    mindist = system.get_mindist()

    connect = Connect(min1, min2, pot, mindist, database)
    connect.connect()

    graph = connect.graph
    if False:
        print graph
        for node in graph.graph.nodes():
            print node.id(), node.energy
    for ts in graph.storage.transition_states():
        print ts.minimum1.id(), ts.minimum2.id(
        ), "E", ts.minimum1.energy, ts.minimum2.energy, ts.energy

    ret = graph.getPath(min1, min2)
    if ret is None:
        print "no path found"
        return
    distances, path = ret
    with open("path.out", "w") as fout:
        for i in range(len(path) - 1):
            m1 = path[i]
            m2 = path[i + 1]
            n1 = m1.id()
            m2 = m2.id()
            # ts = graph._getTS(n1, n2)
            # print "path", n1, "->", n2, m1.E, "/->", ts.E, "\->", m2.E
            fout.write("%f\n" % m1.energy)
            fout.write("%f\n" % ts.energy)
        m2 = path[-1]
        n2 = m2.id()
        fout.write("%f\n" % m2.energy)
예제 #11
0
    def test2(self):
        from pele.storage import Database
        from pele.systems import LJCluster
        np.random.seed(0)

        natoms = 13
        system = LJCluster(natoms)
        pot = system.get_potential()
        mindist = system.get_mindist(niter=1)
        
        db = Database()
        db.addMinimum(pot.getEnergy(_x1), _x1)
        db.addMinimum(pot.getEnergy(_x2), _x2)
        m1, m2 = db.minima()
        
        connect = DoubleEndedConnect(m1, m2, pot, mindist, db, verbosity=10)
        connect.connect()
        self.assertTrue(connect.success())
        
        path = connect.returnPath()
예제 #12
0
minimum2 = db.addMinimum(e2, coords2)

# do a basinhopping run to find the global minimum and build up the database of minima
bh = system.get_basinhopping(database=db, outstream=None)
niter = 20
bh.run(niter)
print "the lowest energy found after", niter, " basinhopping steps is", db.minima()[0].energy

# print the energies of all the minima found
print "the minima in the database have energies"
for minimum in db.minima():
    print "  ", minimum.energy

# find the minimum distance (a.k.a. mindist) between the two lowest minima
m1, m2 = db.minima()[:2]
mindist = system.get_mindist()
dist, coords1, coords2 = mindist(m1.coords, m2.coords)
print "the minimum distance between the two lowest minima is", dist

# find a connected series of minima and transition states between m1 and m2
# 
# first use the logging module to turn off the status messages 
logger = logging.getLogger("pele.connect")
logger.setLevel("WARNING")
# now create the double ended connect object
connect = system.get_double_ended_connect(m1, m2, db)
connect.connect()
mints, S, energies = connect.returnPath()
nts = (len(mints) - 1)/2
print "\nprint found a connection with", nts, "transition states"
예제 #13
0
import numpy as np
from pele.systems import LJCluster
from pele.utils.xyz import write_xyz

natoms=38
system = LJCluster(natoms)
db = system.create_database()
bh = system.get_basinhopping(db)
bh.run(1000)

m1, m2 = db.minima()[:2]

if False:
    mindist = system.get_mindist()
    d, x1, x2 = mindist(m1.coords, m2.coords)
else:
    x1, x2 = m1.coords, m2.coords


#write_xyz(open("lj6_m1.xyz", "w"), x1)
#write_xyz(open("lj6_m2.xyz", "w"), x2)
np.savetxt("lj{}_m1".format(natoms), x1.reshape(-1,3))
np.savetxt("lj{}_m2".format(natoms), x2.reshape(-1,3))