a0_best = np.loadtxt("output_varpeps_tfi/params_D=3_h={:f}_globalrandom.dat".format(h))
    Emin = get_energy(a0_best)
    print "starting global ground state search with energy {:.15e}".format(Emin)
    sys.stdout.flush()
else:
    Emin = 0
    a0_best = None

found_new_min = False

for j in xrange(num_tries):
    print "try number {:d}".format(j)
    sys.stdout.flush()
    a0 = np.random.rand(num_params)
    res = scipy.optimize.minimize(get_energy, a0)
    a0 = res.x
    E, mz = get_energy(a0, True)
    if E < Emin:
        Emin = E
        a0_best = np.copy(a0)
        found_new_min = True
        print "found new minimal energy {:.15e} at try {:d} (mz = {:.15e})".format(E, j+1, mz)
        sys.stdout.flush()

if found_new_min:
    peps.save([get_symm_tensor(a0_best)], lut, "output_varpeps_tfi/state_D=3_h={:f}_globalrandom.peps".format(h))
    np.savetxt("output_varpeps_tfi/params_D=3_h={:f}_globalrandom.dat".format(h), a0_best)

print "needed {:f} seconds".format(time() - t0)

Esempio n. 2
0
            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)
Esempio n. 3
0
def save_callback(a):
    peps.save(a, lut, basepath_out + statefile[statefile.rfind("/") + 1 :])
Esempio n. 4
0
a0 = np.array([1]+[0]*41, dtype=float) # fm peps

for h_it in np.concatenate([
    np.linspace(0, 2.7, 27, endpoint=False),
    np.linspace(2.7, 2.9, 8, endpoint=False),
    np.linspace(2.9, 3.15, 21),
    np.linspace(3.2, 3.4, 3)]):
    h = h_it
    
    #a0 = np.loadtxt("output_varpeps_tfi/params_D=2_h={:f}.dat".format(h))
    #a0 = vec2_to_vec3(a0)
    #res = scipy.optimize.minimize(get_energy, a0)
    res = scipy.optimize.basinhopping(get_energy, a0, niter=500, interval=10, T=2.0, stepsize=0.2, disp=True)
    a0 = res.x
    
    peps.save([get_symm_tensor(a0)], lut, "output_varpeps_tfi/state_D=3_h={:f}.peps".format(h))
    
    f2 = open("output_varpeps_tfi/params_D=3_h={:f}.dat".format(h), "w")
    for j in xrange(len(a0)):
        f2.write("{:.15e}\n".format(a0[j]))
    f2.close()
    
    if res.success:
        print h, res.success
    else:
        print h, res.success, res.message
    
    E, mz = get_energy(a0, True)
    f.write("{:.15e} {:.15e} {:.15e}\n".format(h, mz, E))
    f.flush()