示例#1
0
    def setUp(self):
        from pygmin.landscape import DoubleEndedConnect
        from pygmin.landscape._graph import create_random_database
        from pygmin.systems import LJCluster
        #        from pygmin.mindist import minPermDistStochastic, MinDistWrapper
        #        from pygmin.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]

        connect = DoubleEndedConnect(min1,
                                     min2,
                                     pot,
                                     mindist,
                                     db,
                                     use_all_min=True,
                                     merge_minima=True,
                                     max_dist_merge=1e100)

        self.connect = connect
        self.db = db
        self.natoms = natoms
示例#2
0
    def setUp(self):
        from pygmin.landscape import DoubleEndedConnect
        from pygmin.landscape._graph import create_random_database
        from pygmin.systems import LJCluster
#        from pygmin.mindist import minPermDistStochastic, MinDistWrapper
#        from pygmin.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] 
        
        
        connect = DoubleEndedConnect(min1, min2, pot, mindist, db, use_all_min=True, 
                                     merge_minima=True, max_dist_merge=1e100)

        self.connect = connect
        self.db = db
        self.natoms = natoms
def guessts(coords1, coords2, pot):
    from pygmin.optimize import lbfgs_py as quench
#    from pygmin.mindist.minpermdist_stochastic import minPermDistStochastic as mindist
    from pygmin.transition_states import NEB
    from pygmin.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 pygmin.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,:]
def guessts(coords1, coords2, pot):
    from pygmin.optimize import lbfgs_py as quench
    #    from pygmin.mindist.minpermdist_stochastic import minPermDistStochastic as mindist
    from pygmin.transition_states import NEB
    from pygmin.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 pygmin.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, :]
示例#5
0
def test(Connect=DoubleEndedConnect, natoms=16):
#    from pygmin.landscape import Graph
#    from pygmin.storage.database import Database
    from pygmin.systems import LJCluster
    #get min1
    system = LJCluster(natoms)
    pot, database = getSetOfMinLJ(system)
#    from pygmin.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)
示例#6
0
def getPairLJ(natoms=38):
    from pygmin.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 getPairLJ(natoms=38):
    from pygmin.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
示例#8
0
def test(Connect=DoubleEndedConnect, natoms=16):
    #    from pygmin.landscape import TSGraph
    #    from pygmin.storage.database import Database
    from pygmin.systems import LJCluster
    #get min1
    system = LJCluster(natoms)
    pot, database = getSetOfMinLJ(system)
    #    from pygmin.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)
示例#9
0
# 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("pygmin.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"
示例#10
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("pygmin.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"