Skip to content

Commit

Permalink
Automatically convert TimeDependentOperatorSum to liouvillian
Browse files Browse the repository at this point in the history
  • Loading branch information
albertomercurio committed Sep 26, 2024
1 parent db333c2 commit 96d6f0a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/qobj/operator_sum.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export OperatorSum
@doc raw"""
struct OperatorSum
A structure to represent a sum of operators ``\sum_i c_i \hat{O}_i`` with a list of coefficients ``c_i`` and a list of operators ``\hat{O}_i``.
A constructor to represent a sum of operators ``\sum_i c_i \hat{O}_i`` with a list of coefficients ``c_i`` and a list of operators ``\hat{O}_i``.
This is very useful when we have to update only the coefficients, without allocating memory by performing the sum of the operators.
"""
Expand Down Expand Up @@ -47,3 +47,7 @@ end
end
return y
end

function liouvillian(A::OperatorSum, Id_cache = I(prod(A.operators[1].dims)))
return OperatorSum(A.coefficients, liouvillian.(A.operators, Ref(Id_cache)))
end
4 changes: 4 additions & 0 deletions src/time_evolution/mesolve.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ function mesolveProblem(
is_empty_e_ops = isempty(e_ops)
end

if H_t isa TimeDependentOperatorSum
H_t = liouvillian(H_t)
end

p = (
L = L,
progr = progr,
Expand Down
4 changes: 4 additions & 0 deletions src/time_evolution/time_evolution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ end
return mul!(y, A.operator_sum, x, α, β)
end

function liouvillian(A::TimeDependentOperatorSum, Id_cache = I(prod(A.operator_sum.operators[1].dims)))
return TimeDependentOperatorSum(A.coefficient_functions, liouvillian(A.operator_sum, Id_cache))
end

#######################################

### LIOUVILLIAN ###
Expand Down
2 changes: 1 addition & 1 deletion test/core-test/steady_state.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
e_ops = [a_d * a]
psi0 = fock(N, 3)
t_l = LinRange(0, 100 * 2π, 1000)
H_t_f = TimeDependentOperatorSum([(t, p) -> sin(t)], [liouvillian(H_t)])
H_t_f = TimeDependentOperatorSum((((t, p) -> sin(t)),), [H_t]) # It will be converted to liouvillian internally
sol_me = mesolve(H, psi0, t_l, c_ops, e_ops = e_ops, H_t = H_t_f, progress_bar = Val(false))
ρ_ss1 = steadystate_floquet(H, -1im * 0.5 * H_t, 1im * 0.5 * H_t, 1, c_ops, solver = SSFloquetLinearSystem())[1]
ρ_ss2 =
Expand Down

0 comments on commit 96d6f0a

Please sign in to comment.