本文整理汇总了Python中qutip.qobj.Qobj.tr方法的典型用法代码示例。如果您正苦于以下问题:Python Qobj.tr方法的具体用法?Python Qobj.tr怎么用?Python Qobj.tr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qutip.qobj.Qobj
的用法示例。
在下文中一共展示了Qobj.tr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _steadystate_svd_dense
# 需要导入模块: from qutip.qobj import Qobj [as 别名]
# 或者: from qutip.qobj.Qobj import tr [as 别名]
def _steadystate_svd_dense(L, atol=1e-12, rtol=0, all_steadystates=False,
verbose=False):
"""
Find the steady state(s) of an open quantum system by solving for the
nullspace of the Liouvillian.
"""
if verbose:
print('Starting SVD solver...')
start_time = time.time()
u, s, vh = svd(L.full(), full_matrices=False)
tol = max(atol, rtol * s[0])
nnz = (s >= tol).sum()
ns = vh[nnz:].conj().T
if verbose:
print('SVD solver time: ', time.time() - start_time)
if all_steadystates:
rhoss_list = []
for n in range(ns.shape[1]):
rhoss = Qobj(vec2mat(ns[:, n]), dims=L.dims[0])
rhoss_list.append(rhoss / rhoss.tr())
return rhoss_list
else:
rhoss = Qobj(vec2mat(ns[:, 0]), dims=L.dims[0])
return rhoss / rhoss.tr()
示例2: _steadystate_svd_dense
# 需要导入模块: from qutip.qobj import Qobj [as 别名]
# 或者: from qutip.qobj.Qobj import tr [as 别名]
def _steadystate_svd_dense(L, ss_args):
"""
Find the steady state(s) of an open quantum system by solving for the
nullspace of the Liouvillian.
"""
ss_args['info'].pop('weight', None)
atol = 1e-12
rtol = 1e-12
if settings.debug:
logger.debug('Starting SVD solver.')
_svd_start = time.time()
u, s, vh = svd(L.full(), full_matrices=False)
tol = max(atol, rtol * s[0])
nnz = (s >= tol).sum()
ns = vh[nnz:].conj().T
_svd_end = time.time()
ss_args['info']['solution_time'] = _svd_end-_svd_start
if ss_args['all_states']:
rhoss_list = []
for n in range(ns.shape[1]):
rhoss = Qobj(vec2mat(ns[:, n]), dims=L.dims[0])
rhoss_list.append(rhoss / rhoss.tr())
if ss_args['return_info']:
return rhoss_list, ss_args['info']
else:
if ss_args['return_info']:
return rhoss_list, ss_args['info']
else:
return rhoss_list
else:
rhoss = Qobj(vec2mat(ns[:, 0]), dims=L.dims[0])
return rhoss / rhoss.tr()
示例3: _steadystate_svd_dense
# 需要导入模块: from qutip.qobj import Qobj [as 别名]
# 或者: from qutip.qobj.Qobj import tr [as 别名]
def _steadystate_svd_dense(L, ss_args):
"""
Find the steady state(s) of an open quantum system by solving for the
nullspace of the Liouvillian.
"""
atol = 1e-12
rtol = 1e-12
if settings.debug:
print('Starting SVD solver...')
u, s, vh = svd(L.full(), full_matrices=False)
tol = max(atol, rtol * s[0])
nnz = (s >= tol).sum()
ns = vh[nnz:].conj().T
if ss_args['all_states']:
rhoss_list = []
for n in range(ns.shape[1]):
rhoss = Qobj(vec2mat(ns[:, n]), dims=L.dims[0])
rhoss_list.append(rhoss / rhoss.tr())
return rhoss_list
else:
rhoss = Qobj(vec2mat(ns[:, 0]), dims=L.dims[0])
return rhoss / rhoss.tr()
示例4: propagator_steadystate
# 需要导入模块: from qutip.qobj import Qobj [as 别名]
# 或者: from qutip.qobj.Qobj import tr [as 别名]
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 density matrix.
"""
evals, evecs = la.eig(U.full())
ev_min, ev_idx = _get_min_and_index(abs(evals - 1.0))
evecs = evecs.T
rho = Qobj(vec2mat(evecs[ev_idx]), dims=U.dims[0])
rho = rho * (1.0 / rho.tr())
rho = 0.5 * (rho + rho.dag()) # make sure rho is herm
return rho
示例5: _steadystate_eigen
# 需要导入模块: from qutip.qobj import Qobj [as 别名]
# 或者: from qutip.qobj.Qobj import tr [as 别名]
def _steadystate_eigen(L, ss_args):
"""
Internal function for solving the steady state problem by
finding the eigenvector corresponding to the zero eigenvalue
of the Liouvillian using ARPACK.
"""
if settings.debug:
print('Starting Eigen solver...')
dims = L.dims[0]
shape = prod(dims[0])
L = L.data.tocsc()
if ss_args['use_rcm']:
if settings.debug:
old_band = sp_bandwidth(L)[0]
print('Original bandwidth:', old_band)
perm = reverse_cuthill_mckee(L)
rev_perm = np.argsort(perm)
L = sp_permute(L, perm, perm, 'csc')
if settings.debug:
rcm_band = sp_bandwidth(L)[0]
print('RCM bandwidth:', rcm_band)
print('Bandwidth reduction factor:', round(old_band/rcm_band, 1))
eigval, eigvec = eigs(L, k=1, sigma=1e-15, tol=ss_args['tol'],
which='LM', maxiter=ss_args['maxiter'])
if ss_args['use_rcm']:
eigvec = eigvec[np.ix_(rev_perm,)]
data = vec2mat(eigvec)
data = 0.5 * (data + data.conj().T)
out = Qobj(data, dims=dims, isherm=True)
return out/out.tr()
示例6: _steadystate_eigen
# 需要导入模块: from qutip.qobj import Qobj [as 别名]
# 或者: from qutip.qobj.Qobj import tr [as 别名]
def _steadystate_eigen(L, ss_args):
"""
Internal function for solving the steady state problem by
finding the eigenvector corresponding to the zero eigenvalue
of the Liouvillian using ARPACK.
"""
ss_args['info'].pop('weight', None)
if settings.debug:
logger.debug('Starting Eigen solver.')
dims = L.dims[0]
L = L.data.tocsc()
if ss_args['use_rcm']:
ss_args['info']['perm'].append('rcm')
if settings.debug:
old_band = sp_bandwidth(L)[0]
logger.debug('Original bandwidth: %i' % old_band)
perm = reverse_cuthill_mckee(L)
rev_perm = np.argsort(perm)
L = sp_permute(L, perm, perm, 'csc')
if settings.debug:
rcm_band = sp_bandwidth(L)[0]
logger.debug('RCM bandwidth: %i' % rcm_band)
logger.debug('Bandwidth reduction factor: %f' %
(old_band/rcm_band))
_eigen_start = time.time()
eigval, eigvec = eigs(L, k=1, sigma=1e-15, tol=ss_args['tol'],
which='LM', maxiter=ss_args['maxiter'])
_eigen_end = time.time()
ss_args['info']['solution_time'] = _eigen_end - _eigen_start
if ss_args['return_info']:
ss_args['info']['residual_norm'] = la.norm(L*eigvec, np.inf)
if ss_args['use_rcm']:
eigvec = eigvec[np.ix_(rev_perm,)]
_temp = vec2mat(eigvec)
data = dense2D_to_fastcsr_fmode(_temp, _temp.shape[0], _temp.shape[1])
data = 0.5 * (data + data.H)
out = Qobj(data, dims=dims, isherm=True)
if ss_args['return_info']:
return out/out.tr(), ss_args['info']
else:
return out/out.tr()