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


a, nns = peps.load(basepath_in + statefile)
lut = util.build_lattice_lookup_table(nns, [4, 4])


def save_callback(a):
    peps.save(a, lut, basepath_out + statefile[statefile.rfind("/") + 1 :])


ecf = tebd.CTMRGEnvContractorFactory(lut, chi, test_fct, 1e-12, 1e-15)
a = polish(a, lut, ecf, num_workers=num_workers, peps_save_callback=save_callback)

peps.save(a, lut, basepath_out + statefile[statefile.rfind("/") + 1 :])

print "tfi_gs_polish.py done; needed {0:f} seconds".format(time() - t0)
import numpy as np
import gates
import util
import scipy.optimize
import matplotlib.pyplot as plt
import os
import sys
from time import time

t0 = time()

chi = 30
p = 2
D = 3
h = float(sys.argv[1])
lut = util.build_lattice_lookup_table([[0],[0]], [4,4])
num_params = 42

sys.stdout = open("output_varpeps_tfi/log_varpeps_tfi3_globalrandom_h={:f}.txt".format(h), "a")
sys.stderr = open("output_varpeps_tfi/err_varpeps_tfi3_globalrandom_h={:f}.txt".format(h), "a")

def get_symm_tensor(c):
    A = np.ndarray((2,3,3,3,3))
    A[0,0,0,0,0] = c[0]
    A[0,0,0,0,1] = A[0,0,0,1,0] = A[0,0,1,0,0] = A[0,1,0,0,0] = c[1]
    A[0,0,0,0,2] = A[0,0,0,2,0] = A[0,0,2,0,0] = A[0,2,0,0,0] = c[2]
    A[0,0,0,1,1] = A[0,0,1,1,0] = A[0,1,1,0,0] = A[0,1,0,0,1] = c[3]
    A[0,0,0,1,2] = A[0,0,1,2,0] = A[0,1,2,0,0] = A[0,2,0,0,1] = c[4]
    A[0,0,0,2,1] = A[0,0,2,1,0] = A[0,2,1,0,0] = A[0,1,0,0,2] = c[4]
    A[0,0,0,2,2] = A[0,0,2,2,0] = A[0,2,2,0,0] = A[0,2,0,0,2] = c[5]
    A[0,0,1,0,1] = A[0,1,0,1,0] = c[6]
Exemple #3
0
basepath = "output_tfi/"
if mode == "su":
    basepath = "output_tfi_su/"

if name_suffix != "":
    name_suffix = "_" + name_suffix

if not output_to_terminal:
    f = open(basepath + "log_tfi_gs_2d_D={:d}_chi={:d}_h={:f}_tau={:.0e}{:s}.txt".format(D, chi, h, tau, name_suffix), "a")
    sys.stdout = f
    sys.stderr = f

if os.path.isfile(basepath + statefile):
    a, nns = peps.load(basepath + statefile)
    lut = util.build_lattice_lookup_table(nns, [4,4])
    if a[0].shape[1] < D:
        a = peps.increase_bond_dimension(a, D)
    _D = int(filter(lambda s: s.find("D=") != -1, statefile[:-5].split("_"))[0].split("=")[-1])
    _chi = int(filter(lambda s: s.find("chi=") != -1, statefile[:-5].split("_"))[0].split("=")[-1])
    _h = float(filter(lambda s: s.find("h=") != -1, statefile[:-5].split("_"))[0].split("=")[-1])
    _trotter2 = "_trotter2" in statefile
    if _D != D or _chi != chi or _h != h or _trotter2 != trotter_second_order:
        t0 = 0
    else:
        t0 = float(filter(lambda s: s.find("t=") != -1, statefile[:-5].split("_"))[0].split("=")[-1])
    
else:
    print "no file \"{:s}\" found! starting new calculation".format(basepath + statefile)
    a = [None]*2
    for j in xrange(len(a)):