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 guesstsATLJ():
    from pygmin.potentials.ATLJ import ATLJ
    pot = ATLJ(Z = 2.)
    a = 1.12 #2.**(1./6.)
    theta = 60./360*np.pi
    coords1 = np.array([ 0., 0., 0., \
              -a, 0., 0., \
              -a/2, -a*np.cos(theta), 0. ])
    coords2 = np.array([ 0., 0., 0., \
              -a, 0., 0., \
              a, 0., 0. ])
    from pygmin.optimize import lbfgs_py as quench
    from pygmin.transition_states import InterpolatedPath
    ret1 = quench(coords1, pot.getEnergyGradient)
    ret2 = quench(coords2, pot.getEnergyGradient)
    coords1 = ret1[0]
    coords2 = ret2[0]
    from pygmin.transition_states import NEB
    neb = NEB(InterpolatedPath(coords1, coords2, 30), pot)
    neb.optimize()
    neb.MakeAllMaximaClimbing()
    #neb.optimize()
    for i in xrange(len(neb.energies)):
        if(neb.isclimbing[i]):
            coords = neb.coords[i,:]
    return pot, coords
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 guesstsATLJ():
    from pygmin.potentials.ATLJ import ATLJ
    pot = ATLJ(Z=2.)
    a = 1.12  #2.**(1./6.)
    theta = 60. / 360 * np.pi
    coords1 = np.array([ 0., 0., 0., \
              -a, 0., 0., \
              -a/2, -a*np.cos(theta), 0. ])
    coords2 = np.array([ 0., 0., 0., \
              -a, 0., 0., \
              a, 0., 0. ])
    from pygmin.optimize import lbfgs_py as quench
    from pygmin.transition_states import InterpolatedPath
    ret1 = quench(coords1, pot.getEnergyGradient)
    ret2 = quench(coords2, pot.getEnergyGradient)
    coords1 = ret1[0]
    coords2 = ret2[0]
    from pygmin.transition_states import NEB
    neb = NEB(InterpolatedPath(coords1, coords2, 30), pot)
    neb.optimize()
    neb.MakeAllMaximaClimbing()
    #neb.optimize()
    for i in xrange(len(neb.energies)):
        if (neb.isclimbing[i]):
            coords = neb.coords[i, :]
    return pot, coords
Example #5
0
                if(np.linalg.norm(p2n - p1) > np.linalg.norm(p2 - p1)):
                    break
                p2[:]=p2n
                
            while True:
                p2n = p2-n2
                if(np.linalg.norm(p2n - p1) > np.linalg.norm(p2 - p1)):
                    break
                p2[:]=p2n  
            
    defaults.NEBquenchParams["nsteps"]=2000
    defaults.NEBquenchParams["maxErise"]=1e-1
    defaults.NEBquenchParams["tol"]=1e-5
    defaults.NEBquenchParams["iprint"]=1
    defaults.NEBquenchParams["maxstep"]=.1
    neb = NEB(path, pot, k=10., dneb=True, with_springenergy=True)
    neb.optimize()

    path = neb.coords


print np.linalg.norm(path[1] - path[0])

for x in neb.coords:
    export_xyz(traj, x)
    
#np.savetxt("energies.txt", neb.energies)
import pylab as pl
pl.plot(neb.energies)
#pl.plot(e1)
#pl.plot(e2, "x")
Example #6
0
defaults.NEBquenchParams["maxstep"] = 0.1
defaults.NEBquenchParams["maxErise"] = 0.1
defaults.NEBquenchParams["tol"] = 1e-6
defaults.NEBquenchRoutine = mylbfgs
k = 10.
nimages=50
dneb=True

#print coords2[-6:],coords1[-6:]   

path = tip4p.get_path(system, coords1, coords2, nimages)
path_energy = [pot.getEnergy(coords) for coords in path]
# try the old neb
dump_path("interpolate.xyz", system, path)

neb = NEB(path, pot, k=k, dneb=dneb, with_springenergy = False)
neb.optimize()
neb_1 = neb.copy()
dump_path("neb1.xyz", system, neb_1.coords)
neb.optimize()
neb_2 = neb
dump_path("neb2.xyz", system, neb_2.coords)

# try the new neb
aaneb = NEB(path, pot, distance=system.neb_distance, k=k/20., dneb=dneb, with_springenergy = False)
aaneb.optimize()
aaneb_1 = aaneb.copy()
dump_path("aaneb1.xyz", system, aaneb_1.coords)

aaneb.optimize()
aaneb_2 = aaneb
Example #7
0
decp["local_connect_params"]["NEBparams"]["NEBquenchParams"] = NEBquenchParams
decp["local_connect_params"]["NEBparams"][
    "NEBquenchRoutine"] = NEBquenchRoutine

k = 10.
nimages = 50
dneb = True

#print coords2[-6:],coords1[-6:]

path = tip4p.get_path(system, coords1, coords2, nimages)
path_energy = [pot.getEnergy(coords) for coords in path]
# try the old neb
dump_path("interpolate.xyz", system, path)

neb = NEB(path, pot, k=k, dneb=dneb, with_springenergy=False)
neb.optimize()
neb_1 = neb.copy()
dump_path("neb1.xyz", system, neb_1.coords)
neb.optimize()
neb_2 = neb
dump_path("neb2.xyz", system, neb_2.coords)

# try the new neb
aaneb = NEB(path,
            pot,
            distance=system.neb_distance,
            k=k / 20.,
            dneb=dneb,
            with_springenergy=False)
aaneb.optimize()
Example #8
0
def create_NEB(pot,
               coords1,
               coords2,
               image_density=10,
               max_images=40,
               iter_density=15,
               NEBquenchParams=dict(),
               interpolator=None,
               verbose=False,
               factor=1,
               parallel=False,
               ncores=4,
               **NEBparams):
    """
    a wrapper function to do the interpolation and set up the nudged elastic band object
    
    Parameters
    ----------
    image_density : float
        how many NEB images per unit distance to use.
    coords1, coords2 : array
        the structures to connect with the band
    max_images : int
        the maximum number of NEB images
    iter_density : float
    NEBquenchParams : dict
        parameters passed to the NEB minimization routine
    NEBparams : dict
        NEB setup parameters.  These are passed directly to the NEB class.  Use
        NEBquenchParams for parameters related to the optimization of the band.
    verbose : bool
    factor : int
        The number of images is multiplied by this factor.  If the number of 
        images is already at it's maximum, then the number of iterations is 
        multiplied by this factor instead
    parallel : bool
        if True, then use class NEBPar to evaluate the image potentials in parallel
    ncores : int
        the number of cores to use.  Ignored if parallel is False
    interpolator : callable, optional
        the function used to do the path interpolation for the NEB
    
    Returns
    -------
    neb : an initialized NEB object
    
    See Also
    ---------
    NEB
    InterpolatedPath
    """
    #determine the number of images to use
    dist = np.linalg.norm(coords1 - coords2)
    nimages = int(max(1., dist) * image_density * factor)
    if nimages > max_images:
        nimages = max_images

    #determine the number of iterations
    NEBquenchParams = NEBquenchParams.copy()
    if NEBquenchParams.has_key("nsteps"):
        niter = NEBquenchParams["nsteps"]
    else:
        niter = int(iter_density * nimages)
        NEBquenchParams["nsteps"] = niter

    #if nimages is already max_images then increasing the number
    #of images with factor will have no effect.  so double the number of steps instead
    if factor > 1. and nimages == max_images:
        niter *= factor
        NEBquenchParams["nsteps"] = niter

    if verbose:
        print "    NEB: nimages", nimages
        print "    NEB: nsteps ", niter

    if parallel:
        return NEBPar(InterpolatedPath(coords1,
                                       coords2,
                                       nimages,
                                       interpolator=interpolator),
                      pot,
                      quenchParams=NEBquenchParams,
                      ncores=ncores,
                      **NEBparams)
    else:
        return NEB(InterpolatedPath(coords1,
                                    coords2,
                                    nimages,
                                    interpolator=interpolator),
                   pot,
                   quenchParams=NEBquenchParams,
                   **NEBparams)
Example #9
0
            while True:
                p2n = p2 - n2
                if (np.linalg.norm(p2n - p1) > np.linalg.norm(p2 - p1)):
                    break
                p2[:] = p2n

    NEBquenchParams = dict()
    NEBquenchParams["nsteps"] = 2000
    NEBquenchParams["maxErise"] = 1e-1
    NEBquenchParams["tol"] = 1e-5
    NEBquenchParams["iprint"] = 1
    NEBquenchParams["maxstep"] = .1
    neb = NEB(path,
              pot,
              k=10.,
              dneb=True,
              with_springenergy=True,
              quenchParams=NEBquenchParams)
    neb.optimize()

    path = neb.coords

print np.linalg.norm(path[1] - path[0])

for x in neb.coords:
    export_xyz(traj, x)

#np.savetxt("energies.txt", neb.energies)
import pylab as pl
pl.plot(neb.energies)
#pl.plot(e1)