Beispiel #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)
Beispiel #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)
Beispiel #3
0
 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)
Beispiel #4
0
 def setUp(self):
     self.pot = XYModel(dim=[L, L], phi=0, periodic=True)
     self.x0 = _x0_xy
     self.e0 = -0.08896226597510098
Beispiel #5
0
 def setUp(self):
     self.pot = XYModel(dim=[L, L], phi=0, periodic=False, phases=None)
     self.x0 = _x0_xy
     self.e0 = -0.6195031129867052
Beispiel #6
0
def printspins(fout, pot, angles):
    nspins = len(angles)
    for node in pot.G.nodes():
        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)
    
Beispiel #7
0
 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)
Beispiel #8
0
    return np.array([cos(a), sin(a)])


def printspins(fout, pot, angles):
    for node in pot.G.nodes():
        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)