Example #1
0
def propagator_steadystate(U):
    """Find the steady state for successive applications of the propagator :math:`U`.
    
    Parameters
    ----------
    U : qobj 
        Operator representing the propagator.
    
    Returns
    ------- 
    a : qobj
        Instance representing the steady-state vector.
    
    """

    evals, evecs = la.eig(U.full())

    ev_min, ev_idx = get_min_and_index(abs(evals - 1.0))

    N = int(sqrt(len(evals)))

    evecs = evecs.T
    rho = Qobj(vec2mat(evecs[ev_idx]))

    return rho * (1 / real(rho.tr()))
Example #2
0
def propagator_steadystate(U):
    """Find the steady state for successive applications of the propagator :math:`U`.
    
    Parameters
    ----------
    U : qobj 
        Operator representing the propagator.
    
    Returns
    ------- 
    a : qobj
        Instance representing the steady-state vector.
    
    """

    evals,evecs = la.eig(U.full())

    ev_min, ev_idx = get_min_and_index(abs(evals-1.0))

    N = int(sqrt(len(evals)))

    evecs = evecs.T
    rho = Qobj(vec2mat(evecs[ev_idx]))

    return rho * (1 / real(rho.tr()))
Example #3
0
File: wigner.py Project: maij/qutip
def _qfunc_check_state(state: Qobj):
    if not isinstance(state, Qobj):
        raise TypeError(f"state must be Qobj, but is {state}")
    # This is only approximate, but it's enough for our purposes; doing more
    # than this would take computational effort we don't _need_ to do.
    isdm = (state.isoper and state.dims[0] == state.dims[1] and state.isherm
            and abs(state.tr() - 1) < qutip.settings.atol)
    if not (state.isket or isdm):
        raise ValueError(
            f"state must be a ket or density matrix, but is {state}")
    if len(state.dims[0]) != 1:
        raise ValueError(
            "state must not have tensor structure, but has dimensions:"
            f" {state.dims}")
    return state
Example #4
0
print("Sigma Z: ", sz)

wait()

# Arithmetic with quantum objects
H = 1.0 * sz + 0.1 * sy
print("Qubit Hamiltonian (H = sz + 0.1 * sy):\n", H)
print("Eigenenergies/ Eigenvalues of H: ", H.eigenenergies())

wait()

print("sy: ", sy)
print("Hermitian Conjugate/Conjugate Transpose of sy: ",
      sy.dag())  # Same as sy
print("Trace of sy: ", sy.tr())

wait()
""" --------------- </States> --------------- """

# Fundamental Basis States (Fock states of oscillator modes)
N = 2  # number of states in the hilbert space
n = 1  # state which will be occupied

print("Basis with {N} states, where state {n} is occupied:\n".format(N=N, n=n),
      basis(N, n))  # Same as fock(N,n)
print()

# Similarly,
print("Basis with {N} states, where state {n} is occupied:\n".format(N=4, n=2),
      fock(4, 2))