示例#1
0
def Quantum_system(mat, click, state):
    start = mat
    for i in range(click):
        state_click = mat_op.mult_mat(start, mat_op.transpuesta(state))
        start = mat_op.mult_mat(start, mat)
    state_click = [[round((state_click[i][0].mod())**2, 2)]
                   for i in range(len(state_click))]
    Plot(len(state_click), mat_op.transpuesta(state_click))
    return state_click
示例#2
0
def Dynamics(n, U_n, state):
    if mat_op.unitary(U_n):
        U = U_n
        for i in range(n):
            ans = mat_op.mult_mat(U, state)
            U = mat_op.mult_mat(U, U_n)
        prob = ans
        prob = [round(ans[i][0].mod()**2, 2) for i in range(len(ans))]
        return prob
    else:
        return 'Matriz no unitaria'
示例#3
0
def exp_complex_slit(mat):
    A = mat
    V = [complex_cart(0, 0) for i in range(len(mat))]
    V[0] = complex_cart(1, 0)
    V = mat_op.transpuesta(V)
    for i in range(2):
        C = mat_op.mult_mat(A, V)
        A = mat_op.mult_mat(A, mat)
    B = mat_op.transpuesta(C[:])
    for i in range(len(B)):
        B[i] = round(B[i].mod()**2, 2)
    Plot(len(B), B)

    return mat_op.transpuesta(B)
 def test_mult_mat(self):
     self.assertEqual(
         str(mat_op.mult_mat(self.mat_comp_b, self.mat_comp_a)),
         '[[-6 + 18i, -6 + 18i], [-6 + 18i, -6 + 18i], [-6 + 18i, -6 + 18i]]'
     )
     self.assertEqual(
         str(
             mat_op.mult_mat(self.mat_comp_b,
                             mat_op.transpuesta(self.mat_comp_b))),
         '[[0 + 28i, 0 + 28i, 0 + 28i], [0 + 28i, 0 + 28i, 0 + 28i], [0 + 28i, 0 + 28i, 0 + 28i]]'
     )
     self.assertEqual(
         str(
             mat_op.mult_mat(self.mat_comp_a,
                             mat_op.transpuesta(self.mat_comp_a))),
         '[[-6 + 8i, -6 + 8i, -6 + 8i], [-6 + 8i, -6 + 8i, -6 + 8i], [-6 + 8i, -6 + 8i, -6 + 8i]]'
     )
示例#5
0
def Observables(observable, ket):

    if mat_op.hermitian(observable):

        ans = mat_op.mult_mat(observable, ket)
        media = mat_op.product_in(mat_op.transpuesta(ans),
                                  mat_op.transpuesta(ket))

        identy = mat_op.mult_esc_mat(media, Identy(len(observable)))
        operador = mat_op.sum_mat_com(observable, mat_op.inv_adit_mat(identy))
        operador_1 = mat_op.mult_mat(operador, operador)
        ket_operador = mat_op.transpuesta(mat_op.mult_mat(operador_1, ket))
        var = mat_op.product_in(mat_op.transpuesta(ket), ket_operador)
        return var.a

    else:

        return None
示例#6
0
def Problem(x):
    if x == '4.3.1':
        observable = [[complex_cart(0, 0),
                       complex_cart(1, 0)],
                      [complex_cart(1, 0),
                       complex_cart(0, 0)]]
        ket = [[complex_cart(1, 0)], [complex_cart(0, 0)]]
        ans = Measuring(observable, ket)
        return ans[1]
    elif x == '4.3.2':
        observable = [[complex_cart(0, 0),
                       complex_cart(1, 0)],
                      [complex_cart(1, 0),
                       complex_cart(0, 0)]]
        ket = [[complex_cart(1, 0)], [complex_cart(0, 0)]]
        ans = Measuring(observable, ket)
        value = ans[0][0] * complex_cart(
            ans[2][0], 0) + ans[0][1] * complex_cart(ans[2][1], 0)
        print(value)

        ans_1 = mat_op.mult_mat(observable, ket)
        media = mat_op.product_in(mat_op.transpuesta(ans_1),
                                  mat_op.transpuesta(ket))
        print(media)
        print(
            'El valor de la distribucion hallado es igual al que se obtiene en el calculo de la media'
        )
        return (media)
    elif x == '4.4.1':
        U_1 = [[complex_cart(0, 0), complex_cart(1, 0)],
               [complex_cart(1, 0), complex_cart(0, 0)]]
        U_2 = [[
            complex_cart(math.sqrt(2 / 4), 0),
            complex_cart(math.sqrt(2 / 4), 0)
        ],
               [
                   complex_cart(math.sqrt(2 / 4), 0),
                   complex_cart(-math.sqrt(2 / 4), 0)
               ]]
        print(mat_op.unitary(U_1, ), mat_op.unitary(U_2))
        print('Las dos matrices son unitarias')
        U_3 = mat_op.mult_mat(U_1, U_2)
        print(mat_op.unitary(U_3))
        print('El producto de las matrices es unitario')
        return [mat_op.unitary(U_3)]

    elif x == '4.4.2':
        U_n = [[
            complex_cart(0, 0),
            complex_cart(1 / math.sqrt(2), 0),
            complex_cart(1 / math.sqrt(2), 0),
            complex_cart(0, 0)
        ],
               [
                   complex_cart(0, 1 / math.sqrt(2)),
                   complex_cart(0, 0),
                   complex_cart(0, 0),
                   complex_cart(1 / math.sqrt(2), 0)
               ],
               [
                   complex_cart(1 / math.sqrt(2), 0),
                   complex_cart(0, 0),
                   complex_cart(0, 0),
                   complex_cart(0, 1 / math.sqrt(2))
               ],
               [
                   complex_cart(0, 0),
                   complex_cart(1 / math.sqrt(2), 0),
                   complex_cart(-1 / math.sqrt(2), 0),
                   complex_cart(0, 0)
               ]]
        state = state = mat_op.transpuesta([
            complex_cart(1, 0),
            complex_cart(0, 0),
            complex_cart(0, 0),
            complex_cart(0, 0)
        ])
        ans = Dynamics(3, U_n, state)
        return ans[3]
    elif x == '4.5.2':
        return 'hola'
    else:
        return 'EL ejercicio no fue propuesto'