Exemplo n.º 1
0
def rand_super(dim=5):
    H = rand_herm(dim)
    return propagator(
        H, np.random.rand(),
        [create(dim),
         destroy(dim),
         jmat(float(dim - 1) / 2.0, 'z')])
Exemplo n.º 2
0
def rand_super(N=5, dims=None):
    """
    Returns a randomly drawn superoperator acting on operators acting on
    N dimensions.

    Parameters
    ----------
    N : int
        Square root of the dimension of the superoperator to be returned.
    dims : list
        Dimensions of quantum object.  Used for specifying
        tensor structure. Default is dims=[[[N],[N]], [[N],[N]]].
    """
    if dims is not None:
        # TODO: check!
        pass
    else:
        dims = [[[N], [N]], [[N], [N]]]
    H = rand_herm(N)
    S = propagator(
        H, np.random.rand(),
        [create(N), destroy(N),
         jmat(float(N - 1) / 2.0, 'z')])
    S.dims = dims
    return S
Exemplo n.º 3
0
def floquet_modes(H, T, args=None, sort=False):
    """
    Calculate the initial Floquet modes Phi_alpha(0) for a driven system with
    period T.
    
    Returns a list of :class:`qutip.Qobj` instances representing the Floquet
    modes and a list of corresponding quasienergies, sorted by increasing
    quasienergy in the interval [-pi/T, pi/T]. The optional parameter `sort`
    decides if the output is to be sorted in increasing quasienergies or not.

    Parameters
    ----------
    
    H : :class:`qutip.Qobj`
        system Hamiltonian, time-dependent with period `T`
        
    args : dictionary
        dictionary with variables required to evaluate H
     
    T : float
        The period of the time-dependence of the hamiltonian. The default value
        'None' indicates that the 'tlist' spans a single period of the driving.
     
    Returns
    -------

    output : list of kets, list of quasi energies

        Two lists: the Floquet modes as kets and the quasi energies.

    """

    # get the unitary propagator
    U = propagator(H, T, [], args)

    # find the eigenstates for the propagator
    evals,evecs = la.eig(U.full())

    eargs = angle(evals)
    
    # make sure that the phase is in the interval [-pi, pi], so that the
    # quasi energy is in the interval [-pi/T, pi/T] where T is the period of the
    # driving.
    #eargs  += (eargs <= -2*pi) * (2*pi) + (eargs > 0) * (-2*pi)
    eargs  += (eargs <= -pi) * (2*pi) + (eargs > pi) * (-2*pi)
    e_quasi = -eargs/T

    # sort by the quasi energy
    if sort == True:
        order = np.argsort(-e_quasi)
    else:
        order = list(range(len(evals)))

    # prepare a list of kets for the floquet states
    new_dims  = [U.dims[0], [1] * len(U.dims[0])]
    new_shape = [U.shape[0], 1]
    kets_order = [Qobj(np.matrix(evecs[:,o]).T, dims=new_dims, shape=new_shape) for o in order]

    return kets_order, e_quasi[order]
Exemplo n.º 4
0
 def test_SuperChoiSuper(self):
     """
     Superoperator: Converting superoperator to Choi matrix and back.
     """
     h_5 = rand_herm(5)
     superoperator = propagator(h_5, scipy.rand(),
                                [create(5), destroy(5), jmat(2, 'z')])
     choi_matrix = super_to_choi(superoperator)
     test_supe = choi_to_super(choi_matrix)
     assert_((test_supe - superoperator).norm() < 1e-12)
Exemplo n.º 5
0
 def test_ChoiKrausChoi(self):
     """
     Superoperator: Converting superoperator to Choi matrix and back.
     """
     h_5 = rand_herm(5)
     superoperator = propagator(h_5, scipy.rand(),
                                [create(5), destroy(5), jmat(2, 'z')])
     choi_matrix = super_to_choi(superoperator)
     kraus_ops = choi_to_kraus(choi_matrix)
     test_choi = kraus_to_choi(kraus_ops)
     assert_((test_choi - choi_matrix).norm() < 1e-12)
Exemplo n.º 6
0
 def test_SuperChoiSuper(self):
     """
     Superoperator: Converting superoperator to Choi matrix and back.
     """
     h_5 = rand_herm(5)
     superoperator = propagator(
         h_5, scipy.rand(),
         [create(5), destroy(5), jmat(2, 'z')])
     choi_matrix = super_to_choi(superoperator)
     test_supe = choi_to_super(choi_matrix)
     assert_((test_supe - superoperator).norm() < 1e-12)
Exemplo n.º 7
0
 def test_ChoiKrausChoi(self):
     """
     Superoperator: Converting superoperator to Choi matrix and back.
     """
     h_5 = rand_herm(5)
     superoperator = propagator(
         h_5, scipy.rand(),
         [create(5), destroy(5), jmat(2, 'z')])
     choi_matrix = super_to_choi(superoperator)
     kraus_ops = choi_to_kraus(choi_matrix)
     test_choi = kraus_to_choi(kraus_ops)
     assert_((test_choi - choi_matrix).norm() < 1e-12)
Exemplo n.º 8
0
def floquet_modes_t(f_modes_0, f_energies, t, H, T, args=None):
    """
    Calculate the Floquet modes at times tlist Phi_alpha(tlist) propagting the
    initial Floquet modes Phi_alpha(0)

    Parameters
    ----------

    f_modes_0 : list of :class:`qutip.qobj` (kets)
        Floquet modes at :math:`t`

    f_energies : list
        Floquet energies.

    t : float
        The time at which to evaluate the floquet modes.

    H : :class:`qutip.qobj`
        system Hamiltonian, time-dependent with period `T`

    args : dictionary
        dictionary with variables required to evaluate H

    T : float
        The period of the time-dependence of the hamiltonian.

    Returns
    -------

    output : list of kets

        The Floquet modes as kets at time :math:`t`

    """

    # find t in [0,T] such that t_orig = t + n * T for integer n
    t = t - int(t / T) * T

    f_modes_t = []

    # get the unitary propagator from 0 to t
    if t > 0.0:
        U = propagator(H, t, [], args)

        for n in np.arange(len(f_modes_0)):
            f_modes_t.append(U * f_modes_0[n] * exp(1j * f_energies[n] * t))

    else:
        f_modes_t = f_modes_0

    return f_modes_t
Exemplo n.º 9
0
def floquet_modes_t(f_modes_0, f_energies, t, H, T, args=None):
    """
    Calculate the Floquet modes at times tlist Phi_alpha(tlist) propagting the
    initial Floquet modes Phi_alpha(0)

    Parameters
    ----------

    f_modes_0 : list of :class:`qutip.qobj` (kets)
        Floquet modes at :math:`t`

    f_energies : list
        Floquet energies.

    t : float
        The time at which to evaluate the floquet modes.

    H : :class:`qutip.qobj`
        system Hamiltonian, time-dependent with period `T`

    args : dictionary
        dictionary with variables required to evaluate H

    T : float
        The period of the time-dependence of the hamiltonian.

    Returns
    -------

    output : list of kets

        The Floquet modes as kets at time :math:`t`

    """

    # find t in [0,T] such that t_orig = t + n * T for integer n
    t = t - int(t / T) * T

    f_modes_t = []

    # get the unitary propagator from 0 to t
    if t > 0.0:
        U = propagator(H, t, [], args)

        for n in np.arange(len(f_modes_0)):
            f_modes_t.append(U * f_modes_0[n] * exp(1j * f_energies[n] * t))

    else:
        f_modes_t = f_modes_0

    return f_modes_t
Exemplo n.º 10
0
def rand_super(N=5, dims=None):
    """
    Returns a randomly drawn superoperator acting on operators acting on
    N dimensions.

    Parameters
    ----------
    N : int
        Square root of the dimension of the superoperator to be returned.
    dims : list
        Dimensions of quantum object.  Used for specifying
        tensor structure. Default is dims=[[[N],[N]], [[N],[N]]].
    """
    if dims is not None:
        # TODO: check!
        pass
    else:
        dims = [[[N], [N]], [[N], [N]]]
    H = rand_herm(N)
    S = propagator(H, np.random.rand(), [create(N), destroy(N), jmat(float(N - 1) / 2.0, "z")])
    S.dims = dims
    return S
Exemplo n.º 11
0
def floquet_modes(H, T, args=None, sort=False, U=None):
    """
    Calculate the initial Floquet modes Phi_alpha(0) for a driven system with
    period T.

    Returns a list of :class:`qutip.qobj` instances representing the Floquet
    modes and a list of corresponding quasienergies, sorted by increasing
    quasienergy in the interval [-pi/T, pi/T]. The optional parameter `sort`
    decides if the output is to be sorted in increasing quasienergies or not.

    Parameters
    ----------

    H : :class:`qutip.qobj`
        system Hamiltonian, time-dependent with period `T`

    args : dictionary
        dictionary with variables required to evaluate H

    T : float
        The period of the time-dependence of the hamiltonian. The default value
        'None' indicates that the 'tlist' spans a single period of the driving.

    U : :class:`qutip.qobj`
        The propagator for the time-dependent Hamiltonian with period `T`.
        If U is `None` (default), it will be calculated from the Hamiltonian
        `H` using :func:`qutip.propagator.propagator`.

    Returns
    -------

    output : list of kets, list of quasi energies

        Two lists: the Floquet modes as kets and the quasi energies.

    """

    if U is None:
        # get the unitary propagator
        U = propagator(H, T, [], args)

    # find the eigenstates for the propagator
    evals, evecs = la.eig(U.full())

    eargs = angle(evals)

    # make sure that the phase is in the interval [-pi, pi], so that
    # the quasi energy is in the interval [-pi/T, pi/T] where T is the
    # period of the driving.  eargs += (eargs <= -2*pi) * (2*pi) +
    # (eargs > 0) * (-2*pi)
    eargs += (eargs <= -pi) * (2 * pi) + (eargs > pi) * (-2 * pi)
    e_quasi = -eargs / T

    # sort by the quasi energy
    if sort:
        order = np.argsort(-e_quasi)
    else:
        order = list(range(len(evals)))

    # prepare a list of kets for the floquet states
    new_dims = [U.dims[0], [1] * len(U.dims[0])]
    new_shape = [U.shape[0], 1]
    kets_order = [
        Qobj(np.matrix(evecs[:, o]).T, dims=new_dims, shape=new_shape)
        for o in order
    ]

    return kets_order, e_quasi[order]
Exemplo n.º 12
0
 def rand_super(self):
     h_5 = rand_herm(5)
     return propagator(
         h_5, scipy.rand(),
         [create(5), destroy(5), jmat(2, 'z')])
Exemplo n.º 13
0
def rand_super():
    h_5 = rand_herm(5)
    return propagator(h_5, scipy.rand(), [
        create(5), destroy(5), jmat(2, 'z')
    ])
Exemplo n.º 14
0
def rand_super(dim=5):
    H = rand_herm(dim)
    return propagator(H, np.random.rand(), [
        create(dim), destroy(dim), jmat(float(dim - 1) / 2.0, 'z')
    ])