def example_TEBD_gs_infinite(g): print("infinite TEBD, imaginary time evolution, g={g:.2f}".format(g=g)) model_params = dict(L=2, J=1., g=g, bc_MPS='infinite', conserve=None, verbose=0) M = TFIChain(model_params) psi = MPS.from_product_state(M.lat.mps_sites(), [0] * 2, bc='infinite') 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': 1 } eng = tebd.Engine(psi, M, tebd_params) eng.run_GS() # the main work... E = np.mean(psi.expectation_value(M.H_bond)) print("E = {E:.13f}".format(E=E)) print("final bond dimensions: ", psi.chi) print("correlation length:", psi.correlation_length()) # compare to exact result E_exact = tfi_exact.infinite_gs_energy(1., g) print("Analytic result: E/L = {E:.13f}".format(E=E_exact)) print("relative error: ", abs((E - E_exact) / E_exact)) return E, psi, M
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
def example_DMRG_tf_ising_infinite(g, verbose=True): print("infinite DMRG, transverse field Ising model") 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) dmrg_params = { 'mixer': True, # setting this to True helps to escape local minima 'trunc_params': { 'chi_max': 30, 'svd_min': 1.e-10 }, 'max_E_err': 1.e-10, 'verbose': verbose, } # instead of # info = dmrg.run(psi, M, dmrg_params) # E = info['E'] # we can also use the a Engine directly: eng = dmrg.EngineCombine(psi, M, dmrg_params) E, psi = eng.run() # equivalent to dmrg.run() up to the return parameters. print("E = {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
def example_1site_DMRG_tf_ising_infinite(g): print("single-site infinite DMRG, transverse field Ising model") print("g={g:.2f}".format(g=g)) model_params = dict(L=2, J=1., g=g, bc_MPS='infinite', conserve=None) 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) dmrg_params = { 'mixer': True, # setting this to True is essential for the 1-site algorithm to work. 'trunc_params': { 'chi_max': 30, 'svd_min': 1.e-10 }, 'max_E_err': 1.e-10, 'combine': True } eng = dmrg.SingleSiteDMRGEngine(psi, M, dmrg_params) E, psi = eng.run() # equivalent to dmrg.run() up to the return parameters. print("E = {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))
def example_DMRG_infinite(g): print("infinite DMRG, g={g:.2f}".format(g=g)) model_params = dict(L=2, J=1., g=g, bc_MPS='infinite', conserve=None, verbose=0) M = TFIChain(model_params) psi = MPS.from_product_state(M.lat.mps_sites(), [0] * 2, bc='infinite') dmrg_params = { 'mixer': True, 'trunc_params': { 'chi_max': 30, 'svd_min': 1.e-10 }, 'max_E_err': 1.e-10, 'verbose': 1 } dmrg.run(psi, M, dmrg_params) E = np.mean(psi.expectation_value(M.H_bond)) print("E = {E:.13f}".format(E=E)) print("final bond dimensions: ", psi.chi) print("correlation length:", psi.correlation_length()) # compare to exact result E_exact = tfi_exact.infinite_gs_energy(1., g) print("Analytic result: E/L = {E:.13f}".format(E=E_exact)) print("relative error: ", abs((E - E_exact) / E_exact)) return E, psi, M
def example_TEBD_gs_infinite(g): print("infinite TEBD, imaginary time evolution, g={g:.2f}".format(g=g)) import a_mps import b_model M = b_model.TFIModel(L=2, J=1., g=g, bc='infinite') psi = a_mps.init_FM_MPS(M.L, M.d, M.bc) for dt in [0.1, 0.01, 0.001, 1.e-4, 1.e-5]: U_bonds = calc_U_bonds(M.H_bonds, dt) run_TEBD(psi, U_bonds, N_steps=500, chi_max=30, eps=1.e-10) E = np.mean(psi.bond_expectation_value(M.H_bonds)) print("dt = {dt:.5f}: E/L = {E:.13f}".format(dt=dt, E=E)) print("final bond dimensions: ", psi.get_chi()) print("correlation length:", psi.correlation_length()) # compare to exact result E_exact = tfi_exact.infinite_gs_energy(1., g) print("Analytic result: E/L = {E:.13f}".format(E=E_exact)) print("relative error: ", abs((E - E_exact) / E_exact)) return E, psi, M
def example_DMRG_infinite(g): print("infinite DMRG, g={g:.2f}".format(g=g)) import a_mps import b_model M = b_model.TFIModel(L=2, J=1., g=g, bc='infinite') psi = a_mps.init_FM_MPS(M.L, M.d, M.bc) eng = SimpleDMRGEngine(psi, M, chi_max=20, eps=1.e-14) for i in range(20): eng.sweep() E = np.mean(psi.bond_expectation_value(M.H_bonds)) print("sweep {i:2d}: E/L = {E:.13f}".format(i=i + 1, E=E)) print("final bond dimensions: ", psi.get_chi()) 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/L = {E:.13f}".format(E=E_exact)) print("relative error: ", abs((E - E_exact) / E_exact)) return E, psi, M