@@ -25,24 +25,24 @@ The return depends on `fock_basis`.
2525- `fock_basis=Val(false)`: return the Bloch-Redfield tensor (in the eigen basis) along with the transformation matrix from eigen to fock basis.
2626"""
2727function bloch_redfield_tensor (
28- H:: QuantumObject{Operator} ,
29- a_ops:: Union{AbstractVector, Tuple} ,
30- c_ops:: Union{AbstractVector, Tuple, Nothing} = nothing ;
31- sec_cutoff:: Real = 0.1 ,
32- fock_basis:: Union{Val,Bool} = Val (false )
33- )
28+ H:: QuantumObject{Operator} ,
29+ a_ops:: Union{AbstractVector,Tuple} ,
30+ c_ops:: Union{AbstractVector,Tuple,Nothing} = nothing ;
31+ sec_cutoff:: Real = 0.1 ,
32+ fock_basis:: Union{Val,Bool} = Val (false ),
33+ )
3434 rst = eigenstates (H)
3535 U = QuantumObject (rst. vectors, Operator (), H. dimensions)
3636 sec_cutoff = float (sec_cutoff)
3737
3838 # in fock basis
3939 R0 = liouvillian (H, c_ops)
40-
40+
4141 # set fock_basis=Val(false) and change basis together at the end
4242 R1 = 0
4343 if ! isempty (a_ops)
44- R1 += mapreduce (x -> _brterm (rst, x[1 ], x[2 ], sec_cutoff, Val (false )), + , a_ops)
45-
44+ R1 += mapreduce (x -> _brterm (rst, x[1 ], x[2 ], sec_cutoff, Val (false )), + , a_ops)
45+
4646 # do (a_op, spectra)
4747 # _brterm(rst, a_op, spectra, sec_cutoff, Val(false))
4848 # end
@@ -83,12 +83,12 @@ The return depends on `fock_basis`.
8383- `fock_basis=Val(false)`: return the Bloch-Redfield term (in the eigen basis) along with the transformation matrix from eigen to fock basis.
8484"""
8585function brterm (
86- H:: QuantumObject{Operator} ,
87- a_op:: QuantumObject{Operator} ,
88- spectra:: Function ;
89- sec_cutoff:: Real = 0.1 ,
90- fock_basis:: Union{Bool, Val} = Val (false )
91- )
86+ H:: QuantumObject{Operator} ,
87+ a_op:: QuantumObject{Operator} ,
88+ spectra:: Function ;
89+ sec_cutoff:: Real = 0.1 ,
90+ fock_basis:: Union{Bool,Val} = Val (false ),
91+ )
9292 rst = eigenstates (H)
9393 term = _brterm (rst, a_op, spectra, sec_cutoff, makeVal (fock_basis))
9494 if getVal (fock_basis)
@@ -99,20 +99,19 @@ function brterm(
9999end
100100
101101function _brterm (
102- rst:: EigsolveResult ,
103- a_op:: T ,
104- spectra:: F ,
105- sec_cutoff:: Real ,
106- fock_basis:: Union{Val{true},Val{false}}
107- ) where {T<: QuantumObject{Operator} ,F<: Function }
108-
102+ rst:: EigsolveResult ,
103+ a_op:: T ,
104+ spectra:: F ,
105+ sec_cutoff:: Real ,
106+ fock_basis:: Union{Val{true},Val{false}} ,
107+ ) where {T<: QuantumObject{Operator} ,F<: Function }
109108 _check_br_spectra (spectra)
110109
111- U, N = rst. vectors, prod (rst. dimensions)
112-
110+ U, N = rst. vectors, prod (rst. dimensions)
111+
113112 skew = @. rst. values - rst. values' |> real
114113 spectrum = spectra .(skew)
115-
114+
116115 A_mat = U' * a_op. data * U
117116
118117 ac_term = (A_mat .* spectrum) * A_mat
@@ -128,16 +127,14 @@ function _brterm(
128127 vec_skew = vec (skew)
129128 M_cut = @. abs (vec_skew - vec_skew' ) < sec_cutoff
130129 end
131-
132- out = 0.5 * (
133- + _sprepost (A_mat .* trans (spectrum), A_mat)
134- + _sprepost (A_mat, A_mat .* spectrum)
135- - _spost (ac_term, Id)
136- - _spre (bd_term, Id)
137- )
130+
131+ out =
132+ 0.5 * (
133+ + _sprepost (A_mat .* trans (spectrum), A_mat) + _sprepost (A_mat, A_mat .* spectrum) - _spost (ac_term, Id) -
134+ _spre (bd_term, Id)
135+ )
138136
139137 (sec_cutoff != - 1 ) && (out .*= M_cut)
140-
141138
142139 if getVal (fock_basis)
143140 SU = _sprepost (U, U' )
@@ -147,8 +144,6 @@ function _brterm(
147144 end
148145end
149146
150-
151-
152147@doc raw """
153148 brmesolve(
154149 H::QuantumObject{Operator},
@@ -183,25 +178,23 @@ Solves for the dynamics of a system using the Bloch-Redfield master equation, gi
183178- `sol::TimeEvolutionSol`: The solution of the time evolution. See also [`TimeEvolutionSol`](@ref)
184179"""
185180function brmesolve (
186- H:: QuantumObject{Operator} ,
187- ψ0:: QuantumObject ,
188- tlist:: AbstractVector ,
189- a_ops:: Union{Nothing, AbstractVector, Tuple} ,
190- c_ops:: Union{Nothing, AbstractVector, Tuple} = nothing ;
191- sec_cutoff:: Real = 0.1 ,
192- e_ops:: Union{Nothing, AbstractVector} = nothing ,
193- kwargs... ,
194- )
195-
196- R = bloch_redfield_tensor (H, a_ops, c_ops; sec_cutoff= sec_cutoff, fock_basis= Val (true ))
197-
198- return mesolve (R, ψ0, tlist, nothing ; e_ops= e_ops, kwargs... )
181+ H:: QuantumObject{Operator} ,
182+ ψ0:: QuantumObject ,
183+ tlist:: AbstractVector ,
184+ a_ops:: Union{Nothing,AbstractVector,Tuple} ,
185+ c_ops:: Union{Nothing,AbstractVector,Tuple} = nothing ;
186+ sec_cutoff:: Real = 0.1 ,
187+ e_ops:: Union{Nothing,AbstractVector} = nothing ,
188+ kwargs... ,
189+ )
190+ R = bloch_redfield_tensor (H, a_ops, c_ops; sec_cutoff = sec_cutoff, fock_basis = Val (true ))
191+
192+ return mesolve (R, ψ0, tlist, nothing ; e_ops = e_ops, kwargs... )
199193end
200194
201195function _check_br_spectra (f:: Function )
202196 meths = methods (f, [Real])
203- length (meths. ms) == 0 && throw (
204- ArgumentError (" The following function must accept one argument: `$(meths. mt. name) (ω)` with ω<:Real" )
205- )
197+ length (meths. ms) == 0 &&
198+ throw (ArgumentError (" The following function must accept one argument: `$(meths. mt. name) (ω)` with ω<:Real" ))
206199 return nothing
207200end
0 commit comments