Exemple #1
0
def AKLT(L, pbc=False):
    '''  S1 * S1 + 1/3 (S1 * S1)^2 '''

    print "\n--> Construct the Hamiltonian for the AKLT model of size L=%d ..." % L

    store = [[None, None, None, None, None, None, None] for i in range(L + 1)]
    store[1][0] = op.spin1_x().times(0)
    store[1][1] = op.spin1_x()
    store[1][2] = op.spin1_x()
    store[1][3] = op.spin1_y()
    store[1][4] = op.spin1_y()
    store[1][5] = op.spin1_z()
    store[1][6] = op.spin1_z()

    def iterate(l):
        if store[l] != store[0]: return store[l]

        le = int(l / 2)
        lH, llx, lrx, lly, lry, llz, lrz = iterate(le)
        rH, rlx, rrx, rly, rry, rlz, rrz = iterate(l - le)

        lid = lH.identity()
        rid = rH.identity()
        store[l][0] = lH.kron(rid)
        temp = lid.kron(rH)
        store[l][0].plus(temp)
        temp = lrx.kron(rlx)
        temp.plus(lry.kron(rly))
        temp.plus(lrz.kron(rlz))
        store[l][0].plus(temp)
        store[l][0].plus(temp.mult(temp).times(1 / 3.))
        store[l][1] = llx.kron(rid)
        store[l][2] = lid.kron(rrx)
        store[l][3] = lly.kron(rid)
        store[l][4] = lid.kron(rry)
        store[l][5] = llz.kron(rid)
        store[l][6] = lid.kron(rrz)
        return store[l]

    H, lx, rx, ly, ry, lz, rz = iterate(L)
    if pbc:
        edge = lx.mult(rx)
        edge.plus(ly.mult(ry))
        edge.plus(lz.mult(rz))
        H.plus(edge)
        H.plus(edge.mult(edge).times(1. / 3))
    print "--> Hamiltonian constructed."
    H.basis = op.basis(3)
    H.L = L
    return H
Exemple #2
0
def Potts_n(L, n=3, J=1., h=1., theta=0., phi=0., pbc=False):
    ''' - J * Sz * Sz * e^{i theta} + h.c. - h * Sx * e^{i phi}'''

    print "\n--> Construct the Hamiltonian for the %d-Potts model of size L=%d ..." % (
        n, L)

    store = [[None, None, None] for i in range(L + 1)]
    store[1][0] = op.tau_n(n).times(-h / 2 * (np.cos(phi) + 1j * np.sin(phi)))
    store[1][1] = op.sigma_n(n)
    store[1][2] = op.sigma_n(n).hermitian().times(
        -J * (np.cos(theta) + 1j * np.sin(theta)))

    def iterate(l):
        if store[l] != store[0]: return store[l]

        le = int(l / 2)
        lH, llo, lro = iterate(le)
        rH, rlo, rro = iterate(l - le)

        lid = lH.identity()
        rid = rH.identity()
        store[l][0] = lH.kron(rid)
        temp = lid.kron(rH)
        store[l][0].plus(temp)
        store[l][0].plus(lro.kron(rlo))
        store[l][1] = llo.kron(rid)
        store[l][2] = lid.kron(rro)
        return store[l]

    H, lo, ro = iterate(L)
    if pbc:
        edge = operator(L, [store[1][1], store[1][2]], [0, L - 1])
        edge.times(-J)
        H.plus(edge)
    temp = H.hermitian()
    H.plus(temp)
    print "--> Hamiltonian constructed."
    H.basis = op.basis(n)
    H.L = L
    return H
Exemple #3
0
def Kitaev(L, t=1., u=1., d=1., pbc=False):
    ''' - t * c^d * c + 2u * n + d * c * c
		= ( -t * c^d + d * c) * c + h.c. + 2u * n '''
    print "\n--> Construct the Hamiltonian for the Kitaev model of size L=%d ..." % (
        L)

    store = [[None, None, None] for i in range(L + 1)]
    store[1][0] = op.fermion_c().hermitian().mult(op.fermion_c()).times(u)
    store[1][1] = op.fermion_c().hermitian().times(-t).plus(
        op.fermion_c().times(d))
    store[1][2] = op.fermion_c()

    def iterate(l):
        if store[l] != store[0]: return store[l]

        le = int(l / 2)
        lH, llo, lro = iterate(le)
        rH, rlo, rro = iterate(l - le)

        lid = lH.identity()
        rid = rH.identity()
        store[l][0] = lH.kron(rid)
        temp = lid.kron(rH)
        store[l][0].plus(temp)
        store[l][0].plus(lro.kron(rlo))
        store[l][1] = llo.kron(rid)
        store[l][2] = lid.kron(rro)
        return store[l]

    H, lo, ro = iterate(L)
    if pbc:
        edge = operator(L, [store[1][1], store[1][2]], [0, L - 1])
        edge.times(-d)
        H.plus(edge)
    temp = H.hermitian()
    H.plus(temp)
    print "--> Hamiltonian constructed."
    H.basis = op.basis(2)
    H.L = L
    return H
Exemple #4
0
def SSH(L, t=1., d=1., pbc=False):
    ''' - (t-d) * c^d * c - (t+d) * c^d * c '''

    print "\n--> Construct the Hamiltonian for the SSH model of size L=%d ..." % (
        L)

    ope_z = op.fermion_c().times(0.0)
    ope_c = op.fermion_c()
    ope_cd = op.fermion_c().hermitian()

    def iterate(a, b):

        if a == b: return [ope_z, ope_c, ope_cd]

        ab = a + int((b - a + 1) / 2)
        lH, llo, lro = iterate(a, ab - 1)
        rH, rlo, rro = iterate(ab, b)

        lid = lH.identity()
        rid = rH.identity()
        H = lH.kron(rid)
        temp = lid.kron(rH)
        H.plus(temp)
        td = -t + d
        if ab % 2: td = -t - d
        H.plus(lro.kron(rlo).times(td))
        return [H, llo.kron(rid), lid.kron(rro)]

    H, lo, ro = iterate(1, L)
    if pbc:
        edge = operator(L, [ope_cd, ope_c], [0, L - 1])
        edge.times(t + d)
        H.plus(edge)
    temp = H.hermitian()
    H.plus(temp)
    print "--> Hamiltonian constructed."
    H.basis = op.basis(2)
    H.L = L
    return H
nphot0 = 0
tmax = 20
dt = 0.1

# setup basis with ntls spin, each of Hilbert space dimentsion
# 2 and photon with dimension nphot
setup_basis(ntls, 2, nphot)

#run other setup routines
list_equivalent_elements()
setup_convert_rho()
from basis import nspins, ldim_p, ldim_s

#setup inital state and calculate Liouvillian
L = setup_Dicke(omega, omega0, U, g, gp, kappa, gam_phi, gam_dn, 3)
initial = setup_rho(basis(ldim_p, nphot0), basis(ldim_s, 1))
print "setup L"

#operators to calculate expectation values for
na = tensor(create(ldim_p) * destroy(ldim_p), qeye(ldim_s))
sz = tensor(qeye(ldim_p), sigmaz())

#propagate
t0 = time()
resultscomp = time_evolve(L, initial, tmax, dt, [na, sz])
tf = time() - t0

print "Time evollution complete"
print tf

#plot time evolution
Exemple #6
0
def FK(L=8, sec=0, t1=1., t2=1.0, f0=1., f1=1., pbc=False):
	''' see the paper for Hamiltonian
		hopping t: i c^d c
		f0: -(2n-1)(2n-1)
		f1: -4(n+n-1)(n+n-1) + 8(cccc+h.c.) '''
	if L not in [1,2,4,8]:
		raise Exception("Illegal L value")
	print "\n--> Construct the Hamiltonian for the FK model of size L=%d ..." % (L)

	n_up = op.fermion_up4().hermitian().mult( op.fermion_up4() )
	n_down = op.fermion_down4().hermitian().mult( op.fermion_down4() )
	pp = op.fermion_up4().mult( op.fermion_down4() )	# cc
	ide = n_up.identity()
	n2_up = n_up.copy().times(-2).plus( ide )		# 1-2n
	n2_down = n_down.copy().times(-2).plus( ide )	# 1-2n
	nn = n2_up.copy().plus(n2_down)		# 2(1-n-n)
	mH = n2_up.mult( n2_down ).times(-f0/2.)
	if L==1:
		H = mH.hermitian().plus(mH)
	 	H.L = 1
	 	H.basis = op.basis(4)
		return H

	# the 2-stie ham with the hopping t1 and onsite-interaction f0
	H2 = op.fermion_up4().hermitian().kron( op.fermion_up4() )
	H2.plus( op.fermion_down4().hermitian().kron( op.fermion_down4() ) )
	H2.times( 2.j*float(t1) )
	H2.plus( mH.kron(ide).plus( ide.kron(mH) ) )
	if L==2:
		H = H2.hermitian().plus(H2)
	 	H.L = 1
	 	H.basis = op.basis(4)
		return H

	# the 4 site ham with interaction f1 and hopping t2
	H4 = ham.operator(4, [op.fermion_up4().hermitian(), op.fermion_up4()], [1,3])
	H4.plus( ham.operator(4, [op.fermion_down4().hermitian(), op.fermion_down4()], [1,3]) )
	H4.times( 2.j*float(t2) )
	ide = H2.identity()
	H4.plus( H2.kron(ide).plus( ide.kron(H2) ) )
	H4.plus( ham.operator(4, [nn, nn], [1,2]).times(-f1/2.) )
	H4.plus( ham.operator(4, [pp, pp], [1,2]).times(f1*8.) )

	if L==4:
		H = H4.hermitian().plus(H4)
	 	H.L = 1
	 	H.basis = op.basis(4)
		return H

	def kron_s(A, B, sec):
		fp = A.fparity
		ss = A.sym_sum
		sym = A.sym
		dim = sym * A.dim * B.dim
		ret = csr((dim, dim), dtype=np.complex)
		for row1 in range(sym):
			for col1 in range(sym):
				row2 = ss(sec, -row1)
				col2 = ss(sec, -col1)
				if not A._empty_(row1, col1) and not B._empty_(row2, col2):
					sign = 1 - 2*( fp[col1] * fp[ss(col2, -row2)] )
					temp = coo( sparse.kron(A.val[row1][col1], B.val[row2][col2]) * sign )
					block = A.dim * B.dim
					add = coo((temp.data, (temp.row + row1*block, temp.col + col1*block)),(dim, dim), dtype=np.complex)
					ret += add
		return ret

	# the 8 site ham
	lup = ham.operator(4, [op.fermion_up4().hermitian()], [2])
	rup = ham.operator(4, [op.fermion_up4()], [0])
	ldown = ham.operator(4, [op.fermion_down4().hermitian()], [2])
	rdown = ham.operator(4, [op.fermion_down4()], [0])
	ide = H4.identity()
	ln = ham.operator(4, [nn], [3])
	rn = ham.operator(4, [nn], [0])
	lp = ham.operator(4, [pp], [3])
	rp = ham.operator(4, [pp], [0])

	Hs = coo((16384, 16384), dtype=np.complex)
	Hs += kron_s(lup, rup, sec)
	Hs += kron_s(ldown, rdown, sec)
	Hs *= 2.j*float(t2)
	Hs += kron_s(H4, ide, sec)
	Hs += kron_s(ide, H4, sec)
	Hs += kron_s(ln, rn, sec)*(-f1/2.)
	Hs += kron_s(lp, rp, sec)*(f1*8.)

	if pbc:
		edge = kron_s(rup,lup, sec)
		edge += kron_s(rdown, ldown, sec)
		edge *= -2.j*float(t2)
		Hs += edge
		Hs += kron_s(rn, ln, sec)*(-f1/2.)
		Hs += kron_s(rp, lp, sec)*(f1*8.)

	Hs += Hs.conjugate().transpose()
	print "--> Hamiltonian constructed."
	return Hs
Exemple #7
0
			H = FK(L=8, sec=sec, t1=t1, t2=t2, f0=f0, f1=f1, pbc=pbc)
			evals, evecs = eigsh(H, which='SA')
			arg = np.argsort(evals)
			evals_all.append( evals[arg] )
			evecs_all.append( evecs[:,arg] )
		return np.array(evals_all), np.array(evecs_all)

	H = FK(L=L, sec=0, t1=t1, t2=t2, f0=f0, f1=f1, pbc=pbc)
	for sec in range(0,4):
	 	D, U = eigh(H.val[sec][sec].todense())
		evals_all.append(D)
		evecs_all.append(U)
	return np.array(evals_all), np.array(evecs_all)

L = 8
basis = ham.basis(L, op.basis(4), op.fermion_up4().sym_sum)
evals, evecs = FK_eig(L=L, t1=1.0, t2=1., f0=0.25, f1=0.25, pbc=True)
print evals[:,:5]

sec = 0
rho = func.reduced_density_matrix(evecs[sec,:,0], basis[sec], 4, 4)
u, d, v = svd(rho)
ee = -np.sum(d**2 * np.log( d**2) )
print "Entanglement entropy:", ee, "or", ee/np.log(2), "ln2"
rho = func.reduced_density_matrix(evecs[sec,:,1], basis[sec], 4, 4)
u, d, v = svd(rho)
ee = -np.sum(d**2 * np.log( d**2) )
print "Entanglement entropy:", ee, "or", ee/np.log(2), "ln2"
sec = 3
rho = func.reduced_density_matrix(evecs[sec,:,0], basis[sec], 4, 4)
u, d, v = svd(rho)
Exemple #8
0
def FK(L=8, sec=0, t1=1., t2=1.0, f0=1., f1=1., pbc=False):
    ''' see the paper for Hamiltonian
		hopping t: i c^d c
		f0: -(2n-1)(2n-1)
		f1: -4(n+n-1)(n+n-1) + 8(cccc+h.c.) '''
    if L not in [1, 2, 4, 8]:
        raise Exception("Illegal L value")
    print "\n--> Construct the Hamiltonian for the FK model of size L=%d ..." % (
        L)

    n_up = op.fermion_up4().hermitian().mult(op.fermion_up4())
    n_down = op.fermion_down4().hermitian().mult(op.fermion_down4())
    pp = op.fermion_up4().mult(op.fermion_down4())  # cc
    ide = n_up.identity()
    n2_up = n_up.copy().times(-2).plus(ide)  # 1-2n
    n2_down = n_down.copy().times(-2).plus(ide)  # 1-2n
    nn = n2_up.copy().plus(n2_down)  # 2(1-n-n)
    mH = n2_up.mult(n2_down).times(-f0 / 2.)
    if L == 1:
        H = mH.hermitian().plus(mH)
        H.L = 1
        H.basis = op.basis(4)
        return H

    # the 2-stie ham with the hopping t1 and onsite-interaction f0
    H2 = op.fermion_up4().hermitian().kron(op.fermion_up4())
    H2.plus(op.fermion_down4().hermitian().kron(op.fermion_down4()))
    H2.times(2.j * float(t1))
    H2.plus(mH.kron(ide).plus(ide.kron(mH)))
    if L == 2:
        H = H2.hermitian().plus(H2)
        H.L = 1
        H.basis = op.basis(4)
        return H

    # the 4 site ham with interaction f1 and hopping t2
    H4 = ham.operator(4, [op.fermion_up4().hermitian(),
                          op.fermion_up4()], [1, 3])
    H4.plus(
        ham.operator(4, [op.fermion_down4().hermitian(),
                         op.fermion_down4()], [1, 3]))
    H4.times(2.j * float(t2))
    ide = H2.identity()
    H4.plus(H2.kron(ide).plus(ide.kron(H2)))
    H4.plus(ham.operator(4, [nn, nn], [1, 2]).times(-f1 / 2.))
    H4.plus(ham.operator(4, [pp, pp], [1, 2]).times(f1 * 8.))

    if L == 4:
        H = H4.hermitian().plus(H4)
        H.L = 1
        H.basis = op.basis(4)
        return H

    def kron_s(A, B, sec):
        fp = A.fparity
        ss = A.sym_sum
        sym = A.sym
        dim = sym * A.dim * B.dim
        ret = csr((dim, dim), dtype=np.complex)
        for row1 in range(sym):
            for col1 in range(sym):
                row2 = ss(sec, -row1)
                col2 = ss(sec, -col1)
                if not A._empty_(row1, col1) and not B._empty_(row2, col2):
                    sign = 1 - 2 * (fp[col1] * fp[ss(col2, -row2)])
                    temp = coo(
                        sparse.kron(A.val[row1][col1], B.val[row2][col2]) *
                        sign)
                    block = A.dim * B.dim
                    add = coo(
                        (temp.data,
                         (temp.row + row1 * block, temp.col + col1 * block)),
                        (dim, dim),
                        dtype=np.complex)
                    ret += add
        return ret

    # the 8 site ham
    lup = ham.operator(4, [op.fermion_up4().hermitian()], [2])
    rup = ham.operator(4, [op.fermion_up4()], [0])
    ldown = ham.operator(4, [op.fermion_down4().hermitian()], [2])
    rdown = ham.operator(4, [op.fermion_down4()], [0])
    ide = H4.identity()
    ln = ham.operator(4, [nn], [3])
    rn = ham.operator(4, [nn], [0])
    lp = ham.operator(4, [pp], [3])
    rp = ham.operator(4, [pp], [0])

    Hs = coo((16384, 16384), dtype=np.complex)
    Hs += kron_s(lup, rup, sec)
    Hs += kron_s(ldown, rdown, sec)
    Hs *= 2.j * float(t2)
    Hs += kron_s(H4, ide, sec)
    Hs += kron_s(ide, H4, sec)
    Hs += kron_s(ln, rn, sec) * (-f1 / 2.)
    Hs += kron_s(lp, rp, sec) * (f1 * 8.)

    if pbc:
        edge = kron_s(rup, lup, sec)
        edge += kron_s(rdown, ldown, sec)
        edge *= -2.j * float(t2)
        Hs += edge
        Hs += kron_s(rn, ln, sec) * (-f1 / 2.)
        Hs += kron_s(rp, lp, sec) * (f1 * 8.)

    Hs += Hs.conjugate().transpose()
    print "--> Hamiltonian constructed."
    return Hs
Exemple #9
0
            evals, evecs = eigsh(H, which='SA')
            arg = np.argsort(evals)
            evals_all.append(evals[arg])
            evecs_all.append(evecs[:, arg])
        return np.array(evals_all), np.array(evecs_all)

    H = FK(L=L, sec=0, t1=t1, t2=t2, f0=f0, f1=f1, pbc=pbc)
    for sec in range(0, 4):
        D, U = eigh(H.val[sec][sec].todense())
        evals_all.append(D)
        evecs_all.append(U)
    return np.array(evals_all), np.array(evecs_all)


L = 8
basis = ham.basis(L, op.basis(4), op.fermion_up4().sym_sum)
evals, evecs = FK_eig(L=L, t1=1.0, t2=1., f0=0.25, f1=0.25, pbc=True)
print evals[:, :5]

sec = 0
rho = func.reduced_density_matrix(evecs[sec, :, 0], basis[sec], 4, 4)
u, d, v = svd(rho)
ee = -np.sum(d**2 * np.log(d**2))
print "Entanglement entropy:", ee, "or", ee / np.log(2), "ln2"
rho = func.reduced_density_matrix(evecs[sec, :, 1], basis[sec], 4, 4)
u, d, v = svd(rho)
ee = -np.sum(d**2 * np.log(d**2))
print "Entanglement entropy:", ee, "or", ee / np.log(2), "ln2"
sec = 3
rho = func.reduced_density_matrix(evecs[sec, :, 0], basis[sec], 4, 4)
u, d, v = svd(rho)