Skip to content

Commit 670cb4b

Browse files
TendonFFFcailixun
andauthored
Use FillArrays.jl (#214)
Co-authored-by: cailixun <[email protected]>
1 parent f710893 commit 670cb4b

22 files changed

+174
-116
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ authors = ["Yi-Te Huang"]
66
[deps]
77
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
88
FastExpm = "7868e603-8603-432e-a1a1-694bd70b01f2"
9+
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
910
IncompleteLU = "40713840-3770-5561-ab4c-a76e7d0d7895"
1011
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1112
LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae"
@@ -30,14 +31,15 @@ HierarchicalEOM_CUDAExt = "CUDA"
3031
CUDA = "5"
3132
DiffEqCallbacks = "2 - 4"
3233
FastExpm = "1.1"
34+
FillArrays = "1"
3335
IncompleteLU = "0.2"
3436
LinearAlgebra = "1"
3537
LinearSolve = "2.4.2 - 3"
3638
OrdinaryDiffEqCore = "1"
3739
OrdinaryDiffEqLowOrderRK = "1"
3840
Pkg = "1"
3941
ProgressMeter = "1.11.0"
40-
QuantumToolbox = "0.38.1"
42+
QuantumToolbox = "0.39"
4143
Reexport = "1"
4244
SciMLBase = "2.105"
4345
SciMLOperators = "1.4"

docs/make.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ using Documenter, HierarchicalEOM
66

77
DocMeta.setdocmeta!(HierarchicalEOM, :DocTestSetup, :(using HierarchicalEOM); recursive = true)
88

9-
const DRAFT = false # set `true` to disable cell evaluation
9+
# some options for makedocs
10+
const DRAFT = get(ENV, "DRAFT", false) == "true" # DRAFT = true disables cell evaluation
1011

1112
const MathEngine = MathJax3(
1213
Dict(

docs/src/bath_boson/bosonic_bath_intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ c_list = correlation_function(bath, tlist)
6262
```
6363
Here, `c_list` is a list which contains the value of ``C(t)`` corresponds to the given time series `tlist`.
6464

65-
## Exponent
65+
## Exponential terms of the Bosonic Bath
6666
`HierarchicalEOM.jl` also supports users to access the specific exponential term with brackets `[]`. This returns an [`Exponent`](@ref) object, which contains the corresponding value of ``\eta_i`` and ``\gamma_i``:
6767
```julia
6868
e = bath[2] # the 2nd-term

docs/src/bath_boson_RWA/bosonic_bath_RWA_intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cp_list, cm_list = correlation_function(bath, tlist)
4747
```
4848
Here, `cp_list` and `cm_list` are the lists which contain the value of ``C^{\nu=+}(t)`` and ``C^{\nu=-}(t)`` correspond to the given time series `tlist`, respectively.
4949

50-
## Exponent
50+
## Exponential terms of the Bosonic Bath (RWA)
5151
`HierarchicalEOM.jl` also supports users to access the specific exponential term with brackets `[]`. This returns an [`Exponent`](@ref) object, which contains the corresponding value of ``\eta_i^\nu`` and ``\gamma_i^\nu``:
5252
```julia
5353
e = bath[2] # the 2nd-term

docs/src/bath_fermion/fermionic_bath_intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ cp_list, cm_list = correlation_function(bath, tlist)
5050
```
5151
Here, `cp_list` and `cm_list` are the lists which contain the value of ``C^{\nu=+}(t)`` and ``C^{\nu=-}(t)`` correspond to the given time series `tlist`, respectively.
5252

53-
## Exponent
53+
## Exponential terms of the Fermionic Bath
5454
`HierarchicalEOM.jl` also supports users to access the specific exponential term with brackets `[]`. This returns an [`Exponent`](@ref) object, which contains the corresponding value of ``\eta_i^\nu`` and ``\gamma_i^\nu``:
5555
```julia
5656
e = bath[2] # the 2nd-term

docs/src/libraryAPI.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ M_Fermion
7272
M_Fermion(Hsys::QuantumObject, tier::Int, Bath::Vector{FermionBath}, parity::AbstractParity=EVEN; threshold::Real=0.0, verbose::Bool=true)
7373
M_Boson_Fermion
7474
M_Boson_Fermion(Hsys::QuantumObject, tier_b::Int, tier_f::Int, Bath_b::Vector{BosonBath}, Bath_f::Vector{FermionBath}, parity::AbstractParity=EVEN; threshold::Real=0.0, verbose::Bool=true)
75-
size(M::HEOMSuperOp)
76-
size(M::HEOMSuperOp, dim::Int)
77-
size(M::AbstractHEOMLSMatrix)
78-
size(M::AbstractHEOMLSMatrix, dim::Int)
79-
eltype(M::HEOMSuperOp)
80-
eltype(M::AbstractHEOMLSMatrix)
75+
Base.size(M::HEOMSuperOp)
76+
Base.size(M::HEOMSuperOp, dim::Int)
77+
Base.size(M::AbstractHEOMLSMatrix)
78+
Base.size(M::AbstractHEOMLSMatrix, dim::Int)
79+
Base.eltype(M::HEOMSuperOp)
80+
Base.eltype(M::AbstractHEOMLSMatrix)
81+
iscached
82+
isconstant
8183
Propagator
8284
addBosonDissipator
8385
addFermionDissipator
@@ -88,8 +90,8 @@ addTerminator
8890
```@docs
8991
ADOs
9092
ADOs(V::AbstractVector, N::Int)
91-
length(A::ADOs)
92-
eltype(A::ADOs)
93+
Base.length(A::ADOs)
94+
Base.eltype(A::ADOs)
9395
getRho
9496
getADO
9597
QuantumToolbox.expect
@@ -106,6 +108,7 @@ getIndexEnsemble
106108
## [Time Evolution](@id lib-Time-Evolution)
107109
There are two function definitions of `HEOMsolve`, which depend on different methods to solve the time evolution:
108110
```@docs
111+
HEOMsolveProblem
109112
HEOMsolve
110113
HEOMsolve_map
111114
TimeEvolutionHEOMSol

docs/src/time_evolution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ The first method is implemented by solving the ordinary differential equation (O
6666
See the docstring of this method:
6767

6868
```@docs
69-
HEOMsolve(M::AbstractHEOMLSMatrix, ρ0::T_state, tlist::AbstractVector; e_ops::Union{Nothing,AbstractVector} = nothing, alg::OrdinaryDiffEqAlgorithm = DP5(), H_t::Union{Nothing,Function} = nothing, params::NamedTuple = NamedTuple(), progress_bar::Union{Val,Bool} = Val(true), inplace::Union{Val,Bool} = Val(true), kwargs...) where {T_state<:Union{QuantumObject,ADOs}}
69+
HEOMsolve(M::AbstractHEOMLSMatrix, ρ0::T_state, tlist::AbstractVector; e_ops::Union{Nothing,AbstractVector} = nothing, alg::AbstractODEAlgorithm = DP5(), H_t::Union{Nothing,Function} = nothing, params::NamedTuple = NamedTuple(), progress_bar::Union{Val,Bool} = Val(true), inplace::Union{Val,Bool} = Val(true), kwargs...) where {T_state<:Union{QuantumObject,ADOs}}
7070
```
7171

7272
```julia

src/HeomBase.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
export AbstractHEOMLSMatrix
22

3+
@doc raw"""
4+
abstract type AbstractHEOMLSMatrix{T}
5+
6+
Abstract type for all HEOM liouvillian superoperators
7+
"""
38
abstract type AbstractHEOMLSMatrix{T} end
49

510
function Base.getproperty(M::AbstractHEOMLSMatrix, key::Symbol)

src/HierarchicalEOM.jl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ module HierarchicalEOM
44
using LinearAlgebra
55
using SparseArrays
66

7+
import Base.Threads: @threads, nthreads, Channel
8+
import Pkg
9+
710
# Re-export QuantumToolbox
811
import Reexport: @reexport
912
@reexport using QuantumToolbox
@@ -17,11 +20,13 @@ import QuantumToolbox:
1720
_spost,
1821
_sprepost,
1922
_liouvillian,
23+
_sum_lindblad_dissipators,
2024
_gen_dimensions,
2125
_get_dims_string,
2226
dimensions_to_dims,
2327
_save_func,
2428
_merge_saveat,
29+
_merge_tstops,
2530
_merge_kwargs_with_callback,
2631
_get_expvals,
2732
_se_me_map_prob_func,
@@ -47,19 +52,24 @@ import SciMLBase:
4752
EnsembleThreads,
4853
FullSpecialize,
4954
CallbackSet,
50-
NullParameters
55+
NullParameters,
56+
AbstractODEAlgorithm
5157
import SciMLOperators:
52-
AbstractSciMLOperator, MatrixOperator, ScaledOperator, AddedOperator, update_coefficients!, concretize
53-
import OrdinaryDiffEqCore: OrdinaryDiffEqAlgorithm
58+
SciMLOperators,
59+
AbstractSciMLOperator,
60+
MatrixOperator,
61+
ScaledOperator,
62+
AddedOperator,
63+
update_coefficients!,
64+
concretize
5465
import OrdinaryDiffEqLowOrderRK: DP5
5566
import DiffEqCallbacks: FunctionCallingCallback, TerminateSteadyState
5667
import LinearSolve: LinearProblem, SciMLLinearSolveAlgorithm, KrylovJL_GMRES
5768

5869
# other dependencies (in alphabetical order)
59-
import Base.Threads: @threads, nthreads, Channel
6070
import FastExpm: fastExpm
71+
import FillArrays: Eye
6172
import IncompleteLU: ilu
62-
import Pkg
6373
import ProgressMeter: Progress, next!
6474

6575
# Basic functions

src/bath/BosonBath.jl

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,7 @@ function bosonReal(op::QuantumObject, η_real::Vector{Ti}, γ_real::Vector{Tj})
240240
if N_exp_term != length(γ_real)
241241
error("The length of \'η_real\' and \'γ_real\' should be the same.")
242242
end
243-
Id_cache = I(size(_op, 1))
244-
return bosonReal(_spre(_op.data, Id_cache) - _spost(_op.data, Id_cache), _op.dimensions, η_real, γ_real, N_exp_term)
243+
return bosonReal(_spre(_op.data) - _spost(_op.data), _op.dimensions, η_real, γ_real, N_exp_term)
245244
end
246245

247246
@doc raw"""
@@ -285,9 +284,8 @@ function bosonImag(op::QuantumObject, η_imag::Vector{Ti}, γ_imag::Vector{Tj})
285284
if N_exp_term != length(γ_imag)
286285
error("The length of \'η_imag\' and \'γ_imag\' should be the same.")
287286
end
288-
Id_cache = I(size(_op, 1))
289-
spreQ = _spre(_op.data, Id_cache)
290-
spostQ = _spost(_op.data, Id_cache)
287+
spreQ = _spre(_op.data)
288+
spostQ = _spost(_op.data)
291289
return bosonImag(spreQ - spostQ, spreQ + spostQ, _op.dimensions, η_imag, γ_imag, N_exp_term)
292290
end
293291

@@ -340,9 +338,8 @@ function bosonRealImag(
340338
if (N_exp_term != length(η_imag)) || (N_exp_term != length(γ))
341339
error("The length of \'η_real\', \'η_imag\' and \'γ\' should be the same.")
342340
end
343-
Id_cache = I(size(_op, 1))
344-
spreQ = _spre(_op.data, Id_cache)
345-
spostQ = _spost(_op.data, Id_cache)
341+
spreQ = _spre(_op.data)
342+
spostQ = _spost(_op.data)
346343
return bosonRealImag(spreQ - spostQ, spreQ + spostQ, _op.dimensions, η_real, η_imag, γ, N_exp_term)
347344
end
348345

@@ -437,11 +434,10 @@ function bosonAbsorb(
437434
if (N_exp_term != length(γ_absorb)) || (N_exp_term != length(η_emit))
438435
error("The length of \'η_absorb\', \'γ_absorb\' and \'η_emit\' should all be the same.")
439436
end
440-
Id_cache = I(size(_op, 1))
441437
return bosonAbsorb(
442-
_spre(_op.data, Id_cache),
443-
_spost(_op.data, Id_cache),
444-
_spre(adjoint(_op).data, Id_cache) - _spost(adjoint(_op).data, Id_cache),
438+
_spre(_op.data),
439+
_spost(_op.data),
440+
_spre(adjoint(_op).data) - _spost(adjoint(_op).data),
445441
_op.dimensions,
446442
η_absorb,
447443
γ_absorb,
@@ -501,11 +497,10 @@ function bosonEmit(
501497
if (N_exp_term != length(γ_emit)) || (N_exp_term != length(η_absorb))
502498
error("The length of \'η_emit\', \'γ_emit\' and \'η_absorb\' should all be the same.")
503499
end
504-
Id_cache = I(size(_op, 1))
505500
return bosonEmit(
506-
_spre(_op.data, Id_cache),
507-
_spost(_op.data, Id_cache),
508-
_spre(adjoint(_op).data, Id_cache) - _spost(adjoint(_op).data, Id_cache),
501+
_spre(_op.data),
502+
_spost(_op.data),
503+
_spre(adjoint(_op).data) - _spost(adjoint(_op).data),
509504
_op.dimensions,
510505
η_emit,
511506
γ_emit,

0 commit comments

Comments
 (0)