Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing code format #3

Merged
merged 2 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 29 additions & 16 deletions qutip/solver/correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
qeye, Qobj, QobjEvo, liouvillian, spre, unstack_columns, stack_columns,
tensor, qzero, expect
)
from . floquet import FloquetBasis,FLiMESolver
from .floquet import FloquetBasis
from .flimesolve import FLiMESolver
from .mesolve import MESolver
from .mcsolve import MCSolver
from .brmesolve import BRSolver
Expand Down Expand Up @@ -78,7 +79,7 @@ def correlation_2op_1t(H, state0, taulist, c_ops, a_op, b_op,
See, Gardiner, Quantum Noise, Section 5.2.

"""
solver = _make_solver(H, c_ops, args, options, solver,taulist)
solver = _make_solver(H, c_ops, args, options, solver)

if reverse:
A_op, B_op, C_op = a_op, b_op, 1
Expand All @@ -87,7 +88,7 @@ def correlation_2op_1t(H, state0, taulist, c_ops, a_op, b_op,
if state0 is None:
state0 = steadystate(H, c_ops)

return correlation_3op(solver, state0, [0], taulist, A_op, B_op, C_op)#[0]
return correlation_3op(solver, state0, [0], taulist, A_op, B_op, C_op)[0]


def correlation_2op_2t(H, state0, tlist, taulist, c_ops, a_op, b_op,
Expand Down Expand Up @@ -147,8 +148,7 @@ def correlation_2op_2t(H, state0, tlist, taulist, c_ops, a_op, b_op,
See, Gardiner, Quantum Noise, Section 5.2.

"""

solver = _make_solver(H, c_ops, args, options, solver,taulist)
solver = _make_solver(H, c_ops, args, options, solver)
if tlist is None:
tlist = [0]
if state0 is None:
Expand Down Expand Up @@ -215,7 +215,7 @@ def correlation_3op_1t(H, state0, taulist, c_ops, a_op, b_op, c_op,
See, Gardiner, Quantum Noise, Section 5.2.

"""
solver = _make_solver(H, c_ops, args, options, solver,taulist)
solver = _make_solver(H, c_ops, args, options, solver)
if state0 is None:
state0 = steadystate(H, c_ops)
return correlation_3op(solver, state0, [0], taulist, a_op, b_op, c_op)[0]
Expand Down Expand Up @@ -281,7 +281,7 @@ def correlation_3op_2t(H, state0, tlist, taulist, c_ops, a_op, b_op, c_op,
See, Gardiner, Quantum Noise, Section 5.2.

"""
solver = _make_solver(H, c_ops, args, options, solver,taulist)
solver = _make_solver(H, c_ops, args, options, solver)

if tlist is None:
tlist = [0]
Expand Down Expand Up @@ -337,7 +337,7 @@ def coherence_function_g1(
The normalized and unnormalized second-order coherence function.

"""
solver = _make_solver(H, c_ops, args, options, solver,taulist)
solver = _make_solver(H, c_ops, args, options, solver)

# first calculate the photon number
if state0 is None:
Expand Down Expand Up @@ -399,7 +399,7 @@ def coherence_function_g2(H, state0, taulist, c_ops, a_op, solver="me",
The normalized and unnormalized second-order coherence function.

"""
solver = _make_solver(H, c_ops, args, options, solver,taulist)
solver = _make_solver(H, c_ops, args, options, solver)

# first calculate the photon number
if state0 is None:
Expand All @@ -415,18 +415,31 @@ def coherence_function_g2(H, state0, taulist, c_ops, a_op, solver="me",
g2 = G2 / (n[0] * np.array(n))
return g2, G2

def _make_solver(H, c_ops, args, options, solver,taulist = None):
H = QobjEvo(H, args=args)
# c_ops = [QobjEvo(c_op, args=args) for c_op in c_ops]
def _make_solver(H, c_ops, args, options, solver):
if solver =="fme":
if isinstance(H, FloquetBasis):
floquet_basis = H
else:
T = options['T']
# are for the open system evolution.
floquet_basis = FloquetBasis(H, T, args, precompute=None)
try:
time_sense = options['time sense']
except KeyError:
time_sense = 0
solver_instance = FLiMESolver(
floquet_basis,
c_ops,
args,
time_sense=time_sense)
else:
H = QobjEvo(H, args=args)
c_ops = [QobjEvo(c_op, args=args) for c_op in c_ops]
if solver == "me":
solver_instance = MESolver(H, c_ops, options=options)
elif solver == "es":
options = {"method": "diag"}
solver_instance = MESolver(H, c_ops, options=options)
elif solver == "fme":

floquet_basis = FloquetBasis(H,options['T'],args)
solver_instance = FLiMESolver(floquet_basis, c_ops, taulist, args)
elif solver == "mc":
raise ValueError("MC solver for correlation has been removed")
return solver_instance
Expand Down
Loading