Exemple #1
0
def example_TEBD_gs_tf_ising_infinite(g, verbose=True):
    print("infinite TEBD, imaginary time evolution, transverse field Ising")
    print("g={g:.2f}".format(g=g))
    model_params = dict(L=2, J=1., g=g, bc_MPS='infinite', conserve=None, verbose=verbose)
    M = TFIChain(model_params)
    product_state = ["up"] * M.lat.N_sites
    psi = MPS.from_product_state(M.lat.mps_sites(), product_state, bc=M.lat.bc_MPS)
    tebd_params = {
        'order': 2,
        'delta_tau_list': [0.1, 0.01, 0.001, 1.e-4, 1.e-5],
        'N_steps': 10,
        'max_error_E': 1.e-8,
        'trunc_params': {
            'chi_max': 30,
            'svd_min': 1.e-10
        },
        'verbose': verbose,
    }
    eng = tebd.Engine(psi, M, tebd_params)
    eng.run_GS()  # the main work...
    E = np.sum(M.bond_energies(psi))  # M.bond_energies() works only a for NearestNeighborModel
    # alternative: directly measure E2 = np.mean(psi.expectation_value(M.H_bond))
    print("E (per site) = {E:.13f}".format(E=E))
    print("final bond dimensions: ", psi.chi)
    mag_x = np.mean(psi.expectation_value("Sigmax"))
    mag_z = np.mean(psi.expectation_value("Sigmaz"))
    print("<sigma_x> = {mag_x:.5f}".format(mag_x=mag_x))
    print("<sigma_z> = {mag_z:.5f}".format(mag_z=mag_z))
    print("correlation length:", psi.correlation_length())
    # compare to exact result
    from tfi_exact import infinite_gs_energy
    E_exact = infinite_gs_energy(1., g)
    print("Analytic result: E (per site) = {E:.13f}".format(E=E_exact))
    print("relative error: ", abs((E - E_exact) / E_exact))
    return E, psi, M
Exemple #2
0
    def evolve(self):
        for t, g, J in zip(self._ts, self._gs, self._Js):
            self.t = t
            self.g = g
            self.J = J
            model_params = dict(L=2,
                                J=J,
                                g=g,
                                bc_MPS='infinite',
                                conserve=None)
            M = TFIChain(model_params)
            self.M = M
            self.psi = self.Evolver.evolve(self.psi, M)
            self.Es.append(np.mean(M.bond_energies(self.psi)))
            self.Ss.append(self.psi.entanglement_entropy()[-1])
            self.Es_exact.append(exact_energy(J, g))
            self.ts.append(t)
            self.gs.append(g)
            self.Js.append(J)
            self.chis.append(np.mean(self.psi.chi))
            self.Sxs.append(np.mean(self.psi.expectation_value('Sx')))
            self.Sys.append(np.mean(self.psi.expectation_value('Sy')))
            self.Szs.append(np.mean(self.psi.expectation_value('Sz')))

            print('v:', self.v, 'g:', round(g, 5), 'J:', round(J, 5), 'chi:',
                  self.chi, 'Sx:', round(self.Sxs[-1], 6), 'Sy:',
                  round(self.Sys[-1], 6), 'Sz:', round(self.Szs[-1], 6))
            self.write_log()
            self.save_checkpoint()
        self.write_log()
        self.save_checkpoint()
        print('done')
        print('*' * 80)
Exemple #3
0
def example_TEBD_gs_tf_ising_finite(L, g, verbose=True):
    print("finite TEBD, imaginary time evolution, transverse field Ising")
    print("L={L:d}, g={g:.2f}".format(L=L, g=g))
    model_params = dict(L=L,
                        J=1.,
                        g=g,
                        bc_MPS='finite',
                        conserve=None,
                        verbose=verbose)
    M = TFIChain(model_params)
    product_state = ["up"] * M.lat.N_sites
    psi = MPS.from_product_state(M.lat.mps_sites(),
                                 product_state,
                                 bc=M.lat.bc_MPS)
    tebd_params = {
        'order': 2,
        'delta_tau_list': [0.1, 0.01, 0.001, 1.e-4, 1.e-5],
        'N_steps': 10,
        'max_error_E': 1.e-6,
        'trunc_params': {
            'chi_max': 30,
            'svd_min': 1.e-10
        },
        'verbose': verbose,
    }
    eng = tebd.Engine(psi, M, tebd_params)
    eng.run_GS()  # the main work...

    # expectation values
    E = np.sum(M.bond_energies(
        psi))  # M.bond_energies() works only a for NearestNeighborModel
    # alternative: directly measure E2 = np.sum(psi.expectation_value(M.H_bond[1:]))
    print("E = {E:.13f}".format(E=E))
    print("final bond dimensions: ", psi.chi)
    mag_x = np.sum(psi.expectation_value("Sigmax"))
    mag_z = np.sum(psi.expectation_value("Sigmaz"))
    print("magnetization in X = {mag_x:.5f}".format(mag_x=mag_x))
    print("magnetization in Z = {mag_z:.5f}".format(mag_z=mag_z))
    if L < 20:  # compare to exact result
        from tfi_exact import finite_gs_energy
        E_exact = finite_gs_energy(L, 1., g)
        print("Exact diagonalization: E = {E:.13f}".format(E=E_exact))
        print("relative error: ", abs((E - E_exact) / E_exact))
    return E, psi, M
Exemple #4
0
 def solve(self, model_params, psi):
     M = TFIChain(model_params)
     eng = tebd.TEBDEngine(psi, M, self.options)
     eng.run_GS()
     return np.mean(M.bond_energies(psi)), psi