def test_fct(a, A): X = peps.make_double_layer(a, o=gates.sigmax) Z = peps.make_double_layer(a, o=gates.sigmaz) def test_fct_impl(e): e1 = e.get_site_environment() mx = e1.contract(X) / e1.contract(A) e2 = e.get_bond_environment() czz = e2.contract(Z, Z) / e2.contract(A, A) return -2*czz - h*mx return test_fct_impl
def get_energy(a, returnmz=False): global env a = get_symm_tensor(a) A = peps.make_double_layer(a) tester = ctm.CTMRGGenericTester(test_fct(a, A), 1e-9) env = ctm.ctmrg_1x1_hermitian(A, chi, env, tester) E = tester.get_value() if returnmz: e = env.get_site_environment() Z = peps.make_double_layer(a, o=gates.sigmaz) mz = e.contract(Z) / e.contract(A) return E, mz return E
def test_fct(a, A): n = len(a) Z = map(lambda b: peps.make_double_layer(b, o=gates.sigmaz), a) AT = map(lambda B: B.transpose([1, 2, 3, 0]), A) ZT = map(lambda B: B.transpose([1, 2, 3, 0]), Z) X = map(lambda b: peps.make_double_layer(b, o=gates.sigmax), a) Y = map(lambda b: peps.make_double_layer(b, o=gates.sigmay), a) XT = map(lambda B: B.transpose([1, 2, 3, 0]), X) YT = map(lambda B: B.transpose([1, 2, 3, 0]), Y) def test_fct_impl(e): c_zz = 0 c_xx = 0 c_yy = 0 mz = [0, 0] for j in xrange(n): e1 = e.get_site_environment(j) mz[j] = e1.contract(Z[j]) / e1.contract(A[j]) e2 = e.get_bond_environment_horizontal(j) norm = e2.contract(A[j], A[lut[j, 1, 0]]) c_xx += e2.contract(X[j], X[lut[j, 1, 0]]) / norm c_yy += np.real(e2.contract(Y[j], Y[lut[j, 1, 0]]) / norm) c_zz += e2.contract(Z[j], Z[lut[j, 1, 0]]) / norm e2 = e.get_bond_environment_vertical(j) norm = e2.contract(AT[j], AT[lut[j, 0, 1]]) c_xx += e2.contract(XT[j], XT[lut[j, 0, 1]]) / norm c_yy += np.real(e2.contract(YT[j], YT[lut[j, 0, 1]]) / norm) c_zz += e2.contract(ZT[j], ZT[lut[j, 0, 1]]) / norm c_xx /= 2 * n c_yy /= 2 * n c_zz /= 2 * n E = 2 * J * (c_xx + c_yy + c_zz) + h * 0.5 * (mz[0] + mz[1]) return mz + [c_xx, c_yy, c_zz, E] return test_fct_impl
def test_fct(a, A): n = len(a) X = map(lambda b: peps.make_double_layer(b, o=gates.sigmax), a) Z = map(lambda b: peps.make_double_layer(b, o=gates.sigmaz), a) AT = map(lambda B: B.transpose([1,2,3,0]), A) ZT = map(lambda B: B.transpose([1,2,3,0]), Z) def test_fct_impl(e): mx = 0 mz = 0 czz = 0 S = 0 # some pseudo entanglement entropy for j in xrange(n): e1 = e.get_site_environment(j) norm = e1.contract(A[j]) mx += e1.contract(X[j]) / norm mz += e1.contract(Z[j]) / norm e2 = e.get_bond_environment_horizontal(j) norm = e2.contract(A[j], A[lut[j,1,0]]) czz += e2.contract(Z[j], Z[lut[j,1,0]]) / norm e2 = e.get_bond_environment_vertical(j) norm = e2.contract(AT[j], AT[lut[j,0,1]]) czz += e2.contract(ZT[j], ZT[lut[j,0,1]]) / norm w1 = np.dot(e.c1[j], e.c2[lut[j,1,0]]) w2 = np.dot(e.c3[lut[j,1,1]], e.c4[lut[j,0,1]]) xi = np.linalg.svd(np.dot(w1, w2))[1] xi = xi[np.nonzero(xi)] S += np.dot(xi**2, np.log(xi)) E = (-czz - h*mx) / n mz /= n return [mz, S, E] return test_fct_impl
def get_energy(a, returnmz=False): global env a = get_symm_tensor(a) A = peps.make_double_layer(a) f = test_fct(a, A) tester = ctm.CTMRGGenericTester(f, 1e-12) #env = ctm.ctmrg([A], lut, chi, env, tester) #env = ctm.ctmrg_1x1_rotsymm(A, chi, env, tester) env = ctm.ctmrg_1x1_hermitian(A, chi, env, tester) #env2 = ctm.CTMEnvironment(lut, env.c, env.c, env.c, env.c, env.t1, env.t2, env.t1, env.t2) #tester = ctm.CTMRGGenericTester(f, 1e-8) #env2 = ctm.ctmrg([A], lut, chi, env2, tester) E = tester.get_value() if returnmz: e = env.get_site_environment() Z = peps.make_double_layer(a, o=gates.sigmaz) mz = e.contract(Z) / e.contract(A) return E, mz return E
def correlation_fct(component): X = map(lambda b: peps.make_double_layer(b, o=sigma[component]), a) mx = m[component] tmp = tdot(env.c4[lut[0,-1,-1]], env.t4[lut[0,-1,0]], [1,0]) tmp = tdot(tmp, env.c1[lut[0,-1,1]], [2,0]) tmp = tdot(tmp, env.t3[lut[0,0,-1]], [0,2]) tmp2 = tdot(tmp, X[0], [[3,0],[2,3]]) uX = tdot(tmp2, env.t1[lut[0,0,1]], [[0,2],[0,1]]).flatten() tmp2 = tdot(tmp, A[0], [[3,0],[2,3]]) uA = tdot(tmp2, env.t1[lut[0,0,1]], [[0,2],[0,1]]).flatten() vX = [None]*n vA = [None]*n for j in xrange(n): tmp = tdot(env.c3[lut[j,1,-1]], env.t2[lut[j,1,0]], [0,2]) tmp = tdot(tmp, env.c2[lut[j,1,1]], [1,1]) tmp = tdot(tmp, env.t3[lut[j,0,-1]], [0,0]) tmp2 = tdot(tmp, X[j], [[0,2],[1,2]]) vX[j] = tdot(tmp2, env.t1[lut[j,0,1]], [[0,2],[2,1]]).flatten() tmp2 = tdot(tmp, A[j], [[0,2],[1,2]]) vA[j] = tdot(tmp2, env.t1[lut[j,0,1]], [[0,2],[2,1]]).flatten() M = [None]*n for j in xrange(n): tmp = tdot(env.t3[lut[j,0,-1]], A[j], [1,2]) tmp = tdot(tmp, env.t1[lut[j,0,1]], [2,1]) M[j] = tmp.transpose([1,3,4,0,2,5]).reshape(len(vX[lut[j,-1,0]]), len(vX[lut[j,1,0]])) res = np.empty(Lmax+1) j = lut[0,1,0] for L in xrange(Lmax+1): print L res[L] = np.dot(uX, vX[j]) / np.dot(uA, vA[j]) - mx[0]*mx[j] if L < Lmax: uX = np.dot(uX, M[j]) uA = np.dot(uA, M[j]) j = nns[0][j] return res
outfile = sys.argv[2] chi = int(sys.argv[3]) Lmax = int(sys.argv[4]) def test_fct(e): mz = [0]*n for j in xrange(n): e1 = e.get_site_environment(j) mz[j] = e1.contract(Z[j]) / e1.contract(A[j]) return mz a, nns = peps.load(statefile) n = len(a) lut = util.build_lattice_lookup_table(nns, [4,4]) A = map(peps.make_double_layer, a) Z = map(lambda b: peps.make_double_layer(b, o=gates.sigmaz), a) tester = ctm.CTMRGTester(test_fct, 1e-12, 1e-15) env = ctm.ctmrg(A, lut, chi, "random", tester) m = np.empty((3, n)) sigma = [gates.sigmax, np.imag(gates.sigmay), gates.sigmaz] # note: handle take sigmay/i instead of sigmay and multiply with (1/i)^2 = -1 for j in xrange(n): e1 = env.get_site_environment(j) for k in xrange(3): op = sigma[k] O = peps.make_double_layer(a[j], o=op) m[k,j] = e1.contract(O) / e1.contract(A[j])