Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Giguere committed Oct 8, 2024
1 parent b790812 commit e2cbddd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
16 changes: 8 additions & 8 deletions qutip/solver/propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def propagator(
**kwargs :
Extra parameters to use when creating the
:obj:`.QobjEvo` from a list format ``H``. The most common as ``tlist``
and ``order`` for spline time dependance. See :obj:`.QobjEvo` for the
full list.
:obj:`.QobjEvo` from a list format ``H``. The most common are ``tlist``
and ``order`` for array-based time dependance. See :obj:`.QobjEvo` for
the full list.
Returns
-------
Expand All @@ -72,9 +72,9 @@ def propagator(
Notes
-----
Unlike :func:`.sesolve` or :func:`.mesolve`, the output times ``t`` are not
used for time dependent system with array based. ``tlist`` must be passed
as a keyword argument in those case. ``tlist`` and ``t`` can have different
Unlike :func:`.sesolve` or :func:`.mesolve`, the output times in ``t`` are
not used for array time dependent system. ``tlist`` must be passed as a
keyword argument in those case. ``tlist`` and ``t`` can have different
length and values.
"""
Expand All @@ -89,9 +89,9 @@ def propagator(
H = QobjEvo(H, args=args, **kwargs)

if isinstance(c_ops, list):
c_ops = [QobjEvo(op, args=args, **kwargs) for op in c_ops)]
c_ops = [QobjEvo(op, args=args, **kwargs) for op in c_ops]

if c_ops is not None:
if c_ops:
H = liouvillian(H, c_ops)

U0 = qeye_like(H)
Expand Down
18 changes: 16 additions & 2 deletions qutip/tests/solver/test_propagator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from scipy.integrate import trapezoid
from qutip import (destroy, propagator, Propagator, propagator_steadystate,
steadystate, tensor, qeye, basis, QobjEvo, sesolve,
liouvillian)
liouvillian, rand_dm)
import qutip
import pytest
from qutip.solver.brmesolve import BRSolver
from qutip.solver.mesolve import MESolver
from qutip.solver.mesolve import MESolver, mesolve
from qutip.solver.sesolve import SESolver
from qutip.solver.mcsolve import MCSolver

Expand Down Expand Up @@ -49,6 +49,20 @@ def testPropHOTd():
assert (U - U2).norm('max') < 1e-4


def testPropHOTd():
"Propagator: func array td format + open"
a = destroy(5)
H = a.dag()*a
ts = np.linspace(-0.01, 1.01, 103)
coeffs = np.cos(ts)
Htd = [H, [H, coeffs]]
rho_0 = rand_dm(5)
rho_1_prop = propagator(Htd, 1, c_ops=[a], tlist=ts)(rho_0)
rho_1_me = mesolve(QobjEvo(Htd, tlist=ts), rho_0, [0, 1], [a]).final_state

assert (rho_1_prop - rho_1_me).norm('max') < 1e-4


def testPropObjTd():
a = destroy(5)
H = a.dag()*a
Expand Down

0 comments on commit e2cbddd

Please sign in to comment.