Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for QuantumOptics.jl #28

Merged
merged 16 commits into from
Sep 16, 2023
25 changes: 17 additions & 8 deletions .github/workflows/Runtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
julia-version: ['1.8']
julia-arch: [x64]
os: [ubuntu-latest] # [ubuntu-latest, windows-latest, macOS-latest]
group:
- Core
julia-version:
- '1'
- '1.8'
include:
- julia-version: '1'
group: 'HierarchicalEOM_QOExt'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.julia-version }}
- uses: julia-actions/cache@v1
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@latest
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
env:
GROUP: ${{ matrix.group }}
- uses: julia-actions/julia-processcoverage@v1
with:
directories: src,ext
- uses: codecov/codecov-action@v3
with:
file: lcov.info
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@latest
- uses: julia-actions/setup-julia@v1
with:
version: '1.9'
version: '1'
- uses: julia-actions/cache@v1
- name: Install X Server dependencies
run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
Expand All @@ -29,4 +29,11 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ docs/make.jl
run: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' julia --project=docs/ --code-coverage=user docs/make.jl
- uses: julia-actions/julia-processcoverage@v1
with:
directories: src
- uses: codecov/codecov-action@v3
with:
file: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
7 changes: 7 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
QuantumOptics = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SciMLOperators = "c0aeaf25-5076-4817-a8d5-81caf7dfa961"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
SteadyStateDiffEq = "9672c7b4-1e72-59bd-8a11-6ac3964bc41f"

[weakdeps]
QuantumOptics = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c"

[extensions]
HierarchicalEOM_QOExt = "QuantumOptics"

[compat]
Crayons = "4.1"
FastExpm = "1.1.0"
Expand Down
17 changes: 13 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ const PAGES = Any[
"Cite HierarchicalEOM" => "cite.md"
],
"Manual" => Any[
"Bosonic Bath" => "bosonic_bath.md",
"Fermionic Bath" => "fermionic_bath.md",
"Bosonic Bath" => Any[
"Introduction" => "bath_boson/bosonic_bath_intro.md",
"Drude-Lorentz Spectral Density" => "bath_boson/Boson_Drude_Lorentz.md"
],
"Fermionic Bath" => Any[
"Introduction" => "bath_fermion/fermionic_bath_intro.md",
"Lorentz Spectral Density" => "bath_fermion/Fermion_Lorentz.md"
],
"Auxiliary Density Operators" => "ADOs.md",
"HEOMLS Matrices" => Any[
"Introduction" => "heom_matrix/intro.md",
"Introduction" => "heom_matrix/HEOMLS_intro.md",
"HEOMLS for Schrödinger Equation" => "heom_matrix/schrodinger_eq.md",
"HEOMLS for Bosonic Bath" => "heom_matrix/M_Boson.md",
"HEOMLS for Fermionic Bath" => "heom_matrix/M_Fermion.md",
Expand All @@ -66,7 +72,10 @@ const PAGES = Any[
"Stationary State" => "stationary_state.md",
"Spectrum" => "spectrum.md",
"Examples" => EX_output_files,
"Benchmark Solvers" => BM_output_files
"Benchmark Solvers" => BM_output_files,
"Extensions" => Any[
"QuantumOptics.jl" => "extensions/QuantumOptics.md"
]
],
"Library API" => "libraryAPI.md"
]
Expand Down
53 changes: 53 additions & 0 deletions docs/src/bath_boson/Boson_Drude_Lorentz.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# [Drude-Lorentz Spectral Density](@id Boson-Drude-Lorentz)
```math
J(\omega)=\frac{4\Delta W\omega}{\omega^2+W^2}
```
Here, ``\Delta`` represents the coupling strength between system and the bosonic environment with band-width ``W``.

## Matsubara Expansion
With Matsubara Expansion, the correlation function can be analytically solved and expressed as follows:
```math
C(t_1, t_2)=\sum_{l=1}^{\infty} \eta_l \exp(-\gamma_l (t_1-t_2))
```
with
```math
\begin{aligned}
\gamma_{1} &= W,\\
\eta_{1} &= \Delta W\left[-i+\cot\left(\frac{W}{2 k_B T}\right)\right],\\
\gamma_{l\neq 1} &= 2\pi l k_B T,\\
\eta_{l\neq 1} &= -2 k_B T \cdot \frac{2\Delta W \cdot \gamma_l}{-\gamma_l^2 + W^2}.
\end{aligned}
```
This can be constructed by the built-in function [`Boson_DrudeLorentz_Matsubara`](@ref):
```julia
Vs # coupling operator
Δ # coupling strength
W # band-width of the environment
kT # the product of the Boltzmann constant k and the absolute temperature T
N # Number of exponential terms
bath = Boson_DrudeLorentz_Matsubara(Vs, Δ, W, kT, N - 1)
```

## Padé Expansion
With Padé Expansion, the correlation function can be analytically solved and expressed as the following exponential terms:
```math
C(t_1, t_2)=\sum_{l=1}^{\infty} \eta_l \exp(-\gamma_l (t_1-t_2))
```
with
```math
\begin{aligned}
\gamma_{1} &= W,\\
\eta_{1} &= \Delta W\left[-i+\cot\left(\frac{W}{2 k_B T}\right)\right],\\
\gamma_{l\neq 1} &= \zeta_l k_B T,\\
\eta_{l\neq 1} &= -2 \kappa_l k_B T \cdot \frac{2\Delta W \cdot \zeta_l k_B T}{-(\zeta_l k_B T)^2 + W^2},
\end{aligned}
```
where the parameters ``\kappa_l`` and ``\zeta_l`` are described in [J. Chem. Phys. 134, 244106 (2011)](https://doi.org/10.1063/1.3602466). This can be constructed by the built-in function [`Boson_DrudeLorentz_Pade`](@ref):
```julia
Vs # coupling operator
Δ # coupling strength
W # band-width of the environment
kT # the product of the Boltzmann constant k and the absolute temperature T
N # Number of exponential terms
bath = Boson_DrudeLorentz_Pade(Vs, Δ, W, kT, N - 1)
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# [Bosonic Bath](@id doc-Bosonic-Bath)
## [Introduction](@id Bosonic-Bath-Introduction)
## [Overview](@id Bosonic-Bath-Overview)
The [`BosonBath`](@ref) object describes the interaction between the system (``s``) and a exterior bosonic environment (``b``), which can be modeled by
```math
H_{sb}=V_{s}\sum_k g_k (b_k + b_k^\dagger),
Expand All @@ -19,17 +19,15 @@ C(t_1, t_2)=\sum_i \eta_i e^{-\gamma_i (t_1-t_2)}.
```
This allows us to define an iterative procedure which leads to the hierarchical equations of motion (HEOM).

## Methods

### Construct BosonBath (with real and imaginary parts are combined)
## Construct BosonBath (with real and imaginary parts are combined)
One can construct the [`BosonBath`](@ref) object with the coupling operator `Vs::AbstractMatrix` and the two lists `η::AbstractVector` and `γ::AbstractVector` which corresponds to the exponential terms ``\{\eta_i\}_i`` and ``\{\gamma_i\}_i``, respectively.
```julia
bath = BosonBath(Vs, η, γ)
```
!!! warning "Warning"
Here, the length of `η` and `γ` should be the same.

### Construct BosonBath (with real and imaginary parts are separated)
## Construct BosonBath (with real and imaginary parts are separated)
When ``\gamma_i \neq \gamma_i^*``, a closed form for the HEOM can be obtained by further decomposing ``C(t_1, t_2)`` into its real (R) and imaginary (I) parts as
```math
C(t_1, t_2)=\sum_{u=\textrm{R},\textrm{I}}(\delta_{u, \textrm{R}} + i\delta_{u, \textrm{I}})C^{u}(t_1, t_2)
Expand All @@ -48,7 +46,7 @@ Here, `η_real::AbstractVector`, `γ_real::AbstractVector`, `η_imag::AbstractVe
!!! note "Note"
Instead of analytically solving the correlation function ``C(t_1, t_2)`` to obtain a sum of exponential terms, one can also use the built-in functions (for different spectral densities ``J(\omega)`` and spectral decomposition methods, which have been analytically solved by the developers already) listed in the end of this page.

### Print Bosonic Bath
## Print Bosonic Bath
One can check the information of the [`BosonBath`](@ref) by the `print` function, for example:
```julia
print(bath)
Expand All @@ -57,14 +55,14 @@ print(bath)
BosonBath object with (system) dim = 2 and 4 exponential-expansion terms
```

### Calculate the correlation function
## 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``:
```julia
c_list = C(bath, tlist)
```
Here, `c_list` is a list which contains the value of ``C(t)`` corresponds to the given time series `tlist`.

### Methods for Exponent
## Exponent
`HierarchicalEOM.jl` also supports users to access the specific exponential term with brakets `[]`. This returns an [`Exponent`](@ref) object, which contains the corresponding value of ``\eta_i`` and ``\gamma_i``:
```julia
e = bath[2] # the 2nd-term
Expand All @@ -74,6 +72,11 @@ print(e)
Bath Exponent with types = "bRI", operator size = (2, 2), η = 1.5922874021206546e-6 + 0.0im, γ = 0.3141645167860635 + 0.0im.
```

The different types of the (bosonic-bath) [`Exponent`](@ref):
- `"bR"` : from real part of bosonic correlation function ``C^{u=\textrm{R}}(t_1, t_2)``
- `"bI"` : from imaginary part of bosonic correlation function ``C^{u=\textrm{I}}(t_1, t_2)``
- `"bRI"` : from combined (real and imaginary part) bosonic bath correlation function ``C(t_1, t_2)``

One can even obtain the [`Exponent`](@ref) with iterative method:
```julia
for e in bath
Expand All @@ -88,64 +91,4 @@ Bath Exponent with types = "bRI", operator size = (2, 2), η = 1.592287402120654
Bath Exponent with types = "bRI", operator size = (2, 2), η = 1.0039844180003819e-6 + 0.0im, γ = 0.6479143347831898 + 0.0im.

Bath Exponent with types = "bRI", operator size = (2, 2), η = 3.1005439801387293e-6 + 0.0im, γ = 1.8059644711829272 + 0.0im.
```

### Types of Exponent
The different types of the (bosonic-bath) [`Exponent`](@ref):
- `"bR"` : from real part of bosonic correlation function ``C^{u=\textrm{R}}(t_1, t_2)``
- `"bI"` : from imaginary part of bosonic correlation function ``C^{u=\textrm{I}}(t_1, t_2)``
- `"bRI"` : from combined (real and imaginary part) bosonic bath correlation function ``C(t_1, t_2)``

## [Drude-Lorentz Spectral Density](@id Boson-Drude-Lorentz)
```math
J(\omega)=\frac{4\Delta W\omega}{\omega^2+W^2}
```
Here, ``\Delta`` represents the coupling strength between system and the bosonic environment with band-width ``W``.

### Matsubara Expansion
With Matsubara Expansion, the correlation function can be analytically solved and expressed as follows:
```math
C(t_1, t_2)=\sum_{l=1}^{\infty} \eta_l \exp(-\gamma_l (t_1-t_2))
```
with
```math
\begin{aligned}
\gamma_{1} &= W,\\
\eta_{1} &= \Delta W\left[-i+\cot\left(\frac{W}{2 k_B T}\right)\right],\\
\gamma_{l\neq 1} &= 2\pi l k_B T,\\
\eta_{l\neq 1} &= -2 k_B T \cdot \frac{2\Delta W \cdot \gamma_l}{-\gamma_l^2 + W^2}.
\end{aligned}
```
This can be constructed by the built-in function [`Boson_DrudeLorentz_Matsubara`](@ref):
```julia
Vs # coupling operator
Δ # coupling strength
W # band-width of the environment
kT # the product of the Boltzmann constant k and the absolute temperature T
N # Number of exponential terms
bath = Boson_DrudeLorentz_Matsubara(Vs, Δ, W, kT, N - 1)
```

### Padé Expansion
With Padé Expansion, the correlation function can be analytically solved and expressed as the following exponential terms:
```math
C(t_1, t_2)=\sum_{l=1}^{\infty} \eta_l \exp(-\gamma_l (t_1-t_2))
```
with
```math
\begin{aligned}
\gamma_{1} &= W,\\
\eta_{1} &= \Delta W\left[-i+\cot\left(\frac{W}{2 k_B T}\right)\right],\\
\gamma_{l\neq 1} &= \zeta_l k_B T,\\
\eta_{l\neq 1} &= -2 \kappa_l k_B T \cdot \frac{2\Delta W \cdot \zeta_l k_B T}{-(\zeta_l k_B T)^2 + W^2},
\end{aligned}
```
where the parameters ``\kappa_l`` and ``\zeta_l`` are described in [J. Chem. Phys. 134, 244106 (2011)](https://doi.org/10.1063/1.3602466). This can be constructed by the built-in function [`Boson_DrudeLorentz_Pade`](@ref):
```julia
Vs # coupling operator
Δ # coupling strength
W # band-width of the environment
kT # the product of the Boltzmann constant k and the absolute temperature T
N # Number of exponential terms
bath = Boson_DrudeLorentz_Pade(Vs, Δ, W, kT, N - 1)
```
57 changes: 57 additions & 0 deletions docs/src/bath_fermion/Fermion_Lorentz.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# [Lorentz Spectral Density](@id doc-Fermion-Lorentz)
```math
J(\omega)=\frac{\Gamma W^2}{(\omega-\mu)^2+W^2}
```
Here, ``\Gamma`` represents the coupling strength between system and the fermionic environment with chemical potential ``\mu`` and band-width ``W``.

## Matsubara Expansion
With Matsubara Expansion, the correlation function can be analytically solved and expressed as follows:
```math
C^{\nu}(t_1, t_2)=\sum_{l=1}^{\infty} \eta_l^\nu \exp(-\gamma_l^\nu (t_1-t_2))
```
with
```math
\begin{aligned}
\gamma_{1}^{\nu} &= W-\nu i \mu,\\
\eta_{1}^{\nu} &= \frac{\Gamma W}{2} f\left(\frac{iW}{k_B T}\right),\\
\gamma_{l\neq 1}^{\nu} &= \zeta_l k_B T - \nu i \mu,\\
\eta_{l\neq 1}^{\nu} &= -i k_B T \cdot \frac{\Gamma W^2}{-(\zeta_l k_B T)^2+W^2},\\
f(x) &= \{\exp(x) + 1\}^{-1},
\end{aligned}
```
where ``\zeta_l=(2 l - 1)\pi``. This can be constructed by the built-in function [`Fermion_Lorentz_Matsubara`](@ref):
```julia
ds # coupling operator
Γ # coupling strength
μ # chemical potential of the environment
W # band-width of the environment
kT # the product of the Boltzmann constant k and the absolute temperature T
N # Number of exponential terms for each correlation functions (C^{+} and C^{-})
bath = Fermion_Lorentz_Matsubara(ds, Γ, μ, W, kT, N - 1)
```

## Padé Expansion
With Padé Expansion, the correlation function can be analytically solved and expressed as the following exponential terms:
```math
C^\nu(t_1, t_2)=\sum_{l=1}^{\infty} \eta_l^\nu \exp(-\gamma_l^\nu (t_1-t_2))
```
with
```math
\begin{aligned}
\gamma_{1}^{\nu} &= W-\nu i \mu,\\
\eta_{1}^{\nu} &= \frac{\Gamma W}{2} f\left(\frac{iW}{k_B T}\right),\\
\gamma_{l\neq 1}^{\nu} &= \zeta_l k_B T - \nu i \mu,\\
\eta_{l\neq 1}^{\nu} &= -i \kappa_l k_B T \cdot \frac{\Gamma W^2}{-(\zeta_l k_B T)^2+W^2},\\
f(x) &= \frac{1}{2}-\sum_{l=2}^{N} \frac{2\kappa_l x}{x^2+\zeta_l^2},
\end{aligned}
```
where the parameters ``\kappa_l`` and ``\zeta_l`` are described in [J. Chem. Phys. 134, 244106 (2011)](https://doi.org/10.1063/1.3602466) and ``N`` represents the number of exponential terms for ``C^{\nu=\pm}``. This can be constructed by the built-in function [`Fermion_Lorentz_Pade`](@ref):
```julia
ds # coupling operator
Γ # coupling strength
μ # chemical potential of the environment
W # band-width of the environment
kT # the product of the Boltzmann constant k and the absolute temperature T
N # Number of exponential terms for each correlation functions (C^{+} and C^{-})
bath = Fermion_Lorentz_Pade(ds, Γ, μ, W, kT, N - 1)
```
Loading