예제 #1
0
    def constructIsing2D(self, theta):
        '''construct a sparse representation of an ising spin glass
        problem with basis spin directions given by nx, nz'''

        h, J, gam = self.h, self.J, self.gam

        nx = np.cos(theta)
        nz = np.sin(theta)

        # compute prefactors for simple terms
        _gam = gam*nz + h*nx
        _h = -gam*nx + h*nz

        # compute prefactors for complex terms
        _chi = J*np.outer(nx, nx)
        _J = J*np.outer(nz, nz)
        _Gam = J*np.outer(nx, nz)

        # standard Ising components
        Hx = -core.comp_Ha(_gam, 'x')
        Hz = core.comp_Hz(_h, _J)

        # compute additional off-diagonal components
        Hxx = core.comp_Hab(_chi, 'x', 'x')
        Hxz = core.comp_Hab(_Gam, 'x', 'z')

        Hs = Hx + Hxx - Hxz + sp.diags(Hz,0)

        return Hs
예제 #2
0
    def constructIsing3D(self, theta):
        '''construct a sparse representation of an ising spin glass problem
        with basis spin directions specified by euler angles'''

        N, h, J, gam = self.N, self.h, self.J, self.gam
        nx, ny, nz = [np.zeros([N,3], dtype=float) for _ in range(3)]

        # convert euler angles to basis vectors
        for i in range(N):
            R = eulerToRot(*theta[3*i:3*(i+1)])
            nx[i,:] = R[:,0]
            ny[i,:] = R[:,1]
            nz[i,:] = R[:,2]

        # compute prefactors for linear terms
        _gam = gam*nx[:,0] - h*nx[:,2]
        _mu = gam*ny[:,0] - h*ny[:,2]
        _h = h*nz[:,2] - gam*nz[:,0]

        # compute prefactors for quadratic terms
        _Jx = J*np.outer(nx[:,2], nx[:,2])
        _Jy = J*np.outer(ny[:,2], ny[:,2])
        _Jz = J*np.outer(nz[:,2], nz[:,2])

        _Gxy = J*np.outer(nx[:,2], ny[:,2])
        _Gyz = J*np.outer(ny[:,2], nz[:,2])
        _Gxz = J*np.outer(nx[:,2], nz[:,2])

        # construct Hamiltonian
        Hs = sp.diags(core.comp_Hz(_h, _Jz))
        Hs -= core.comp_Ha(_gam, 'x')
        Hs -= core.comp_Ha(_mu, 'y')

        # compute additional off-diagonal components
        Hs += core.comp_Hab(_Jx, 'x', 'x')
        Hs += core.comp_Hab(_Jy, 'y', 'y')

        Hs += core.comp_Hab(_Gxy, 'x', 'y')
        Hs += core.comp_Hab(_Gyz, 'y', 'z')
        Hs += core.comp_Hab(_Gxz, 'x', 'z')

        return Hs