Пример #1
0
def amp_damping(p0_up, p1_up, p1_down, p2_down):
    """
    A gate, that excites or relaxes a qubit with a certain probability.

    Parameters
    ----------
    p0_up : float
        Probability to excite to state 1, being in the state 0
    p1_up : float
        Probability to excite to state 2, being in the state 1
    p1_down : float
        Probability to relax to state 0, being in the state 1
    p2_down : float
        Probability to relax to state 1, being in the state 2

    Returns
    -------
        quantumsim.operation._PTMOperation
    """
    ptm = np.identity(9, dtype=float)
    ptm[:3, :3] = [[1. - p0_up, p1_down, 0.],
                   [p0_up, 1. - p1_down - p1_up, p2_down],
                   [0., p1_up, 1 - p2_down]]
    basis = (bases.general(3), )
    return Operation.from_ptm(ptm, basis, basis)
Пример #2
0
def phase_damping(total_rate=None, *, x_deph_rate=None,
                  y_deph_rate=None, z_deph_rate=None):
    if total_rate is not None:
        kraus = np.array([[[1, 0], [0, np.sqrt(1 - total_rate)]],
                          [[0, 0], [0, np.sqrt(total_rate)]]])
        return Operation.from_kraus(kraus, 2)
    else:
        if None in (x_deph_rate, y_deph_rate, z_deph_rate):
            raise ValueError(
                "Either the total_rate or the dephasing rates along each of "
                "the three axis must be provided")
        ptm = np.diag(
            [1, 1 - x_deph_rate, 1 - y_deph_rate, 1 - z_deph_rate])
        return Operation.from_ptm(ptm, (bases.gell_mann(2),))
Пример #3
0
def amp_damping(total_rate=None, *, exc_rate=None, damp_rate=None):
    if total_rate is not None:
        kraus = np.array([[[1, 0], [0, np.sqrt(1 - total_rate)]],
                          [[0, np.sqrt(total_rate)], [0, 0]]])
        return Operation.from_kraus(kraus, 2)
    else:
        if None in (exc_rate, damp_rate):
            raise ValueError(
                "Either the total_rate or both the exc_rate and damp_rate "
                "must be provided")
        comb_rate = exc_rate + damp_rate
        ptm = np.array([[1, 0, 0, 0], [0, np.sqrt((1 - comb_rate)), 0, 0],
                        [0, 0, np.sqrt((1 - comb_rate)), 0],
                        [2 * damp_rate - comb_rate, 0, 0, 1 - comb_rate]])
        return Operation.from_ptm(ptm, (bases.gell_mann(2), ))
Пример #4
0
def phase_damping(total_rate=None,
                  *,
                  x_deph_rate=None,
                  y_deph_rate=None,
                  z_deph_rate=None):
    if total_rate is not None:
        kraus = np.array([[[1, 0], [0, np.sqrt(1 - total_rate)]],
                          [[0, 0], [0, np.sqrt(total_rate)]]])
        return Operation.from_kraus(kraus, 2)
    else:
        if None in (x_deph_rate, y_deph_rate, z_deph_rate):
            raise ValueError(
                "Either the total_rate or the dephasing rates along each of "
                "the three axis must be provided")
        ptm = np.diag([1, 1 - x_deph_rate, 1 - y_deph_rate, 1 - z_deph_rate])
        return Operation.from_ptm(ptm, (bases.gell_mann(2), ))
Пример #5
0
def amp_damping(total_rate=None, *, exc_rate=None, damp_rate=None):
    if total_rate is not None:
        kraus = np.array([[[1, 0], [0, np.sqrt(1 - total_rate)]],
                          [[0, np.sqrt(total_rate)], [0, 0]]])
        return Operation.from_kraus(kraus, 2)
    else:
        if None in (exc_rate, damp_rate):
            raise ValueError(
                "Either the total_rate or both the exc_rate and damp_rate "
                "must be provided")
        comb_rate = exc_rate + damp_rate
        ptm = np.array([
            [1, 0, 0, 0],
            [0, np.sqrt((1 - comb_rate)), 0, 0],
            [0, 0, np.sqrt((1 - comb_rate)), 0],
            [2*damp_rate - comb_rate, 0, 0, 1 - comb_rate]])
        return Operation.from_ptm(ptm, (bases.gell_mann(2),))
Пример #6
0
    def test_ptm(self):
        # Some random gate sequence
        op_indices = [(lib2.rotate_x(np.pi / 2), (0, )),
                      (lib2.rotate_y(0.3333), (1, )), (lib2.cphase(), (0, 2)),
                      (lib2.cphase(), (1, 2)),
                      (lib2.rotate_x(-np.pi / 2), (0, ))]
        circuit = Operation.from_sequence(*(op.at(*ix)
                                            for op, ix in op_indices))

        b = (bases.general(2), ) * 3
        ptm = circuit.ptm(b, b)
        assert isinstance(ptm, np.ndarray)

        op_3q = Operation.from_ptm(ptm, b)
        dm = random_hermitian_matrix(8, seed=93)
        state1 = PauliVector.from_dm(dm, b)
        state2 = PauliVector.from_dm(dm, b)

        circuit(state1, 0, 1, 2)
        op_3q(state2, 0, 1, 2)
        assert np.allclose(state1.to_pv(), state2.to_pv())