def correlation_es(H, rho0, tlist, taulist, c_op_list, a_op, b_op): """ Internal function for calculating correlation functions using the exponential series solver. See :func:`correlation` usage. """ # contruct the Liouvillian L = liouvillian(H, c_op_list) if rho0 is None: rho0 = steady(L) C_mat = np.zeros([np.size(tlist), np.size(taulist)], dtype=complex) solES_t = ode2es(L, rho0) for t_idx in range(len(tlist)): rho_t = esval(solES_t, [tlist[t_idx]]) solES_tau = ode2es(L, b_op * rho_t) C_mat[t_idx, :] = esval(expect(a_op, solES_tau), taulist) return C_mat
def _correlation_es_2t(H, state0, tlist, taulist, c_ops, a_op, b_op, c_op): """ Internal function for calculating the three-operator two-time correlation function: <A(t)B(t+tau)C(t)> using an exponential series solver. """ # the solvers only work for positive time differences and the correlators # require positive tau if state0 is None: rho0 = steadystate(H, c_ops) tlist = [0] elif isket(state0): rho0 = ket2dm(state0) else: rho0 = state0 if debug: print(inspect.stack()[0][3]) # contruct the Liouvillian L = liouvillian(H, c_ops) corr_mat = np.zeros([np.size(tlist), np.size(taulist)], dtype=complex) solES_t = ode2es(L, rho0) # evaluate the correlation function for t_idx in range(len(tlist)): rho_t = esval(solES_t, [tlist[t_idx]]) solES_tau = ode2es(L, c_op * rho_t * a_op) corr_mat[t_idx, :] = esval(expect(b_op, solES_tau), taulist) return corr_mat
def _correlation_es_2op_1t(H, rho0, tlist, c_ops, a_op, b_op, reverse=False, args=None, options=Odeoptions()): """ Internal function for calculating correlation functions using the exponential series solver. See :func:`correlation_ss` usage. """ if debug: print(inspect.stack()[0][3]) # contruct the Liouvillian L = liouvillian(H, c_ops) # find the steady state if rho0 is None: rho0 = steadystate(L) elif rho0 and isket(rho0): rho0 = ket2dm(rho0) # evaluate the correlation function if reverse: # <A(t)B(t+tau)> solC_tau = ode2es(L, rho0 * a_op) return esval(expect(b_op, solC_tau), tlist) else: # default: <A(t+tau)B(t)> solC_tau = ode2es(L, b_op * rho0) return esval(expect(a_op, solC_tau), tlist)
def correlation_es(H, rho0, tlist, taulist, c_op_list, a_op, b_op): """ Internal function for calculating correlation functions using the exponential series solver. See :func:`correlation` usage. """ # contruct the Liouvillian L = liouvillian(H, c_op_list) if rho0 == None: rho0 = steady(L) C_mat = np.zeros([np.size(tlist), np.size(taulist)], dtype=complex) solES_t = ode2es(L, rho0) for t_idx in range(len(tlist)): rho_t = esval_op(solES_t, [tlist[t_idx]]) solES_tau = ode2es(L, b_op * rho_t) C_mat[t_idx, :] = esval(expect(a_op, solES_tau), taulist) return C_mat
def _correlation_es_2op_2t(H, rho0, tlist, taulist, c_ops, a_op, b_op, reverse=False, args=None, options=Odeoptions()): """ Internal function for calculating correlation functions using the exponential series solver. See :func:`correlation` usage. """ if debug: print(inspect.stack()[0][3]) # contruct the Liouvillian L = liouvillian(H, c_ops) if rho0 is None: rho0 = steadystate(L) elif rho0 and isket(rho0): rho0 = ket2dm(rho0) C_mat = np.zeros([np.size(tlist), np.size(taulist)], dtype=complex) solES_t = ode2es(L, rho0) # evaluate the correlation function if reverse: # <A(t)B(t+tau)> for t_idx in range(len(tlist)): rho_t = esval(solES_t, [tlist[t_idx]]) solES_tau = ode2es(L, rho_t * a_op) C_mat[t_idx, :] = esval(expect(b_op, solES_tau), taulist) else: # default: <A(t+tau)B(t)> for t_idx in range(len(tlist)): rho_t = esval(solES_t, [tlist[t_idx]]) solES_tau = ode2es(L, b_op * rho_t) C_mat[t_idx, :] = esval(expect(a_op, solES_tau), taulist) return C_mat
def essolve(H, rho0, tlist, c_op_list, expt_op_list): """ Evolution of a state vector or density matrix (`rho0`) for a given Hamiltonian (`H`) and set of collapse operators (`c_op_list`), by expressing the ODE as an exponential series. The output is either the state vector at arbitrary points in time (`tlist`), or the expectation values of the supplied operators (`expt_op_list`). Parameters ---------- H : qobj/function_type System Hamiltonian. rho0 : :class:`qutip.qobj` Initial state density matrix. tlist : list/array ``list`` of times for :math:`t`. c_op_list : list of :class:`qutip.qobj` ``list`` of :class:`qutip.qobj` collapse operators. expt_op_list : list of :class:`qutip.qobj` ``list`` of :class:`qutip.qobj` operators for which to evaluate expectation values. Returns ------- expt_array : array Expectation values of wavefunctions/density matrices for the times specified in ``tlist``. .. note:: This solver does not support time-dependent Hamiltonians. """ n_expt_op = len(expt_op_list) n_tsteps = len(tlist) # Calculate the Liouvillian if c_op_list is None or len(c_op_list) == 0: L = H else: L = liouvillian(H, c_op_list) es = ode2es(L, rho0) # evaluate the expectation values if n_expt_op == 0: result_list = [Qobj()] * n_tsteps else: result_list = np.zeros([n_expt_op, n_tsteps], dtype=complex) for n in range(0, n_expt_op): result_list[n, :] = esval(expect(expt_op_list[n], es), tlist) return result_list
def correlation_ss_es(H, tlist, c_op_list, a_op, b_op, rho0=None): """ Internal function for calculating correlation functions using the exponential series solver. See :func:`correlation_ss` usage. """ # contruct the Liouvillian L = liouvillian(H, c_op_list) # find the steady state if rho0 is None: rho0 = steady(L) # evaluate the correlation function solC_tau = ode2es(L, b_op * rho0) return esval(expect(a_op, solC_tau), tlist)
def correlation_ss_es(H, tlist, c_op_list, a_op, b_op, rho0=None): """ Internal function for calculating correlation functions using the exponential series solver. See :func:`correlation_ss` usage. """ # contruct the Liouvillian L = liouvillian(H, c_op_list) # find the steady state if rho0 == None: rho0 = steady(L) # evaluate the correlation function solC_tau = ode2es(L, b_op * rho0) return esval(expect(a_op, solC_tau), tlist)
def essolve(H, rho0, tlist, c_op_list, e_ops): """ Evolution of a state vector or density matrix (`rho0`) for a given Hamiltonian (`H`) and set of collapse operators (`c_op_list`), by expressing the ODE as an exponential series. The output is either the state vector at arbitrary points in time (`tlist`), or the expectation values of the supplied operators (`e_ops`). .. deprecated:: 4.6.0 :obj:`~essolev` will be removed in QuTiP 5. Please use :obj:`~sesolve` or :obj:`~mesolve` for general-purpose integration of the Schroedinger/Lindblad master equation. This will likely be faster than :obj:`~essolve` for you. Parameters ---------- H : qobj/function_type System Hamiltonian. rho0 : :class:`qutip.qobj` Initial state density matrix. tlist : list/array ``list`` of times for :math:`t`. c_op_list : list of :class:`qutip.qobj` ``list`` of :class:`qutip.qobj` collapse operators. e_ops : list of :class:`qutip.qobj` ``list`` of :class:`qutip.qobj` operators for which to evaluate expectation values. Returns ------- expt_array : array Expectation values of wavefunctions/density matrices for the times specified in ``tlist``. .. note:: This solver does not support time-dependent Hamiltonians. """ n_expt_op = len(e_ops) n_tsteps = len(tlist) # Calculate the Liouvillian if (c_op_list is None or len(c_op_list) == 0) and isket(rho0): L = H else: L = liouvillian(H, c_op_list) es = ode2es(L, rho0) # evaluate the expectation values if n_expt_op == 0: results = [Qobj()] * n_tsteps else: results = np.zeros([n_expt_op, n_tsteps], dtype=complex) for n, e in enumerate(e_ops): results[n, :] = expect(e, esval(es, tlist)) data = Result() data.solver = "essolve" data.times = tlist data.expect = [ np.real(results[n, :]) if e.isherm else results[n, :] for n, e in enumerate(e_ops) ] return data