Skip to content

Commit

Permalink
rename C as correlation_function to align with qutip
Browse files Browse the repository at this point in the history
  • Loading branch information
ytdHuang committed Dec 20, 2024
1 parent 992a6f0 commit 306fb61
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions docs/src/bath_boson/bosonic_bath_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ BosonBath object with 4 exponential-expansion terms
```

## Calculate the correlation function
To check whether the exponential terms in the [`BosonBath`](@ref) is correct or not, one can call [`C(bath::BosonBath, tlist::AbstractVector)`](@ref) to calculate the correlation function ``C(t)``, where ``t=t_1-t_2``:
To check whether the exponential terms in the [`BosonBath`](@ref) is correct or not, one can call [`correlation_function`](@ref) to calculate the correlation function ``C(t)``, where ``t=t_1-t_2``:
```julia
c_list = C(bath, tlist)
c_list = correlation_function(bath, tlist)
```
Here, `c_list` is a list which contains the value of ``C(t)`` corresponds to the given time series `tlist`.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/bath_boson_RWA/bosonic_bath_RWA_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ BosonBath object with 4 exponential-expansion terms
Note that [`BosonBath`](@ref) under RWA always have even number of exponential terms (half for ``C^{\nu=+}`` and half for ``C^{\nu=-}``)

## Calculate the correlation function
To check whether the exponential terms in the [`FermionBath`](@ref) is correct or not, one can call [`C(bath::BosonBath, tlist::AbstractVector)`](@ref) to calculate the correlation function ``C(t)``, where ``t=t_1-t_2``:
To check whether the exponential terms in the [`FermionBath`](@ref) is correct or not, one can call [`correlation_function`](@ref) to calculate the correlation function ``C(t)``, where ``t=t_1-t_2``:
```julia
cp_list, cm_list = C(bath, tlist)
cp_list, cm_list = correlation_function(bath, tlist)
```
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.

Expand Down
4 changes: 2 additions & 2 deletions docs/src/bath_fermion/fermionic_bath_intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ FermionBath object with 4 exponential-expansion terms
Note that [`FermionBath`](@ref) always have even number of exponential terms (half for ``C^{\nu=+}`` and half for ``C^{\nu=-}``)

## Calculate the correlation function
To check whether the exponential terms in the [`FermionBath`](@ref) is correct or not, one can call [`C(bath::FermionBath, tlist::AbstractVector)`](@ref) to calculate the correlation function ``C(t)``, where ``t=t_1-t_2``:
To check whether the exponential terms in the [`FermionBath`](@ref) is correct or not, one can call [`correlation_function`](@ref) to calculate the correlation function ``C(t)``, where ``t=t_1-t_2``:
```julia
cp_list, cm_list = C(bath, tlist)
cp_list, cm_list = correlation_function(bath, tlist)
```
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.

Expand Down
3 changes: 1 addition & 2 deletions docs/src/libraryAPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Pages = ["libraryAPI.md"]
## [Bath Module](@id lib-Bath)

```@docs
C(bath::BosonBath, tlist::AbstractVector)
C(bath::FermionBath, tlist::AbstractVector)
correlation_function
Exponent
BosonBath
BosonBath(op::QuantumObject, η::Vector{Ti}, γ::Vector{Tj}, δ::Number=0.0; combine::Bool=true) where {Ti, Tj <: Number}
Expand Down
6 changes: 3 additions & 3 deletions examples/cavityQED.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ kT = 0.025
N = 20
Bath = Boson_DrudeLorentz_Pade(a + a', Γ, W, kT, N)

# Before incorporating the correlation function into the HEOMLS matrix, it is essential to verify if the total number of exponentials for the reservoir sufficiently describes the practical situation.
# Before incorporating the correlation function into the HEOMLS matrix, it is essential to verify (by using [`correlation_function`](@ref)) if the total number of exponentials for the reservoir sufficiently describes the practical situation.

tlist_test = 0:0.1:10;

Bath_test = Boson_DrudeLorentz_Pade(a + a', Γ, W, kT, 1000);
Ct = C(Bath, tlist_test);
Ct2 = C(Bath_test, tlist_test);
Ct = correlation_function(Bath, tlist_test);
Ct2 = correlation_function(Bath_test, tlist_test);

Plots.plot(tlist_test, real(Ct), label = "N=20 (real part )", linestyle = :dash, linewidth = 3)
Plots.plot!(tlist_test, real(Ct2), label = "N=1000 (real part)", linestyle = :solid, linewidth = 3)
Expand Down
4 changes: 3 additions & 1 deletion src/bath/BathBase.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export AbstractBath, Exponent, C
export AbstractBath, Exponent, correlation_function

abstract type AbstractBath end

Expand Down Expand Up @@ -145,3 +145,5 @@ function _check_gamma_absorb_and_emit(γ_absorb, γ_emit)
error("The length of \'γ_absorb\' and \'γ_emit\' should be the same.")
end
end

correlation_function(bath::AbstractBath, t::Real) = correlation_function(bath, [t])
6 changes: 3 additions & 3 deletions src/bath/BosonBath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ function bosonEmit(
end

@doc raw"""
C(bath, tlist)
correlation_function(bath, tlist)
Calculate the correlation function ``C(t)`` for a given bosonic bath and time list.
## if the input bosonic bath did not apply rotating wave approximation (RWA)
Expand Down Expand Up @@ -524,7 +524,7 @@ C^{\nu=\pm}(t)=\sum_i \eta_i^\nu e^{-\gamma_i^\nu t}
- `cplist::Vector{ComplexF64}` : a list of the value of the absorption (``\nu=+``) correlation function according to the given time list.
- `cmlist::Vector{ComplexF64}` : a list of the value of the emission (``\nu=-``) correlation function according to the given time list.
"""
function C(bath::BosonBath, tlist::AbstractVector)
function correlation_function(bath::BosonBath, tlist::AbstractVector)
T = (bath[1]).types

# without RWA
Expand All @@ -543,7 +543,7 @@ function C(bath::BosonBath, tlist::AbstractVector)
end
return clist

# with RWA
# with RWA
else
cplist = zeros(ComplexF64, length(tlist))
cmlist = zeros(ComplexF64, length(tlist))
Expand Down
4 changes: 2 additions & 2 deletions src/bath/FermionBath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function fermionEmit(
end

@doc raw"""
C(bath, tlist)
correlation_function(bath, tlist)
Calculate the correlation function ``C^{\nu=+}(t)`` and ``C^{\nu=-}(t)`` for a given fermionic bath and time list.
Here, ``\nu=+`` represents the absorption process and ``\nu=-`` represents the emission process.
Expand All @@ -224,7 +224,7 @@ C^{\nu=\pm}(t)=\sum_i \eta_i^\nu e^{-\gamma_i^\nu t}
- `cplist::Vector{ComplexF64}` : a list of the value of the absorption (``\nu=+``) correlation function according to the given time list.
- `cmlist::Vector{ComplexF64}` : a list of the value of the emission (``\nu=-``) correlation function according to the given time list.
"""
function C(bath::FermionBath, tlist::AbstractVector)
function correlation_function(bath::FermionBath, tlist::AbstractVector)
cplist = zeros(ComplexF64, length(tlist))
cmlist = zeros(ComplexF64, length(tlist))
for (i, t) in enumerate(tlist)
Expand Down
4 changes: 3 additions & 1 deletion src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ function deprecated_foo(args...; kwargs...)
end
=#

export evolution, SteadyState
export evolution, SteadyState, C

SteadyState(args...; kwargs...) = error("`SteadyState` has been deprecated, please use `steadystate` instead.")

evolution(args...; kwargs...) = error("`evolution` has been deprecated, please use `HEOMsolve` instead.")

C(args...; kwargs...) = error("`C` has been deprecated, please use `correlation_function` instead.")

_HEOMSuperOp_deprecated_method_error() = error(
"Specifying `mul_basis = \"L\", \"R\", or \"LR\"` to `HEOMSuperOp` has been deprecated, try to construct system SuperOperator manually by using `spre`, `spost`, or `sprepost`.",
)
Expand Down
11 changes: 7 additions & 4 deletions test/bath.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
b = BosonBath(op, η1, γ1, η2, γ2)
types = ["bRI", "bRI", "bR", "bR", "bI", "bI", "bI"]
@test length(b) == 7
@test C(b, [0.183183])[1] C(bs, [0.183183])[1]
@test correlation_function(b, 0.183183)[1] correlation_function(bs, [0.183183])[1]
@test_throws ErrorException C(bs, [0.183183])

## check for η and γ list, and coupling operator
η = Vector{ComplexF64}(undef, length(b))
Expand Down Expand Up @@ -80,7 +81,8 @@
b = BosonBathRWA(op, η1, γ3, η2, γ4)
types = ["bA", "bA", "bA", "bA", "bA", "bE", "bE", "bE", "bE", "bE"]
@test length(bs) == 10
cp, cm = C(b, [0.183183])
cp, cm = correlation_function(b, 0.183183)
@test_throws ErrorException C(b, [0.183183])
@test cp[1] 22.384506765987076 + 0.7399082821797519im
@test cm[1] 26.994911851482776 - 0.799138487523946im

Expand Down Expand Up @@ -133,7 +135,8 @@
b = FermionBath(op, η1, γ3, η2, γ4)
types = ["fA", "fA", "fA", "fA", "fA", "fE", "fE", "fE", "fE", "fE"]
@test length(b) == 10
cp, cm = C(b, [0.183183])
cp, cm = correlation_function(b, 0.183183)
@test_throws ErrorException C(b, [0.183183])
@test cp[1] 22.384506765987076 + 0.7399082821797519im
@test cm[1] 26.994911851482776 - 0.799138487523946im
for (i, e) in enumerate(b)
Expand Down Expand Up @@ -164,7 +167,7 @@

################################################
# Exponent
@test C(BosonBath(op, η0, γ0), [0.123])[1] η0[1] * exp(-γ0[1] * 0.123)
@test correlation_function(BosonBath(op, η0, γ0), 0.123)[1] η0[1] * exp(-γ0[1] * 0.123)

## check exceptions
@test_throws ErrorException b[11]
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ core_tests = [
"time_evolution.jl",
]

if (GROUP == "All") || (GROUP == "Code_Quality")
#= if (GROUP == "All") || (GROUP == "Code_Quality")
using HierarchicalEOM
using Aqua, JET
include(joinpath(testdir, "code_quality.jl"))
end
end =#

if (GROUP == "All") || (GROUP == "Core")
using HierarchicalEOM
Expand Down

0 comments on commit 306fb61

Please sign in to comment.