Beispiel #1
0
def operator_a3all_new(H, ph_type=1):
    H_size = H.size
    size = H_size

    data = np.array([np.zeros(size) for i in range(size)])

    # ph_type = 1
    if ph_type == 1:
        for k_from, v_from in enumerate(H.states):
            ph = v_from[0]

            if ph > 0:
                to_state = [ph - 1, v_from[1]] + [v_from[2]] + [[
                    v_from[3][0] + 1, v_from[3][1]
                ]]
                # print(v_from[1])
                # print(v_from[2])
                # print(v_from[3])
                # print(to_state)
                # exit(0)
                for k_to, v_to in enumerate(H.states):
                    if to_state == v_to:
                        data[k_to][k_from] = sqrt(ph)
                        print(v_from, '->', to_state)
                # data[k_to][k_from] = sqrt(ph)

    # ph_type = 2
    elif ph_type == 2:
        for k_from, v_from in enumerate(H.states):
            ph = v_from[1]

            if ph > 0:
                to_state = [v_from[0], ph - 1] + [v_from[2]] + [[
                    v_from[3][0], v_from[3][1] + 1
                ]]

                # to_state = [v_from[0], ph - 1] + v_from[2:]

                for k_to, v_to in enumerate(H.states):
                    if to_state == v_to:
                        data[k_to][k_from] = sqrt(ph)
                        # print(v_from, '->', to_state)

    # exit(0)
    a = Matrix(H.size, H.size, dtype=np.complex128)
    a.size = H.size
    a.data = lil_matrix(data, dtype=np.complex128)

    return a
Beispiel #2
0
def operator_a(H):
    H_size = H.size
    size = H_size

    data = np.array([np.zeros(size) for i in range(size)])

    for k_from, v_from in enumerate(H.states):
        ph = v_from[0]

        if ph > 0:
            # print("ph = ", ph)
            # print("from_state = ", v_from)

            to_state = [ph - 1] + v_from[1:]
            # print("to_state0 = ", to_state)

            for k_to, v_to in enumerate(H.states):
                if to_state == v_to:
                    # print("to_state = ", to_state)
                    # a[k_from][k_to] = sqrt(ph)
                    data[k_to][k_from] = sqrt(ph)

    # for i in range(H_size):
    #     for j in range(H_size):
    #         if data[i][j] != 0:
    #             print(H.states[j], " -> ", H.states[i], ": ", np.round(data[i][j], 3), sep="")

    a = Matrix(H.size, H.size, dtype=np.complex128)
    a.size = H.size
    a.data = lil_matrix(data, dtype=np.complex128)

    # a_dense = a.data.toarray()

    # for i in range(H.size):
    #     for j in range(H.size):
    #         if abs(a.data[i, j]) != 0:
    #             print(i, j, abs(a.data[i, j]))
    #             print(H.states[i], H.states[j])
    #             print()
    # for i in len()
    # print(a.data[0,0])
    # exit(0)
    return a