Exemple #1
0
 def test1(self):
     system = LJCluster(6)
     ss0 = 1.
     displace = RandomDisplacement(stepsize=ss0)
     ts = AdaptiveStepsizeTemperature(displace, interval=10)
     bh = system.get_basinhopping(takestep=ts)
     bh.run(9)
     self.assertAlmostEqual(displace.stepsize, ss0, 10)
     bh.run(2)
     self.assertNotAlmostEqual(displace.stepsize, ss0, 1)
Exemple #2
0
 def get_takestep(self, **kwargs):
     """return the takestep object for use in basinhopping, etc.
     
     Notes
     -----
     default is random displacement with adaptive step size and
     adaptive temperature
     
     See Also
     --------
     pele.takestep
     """
     kwargs = dict_copy_update(self.params["takestep"], kwargs)
     try:
         stepsize = kwargs.pop("stepsize")
     except KeyError:
         stepsize = 0.6
     takeStep = RandomDisplacement(stepsize=stepsize)
     tsAdaptive = AdaptiveStepsizeTemperature(takeStep, **kwargs)
     return tsAdaptive
Exemple #3
0
def bh_no_system_class():
    import numpy as np
    from pele.potentials import LJ
    natoms = 17
    potential = LJ()
    x0 = np.random.uniform(-1, 1, 3*natoms)
    
    from pele.takestep import RandomDisplacement, AdaptiveStepsizeTemperature
    displace = RandomDisplacement()
    adaptive_displacement = AdaptiveStepsizeTemperature(displace)
    
    from pele.storage import Database
    database = Database("lj17.sqlite")
    
    from pele.basinhopping import BasinHopping
    bh = BasinHopping(x0, potential, adaptive_displacement, storage=database.minimum_adder)
    bh.run(10)
    
    for m in database.minima():
        print m.energy
Exemple #4
0
    def test_BH(self, db, nsteps):

        self.potential = self.get_potential()

        from pele.takestep import RandomDisplacement, AdaptiveStepsizeTemperature

        takeStepRnd = RandomDisplacement(stepsize=2)
        tsAdaptive = AdaptiveStepsizeTemperature(takeStepRnd,
                                                 interval=10,
                                                 verbose=True)

        self.params.basinhopping["temperature"] = 10.0

        # todo - how do you save N lowest?

        bh = self.get_basinhopping(database=db, takestep=takeStepRnd)
        bh = self.get_basinhopping(database=db, takestep=tsAdaptive)

        print 'Running BH .. '
        bh.run(nsteps)

        print "Number of minima found = ", len(db.minima())
        min0 = db.minima()[0]
        print "lowest minimum found has energy = ", min0.energy
Exemple #5
0
"""
Example 4: modify the parameters of the adaptive stepsize
note that the system class uses adaptive stepsize by default, 
so the previous examples also use adaptive stepsize
"""
from __future__ import print_function
from pele.systems import LJCluster
from pele.takestep import RandomDisplacement, AdaptiveStepsizeTemperature

natoms = 12
niter = 100
system = LJCluster(natoms)

db = system.create_database()

# create takestep routine manually
step = RandomDisplacement(stepsize=0.3)
# wrap it in the class which will adaptively improve the stepsize
wrapped_step = AdaptiveStepsizeTemperature(step, interval=30)

bh = system.get_basinhopping(database=db, takestep=wrapped_step)
bh.run(niter)
print("the lowest energy found after", niter, " basinhopping steps is", db.minima()[0].energy)
print("")