本文整理匯總了Python中qutip.solver.Result.expect[m][i]方法的典型用法代碼示例。如果您正苦於以下問題:Python Result.expect[m][i]方法的具體用法?Python Result.expect[m][i]怎麽用?Python Result.expect[m][i]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qutip.solver.Result
的用法示例。
在下文中一共展示了Result.expect[m][i]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ttmsolve
# 需要導入模塊: from qutip.solver import Result [as 別名]
# 或者: from qutip.solver.Result import expect[m][i] [as 別名]
#.........這裏部分代碼省略.........
Initial density matrix or state vector (ket).
times : array_like
list of times :math:`t_n` at which to compute :math:`\\rho(t_n)`.
Must be uniformily spaced.
e_ops : list of :class:`qutip.Qobj` / callback function
single operator or list of operators for which to evaluate
expectation values.
learningtimes : array_like
list of times :math:`t_k` for which we have knowledge of the dynamical
maps :math:`E(t_k)`.
tensors : array_like
optional list of precomputed tensors :math:`T_k`
kwargs : dictionary
Optional keyword arguments. See
:class:`qutip.nonmarkov.ttm.TTMSolverOptions`.
Returns
-------
output: :class:`qutip.solver.Result`
An instance of the class :class:`qutip.solver.Result`.
"""
opt = TTMSolverOptions(dynmaps=dynmaps, times=times,
learningtimes=learningtimes, **kwargs)
diff = None
if isket(rho0):
rho0 = ket2dm(rho0)
output = Result()
e_sops_data = []
if callable(e_ops):
n_expt_op = 0
expt_callback = True
else:
try:
tmp = e_ops[:]
del tmp
n_expt_op = len(e_ops)
expt_callback = False
if n_expt_op == 0:
# fall back on storing states
opt.store_states = True
for op in e_ops:
e_sops_data.append(spre(op).data)
if op.isherm and rho0.isherm:
output.expect.append(np.zeros(len(times)))
else:
output.expect.append(np.zeros(len(times), dtype=complex))
except TypeError:
raise TypeError("Argument 'e_ops' should be a callable or" +
"list-like.")
if tensors is None:
tensors, diff = _generatetensors(dynmaps, learningtimes, opt=opt)
rho0vec = operator_to_vector(rho0)
K = len(tensors)
states = [rho0vec]
for n in range(1, len(times)):
states.append(None)
for k in range(n):
if n-k < K:
states[-1] += tensors[n-k]*states[k]
for i, r in enumerate(states):
if opt.store_states or expt_callback:
if r.type == 'operator-ket':
states[i] = vector_to_operator(r)
else:
states[i] = r
if expt_callback:
# use callback method
e_ops(times[i], states[i])
for m in range(n_expt_op):
if output.expect[m].dtype == complex:
output.expect[m][i] = expect_rho_vec(e_sops_data[m], r, 0)
else:
output.expect[m][i] = expect_rho_vec(e_sops_data[m], r, 1)
output.solver = "ttmsolve"
output.times = times
output.ttmconvergence = diff
if opt.store_states:
output.states = states
return output