Example #1
0
class TestXYModelDisorder(_base_test._TestConfiguration):
    def setUp(self):
        self.pot = XYModel(dim=[L, L], phi=1., periodic=False, phases=phases)
        self.x0 = _x0_xy
        self.e0 = -1.3466543852399337
        self.assertEqual(self.pot.nspins, self.x0.size)

    def test_spin_energies(self):
        e = self.pot.getEnergy(self.x0)
        energies = self.pot.get_spin_energies(self.x0)
        self.assertAlmostEqual(e, energies.sum() / 2, 5)

    def test_python_version(self):
        e, g = self.pot.getEnergyGradient(self.x0)
        e1, g1 = xy_energy_gradient(self.pot, self.x0)
        self.assertAlmostEqual(e, e1, 5)
        self.compare_arrays(g, g1)
Example #2
0
class TestXYModelDisorder(_base_test._TestConfiguration):
    def setUp(self):
        self.pot = XYModel(dim=[L, L], phi=1., periodic=False, phases=phases)
        self.x0 = _x0_xy
        self.e0 = -1.3466543852399337
        self.assertEqual(self.pot.nspins, self.x0.size)

    def test_spin_energies(self):
        e = self.pot.getEnergy(self.x0)
        energies = self.pot.get_spin_energies(self.x0)
        self.assertAlmostEqual(e, energies.sum() / 2, 5)

    def test_python_version(self):
        e, g = self.pot.getEnergyGradient(self.x0)
        e1, g1 = xy_energy_gradient(self.pot, self.x0)
        self.assertAlmostEqual(e, e1, 5)
        self.compare_arrays(g, g1)
Example #3
0
        fout.write("%g %g " % (node[0], node[1]) )
        fout.write("%g %g\n" % (s[0], s[1]) )
        


pi = np.pi
L = 24
nspins = L**2

pot = XYModel( dim = [L,L], phi = np.pi)


angles = np.random.uniform(-pi, pi, nspins)
print angles

e = pot.getEnergy(angles)
print "energy ", e



# try a quench
if False:
    from pele.optimize import mylbfgs
    ret = mylbfgs(angles, pot)
    
    print ret


# set up and run basin hopping

from pele.basinhopping import BasinHopping
Example #4
0
        i = pot.indices[node]
        s = angle2vec(angles[i])
        fout.write("%g %g " % (node[0], node[1]))
        fout.write("%g %g\n" % (s[0], s[1]))


pi = np.pi
L = 24
nspins = L**2

pot = XYModel(dim=[L, L], phi=np.pi)

angles = np.random.uniform(-pi, pi, nspins)
print(angles)

e = pot.getEnergy(angles)
print("energy ", e)

# try a quench
if False:
    from pele.optimize import mylbfgs

    ret = mylbfgs(angles, pot)

    print(ret)

# set up and run basin hopping

from pele.basinhopping import BasinHopping
from pele.takestep.displace import RandomDisplacement
from pele.takestep.adaptive import AdaptiveStepsize