Sz_array = np.zeros([N_iter, L], dtype=np.complex) ent_array = np.zeros([N_iter, L - 1], dtype=np.double) num_iter_array = np.zeros([N_iter], dtype=np.int) ################# INITIALIZATION ###################### product_state = [np.array([1., 0.]).reshape([2, 1, 1]) for i in range(L)] for dep_idx in range(depth): my_circuit.append([qTEBD.random_2site_U(2) for i in range(L - 1)]) current_depth = dep_idx + 1 mps_of_layer = qTEBD.circuit_2_mps(my_circuit, product_state) mps_of_last_layer = [A.copy() for A in mps_of_layer[current_depth]] Sz_array[0, :] = mps_func.expectation_values_1_site( mps_of_layer[-1], Sz_list) ent_array[0, :] = mps_func.get_entanglement(mps_of_last_layer) fidelity_reached = np.abs(mps_func.overlap(target_mps, mps_of_last_layer))**2 error_list.append(1. - fidelity_reached) stop_crit = 1e-1 assert np.isclose(mps_func.overlap(target_mps, target_mps), 1.) for idx in range(0, N_iter): ################################# #### variational optimzation #### ################################# mps_of_last_layer, my_circuit = qTEBD.var_circuit( target_mps, mps_of_last_layer, my_circuit, product_state) ################# #### Measure #### #################
mps_func.right_canonicalize(trunc_mps, no_trunc=True) print("trunc_error : ", trunc_error) target_mps_ = mps_func.plr_2_lpr(target_mps) trunc_mps_ = mps_func.plr_2_lpr(trunc_mps) trunc_error_ = mps_func.MPS_compression_variational(trunc_mps_, target_mps_, verbose=1) print("trunc_error (var) : ", trunc_error_) trunc_mps = mps_func.lpr_2_plr(trunc_mps_) mps_func.left_canonicalize(trunc_mps, no_trunc=True) E_list.append(np.sum(mps_func.expectation_values(trunc_mps, H_list))) Sz_array[T_idx, :] = mps_func.expectation_values_1_site( trunc_mps, Sz_list) ent_array[T_idx, :] = mps_func.get_entanglement(trunc_mps) # print("ENTANGLEMENT !!!!! : ", mps_func.get_entanglement(trunc_mps)) fidelity_reached = np.abs(mps_func.overlap(target_mps, trunc_mps))**2 error_list.append(1. - fidelity_reached) t_list.append(T) # trunc_mps_dir_path = 'data_tebd_dt%e/1d_%s_g%.4f_h%.4f/L%d/trunc_wf_chi%d_%s/' % (data_dt, Hamiltonian, g, h, L, new_chi, data_order) # if not os.path.exists(trunc_mps_dir_path): # os.makedirs(trunc_mps_dir_path) # filename = trunc_mps_dir_path + 'T%.1f.pkl' % T # pickle.dump(trunc_mps, open(filename, 'wb')) num_data = len(t_list) assert num_data > 0 Sz_array = Sz_array[:num_data, :]
mps_func.right_canonicalize(trunc_mps, no_trunc=True) trunc_mps, trunc_error = mps_func.left_canonicalize(trunc_mps, no_trunc=False, chi=new_chi) mps_func.right_canonicalize(trunc_mps, no_trunc=True) print("trunc_error : ", trunc_error) target_mps_ = mps_func.plr_2_lpr(target_mps) trunc_mps_ = mps_func.plr_2_lpr(trunc_mps) trunc_error_ = mps_func.MPS_compression_variational(trunc_mps_, target_mps_, verbose=1) print("trunc_error (var) : ", trunc_error_) trunc_mps = mps_func.lpr_2_plr(trunc_mps_) mps_func.left_canonicalize(trunc_mps, no_trunc=True) E_list.append(np.sum(mps_func.expectation_values(trunc_mps, H_list))) Sz_array[T_idx, :] = mps_func.expectation_values_1_site(trunc_mps, Sz_list) ent_array[T_idx, :] = mps_func.get_entanglement(trunc_mps) print("ENTANGLEMENT !!!!! : ", mps_func.get_entanglement(trunc_mps)) fidelity_reached = np.abs(mps_func.overlap(target_mps, trunc_mps))**2 error_list.append(1. - fidelity_reached) t_list.append(T) trunc_mps_dir_path = '../2_time_evolution/data_tebd/1d_%s_g%.4f_h%.4f/L%d/trunc_wf_chi%d_1st/' % (Hamiltonian, g, h, L, new_chi) if not os.path.exists(trunc_mps_dir_path): os.makedirs(trunc_mps_dir_path) filename = trunc_mps_dir_path + 'T%.1f.pkl' % T pickle.dump(trunc_mps, open(filename, 'wb')) num_data = len(t_list) assert num_data > 0 Sz_array = Sz_array[:num_data, :]