E_list = [] update_error_list = [0.] ### DATA_DICT data_dict = {'t_list': t_list, 'E_list': E_list, 'update_error_list': update_error_list} for dep_idx in range(depth): # if dep_idx > 0: # identity_layer = [np.eye(4).reshape([2, 2, 2, 2]) for i in range(L-1)] # my_circuit.append(identity_layer) # else: # random_layer = [qTEBD.random_2site_U(2) for i in range(L-1)] # my_circuit.append(random_layer) random_layer = [qTEBD.random_2site_U(2) for i in range(L-1)] my_circuit.append(random_layer) current_depth = dep_idx + 1 product_state = [np.array([1., 0.]).reshape([2, 1, 1]) for i in range(L)] mps_of_layer = qTEBD.circuit_2_mps(my_circuit, product_state) E_list.append(np.sum(mps_func.expectation_values(mps_of_layer[-1], H_list))) dir_path = 'data/1d_%s_g%.1f_h%.1f/L%d_depth%d/' % (Hamiltonian, g, h, L, depth) if not os.path.exists(dir_path): os.makedirs(dir_path) try: my_circuit, data_dict = misc.load_circuit_simple(dir_path) print("Old data found !!!")
## trotterization initialization idx = 0 my_circuit = [] t_list = [0] error_list = [] 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)] if brickwall: for dep_idx in range(depth): random_layer = [] for idx in range(L - 1): if (idx + dep_idx) % 2 == 0: random_layer.append(qTEBD.random_2site_U(2)) else: random_layer.append(np.eye(4).reshape([2, 2, 2, 2])) my_circuit.append(random_layer) current_depth = dep_idx + 1 else: # not brickwall 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 result_mpo_list = qTEBD.circuit_2_mpo(my_circuit, mpo_base) result_mpo = result_mpo_list[-1] full_result_operator = mps_func.MPO_2_operator(result_mpo) err = np.linalg.norm(full_result_operator - full_operator)**2
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) ################# CIRCUIT INITIALIZATION ###################### # product_state = [np.array([1., 0.]).reshape([2, 1, 1]) for i in range(L)] product_state = np.zeros([2**L], dtype=np.complex128) product_state[0] = 1. for dep_idx in range(depth): # identity_layer = [np.eye(4, dtype=np.complex).reshape([2, 2, 2, 2]) for i in range(L-1)] # my_circuit.append(identity_layer) random_layer = [] for idx in range(L - 1): if (idx + dep_idx) % 2 == 0: random_layer.append(qTEBD.random_2site_U(2)) else: random_layer.append(np.eye(4).reshape([2, 2, 2, 2])) my_circuit.append(random_layer) current_depth = dep_idx + 1 iter_state = qTEBD.circuit_2_state(my_circuit, product_state) ''' 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(qTEBD.overlap_exact(target_state, iter_state))**2 error_list.append(1. - fidelity_reached) stop_crit = 1e-1