Created
December 12, 2017 10:02
-
-
Save rakhuba/0d6996a3283c3e073c445bed22f63ca5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function, absolute_import, division | |
from six.moves import xrange | |
import sys | |
import tt | |
import numpy as np | |
from tt.eigb import eigb | |
import time | |
import copy | |
""" Compute minimal eigenvalues for the Heisenberg model """ | |
def gen_1d(mat,e,i,d): | |
w = mat | |
for j in range(i): | |
w = tt.kron(e,w) | |
for j in range(d-i-1): | |
w = tt.kron(w,e) | |
return w | |
def gen_heisen(d, Jx=0.5, Jz=0.5): | |
sx = [[0,1], [1,0]] | |
sx = np.array(sx,dtype=np.float) | |
sz = [[1,0], [0,-1]] | |
sz = np.array(sz,dtype=np.float) | |
sz = 0.5 * sz | |
sp = [[0,1], [0,0]]; sp = np.array(sp, dtype=np.float) | |
sm = sp.T | |
e = np.eye(2) | |
sx = tt.matrix(sx,1e-12) | |
sz = tt.matrix(sz,1e-12) | |
sp = tt.matrix(sp,1e-12) | |
sm = tt.matrix(sm,1e-12) | |
e = tt.matrix(e,1e-12) | |
#Generate ssx, ssz | |
ssp = [gen_1d(sp, e, i, d) for i in range(d)] | |
ssz = [gen_1d(sz, e, i, d) for i in range(d)] | |
ssm = [gen_1d(sm, e, i, d) for i in range(d)] | |
ssx = [gen_1d(sx, e, i, d) for i in range(d)] | |
A = None | |
Mx = None | |
for i in range(d-1): | |
A = A + Jx * (ssp[i] * ssm[i+1] + ssm[i] * ssp[i+1]) + Jz * (ssz[i] * ssz[i+1]) | |
A = A.round(1e-8) | |
Mx = Mx + 0.5 * ssx[i] | |
Mx = Mx.round(1e-8) | |
A = A + Jx * (ssp[d-1] * ssm[0] + ssm[d-1] * ssp[0]) + Jz * (ssz[d-1] * ssz[0]) | |
A = A.round(1e-8) | |
Mx = Mx + 0.5 * ssx[d-1] | |
Mx = Mx.round(1e-8) | |
return A, Mx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment