コード例 #1
0
            update_error_list.append(1. - fidelity_reached)
            current_energy = np.sum(mps_func.expectation_values(
                A_list, H_list))
            E_list.append(current_energy)
            Sz_array[idx, :] = mps_func.expectation_values_1_site(
                A_list, Sz_list)
            ent_array[idx, :] = mps_func.get_entanglement(A_list)
            t_list.append(t_list[-1] + dt)

            print("T=", t_list[-1], " E=", E_list[-1], " Sz=",
                  Sz_array[idx, L // 2])
            # N_iter = 10
            continue

        if order == '2nd':
            Ap_list = qTEBD.apply_U(A_list, U_half_list, 0)
            Ap_list = qTEBD.apply_U(Ap_list, U_list, 1)
            Ap_list = qTEBD.apply_U(Ap_list, U_half_list, 0)
        else:
            Ap_list = qTEBD.apply_U(A_list, U_list, 0)
            Ap_list = qTEBD.apply_U(Ap_list, U_list, 1)

        # Ap_list = e^(-i dt H) | A_list >
        # print("Norm new mps = ", mps_func.overlap(Ap_list, Ap_list), "new state aimed E = ",
        #       np.sum(mps_func.expectation_values(Ap_list, H_list, check_norm=False))/mps_func.overlap(Ap_list, Ap_list)
        #      )

        ### POLAR DECOMPOSITION UPDATE ###
        Ap_norm_sq = mps_func.overlap(Ap_list, Ap_list)
        fidelity_before = np.abs(mps_func.overlap(Ap_list,
                                                  A_list))**2 / Ap_norm_sq
コード例 #2
0
    running_idx = len(t_list)
    try:
        tuple_loaded = misc.load_circuit(dir_path, depth, N_iter, order)
        running_idx, my_circuit, E_list, t_list, update_error_list, Sz_array, ent_array, num_iter_array = tuple_loaded
        print(" old result loaded ")
        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]]
    except Exception as e:
        print(e)

    stop_crit = 1e-1
    for idx in range(running_idx, int(total_t // dt) + 1):
        # [TODO] remove the assertion below
        assert np.isclose(mps_func.overlap(mps_of_last_layer, mps_of_last_layer), 1.)
        if order == '2nd':
            target_mps = qTEBD.apply_U(mps_of_last_layer,  U_half_list, 0)
            target_mps = qTEBD.apply_U(target_mps, U_list, 1)
            target_mps = qTEBD.apply_U(target_mps, U_half_list, 0)
        else:
            # target_mps = [A.copy() for A in mps_of_last_layer]
            # target_mps, _ = mps_func.right_canonicalize(target_mps, no_trunc=True)
            # target_mps, trunc_error = qTEBD.apply_U_all(target_mps,  U_list, False, no_trunc=True)

            target_mps = qTEBD.apply_U(mps_of_last_layer,  U_list, 0)
            target_mps = qTEBD.apply_U(target_mps, U_list, 1)

        mps_func.right_canonicalize(target_mps, no_trunc=True)
        mps_func.left_canonicalize(target_mps, no_trunc=False)

        # target_mps is the e(-H)|psi0> which is not normalizaed.
        target_mps_norm_sq = mps_func.overlap(target_mps, target_mps)
コード例 #3
0
    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)))

    for dt in [0.05, 0.01, 0.001]:
        U_list = qTEBD.make_U(H_list, dt)
        U_half_list = qTEBD.make_U(H_list, dt / 2.)
        for i in range(int(40 // dt**(0.75))):
            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]]
            # [TODO] remove the assertion below
            assert np.isclose(
                mps_func.overlap(mps_of_last_layer, mps_of_last_layer), 1.)
            if order == '2nd':
                new_mps = qTEBD.apply_U(mps_of_last_layer, U_half_list, 0)
                new_mps = qTEBD.apply_U(new_mps, U_list, 1)
                new_mps = qTEBD.apply_U(new_mps, U_half_list, 0)
            else:
                new_mps = qTEBD.apply_U(mps_of_last_layer, U_list, 0)
                new_mps = qTEBD.apply_U(new_mps, U_list, 1)

            print(
                "Norm new mps = ", mps_func.overlap(new_mps, new_mps),
                "new state aimed E = ",
                np.sum(
                    mps_func.expectation_values(
                        new_mps, H_list, check_norm=False)) /
                mps_func.overlap(new_mps, new_mps))
            # new_mps is the e(-H)|psi0> which is not normalizaed.