Skip to content
Draft
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
4 changes: 2 additions & 2 deletions docs/src/resources/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ dsf_mcsolve

```@docs
TimeEvolutionLRSol
lr_mesolveProblem
lr_mesolve
variational_lr_mesolveProblem
variational_lr_mesolve
```

## [Correlations and Spectrum](@id doc-API:Correlations-and-Spectrum)
Expand Down
2 changes: 1 addition & 1 deletion src/QuantumToolbox.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ include("time_evolution/callback_helpers/ssesolve_callback_helpers.jl")
include("time_evolution/callback_helpers/smesolve_callback_helpers.jl")
include("time_evolution/mesolve.jl")
include("time_evolution/brmesolve.jl")
include("time_evolution/lr_mesolve.jl")
include("time_evolution/variational_lr_mesolve.jl")
include("time_evolution/sesolve.jl")
include("time_evolution/mcsolve.jl")
include("time_evolution/ssesolve.jl")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export lr_mesolve, lr_mesolveProblem, TimeEvolutionLRSol
export variational_lr_mesolve, variational_lr_mesolveProblem, TimeEvolutionLRSol

@doc raw"""
struct TimeEvolutionLRSol
Expand Down Expand Up @@ -44,7 +44,7 @@ struct TimeEvolutionLRSol{
M::TM
end

lr_mesolve_options_default = (
variational_lr_mesolve_options_default = (
alg = DP5(),
progress = true,
err_max = 0.0,
Expand Down Expand Up @@ -104,7 +104,7 @@ end
_calculate_expectation!(p,z,B,idx)

Calculates the expectation values and function values of the operators and functions in p.e_ops and p.f_ops, respectively, and stores them in p.expvals and p.funvals.
The function is called by the callback _save_affect_lr_mesolve!.
The function is called by the callback _save_affect_variational_lr_mesolve!.

# Arguments

Expand Down Expand Up @@ -146,9 +146,9 @@ function _periodicsave_func(integrator)
return u_modified!(integrator, false)
end

_save_control_lr_mesolve(u, t, integrator) = t in integrator.p.times
_save_control_variational_lr_mesolve(u, t, integrator) = t in integrator.p.times

function _save_affect_lr_mesolve!(integrator)
function _save_affect_variational_lr_mesolve!(integrator)
ip = integrator.p
N, M = ip.N, ip.M
idx = select(integrator.t, ip.times)
Expand Down Expand Up @@ -367,19 +367,19 @@ get_B(u::AbstractArray{T}, N::Integer, M::Integer) where {T} = reshape(view(u, (
=#

@doc raw"""
lr_mesolveProblem(
variational_lr_mesolveProblem(
H::QuantumObject{Operator},
z::AbstractArray{T,2},
B::AbstractArray{T,2},
tlist::AbstractVector,
c_ops::Union{AbstractVector,Tuple}=();
e_ops::Union{AbstractVector,Tuple}=(),
f_ops::Union{AbstractVector,Tuple}=(),
opt::NamedTuple = lr_mesolve_options_default,
opt::NamedTuple = variational_lr_mesolve_options_default,
kwargs...,
)

Formulates the ODEproblem for the low-rank time evolution of the system. The function is called by [`lr_mesolve`](@ref). For more information about the low-rank master equation, see [gravina2024adaptive](@cite).
Formulates the ODEproblem for the low-rank time evolution of the system. The function is called by [`variational_lr_mesolve`](@ref). For more information about the low-rank master equation, see [gravina2024adaptive](@cite).

# Arguments
- `H::QuantumObject`: The Hamiltonian of the system.
Expand All @@ -392,15 +392,15 @@ Formulates the ODEproblem for the low-rank time evolution of the system. The fun
- `opt::NamedTuple`: The options of the low-rank master equation.
- `kwargs`: Additional keyword arguments.
"""
function lr_mesolveProblem(
function variational_lr_mesolveProblem(
H::QuantumObject{Operator},
z::AbstractArray{T,2},
B::AbstractArray{T,2},
tlist::AbstractVector,
c_ops::Union{AbstractVector,Tuple} = ();
e_ops::Union{AbstractVector,Tuple} = (),
f_ops::Union{AbstractVector,Tuple} = (),
opt::NamedTuple = lr_mesolve_options_default,
opt::NamedTuple = variational_lr_mesolve_options_default,
kwargs...,
) where {T}
Hdims = H.dimensions
Expand All @@ -418,7 +418,7 @@ function lr_mesolveProblem(
funvals = Array{ComplexF64}(undef, length(f_ops), length(t_l))
Ml = Array{Int64}(undef, length(t_l))

opt = merge(lr_mesolve_options_default, opt)
opt = merge(variational_lr_mesolve_options_default, opt)
if opt.err_max > 0
opt = merge(opt, (is_dynamical = true,))
end
Expand Down Expand Up @@ -458,7 +458,7 @@ function lr_mesolveProblem(
# Initialization of Callbacks
if !isempty(e_ops) || !isempty(f_ops)
_calculate_expectation!(p, z, B, 1)
cb_save = DiscreteCallback(_save_control_lr_mesolve, _save_affect_lr_mesolve!, save_positions = (false, false))
cb_save = DiscreteCallback(_save_control_variational_lr_mesolve, _save_affect_variational_lr_mesolve!, save_positions = (false, false))
kwargs2 = merge(
kwargs2,
haskey(kwargs2, :callback) ? Dict(:callback => CallbackSet(cb_save, kwargs2[:callback])) :
Expand Down Expand Up @@ -498,15 +498,15 @@ function lr_mesolveProblem(
end

@doc raw"""
lr_mesolve(
variational_lr_mesolve(
H::QuantumObject{Operator},
z::AbstractArray{T,2},
B::AbstractArray{T,2},
tlist::AbstractVector,
c_ops::Union{AbstractVector,Tuple}=();
e_ops::Union{AbstractVector,Tuple}=(),
f_ops::Union{AbstractVector,Tuple}=(),
opt::NamedTuple = lr_mesolve_options_default,
opt::NamedTuple = variational_lr_mesolve_options_default,
kwargs...,
)

Expand All @@ -523,22 +523,22 @@ Time evolution of an open quantum system using the low-rank master equation. For
- `opt::NamedTuple`: The options of the low-rank master equation.
- `kwargs`: Additional keyword arguments.
"""
function lr_mesolve(
function variational_lr_mesolve(
H::QuantumObject{Operator},
z::AbstractArray{T2,2},
B::AbstractArray{T2,2},
tlist::AbstractVector,
c_ops::Union{AbstractVector,Tuple} = ();
e_ops::Union{AbstractVector,Tuple} = (),
f_ops::Union{AbstractVector,Tuple} = (),
opt::NamedTuple = lr_mesolve_options_default,
opt::NamedTuple = variational_lr_mesolve_options_default,
kwargs...,
) where {T2}
prob = lr_mesolveProblem(H, z, B, tlist, c_ops; e_ops = e_ops, f_ops = f_ops, opt = opt, kwargs...)
return lr_mesolve(prob; kwargs...)
prob = variational_lr_mesolveProblem(H, z, B, tlist, c_ops; e_ops = e_ops, f_ops = f_ops, opt = opt, kwargs...)
return variational_lr_mesolve(prob; kwargs...)
end

function lr_mesolve(prob::ODEProblem; kwargs...)
function variational_lr_mesolve(prob::ODEProblem; kwargs...)
sol = solve(prob, prob.p.opt.alg, tstops = prob.p.times)
prob.p.opt.progress && print("\n")

Expand Down
2 changes: 1 addition & 1 deletion test/core-test/low_rank_dynamics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

opt = (err_max = 1e-3, p0 = 0.0, atol_inv = 1e-6, adj_condition = "variational", Δt = 0.0, progress = false)

sol_lr = lr_mesolve(H, z, B, tl, c_ops; e_ops = e_ops, f_ops = (f_entropy,), opt = opt)
sol_lr = variational_lr_mesolve(H, z, B, tl, c_ops; e_ops = e_ops, f_ops = (f_entropy,), opt = opt)

# Test
S_lr = real(sol_lr.fexpect[1, end]) / latt.N
Expand Down