Skip to content

Commit 127cb3b

Browse files
authored
Bump version to v2.9.0 to align with main package (#211)
1 parent c48fae0 commit 127cb3b

22 files changed

+183
-156
lines changed

Project.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "HierarchicalEOM"
22
uuid = "a62dbcb7-80f5-4d31-9a88-8b19fd92b128"
3+
version = "2.9.0"
34
authors = ["Yi-Te Huang"]
4-
version = "2.8.0"
55

66
[deps]
77
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
@@ -12,6 +12,7 @@ LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
1212
OrdinaryDiffEqCore = "bbf590c4-e513-4bbe-9b18-05decba2e5d8"
1313
OrdinaryDiffEqLowOrderRK = "1344f307-1e59-4825-a18e-ace9aa3fa4c6"
1414
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
15+
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
1516
QuantumToolbox = "6c2fb7c5-b903-41d2-bc5e-5a7c320b9fab"
1617
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
1718
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
@@ -35,7 +36,8 @@ LinearSolve = "2.4.2 - 3"
3536
OrdinaryDiffEqCore = "1"
3637
OrdinaryDiffEqLowOrderRK = "1"
3738
Pkg = "1"
38-
QuantumToolbox = "0.37"
39+
ProgressMeter = "1.11.0"
40+
QuantumToolbox = "0.38.1"
3941
Reexport = "1"
4042
SciMLBase = "2.105"
4143
SciMLOperators = "1.4"

docs/src/spectrum.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The output of the above listed functions will always be in the type of `Vector{F
1717

1818
## Common and optional parameters
1919
Furthermore, there are two common optional parameters for all the functions provided below:
20-
- `verbose::Bool` : To display verbose output and progress bar during the process or not. Defaults to `true`.
20+
- `progress_bar::Union{Val,Bool}`: Whether to show the progress bar. Defaults to `Val(true)`.
2121
- `filename::String` : If filename was specified, the value of spectrum for each ω will be saved into the file "filename.txt" during the solving process.
2222

2323
If the filename is specified, the function will automatically save (update) the value (together with a comma behind it) to a new line in the file (with ".txt" behind the filename) once it obtains the solution of each specified ``\omega``. For example, if you specify `filename="test"` and `ωlist=0:1:5`, you will obtain a file `test.txt` where each line in this file (as shown below) is the result of spectrum corresponding to the given `ωlist`:

docs/src/time_evolution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ To construct the propagator, we wrap the function in the package [`fastExpm.jl`]
129129
See the docstring of this method:
130130

131131
```@docs
132-
HEOMsolve(M::AbstractHEOMLSMatrix ,ρ0::T_state, Δt::Real, steps::Int; e_ops::Union{Nothing,AbstractVector} = nothing, threshold = 1.0e-6, nonzero_tol = 1.0e-14, verbose::Bool = true) where {T_state<:Union{QuantumObject,ADOs}}
132+
HEOMsolve(M::AbstractHEOMLSMatrix ,ρ0::T_state, Δt::Real, steps::Int; e_ops::Union{Nothing,AbstractVector} = nothing, threshold = 1.0e-6, nonzero_tol = 1.0e-14, progress_bar::Union{Val,Bool} = Val(true)) where {T_state<:Union{QuantumObject,ADOs}}
133133
```
134134

135135
```julia

src/HierarchicalEOM.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import Base.Threads: @threads, nthreads, Channel
6060
import FastExpm: fastExpm
6161
import IncompleteLU: ilu
6262
import Pkg
63+
import ProgressMeter: Progress, next!
6364

6465
# Basic functions
6566
include("HeomBase.jl")

src/density_of_states.jl

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export DensityOfStates
22

33
@doc raw"""
4-
DensityOfStates(M, ρ, d_op, ωlist; alg, verbose, filename, kwargs...)
4+
DensityOfStates(M, ρ, d_op, ωlist; alg, progress_bar, filename, kwargs...)
55
Calculate density of states for the fermionic system in frequency domain.
66
77
```math
@@ -14,7 +14,7 @@ Calculate density of states for the fermionic system in frequency domain.
1414
- `d_op::QuantumObject` : The annihilation operator (``d`` as shown above) acting on the fermionic system.
1515
- `ωlist::AbstractVector` : the specific frequency points to solve.
1616
- `alg::SciMLLinearSolveAlgorithm` : The solving algorithm in package `LinearSolve.jl`. Default to `KrylovJL_GMRES(rtol=1e-12, atol=1e-14)`.
17-
- `verbose::Bool` : To display verbose output and progress bar during the process or not. Defaults to `true`.
17+
- `progress_bar::Union{Val,Bool}`: Whether to show the progress bar. Defaults to `Val(true)`.
1818
- `filename::String` : If filename was specified, the value of spectrum for each ω will be saved into the file "filename.txt" during the solving process.
1919
- `kwargs` : The keyword arguments for `LinearProblem`.
2020
@@ -30,24 +30,22 @@ Calculate density of states for the fermionic system in frequency domain.
3030
d_op::QuantumObject,
3131
ωlist::AbstractVector;
3232
alg::SciMLLinearSolveAlgorithm = KrylovJL_GMRES(rtol = 1e-12, atol = 1e-14),
33-
verbose::Bool = true,
33+
progress_bar::Union{Val,Bool} = Val(true),
3434
filename::String = "",
3535
kwargs...,
3636
)
3737
haskey(kwargs, :solver) &&
38-
error("The keyword argument `solver` for DensityOfStates has been deprecated, please use `alg` instead.")
38+
error("The keyword argument `solver` for DensityOfStates is deprecated, use `alg` instead.")
39+
haskey(kwargs, :verbose) &&
40+
error("The keyword argument `verbose` for DensityOfStates is deprecated, use `progress_bar` instead.")
3941

4042
# check M
41-
if M.parity == EVEN
42-
error("The HEOMLS matrix M must be acting on `ODD`-parity operators.")
43-
end
43+
(M.parity == EVEN) && error("The HEOMLS matrix M must be acting on `ODD`-parity operators.")
4444

4545
# Handle ρ
4646
if typeof(ρ) == ADOs # ρ::ADOs
4747
ados = ρ
48-
if ados.parity != EVEN
49-
error("The parity of ρ must be `EVEN`.")
50-
end
48+
(ados.parity != EVEN) && error("The parity of ρ must be `EVEN`.")
5149
else
5250
ados = ADOs(ρ, M.N)
5351
end
@@ -75,45 +73,36 @@ Calculate density of states for the fermionic system in frequency domain.
7573
Length = length(ωList)
7674
= Vector{Float64}(undef, Length)
7775

78-
if verbose
79-
print("Calculating density of states in frequency domain...\n")
80-
flush(stdout)
81-
end
82-
prog = ProgressBar(Length; enable = verbose)
76+
progr = Progress(
77+
Length;
78+
enabled = getVal(progress_bar),
79+
desc = "[DensityOfStates] ",
80+
QuantumToolbox.settings.ProgressMeterKWARGS...,
81+
)
8382
i = convert(ElType, 1im)
8483
I_total = I(size(M, 1))
85-
cache_m = cache_p = nothing
86-
for ω in ωList
87-
= i * ω * I_total
88-
89-
if prog.counter[] == 0
90-
cache_m = init(LinearProblem(M.data.A - Iω, b_m), alg, kwargs...)
91-
sol_m = solve!(cache_m)
92-
93-
cache_p = init(LinearProblem(M.data.A + Iω, b_p), alg, kwargs...)
94-
sol_p = solve!(cache_p)
95-
else
84+
Iω1 = i * ωList[1] * I_total
85+
cache_m = init(LinearProblem(M.data.A - Iω1, b_m), alg, kwargs...)
86+
cache_p = init(LinearProblem(M.data.A + Iω1, b_p), alg, kwargs...)
87+
for (idx, ω) in enumerate(ωList)
88+
if idx > 1
89+
= i * ω * I_total
9690
cache_m.A = M.data.A -
97-
sol_m = solve!(cache_m)
98-
9991
cache_p.A = M.data.A +
100-
sol_p = solve!(cache_p)
10192
end
93+
sol_m = solve!(cache_m)
94+
sol_p = solve!(cache_p)
10295

10396
# trace over the Hilbert space of system (expectation value)
10497
val = -1 * real(dot(_tr_d_normal, sol_p.u) + dot(_tr_d_dagger, sol_m.u))
105-
Aω[prog.counter[]+1] = val
98+
Aω[idx] = val
10699

107100
if SAVE
108101
open(FILENAME, "a") do file
109102
return write(file, "$(val),\n")
110103
end
111104
end
112-
next!(prog)
105+
next!(progr)
113106
end
114-
if verbose
115-
println("[DONE]")
116-
end
117-
118107
return
119108
end

src/deprecated.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function C(args...)
5353
end
5454

5555
_HEOMSuperOp_deprecated_method_error() = error(
56-
"Specifying `mul_basis = \"L\", \"R\", or \"LR\"` to `HEOMSuperOp` has been deprecated, try to construct system SuperOperator manually by using `spre`, `spost`, or `sprepost`.",
56+
"Specifying `mul_basis = \"L\", \"R\", or \"LR\"` to `HEOMSuperOp` is deprecated, try to construct system SuperOperator manually by using `spre`, `spost`, or `sprepost`.",
5757
)
5858

5959
HEOMSuperOp(op, opParity::AbstractParity, dims, N::Int, mul_basis::AbstractString; Id_cache = I(N)) =

src/evolution.jl

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ function Base.show(io::IO, sol::TimeEvolutionHEOMSol)
5757
end
5858

5959
@doc raw"""
60-
HEOMsolve(M, ρ0, Δt, steps; e_ops, threshold, nonzero_tol, verbose)
61-
heomsolve(M, ρ0, Δt, steps; e_ops, threshold, nonzero_tol, verbose)
60+
HEOMsolve(M, ρ0, Δt, steps; e_ops, threshold, nonzero_tol, progress_bar)
61+
heomsolve(M, ρ0, Δt, steps; e_ops, threshold, nonzero_tol, progress_bar)
6262
6363
Solve the time evolution for auxiliary density operators based on propagator (generated by `FastExpm.jl`).
6464
@@ -70,7 +70,7 @@ Solve the time evolution for auxiliary density operators based on propagator (ge
7070
- `e_ops::Union{Nothing,AbstractVector}`: List of operators for which to calculate expectation values.
7171
- `threshold::Real` : Determines the threshold for the Taylor series. Defaults to `1.0e-6`.
7272
- `nonzero_tol::Real` : Strips elements smaller than `nonzero_tol` at each computation step to preserve sparsity. Defaults to `1.0e-14`.
73-
- `verbose::Bool` : To display verbose output and progress bar during the process or not. Defaults to `true`.
73+
- `progress_bar::Union{Val,Bool}`: Whether to show the progress bar. Defaults to `Val(true)`.
7474
7575
# Notes
7676
- The [`ADOs`](@ref) will be saved depend on the keyword argument `e_ops`.
@@ -91,7 +91,7 @@ function HEOMsolve(
9191
e_ops::Union{Nothing,AbstractVector} = nothing,
9292
threshold = 1.0e-6,
9393
nonzero_tol = 1.0e-14,
94-
verbose::Bool = true,
94+
progress_bar::Union{Val,Bool} = Val(true),
9595
) where {T_state<:Union{QuantumObject,ADOs}}
9696

9797
# handle initial state
@@ -122,31 +122,31 @@ function HEOMsolve(
122122
end
123123

124124
# Generate propagator
125-
verbose && print("Generating propagator...")
125+
getVal(progress_bar) && print("Generating propagator...")
126126
exp_Mt = Propagator(M, Δt; threshold = threshold, nonzero_tol = nonzero_tol)
127-
verbose && println("[DONE]")
127+
getVal(progress_bar) && println("[DONE]")
128128

129129
# start solving
130-
if verbose
131-
print("Solving time evolution for ADOs by propagator method...")
132-
flush(stdout)
133-
end
134-
progr = ProgressBar(steps + 1, enable = verbose)
130+
progr = Progress(
131+
steps + 1;
132+
enabled = getVal(progress_bar),
133+
desc = "[HEOMsolve (propagator)] ",
134+
QuantumToolbox.settings.ProgressMeterKWARGS...,
135+
)
135136
for n in 0:steps
136137
# calculate expectation values
137138
if !is_empty_e_ops
138139
_expect = op -> dot(op, ρvec)
139-
@. expvals[:, progr.counter[]+1] = _expect(tr_e_ops)
140+
@. expvals[:, n+1] = _expect(tr_e_ops)
140141
n == steps ? ADOs_list[1] = ADOs(ρvec, M.dimensions, M.N, M.parity) : nothing
141142
else
142143
ADOs_list[n+1] = ADOs(ρvec, M.dimensions, M.N, M.parity)
143144
end
144145

145146
ρvec = exp_Mt * ρvec
146-
next!(progr)
147-
end
148147

149-
verbose && println("[DONE]")
148+
getVal(progress_bar) && next!(progr)
149+
end
150150

151151
return TimeEvolutionHEOMSol(
152152
_getBtier(M),
@@ -245,11 +245,10 @@ function HEOMsolve(
245245
inplace::Union{Val,Bool} = Val(true),
246246
kwargs...,
247247
) where {T_state<:Union{QuantumObject,ADOs}}
248-
haskey(kwargs, :solver) &&
249-
error("The keyword argument `solver` for HEOMsolve has been deprecated, please use `alg` instead.")
248+
haskey(kwargs, :solver) && error("The keyword argument `solver` for HEOMsolve is deprecated, use `alg` instead.")
250249
haskey(kwargs, :verbose) &&
251-
error("The keyword argument `verbose` for HEOMsolve has been deprecated, please use `progress_bar` instead.")
252-
haskey(kwargs, :filename) && error("The keyword argument `filename` for HEOMsolve has been deprecated.")
250+
error("The keyword argument `verbose` for HEOMsolve is deprecated, use `progress_bar` instead.")
251+
haskey(kwargs, :filename) && error("The keyword argument `filename` for HEOMsolve is deprecated.")
253252

254253
# Move sensealg argument to solve for Enzyme.jl support.
255254
# TODO: Remove it when https://github.com/SciML/SciMLSensitivity.jl/issues/1225 is fixed.
@@ -314,7 +313,7 @@ function _generate_Eops(M::AbstractHEOMLSMatrix, e_ops, Id_sys, Id_HEOM)
314313
return tr_e_ops
315314
end
316315

317-
struct SaveFuncHEOMSolve{TE,PT<:Union{Nothing,ProgressBar},IT,TEXPV<:Union{Nothing,AbstractMatrix}} <: AbstractSaveFunc
316+
struct SaveFuncHEOMSolve{TE,PT<:Union{Nothing,Progress},IT,TEXPV<:Union{Nothing,AbstractMatrix}} <: AbstractSaveFunc
318317
tr_e_ops::TE
319318
progr::PT
320319
iter::IT
@@ -341,7 +340,14 @@ function _generate_heom_kwargs(
341340
)
342341
tr_e_ops = e_ops isa Nothing ? nothing : _generate_Eops(M, e_ops, I(prod(M.dimensions)), I(M.N))
343342

344-
progr = getVal(progress_bar) ? ProgressBar(length(tlist), enable = getVal(progress_bar)) : nothing
343+
progr =
344+
getVal(progress_bar) ?
345+
Progress(
346+
length(tlist);
347+
enabled = getVal(progress_bar),
348+
desc = "[HEOMsolve (ODE)] ",
349+
QuantumToolbox.settings.ProgressMeterKWARGS...,
350+
) : nothing
345351

346352
expvals = e_ops isa Nothing ? nothing : Array{ComplexF64}(undef, length(e_ops), length(tlist))
347353

@@ -451,7 +457,7 @@ HEOMsolve_map(
451457
# this method is for advanced usage
452458
# User can define their own iterator structure, prob_func and output_func
453459
# - `prob_func`: Function to use for generating the ODEProblem.
454-
# - `output_func`: a `Tuple` containing the `Function` to use for generating the output of a single trajectory, the (optional) `ProgressBar` object, and the (optional) `RemoteChannel` object.
460+
# - `output_func`: a `Tuple` containing the `Function` to use for generating the output of a single trajectory, the (optional) `Progress` object, and the (optional) `RemoteChannel` object.
455461
#
456462
# Return: An array of TimeEvolutionSol objects with the size same as the given iter.
457463
function HEOMsolve_map(
@@ -468,7 +474,13 @@ function HEOMsolve_map(
468474
_prob_func = isnothing(prob_func) ? (prob, i, repeat) -> _se_me_map_prob_func(prob, i, repeat, iter) : prob_func
469475
_output_func =
470476
isnothing(output_func) ?
471-
_ensemble_dispatch_output_func(ensemblealg, progress_bar, ntraj, _standard_output_func) : output_func
477+
_ensemble_dispatch_output_func(
478+
ensemblealg,
479+
progress_bar,
480+
ntraj,
481+
_standard_output_func;
482+
progr_desc = "[HEOMsolve_map] ",
483+
) : output_func
472484
ens_prob = TimeEvolutionProblem(
473485
EnsembleProblem(prob.prob, prob_func = _prob_func, output_func = _output_func[1], safetycopy = false),
474486
prob.times,

src/heom_matrices/M_Boson.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ Note that the parity only need to be set as `ODD` when the system contains fermi
9595
if verbose
9696
println("Preparing block matrices for HEOM Liouvillian superoperator (using $(Nthread) threads)...")
9797
flush(stdout)
98-
prog = ProgressBar(Nado)
98+
progr = Progress(Nado; enabled = verbose, desc = "[M_Boson] ", QuantumToolbox.settings.ProgressMeterKWARGS...)
9999
end
100100
@threads for idx in 1:Nado
101101

@@ -146,9 +146,7 @@ Note that the parity only need to be set as `ODD` when the system contains fermi
146146
end
147147
end
148148
end
149-
if verbose
150-
next!(prog) # trigger a progress bar update
151-
end
149+
verbose && next!(progr) # trigger a progress bar update
152150
end
153151
if verbose
154152
print("Constructing matrix...")

src/heom_matrices/M_Boson_Fermion.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,12 @@ Note that the parity only need to be set as `ODD` when the system contains fermi
133133
if verbose
134134
println("Preparing block matrices for HEOM Liouvillian superoperator (using $(Nthread) threads)...")
135135
flush(stdout)
136-
prog = ProgressBar(Nado)
136+
progr = Progress(
137+
Nado;
138+
enabled = verbose,
139+
desc = "[M_Boson_Fermion] ",
140+
QuantumToolbox.settings.ProgressMeterKWARGS...,
141+
)
137142
end
138143
@threads for idx in 1:Nado
139144

@@ -221,9 +226,7 @@ Note that the parity only need to be set as `ODD` when the system contains fermi
221226
end
222227
end
223228
end
224-
if verbose
225-
next!(prog) # trigger a progress bar update
226-
end
229+
verbose && next!(progr) # trigger a progress bar update
227230
end
228231
if verbose
229232
print("Constructing matrix...")

src/heom_matrices/M_Fermion.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Generate the fermion-type HEOM Liouvillian superoperator matrix
9393
if verbose
9494
println("Preparing block matrices for HEOM Liouvillian superoperator (using $(Nthread) threads)...")
9595
flush(stdout)
96-
prog = ProgressBar(Nado)
96+
progr = Progress(Nado; enabled = verbose, desc = "[M_Fermion] ", QuantumToolbox.settings.ProgressMeterKWARGS...)
9797
end
9898
@threads for idx in 1:Nado
9999

@@ -143,9 +143,7 @@ Generate the fermion-type HEOM Liouvillian superoperator matrix
143143
end
144144
end
145145
end
146-
if verbose
147-
next!(prog) # trigger a progress bar update
148-
end
146+
verbose && next!(progr) # trigger a progress bar update
149147
end
150148
if verbose
151149
print("Constructing matrix...")

0 commit comments

Comments
 (0)