From f70fb82167e00e0dfd376fbb5379168f3a2299bf Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Wed, 9 Oct 2024 14:18:40 +0000 Subject: [PATCH] build based on 8f64619 --- dev/.documenter-siteinfo.json | 2 +- dev/api/index.html | 116 ++--- dev/index.html | 2 +- dev/qutip_differences/index.html | 2 +- .../logo/{bd1c4db3.svg => 460466ec.svg} | 4 +- .../logo/{a6daf944.svg => 79a81d5f.svg} | 4 +- dev/tutorials/logo/index.html | 4 +- dev/tutorials/lowrank/index.html | 2 +- dev/type_stability/index.html | 50 +- .../QuantumObject/QuantumObject/index.html | 26 +- .../QuantumObject_functions/index.html | 2 +- dev/users_guide/extensions/cuda/index.html | 2 +- .../states_and_operators/index.html | 2 +- .../{75fdeca2.svg => 88a0c87d.svg} | 481 +++++++++--------- dev/users_guide/steadystate/index.html | 2 +- dev/users_guide/tensor/index.html | 2 +- .../time_evolution/intro/index.html | 2 +- .../time_evolution/mcsolve/index.html | 2 +- .../time_evolution/mesolve/index.html | 2 +- .../time_evolution/sesolve/index.html | 2 +- .../time_evolution/solution/index.html | 2 +- .../time_evolution/stochastic/index.html | 2 +- .../time_evolution/time_dependent/index.html | 2 +- 23 files changed, 357 insertions(+), 360 deletions(-) rename dev/tutorials/logo/{bd1c4db3.svg => 460466ec.svg} (99%) rename dev/tutorials/logo/{a6daf944.svg => 79a81d5f.svg} (99%) rename dev/users_guide/steadystate/{75fdeca2.svg => 88a0c87d.svg} (81%) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 5547dbb9..584c5f07 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.11.0","generation_timestamp":"2024-10-08T09:20:20","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.11.0","generation_timestamp":"2024-10-09T14:18:33","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index 4ae97588..5450bfd2 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -1,5 +1,5 @@ -API · QuantumToolbox.jl

API

Contents

Quantum object (Qobj) and type

QuantumToolbox.QuantumObjectType
struct QuantumObject{MT<:AbstractArray,ObjType<:QuantumObjectType,N}
+API · QuantumToolbox.jl

API

Contents

Quantum object (Qobj) and type

QuantumToolbox.QuantumObjectType
struct QuantumObject{MT<:AbstractArray,ObjType<:QuantumObjectType,N}
     data::MT
     type::ObjType
     dims::SVector{N, Int}
@@ -13,10 +13,10 @@
 ⎣⠀⠀⠀⠀⠀⠀⠀⠀⠈⠢⎦
 
 julia> a isa QuantumObject
-true
source
QuantumToolbox.OperatorSumType
struct OperatorSum

A constructor to represent a sum of operators $\sum_i c_i \hat{O}_i$ with a list of coefficients $c_i$ and a list of operators $\hat{O}_i$.

This is very useful when we have to update only the coefficients, without allocating memory by performing the sum of the operators.

source
Base.sizeFunction
size(A::QuantumObject)
-size(A::QuantumObject, idx::Int)

Returns a tuple containing each dimensions of the array in the QuantumObject.

Optionally, you can specify an index (idx) to just get the corresponding dimension of the array.

source
QuantumToolbox.isunitaryFunction
isunitary(U::QuantumObject; kwargs...)

Test whether the QuantumObject $U$ is unitary operator. This function calls Base.isapprox to test whether $U U^\dagger$ is approximately equal to identity operator.

Note that all the keyword arguments will be passed to Base.isapprox.

source

Qobj arithmetic and attributes

Base.adjointFunction
A'
-adjoint(A::QuantumObject)

Lazy adjoint (conjugate transposition) of the QuantumObject

Note that A' is a synonym for adjoint(A)

source
LinearAlgebra.dotFunction
dot(A::QuantumObject, B::QuantumObject)

Compute the dot product between two QuantumObject: $\langle A | B \rangle$

Note that A and B should be Ket or OperatorKet

A ⋅ B (where can be typed by tab-completing \cdot in the REPL) is a synonym for dot(A, B)

source
dot(i::QuantumObject, A::QuantumObject j::QuantumObject)

Compute the generalized dot product dot(i, A*j) between three QuantumObject: $\langle i | \hat{A} | j \rangle$

Supports the following inputs:

source
QuantumToolbox.OperatorSumType
struct OperatorSum

A constructor to represent a sum of operators $\sum_i c_i \hat{O}_i$ with a list of coefficients $c_i$ and a list of operators $\hat{O}_i$.

This is very useful when we have to update only the coefficients, without allocating memory by performing the sum of the operators.

source
Base.sizeFunction
size(A::QuantumObject)
+size(A::QuantumObject, idx::Int)

Returns a tuple containing each dimensions of the array in the QuantumObject.

Optionally, you can specify an index (idx) to just get the corresponding dimension of the array.

source
QuantumToolbox.isunitaryFunction
isunitary(U::QuantumObject; kwargs...)

Test whether the QuantumObject $U$ is unitary operator. This function calls Base.isapprox to test whether $U U^\dagger$ is approximately equal to identity operator.

Note that all the keyword arguments will be passed to Base.isapprox.

source

Qobj arithmetic and attributes

Base.adjointFunction
A'
+adjoint(A::QuantumObject)

Lazy adjoint (conjugate transposition) of the QuantumObject

Note that A' is a synonym for adjoint(A)

source
LinearAlgebra.dotFunction
dot(A::QuantumObject, B::QuantumObject)

Compute the dot product between two QuantumObject: $\langle A | B \rangle$

Note that A and B should be Ket or OperatorKet

A ⋅ B (where can be typed by tab-completing \cdot in the REPL) is a synonym for dot(A, B)

source
dot(i::QuantumObject, A::QuantumObject j::QuantumObject)

Compute the generalized dot product dot(i, A*j) between three QuantumObject: $\langle i | \hat{A} | j \rangle$

Supports the following inputs:

source
LinearAlgebra.trFunction
tr(A::QuantumObject)

Returns the trace of QuantumObject.

Note that this function only supports for Operator and SuperOperator

Examples

julia> a = destroy(20)
 Quantum Object:   type=Operator   dims=[20]   size=(20, 20)   ishermitian=false
 20×20 SparseMatrixCSC{ComplexF64, Int64} with 19 stored entries:
 ⠈⠢⡀⠀⠀⠀⠀⠀⠀⠀
@@ -26,7 +26,7 @@
 ⠀⠀⠀⠀⠀⠀⠀⠀⠈⠢
 
 julia> tr(a' * a)
-190.0 + 0.0im
source
LinearAlgebra.normFunction
norm(A::QuantumObject, p::Real)

Return the standard vector p-norm or Schatten p-norm of a QuantumObject depending on the type of A:

Examples

julia> ψ = fock(10, 2)
 Quantum Object:   type=Ket   dims=[10]   size=(10,)
 10-element Vector{ComplexF64}:
  0.0 + 0.0im
@@ -41,7 +41,7 @@
  0.0 + 0.0im
 
 julia> norm(ψ)
-1.0
source
QuantumToolbox.ptraceFunction
ptrace(QO::QuantumObject, sel)

Partial trace of a quantum state QO leaving only the dimensions with the indices present in the sel vector.

Note that this function will always return Operator. No matter the input QuantumObject is a Ket, Bra, or Operator.

Examples

Two qubits in the state $\ket{\psi} = \ket{e,g}$:

julia> ψ = kron(fock(2,0), fock(2,1))
+1.0
source
QuantumToolbox.ptraceFunction
ptrace(QO::QuantumObject, sel)

Partial trace of a quantum state QO leaving only the dimensions with the indices present in the sel vector.

Note that this function will always return Operator. No matter the input QuantumObject is a Ket, Bra, or Operator.

Examples

Two qubits in the state $\ket{\psi} = \ket{e,g}$:

julia> ψ = kron(fock(2,0), fock(2,1))
 Quantum Object:   type=Ket   dims=[2, 2]   size=(4,)
 4-element Vector{ComplexF64}:
  0.0 + 0.0im
@@ -65,12 +65,12 @@
 Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
 2×2 Matrix{ComplexF64}:
  0.5+0.0im  0.0+0.0im
- 0.0+0.0im  0.5+0.0im
source
QuantumToolbox.permuteFunction
permute(A::QuantumObject, order::Union{AbstractVector{Int},Tuple})

Permute the tensor structure of a QuantumObject A according to the specified order list

Note that this method currently works for Ket, Bra, and Operator types of QuantumObject.

Examples

If order = [2, 1, 3], the Hilbert space structure will be re-arranged: $\mathcal{H}_1 \otimes \mathcal{H}_2 \otimes \mathcal{H}_3 \rightarrow \mathcal{H}_2 \otimes \mathcal{H}_1 \otimes \mathcal{H}_3$.

julia> ψ1 = fock(2, 0)
+ 0.0+0.0im  0.5+0.0im
source
QuantumToolbox.permuteFunction
permute(A::QuantumObject, order::Union{AbstractVector{Int},Tuple})

Permute the tensor structure of a QuantumObject A according to the specified order list

Note that this method currently works for Ket, Bra, and Operator types of QuantumObject.

Examples

If order = [2, 1, 3], the Hilbert space structure will be re-arranged: $\mathcal{H}_1 \otimes \mathcal{H}_2 \otimes \mathcal{H}_3 \rightarrow \mathcal{H}_2 \otimes \mathcal{H}_1 \otimes \mathcal{H}_3$.

julia> ψ1 = fock(2, 0)
 julia> ψ2 = fock(3, 1)
 julia> ψ3 = fock(4, 2)
 julia> ψ_123 = tensor(ψ1, ψ2, ψ3)
 julia> permute(ψ_123, [2, 1, 3]) ≈ tensor(ψ2, ψ1, ψ3)
-true
Beware of type-stability!

It is highly recommended to use permute(A, order) with order as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.tidyupFunction
tidyup(A::QuantumObject, tol::Real=1e-14)

Given a QuantumObject A, check the real and imaginary parts of each element separately. Remove the real or imaginary value if its absolute value is less than tol.

source
QuantumToolbox.tidyup!Function
tidyup!(A::QuantumObject, tol::Real=1e-14)

Given a QuantumObject A, check the real and imaginary parts of each element separately. Remove the real or imaginary value if its absolute value is less than tol.

Note that this function is an in-place version of tidyup.

source
QuantumToolbox.get_coherenceFunction
get_coherence(ψ::QuantumObject)

Get the coherence value $\alpha$ by measuring the expectation value of the destruction operator $\hat{a}$ on a state $\ket{\psi}$ or a density matrix $\hat{\rho}$.

It returns both $\alpha$ and the corresponding state with the coherence removed: $\ket{\delta_\alpha} = \exp ( \alpha^* \hat{a} - \alpha \hat{a}^\dagger ) \ket{\psi}$ for a pure state, and $\hat{\rho_\alpha} = \exp ( \alpha^* \hat{a} - \alpha \hat{a}^\dagger ) \hat{\rho} \exp ( -\bar{\alpha} \hat{a} + \alpha \hat{a}^\dagger )$ for a density matrix. These states correspond to the quantum fluctuations around the coherent state $\ket{\alpha}$ or $|\alpha\rangle\langle\alpha|$.

source
QuantumToolbox.partial_transposeFunction
partial_transpose(ρ::QuantumObject, mask::Vector{Bool})

Return the partial transpose of a density matrix $\rho$, where mask is an array/vector with length that equals the length of ρ.dims. The elements in mask are boolean (true or false) which indicates whether or not the corresponding subsystem should be transposed.

Arguments

  • ρ::QuantumObject: The density matrix (ρ.type must be OperatorQuantumObject).
  • mask::Vector{Bool}: A boolean vector selects which subsystems should be transposed.

Returns

  • ρ_pt::QuantumObject: The density matrix with the selected subsystems transposed.
source

Qobj eigenvalues and eigenvectors

QuantumToolbox.EigsolveResultType
struct EigsolveResult{T1<:Vector{<:Number}, T2<:AbstractMatrix{<:Number}, ObjType<:Union{Nothing,OperatorQuantumObject,SuperOperatorQuantumObject},N}
+true
Beware of type-stability!

It is highly recommended to use permute(A, order) with order as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.tidyupFunction
tidyup(A::QuantumObject, tol::Real=1e-14)

Given a QuantumObject A, check the real and imaginary parts of each element separately. Remove the real or imaginary value if its absolute value is less than tol.

source
QuantumToolbox.tidyup!Function
tidyup!(A::QuantumObject, tol::Real=1e-14)

Given a QuantumObject A, check the real and imaginary parts of each element separately. Remove the real or imaginary value if its absolute value is less than tol.

Note that this function is an in-place version of tidyup.

source
QuantumToolbox.get_coherenceFunction
get_coherence(ψ::QuantumObject)

Get the coherence value $\alpha$ by measuring the expectation value of the destruction operator $\hat{a}$ on a state $\ket{\psi}$ or a density matrix $\hat{\rho}$.

It returns both $\alpha$ and the corresponding state with the coherence removed: $\ket{\delta_\alpha} = \exp ( \alpha^* \hat{a} - \alpha \hat{a}^\dagger ) \ket{\psi}$ for a pure state, and $\hat{\rho_\alpha} = \exp ( \alpha^* \hat{a} - \alpha \hat{a}^\dagger ) \hat{\rho} \exp ( -\bar{\alpha} \hat{a} + \alpha \hat{a}^\dagger )$ for a density matrix. These states correspond to the quantum fluctuations around the coherent state $\ket{\alpha}$ or $|\alpha\rangle\langle\alpha|$.

source
QuantumToolbox.partial_transposeFunction
partial_transpose(ρ::QuantumObject, mask::Vector{Bool})

Return the partial transpose of a density matrix $\rho$, where mask is an array/vector with length that equals the length of ρ.dims. The elements in mask are boolean (true or false) which indicates whether or not the corresponding subsystem should be transposed.

Arguments

  • ρ::QuantumObject: The density matrix (ρ.type must be OperatorQuantumObject).
  • mask::Vector{Bool}: A boolean vector selects which subsystems should be transposed.

Returns

  • ρ_pt::QuantumObject: The density matrix with the selected subsystems transposed.
source

Qobj eigenvalues and eigenvectors

QuantumToolbox.EigsolveResultType
struct EigsolveResult{T1<:Vector{<:Number}, T2<:AbstractMatrix{<:Number}, ObjType<:Union{Nothing,OperatorQuantumObject,SuperOperatorQuantumObject},N}
     values::T1
     vectors::T2
     type::ObjType
@@ -95,7 +95,7 @@
 julia> T
 2×2 Matrix{ComplexF64}:
  -0.707107+0.0im  0.707107+0.0im
-  0.707107+0.0im  0.707107+0.0im
source
QuantumToolbox.eigenstatesFunction
eigenstates(A::QuantumObject; sparse::Bool=false, kwargs...)

Calculate the eigenvalues and corresponding eigenvectors

Arguments

Returns

  • ::EigsolveResult: containing the eigenvalues, the eigenvectors, and some information from the solver. see also EigsolveResult
source
QuantumToolbox.eigenstatesFunction
eigenstates(A::QuantumObject; sparse::Bool=false, kwargs...)

Calculate the eigenvalues and corresponding eigenvectors

Arguments

Returns

  • ::EigsolveResult: containing the eigenvalues, the eigenvectors, and some information from the solver. see also EigsolveResult
source
LinearAlgebra.eigenFunction
LinearAlgebra.eigen(A::QuantumObject; kwargs...)

Calculates the eigenvalues and eigenvectors of the QuantumObject A using the Julia LinearAlgebra package.

julia> a = destroy(5);
 
 julia> H = a + a'
 Quantum Object:   type=Operator   dims=[5]   size=(5, 5)   ishermitian=true
@@ -124,7 +124,7 @@
   0.447214+0.0im   0.447214+0.0im     -0.447214-0.0im  0.447214-0.0im
 
 julia> expect(H, ψ[1]) ≈ E[1]
-true
source
QuantumToolbox.eigsolveFunction
eigsolve(A::QuantumObject; 
     v0::Union{Nothing,AbstractVector}=nothing, 
     sigma::Union{Nothing, Real}=nothing,
     k::Int = 1,
@@ -132,7 +132,7 @@
     tol::Real = 1e-8,
     maxiter::Int = 200,
     solver::Union{Nothing, SciMLLinearSolveAlgorithm} = nothing,
-    kwargs...)

Solve for the eigenvalues and eigenvectors of a matrix A using the Arnoldi method.

Notes

  • For more details about solver and extra kwargs, please refer to LinearSolve.jl

Returns

  • EigsolveResult: A struct containing the eigenvalues, the eigenvectors, and some information about the eigsolver
source
QuantumToolbox.eigsolve_alFunction
eigsolve_al(H::QuantumObject,
+    kwargs...)

Solve for the eigenvalues and eigenvectors of a matrix A using the Arnoldi method.

Notes

  • For more details about solver and extra kwargs, please refer to LinearSolve.jl

Returns

  • EigsolveResult: A struct containing the eigenvalues, the eigenvectors, and some information about the eigsolver
source
QuantumToolbox.eigsolve_alFunction
eigsolve_al(H::QuantumObject,
     T::Real, c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
     alg::OrdinaryDiffEqAlgorithm=Tsit5(),
     H_t::Union{Nothing,Function}=nothing,
@@ -142,7 +142,7 @@
     krylovdim::Int=min(10, size(H, 1)),
     maxiter::Int=200,
     eigstol::Real=1e-6,
-    kwargs...)

Solve the eigenvalue problem for a Liouvillian superoperator L using the Arnoldi-Lindblad method.

Arguments

  • H: The Hamiltonian (or directly the Liouvillian) of the system.
  • T: The time at which to evaluate the time evolution
  • c_ops: A vector of collapse operators. Default is nothing meaning the system is closed.
  • alg: The differential equation solver algorithm
  • H_t: A function H_t(t) that returns the additional term at time t
  • params: A dictionary of additional parameters
  • ρ0: The initial density matrix. If not specified, a random density matrix is used
  • k: The number of eigenvalues to compute
  • krylovdim: The dimension of the Krylov subspace
  • maxiter: The maximum number of iterations for the eigsolver
  • eigstol: The tolerance for the eigsolver
  • kwargs: Additional keyword arguments passed to the differential equation solver

Notes

Returns

  • EigsolveResult: A struct containing the eigenvalues, the eigenvectors, and some information about the eigsolver

References

  • [1] Minganti, F., & Huybrechts, D. (2022). Arnoldi-Lindblad time evolution: Faster-than-the-clock algorithm for the spectrum of time-independent and Floquet open quantum systems. Quantum, 6, 649.
source

Qobj manipulation

QuantumToolbox.ket2dmFunction
ket2dm(ψ::QuantumObject)

Transform the ket state $\ket{\psi}$ into a pure density matrix $\hat{\rho} = \dyad{\psi}$.

source
QuantumToolbox.expectFunction
expect(O::QuantumObject, ψ::Union{QuantumObject,Vector{QuantumObject}})

Expectation value of the Operator O with the state ψ. The state can be a Ket, Bra or Operator.

If ψ is a Ket or Bra, the function calculates $\langle\psi|\hat{O}|\psi\rangle$.

If ψ is a density matrix (Operator), the function calculates $\textrm{Tr} \left[ \hat{O} \hat{\psi} \right]$

The function returns a real number if O is of Hermitian type or Symmetric type, and returns a complex number otherwise. You can make an operator O hermitian by using Hermitian(O).

Note that ψ can also be given as a list of QuantumObject, it returns a list of expectation values.

Examples

julia> ψ = 1 / √2 * (fock(10,2) + fock(10,4));
+    kwargs...)

Solve the eigenvalue problem for a Liouvillian superoperator L using the Arnoldi-Lindblad method.

Arguments

  • H: The Hamiltonian (or directly the Liouvillian) of the system.
  • T: The time at which to evaluate the time evolution
  • c_ops: A vector of collapse operators. Default is nothing meaning the system is closed.
  • alg: The differential equation solver algorithm
  • H_t: A function H_t(t) that returns the additional term at time t
  • params: A dictionary of additional parameters
  • ρ0: The initial density matrix. If not specified, a random density matrix is used
  • k: The number of eigenvalues to compute
  • krylovdim: The dimension of the Krylov subspace
  • maxiter: The maximum number of iterations for the eigsolver
  • eigstol: The tolerance for the eigsolver
  • kwargs: Additional keyword arguments passed to the differential equation solver

Notes

Returns

  • EigsolveResult: A struct containing the eigenvalues, the eigenvectors, and some information about the eigsolver

References

  • [1] Minganti, F., & Huybrechts, D. (2022). Arnoldi-Lindblad time evolution: Faster-than-the-clock algorithm for the spectrum of time-independent and Floquet open quantum systems. Quantum, 6, 649.
source

Qobj manipulation

QuantumToolbox.ket2dmFunction
ket2dm(ψ::QuantumObject)

Transform the ket state $\ket{\psi}$ into a pure density matrix $\hat{\rho} = \dyad{\psi}$.

source
QuantumToolbox.expectFunction
expect(O::QuantumObject, ψ::Union{QuantumObject,Vector{QuantumObject}})

Expectation value of the Operator O with the state ψ. The state can be a Ket, Bra or Operator.

If ψ is a Ket or Bra, the function calculates $\langle\psi|\hat{O}|\psi\rangle$.

If ψ is a density matrix (Operator), the function calculates $\textrm{Tr} \left[ \hat{O} \hat{\psi} \right]$

The function returns a real number if O is of Hermitian type or Symmetric type, and returns a complex number otherwise. You can make an operator O hermitian by using Hermitian(O).

Note that ψ can also be given as a list of QuantumObject, it returns a list of expectation values.

Examples

julia> ψ = 1 / √2 * (fock(10,2) + fock(10,4));
 
 julia> a = destroy(10);
 
@@ -150,7 +150,7 @@
 3.0 + 0.0im
 
 julia> expect(Hermitian(a' * a), ψ) |> round
-3.0
source
QuantumToolbox.varianceFunction
variance(O::QuantumObject, ψ::Union{QuantumObject,Vector{QuantumObject}})

Variance of the Operator O: $\langle\hat{O}^2\rangle - \langle\hat{O}\rangle^2$,

where $\langle\hat{O}\rangle$ is the expectation value of O with the state ψ (see also expect), and the state ψ can be a Ket, Bra or Operator.

The function returns a real number if O is hermitian, and returns a complex number otherwise.

Note that ψ can also be given as a list of QuantumObject, it returns a list of expectation values.

source
Base.kronFunction
kron(A::QuantumObject, B::QuantumObject, ...)

Returns the Kronecker product $\hat{A} \otimes \hat{B} \otimes \cdots$.

Examples

julia> a = destroy(20)
+3.0
source
QuantumToolbox.varianceFunction
variance(O::QuantumObject, ψ::Union{QuantumObject,Vector{QuantumObject}})

Variance of the Operator O: $\langle\hat{O}^2\rangle - \langle\hat{O}\rangle^2$,

where $\langle\hat{O}\rangle$ is the expectation value of O with the state ψ (see also expect), and the state ψ can be a Ket, Bra or Operator.

The function returns a real number if O is hermitian, and returns a complex number otherwise.

Note that ψ can also be given as a list of QuantumObject, it returns a list of expectation values.

source
Base.kronFunction
kron(A::QuantumObject, B::QuantumObject, ...)

Returns the Kronecker product $\hat{A} \otimes \hat{B} \otimes \cdots$.

Examples

julia> a = destroy(20)
 Quantum Object:   type=Operator   dims=[20]   size=(20, 20)   ishermitian=false
 20×20 SparseMatrixCSC{ComplexF64, Int64} with 19 stored entries:
 ⠈⠢⡀⠀⠀⠀⠀⠀⠀⠀
@@ -182,7 +182,7 @@
 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⠀⠀⠀⠀⠀
 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⠀⠀⠀
 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⠀
-⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠦
source

Generate states and operators

QuantumToolbox.zero_ketFunction
zero_ket(dimensions)

Returns a zero Ket vector with given argument dimensions.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int}, Tuple}: list of dimensions representing the each number of basis in the subsystems.
Beware of type-stability!

It is highly recommended to use zero_ket(dimensions) with dimensions as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.fockFunction
fock(N::Int, j::Int=0; dims::Union{Int,AbstractVector{Int},Tuple}=N, sparse::Union{Bool,Val}=Val(false))

Generates a fock state $\ket{\psi}$ of dimension N.

It is also possible to specify the list of dimensions dims if different subsystems are present.

Beware of type-stability!

If you want to keep type stability, it is recommended to use fock(N, j, dims=dims, sparse=Val(sparse)) instead of fock(N, j, dims=dims, sparse=sparse). Consider also to use dims as a Tuple or SVector instead of Vector. See this link and the related Section about type stability for more details.

source
QuantumToolbox.basisFunction
basis(N::Int, j::Int = 0; dims::Union{Int,AbstractVector{Int},Tuple}=N)

Generates a fock state like fock.

It is also possible to specify the list of dimensions dims if different subsystems are present.

Beware of type-stability!

If you want to keep type stability, it is recommended to use basis(N, j, dims=dims) with dims as a Tuple or SVector instead of Vector. See this link and the related Section about type stability for more details.

source
QuantumToolbox.coherentFunction
coherent(N::Int, α::Number)

Generates a coherent state $|\alpha\rangle$, which is defined as an eigenvector of the bosonic annihilation operator $\hat{a} |\alpha\rangle = \alpha |\alpha\rangle$.

This state is constructed via the displacement operator displace and zero-fock state fock: $|\alpha\rangle = \hat{D}(\alpha) |0\rangle$

source
QuantumToolbox.rand_ketFunction
rand_ket(dimensions)

Generate a random normalized Ket vector with given argument dimensions.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.
Beware of type-stability!

If you want to keep type stability, it is recommended to use rand_ket(dimensions) with dimensions as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.fock_dmFunction
fock_dm(N::Int, j::Int=0; dims::Union{Int,AbstractVector{Int},Tuple}=N, sparse::Union{Bool,Val}=Val(false))

Density matrix representation of a Fock state.

Constructed via outer product of fock.

Beware of type-stability!

If you want to keep type stability, it is recommended to use fock_dm(N, j, dims=dims, sparse=Val(sparse)) instead of fock_dm(N, j, dims=dims, sparse=sparse). Consider also to use dims as a Tuple or SVector instead of Vector. See this link and the related Section about type stability for more details.

source
QuantumToolbox.thermal_dmFunction
thermal_dm(N::Int, n::Real; sparse::Union{Bool,Val}=Val(false))

Density matrix for a thermal state (generating thermal state probabilities) with the following arguments:

  • N::Int: Number of basis states in the Hilbert space
  • n::Real: Expectation value for number of particles in the thermal state.
  • sparse::Union{Bool,Val}: If true, return a sparse matrix representation.
Beware of type-stability!

If you want to keep type stability, it is recommended to use thermal_dm(N, n, sparse=Val(sparse)) instead of thermal_dm(N, n, sparse=sparse). See this link and the related Section about type stability for more details.

source
QuantumToolbox.maximally_mixed_dmFunction
maximally_mixed_dm(dimensions)

Returns the maximally mixed density matrix with given argument dimensions.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.
Beware of type-stability!

If you want to keep type stability, it is recommended to use maximally_mixed_dm(dimensions) with dimensions as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.rand_dmFunction
rand_dm(dimensions; rank::Int=prod(dimensions))

Generate a random density matrix from Ginibre ensemble with given argument dimensions and rank, ensuring that it is positive semi-definite and trace equals to 1.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.

The default keyword argument rank = prod(dimensions) (full rank).

Beware of type-stability!

If you want to keep type stability, it is recommended to use rand_dm(dimensions; rank=rank) with dimensions as Tuple or SVector instead of Vector. See this link and the related Section about type stability for more details.

References

source
QuantumToolbox.spin_stateFunction
spin_state(j::Real, m::Real)

Generate the spin state: $|j, m\rangle$

The eigenstate of the Spin-j $\hat{S}_z$ operator with eigenvalue m, where where j is the spin quantum number and can be a non-negative integer or half-integer

See also jmat.

source
QuantumToolbox.spin_coherentFunction
spin_coherent(j::Real, θ::Real, ϕ::Real)

Generate the coherent spin state (rotation of the $|j, j\rangle$ state), namely

\[|\theta, \phi \rangle = \hat{R}(\theta, \phi) |j, j\rangle\]

where the rotation operator is defined as

\[\hat{R}(\theta, \phi) = \exp \left( \frac{\theta}{2} (\hat{S}_- e^{i\phi} - \hat{S}_+ e^{-i\phi}) \right)\]

and $\hat{S}_\pm$ are plus and minus Spin-j operators, respectively.

Arguments

  • j::Real: The spin quantum number and can be a non-negative integer or half-integer
  • θ::Real: rotation angle from z-axis
  • ϕ::Real: rotation angle from x-axis

See also jmat and spin_state.

Reference

source
QuantumToolbox.bell_stateFunction
bell_state(x::Union{Int}, z::Union{Int})

Return the Bell state depending on the arguments (x, z):

  • (0, 0): $| \Phi^+ \rangle = ( |00\rangle + |11\rangle ) / \sqrt{2}$
  • (0, 1): $| \Phi^- \rangle = ( |00\rangle - |11\rangle ) / \sqrt{2}$
  • (1, 0): $| \Psi^+ \rangle = ( |01\rangle + |10\rangle ) / \sqrt{2}$
  • (1, 1): $| \Psi^- \rangle = ( |01\rangle - |10\rangle ) / \sqrt{2}$

Here, x = 1 (z = 1) means applying Pauli-$X$ ( Pauli-$Z$) unitary transformation on $| \Phi^+ \rangle$.

Example

julia> bell_state(0, 0)
+⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠦
source

Generate states and operators

QuantumToolbox.zero_ketFunction
zero_ket(dimensions)

Returns a zero Ket vector with given argument dimensions.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int}, Tuple}: list of dimensions representing the each number of basis in the subsystems.
Beware of type-stability!

It is highly recommended to use zero_ket(dimensions) with dimensions as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.fockFunction
fock(N::Int, j::Int=0; dims::Union{Int,AbstractVector{Int},Tuple}=N, sparse::Union{Bool,Val}=Val(false))

Generates a fock state $\ket{\psi}$ of dimension N.

It is also possible to specify the list of dimensions dims if different subsystems are present.

Beware of type-stability!

If you want to keep type stability, it is recommended to use fock(N, j, dims=dims, sparse=Val(sparse)) instead of fock(N, j, dims=dims, sparse=sparse). Consider also to use dims as a Tuple or SVector instead of Vector. See this link and the related Section about type stability for more details.

source
QuantumToolbox.basisFunction
basis(N::Int, j::Int = 0; dims::Union{Int,AbstractVector{Int},Tuple}=N)

Generates a fock state like fock.

It is also possible to specify the list of dimensions dims if different subsystems are present.

Beware of type-stability!

If you want to keep type stability, it is recommended to use basis(N, j, dims=dims) with dims as a Tuple or SVector instead of Vector. See this link and the related Section about type stability for more details.

source
QuantumToolbox.coherentFunction
coherent(N::Int, α::Number)

Generates a coherent state $|\alpha\rangle$, which is defined as an eigenvector of the bosonic annihilation operator $\hat{a} |\alpha\rangle = \alpha |\alpha\rangle$.

This state is constructed via the displacement operator displace and zero-fock state fock: $|\alpha\rangle = \hat{D}(\alpha) |0\rangle$

source
QuantumToolbox.rand_ketFunction
rand_ket(dimensions)

Generate a random normalized Ket vector with given argument dimensions.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.
Beware of type-stability!

If you want to keep type stability, it is recommended to use rand_ket(dimensions) with dimensions as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.fock_dmFunction
fock_dm(N::Int, j::Int=0; dims::Union{Int,AbstractVector{Int},Tuple}=N, sparse::Union{Bool,Val}=Val(false))

Density matrix representation of a Fock state.

Constructed via outer product of fock.

Beware of type-stability!

If you want to keep type stability, it is recommended to use fock_dm(N, j, dims=dims, sparse=Val(sparse)) instead of fock_dm(N, j, dims=dims, sparse=sparse). Consider also to use dims as a Tuple or SVector instead of Vector. See this link and the related Section about type stability for more details.

source
QuantumToolbox.thermal_dmFunction
thermal_dm(N::Int, n::Real; sparse::Union{Bool,Val}=Val(false))

Density matrix for a thermal state (generating thermal state probabilities) with the following arguments:

  • N::Int: Number of basis states in the Hilbert space
  • n::Real: Expectation value for number of particles in the thermal state.
  • sparse::Union{Bool,Val}: If true, return a sparse matrix representation.
Beware of type-stability!

If you want to keep type stability, it is recommended to use thermal_dm(N, n, sparse=Val(sparse)) instead of thermal_dm(N, n, sparse=sparse). See this link and the related Section about type stability for more details.

source
QuantumToolbox.maximally_mixed_dmFunction
maximally_mixed_dm(dimensions)

Returns the maximally mixed density matrix with given argument dimensions.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.
Beware of type-stability!

If you want to keep type stability, it is recommended to use maximally_mixed_dm(dimensions) with dimensions as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.rand_dmFunction
rand_dm(dimensions; rank::Int=prod(dimensions))

Generate a random density matrix from Ginibre ensemble with given argument dimensions and rank, ensuring that it is positive semi-definite and trace equals to 1.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.

The default keyword argument rank = prod(dimensions) (full rank).

Beware of type-stability!

If you want to keep type stability, it is recommended to use rand_dm(dimensions; rank=rank) with dimensions as Tuple or SVector instead of Vector. See this link and the related Section about type stability for more details.

References

source
QuantumToolbox.spin_stateFunction
spin_state(j::Real, m::Real)

Generate the spin state: $|j, m\rangle$

The eigenstate of the Spin-j $\hat{S}_z$ operator with eigenvalue m, where where j is the spin quantum number and can be a non-negative integer or half-integer

See also jmat.

source
QuantumToolbox.spin_coherentFunction
spin_coherent(j::Real, θ::Real, ϕ::Real)

Generate the coherent spin state (rotation of the $|j, j\rangle$ state), namely

\[|\theta, \phi \rangle = \hat{R}(\theta, \phi) |j, j\rangle\]

where the rotation operator is defined as

\[\hat{R}(\theta, \phi) = \exp \left( \frac{\theta}{2} (\hat{S}_- e^{i\phi} - \hat{S}_+ e^{-i\phi}) \right)\]

and $\hat{S}_\pm$ are plus and minus Spin-j operators, respectively.

Arguments

  • j::Real: The spin quantum number and can be a non-negative integer or half-integer
  • θ::Real: rotation angle from z-axis
  • ϕ::Real: rotation angle from x-axis

See also jmat and spin_state.

Reference

source
QuantumToolbox.bell_stateFunction
bell_state(x::Union{Int}, z::Union{Int})

Return the Bell state depending on the arguments (x, z):

  • (0, 0): $| \Phi^+ \rangle = ( |00\rangle + |11\rangle ) / \sqrt{2}$
  • (0, 1): $| \Phi^- \rangle = ( |00\rangle - |11\rangle ) / \sqrt{2}$
  • (1, 0): $| \Psi^+ \rangle = ( |01\rangle + |10\rangle ) / \sqrt{2}$
  • (1, 1): $| \Psi^- \rangle = ( |01\rangle - |10\rangle ) / \sqrt{2}$

Here, x = 1 (z = 1) means applying Pauli-$X$ ( Pauli-$Z$) unitary transformation on $| \Phi^+ \rangle$.

Example

julia> bell_state(0, 0)
 Quantum Object:   type=Ket   dims=[2, 2]   size=(4,)
 4-element Vector{ComplexF64}:
  0.7071067811865475 + 0.0im
@@ -196,7 +196,7 @@
                 0.0 + 0.0im
  0.7071067811865475 + 0.0im
  0.7071067811865475 + 0.0im
-                0.0 + 0.0im
Beware of type-stability!

If you want to keep type stability, it is recommended to use bell_state(Val(x), Val(z)) instead of bell_state(x, z). See this link and the related Section for more details.

source
QuantumToolbox.triplet_statesFunction
triplet_states()

Return a list of the two particle triplet states:

  • $|11\rangle$
  • $( |01\rangle + |10\rangle ) / \sqrt{2}$
  • $|00\rangle$
source
QuantumToolbox.w_stateFunction
w_state(n::Union{Int,Val})

Returns the n-qubit W-state:

\[\frac{1}{\sqrt{n}} \left( |100...0\rangle + |010...0\rangle + \cdots + |00...01\rangle \right)\]

Beware of type-stability!

If you want to keep type stability, it is recommended to use w_state(Val(n)) instead of w_state(n). See this link and the related Section for more details.

source
QuantumToolbox.ghz_stateFunction
ghz_state(n::Union{Int,Val}; d::Int=2)

Returns the generalized n-qudit Greenberger–Horne–Zeilinger (GHZ) state:

\[\frac{1}{\sqrt{d}} \sum_{i=0}^{d-1} | i \rangle \otimes \cdots \otimes | i \rangle\]

Here, d specifies the dimension of each qudit. Default to d=2 (qubit).

Beware of type-stability!

If you want to keep type stability, it is recommended to use ghz_state(Val(n)) instead of ghz_state(n). See this link and the related Section for more details.

source
QuantumToolbox.rand_unitaryFunction
rand_unitary(dimensions, distribution=Val(:haar))

Returns a random unitary QuantumObject.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.

The distribution specifies which of the method used to obtain the unitary matrix:

  • :haar: Haar random unitary matrix using the algorithm from reference 1
  • :exp: Uses $\exp(-i\hat{H})$, where $\hat{H}$ is a randomly generated Hermitian operator.

References

  1. F. Mezzadri, How to generate random matrices from the classical compact groups, arXiv:math-ph/0609050 (2007)
Beware of type-stability!

If you want to keep type stability, it is recommended to use rand_unitary(dimensions, Val(distribution)) instead of rand_unitary(dimensions, distribution). Also, put dimensions as Tuple or SVector. See this link and the related Section about type stability for more details.

source
QuantumToolbox.jmatFunction
jmat(j::Real, which::Union{Symbol,Val})

Generate higher-order Spin-j operators, where j is the spin quantum number and can be a non-negative integer or half-integer

The parameter which specifies which of the following operator to return.

  • :x: $\hat{S}_x$
  • :y: $\hat{S}_y$
  • :z: $\hat{S}_z$
  • :+: $\hat{S}_+$
  • :-: $\hat{S}_-$

Note that if the parameter which is not specified, returns a set of Spin-j operators: $(\hat{S}_x, \hat{S}_y, \hat{S}_z)$

Examples

julia> jmat(0.5, :x)
+                0.0 + 0.0im
Beware of type-stability!

If you want to keep type stability, it is recommended to use bell_state(Val(x), Val(z)) instead of bell_state(x, z). See this link and the related Section for more details.

source
QuantumToolbox.triplet_statesFunction
triplet_states()

Return a list of the two particle triplet states:

  • $|11\rangle$
  • $( |01\rangle + |10\rangle ) / \sqrt{2}$
  • $|00\rangle$
source
QuantumToolbox.w_stateFunction
w_state(n::Union{Int,Val})

Returns the n-qubit W-state:

\[\frac{1}{\sqrt{n}} \left( |100...0\rangle + |010...0\rangle + \cdots + |00...01\rangle \right)\]

Beware of type-stability!

If you want to keep type stability, it is recommended to use w_state(Val(n)) instead of w_state(n). See this link and the related Section for more details.

source
QuantumToolbox.ghz_stateFunction
ghz_state(n::Union{Int,Val}; d::Int=2)

Returns the generalized n-qudit Greenberger–Horne–Zeilinger (GHZ) state:

\[\frac{1}{\sqrt{d}} \sum_{i=0}^{d-1} | i \rangle \otimes \cdots \otimes | i \rangle\]

Here, d specifies the dimension of each qudit. Default to d=2 (qubit).

Beware of type-stability!

If you want to keep type stability, it is recommended to use ghz_state(Val(n)) instead of ghz_state(n). See this link and the related Section for more details.

source
QuantumToolbox.rand_unitaryFunction
rand_unitary(dimensions, distribution=Val(:haar))

Returns a random unitary QuantumObject.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.

The distribution specifies which of the method used to obtain the unitary matrix:

  • :haar: Haar random unitary matrix using the algorithm from reference 1
  • :exp: Uses $\exp(-i\hat{H})$, where $\hat{H}$ is a randomly generated Hermitian operator.

References

  1. F. Mezzadri, How to generate random matrices from the classical compact groups, arXiv:math-ph/0609050 (2007)
Beware of type-stability!

If you want to keep type stability, it is recommended to use rand_unitary(dimensions, Val(distribution)) instead of rand_unitary(dimensions, distribution). Also, put dimensions as Tuple or SVector. See this link and the related Section about type stability for more details.

source
QuantumToolbox.jmatFunction
jmat(j::Real, which::Union{Symbol,Val})

Generate higher-order Spin-j operators, where j is the spin quantum number and can be a non-negative integer or half-integer

The parameter which specifies which of the following operator to return.

  • :x: $\hat{S}_x$
  • :y: $\hat{S}_y$
  • :z: $\hat{S}_z$
  • :+: $\hat{S}_+$
  • :-: $\hat{S}_-$

Note that if the parameter which is not specified, returns a set of Spin-j operators: $(\hat{S}_x, \hat{S}_y, \hat{S}_z)$

Examples

julia> jmat(0.5, :x)
 Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
 2×2 SparseMatrixCSC{ComplexF64, Int64} with 2 stored entries:
      ⋅      0.5+0.0im
@@ -214,7 +214,7 @@
  1.5+0.0im      ⋅           ⋅           ⋅    
      ⋅      0.5+0.0im       ⋅           ⋅    
      ⋅          ⋅      -0.5+0.0im       ⋅    
-     ⋅          ⋅           ⋅      -1.5+0.0im
Beware of type-stability!

If you want to keep type stability, it is recommended to use jmat(j, Val(which)) instead of jmat(j, which). See this link and the related Section about type stability for more details.

source
QuantumToolbox.spin_JxFunction
spin_Jx(j::Real)

$\hat{S}_x$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_JyFunction
spin_Jy(j::Real)

$\hat{S}_y$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_JzFunction
spin_Jz(j::Real)

$\hat{S}_z$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_JmFunction
spin_Jm(j::Real)

$\hat{S}_-$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_JpFunction
spin_Jp(j::Real)

$\hat{S}_+$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_J_setFunction
spin_J_set(j::Real)

A set of Spin-j operators $(\hat{S}_x, \hat{S}_y, \hat{S}_z)$, where j is the spin quantum number and can be a non-negative integer or half-integer.

Note that this functions is same as jmat(j). See also jmat.

source
QuantumToolbox.destroyFunction
destroy(N::Int)

Bosonic annihilation operator with Hilbert space cutoff N.

This operator acts on a fock state as $\hat{a} \ket{n} = \sqrt{n} \ket{n-1}$.

Examples

julia> a = destroy(20)
+     ⋅          ⋅           ⋅      -1.5+0.0im
Beware of type-stability!

If you want to keep type stability, it is recommended to use jmat(j, Val(which)) instead of jmat(j, which). See this link and the related Section about type stability for more details.

source
QuantumToolbox.spin_JxFunction
spin_Jx(j::Real)

$\hat{S}_x$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_JyFunction
spin_Jy(j::Real)

$\hat{S}_y$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_JzFunction
spin_Jz(j::Real)

$\hat{S}_z$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_JmFunction
spin_Jm(j::Real)

$\hat{S}_-$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_JpFunction
spin_Jp(j::Real)

$\hat{S}_+$ operator for Spin-j, where j is the spin quantum number and can be a non-negative integer or half-integer.

See also jmat.

source
QuantumToolbox.spin_J_setFunction
spin_J_set(j::Real)

A set of Spin-j operators $(\hat{S}_x, \hat{S}_y, \hat{S}_z)$, where j is the spin quantum number and can be a non-negative integer or half-integer.

Note that this functions is same as jmat(j). See also jmat.

source
QuantumToolbox.destroyFunction
destroy(N::Int)

Bosonic annihilation operator with Hilbert space cutoff N.

This operator acts on a fock state as $\hat{a} \ket{n} = \sqrt{n} \ket{n-1}$.

Examples

julia> a = destroy(20)
 Quantum Object:   type=Operator   dims=[20]   size=(20, 20)   ishermitian=false
 20×20 SparseMatrixCSC{ComplexF64, Int64} with 19 stored entries:
 ⎡⠈⠢⡀⠀⠀⠀⠀⠀⠀⠀⎤
@@ -224,7 +224,7 @@
 ⎣⠀⠀⠀⠀⠀⠀⠀⠀⠈⠢⎦
 
 julia> fock(20, 3)' * a * fock(20, 4)
-2.0 + 0.0im
source
QuantumToolbox.createFunction
create(N::Int)

Bosonic creation operator with Hilbert space cutoff N.

This operator acts on a fock state as $\hat{a}^\dagger \ket{n} = \sqrt{n+1} \ket{n+1}$.

Examples

julia> a_d = create(20)
+2.0 + 0.0im
source
QuantumToolbox.createFunction
create(N::Int)

Bosonic creation operator with Hilbert space cutoff N.

This operator acts on a fock state as $\hat{a}^\dagger \ket{n} = \sqrt{n+1} \ket{n+1}$.

Examples

julia> a_d = create(20)
 Quantum Object:   type=Operator   dims=[20]   size=(20, 20)   ishermitian=false
 20×20 SparseMatrixCSC{ComplexF64, Int64} with 19 stored entries:
 ⎡⠢⡀⠀⠀⠀⠀⠀⠀⠀⠀⎤
@@ -234,15 +234,15 @@
 ⎣⠀⠀⠀⠀⠀⠀⠀⠈⠢⡀⎦
 
 julia> fock(20, 4)' * a_d * fock(20, 3)
-2.0 + 0.0im
source
QuantumToolbox.displaceFunction
displace(N::Int, α::Number)

Generate a displacement operator:

\[\hat{D}(\alpha)=\exp\left( \alpha \hat{a}^\dagger - \alpha^* \hat{a} \right),\]

where $\hat{a}$ is the bosonic annihilation operator, and $\alpha$ is the amount of displacement in optical phase space.

source
QuantumToolbox.squeezeFunction
squeeze(N::Int, z::Number)

Generate a single-mode squeeze operator:

\[\hat{S}(z)=\exp\left( \frac{1}{2} (z^* \hat{a}^2 - z(\hat{a}^\dagger)^2) \right),\]

where $\hat{a}$ is the bosonic annihilation operator.

source
QuantumToolbox.numFunction
num(N::Int)

Bosonic number operator with Hilbert space cutoff N.

This operator is defined as $\hat{N}=\hat{a}^\dagger \hat{a}$, where $\hat{a}$ is the bosonic annihilation operator.

source
QuantumToolbox.positionFunction
position(N::Int)

Position operator with Hilbert space cutoff N.

This operator is defined as $\hat{x}=\frac{1}{\sqrt{2}} (\hat{a}^\dagger + \hat{a})$, where $\hat{a}$ is the bosonic annihilation operator.

source
QuantumToolbox.momentumFunction
momentum(N::Int)

Momentum operator with Hilbert space cutoff N.

This operator is defined as $\hat{p}= \frac{i}{\sqrt{2}} (\hat{a}^\dagger - \hat{a})$, where $\hat{a}$ is the bosonic annihilation operator.

source
QuantumToolbox.phaseFunction
phase(N::Int, ϕ0::Real=0)

Single-mode Pegg-Barnett phase operator with Hilbert space cutoff $N$ and the reference phase $\phi_0$.

This operator is defined as

\[\hat{\phi} = \sum_{m=0}^{N-1} \phi_m |\phi_m\rangle \langle\phi_m|,\]

where

\[\phi_m = \phi_0 + \frac{2m\pi}{N},\]

and

\[|\phi_m\rangle = \frac{1}{\sqrt{N}} \sum_{n=0}^{N-1} \exp(i n \phi_m) |n\rangle.\]

Reference

source
QuantumToolbox.fdestroyFunction
fdestroy(N::Union{Int,Val}, j::Int)

Construct a fermionic destruction operator acting on the j-th site, where the fock space has totally N-sites:

Here, we use the Jordan-Wigner transformation, namely

\[\hat{d}_j = \hat{\sigma}_z^{\otimes j-1} \otimes \hat{\sigma}_{+} \otimes \hat{\mathbb{1}}^{\otimes N-j}\]

The site index j should satisfy: 1 ≤ j ≤ N.

Note that we put $\hat{\sigma}_{+} = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix}$ here because we consider $|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ to be ground (vacant) state, and $|1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ to be excited (occupied) state.

Beware of type-stability!

If you want to keep type stability, it is recommended to use fdestroy(Val(N), j) instead of fdestroy(N, j). See this link and the related Section about type stability for more details.

source
QuantumToolbox.fcreateFunction
fcreate(N::Union{Int,Val}, j::Int)

Construct a fermionic creation operator acting on the j-th site, where the fock space has totally N-sites:

Here, we use the Jordan-Wigner transformation, namely

\[\hat{d}^\dagger_j = \hat{\sigma}_z^{\otimes j-1} \otimes \hat{\sigma}_{-} \otimes \hat{\mathbb{1}}^{\otimes N-j}\]

The site index j should satisfy: 1 ≤ j ≤ N.

Note that we put $\hat{\sigma}_{-} = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$ here because we consider $|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ to be ground (vacant) state, and $|1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ to be excited (occupied) state.

Beware of type-stability!

If you want to keep type stability, it is recommended to use fcreate(Val(N), j) instead of fcreate(N, j). See this link and the related Section about type stability for more details.

source
QuantumToolbox.tunnelingFunction
tunneling(N::Int, m::Int=1; sparse::Union{Bool,Val{<:Bool}}=Val(false))

Generate a tunneling operator defined as:

\[\sum_{n=0}^{N-m} | n \rangle\langle n+m | + | n+m \rangle\langle n |,\]

where $N$ is the number of basis states in the Hilbert space, and $m$ is the number of excitations in tunneling event.

If sparse=true, the operator is returned as a sparse matrix, otherwise a dense matrix is returned.

Beware of type-stability!

If you want to keep type stability, it is recommended to use tunneling(N, m, Val(sparse)) instead of tunneling(N, m, sparse). See this link and the related Section about type stability for more details.

source
QuantumToolbox.qftFunction
qft(dimensions)

Generates a discrete Fourier transform matrix $\hat{F}_N$ for Quantum Fourier Transform (QFT) with given argument dimensions.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.

$N$ represents the total dimension, and therefore the matrix is defined as

\[\hat{F}_N = \frac{1}{\sqrt{N}}\begin{bmatrix} +2.0 + 0.0im

source
QuantumToolbox.displaceFunction
displace(N::Int, α::Number)

Generate a displacement operator:

\[\hat{D}(\alpha)=\exp\left( \alpha \hat{a}^\dagger - \alpha^* \hat{a} \right),\]

where $\hat{a}$ is the bosonic annihilation operator, and $\alpha$ is the amount of displacement in optical phase space.

source
QuantumToolbox.squeezeFunction
squeeze(N::Int, z::Number)

Generate a single-mode squeeze operator:

\[\hat{S}(z)=\exp\left( \frac{1}{2} (z^* \hat{a}^2 - z(\hat{a}^\dagger)^2) \right),\]

where $\hat{a}$ is the bosonic annihilation operator.

source
QuantumToolbox.numFunction
num(N::Int)

Bosonic number operator with Hilbert space cutoff N.

This operator is defined as $\hat{N}=\hat{a}^\dagger \hat{a}$, where $\hat{a}$ is the bosonic annihilation operator.

source
QuantumToolbox.positionFunction
position(N::Int)

Position operator with Hilbert space cutoff N.

This operator is defined as $\hat{x}=\frac{1}{\sqrt{2}} (\hat{a}^\dagger + \hat{a})$, where $\hat{a}$ is the bosonic annihilation operator.

source
QuantumToolbox.momentumFunction
momentum(N::Int)

Momentum operator with Hilbert space cutoff N.

This operator is defined as $\hat{p}= \frac{i}{\sqrt{2}} (\hat{a}^\dagger - \hat{a})$, where $\hat{a}$ is the bosonic annihilation operator.

source
QuantumToolbox.phaseFunction
phase(N::Int, ϕ0::Real=0)

Single-mode Pegg-Barnett phase operator with Hilbert space cutoff $N$ and the reference phase $\phi_0$.

This operator is defined as

\[\hat{\phi} = \sum_{m=0}^{N-1} \phi_m |\phi_m\rangle \langle\phi_m|,\]

where

\[\phi_m = \phi_0 + \frac{2m\pi}{N},\]

and

\[|\phi_m\rangle = \frac{1}{\sqrt{N}} \sum_{n=0}^{N-1} \exp(i n \phi_m) |n\rangle.\]

Reference

source
QuantumToolbox.fdestroyFunction
fdestroy(N::Union{Int,Val}, j::Int)

Construct a fermionic destruction operator acting on the j-th site, where the fock space has totally N-sites:

Here, we use the Jordan-Wigner transformation, namely

\[\hat{d}_j = \hat{\sigma}_z^{\otimes j-1} \otimes \hat{\sigma}_{+} \otimes \hat{\mathbb{1}}^{\otimes N-j}\]

The site index j should satisfy: 1 ≤ j ≤ N.

Note that we put $\hat{\sigma}_{+} = \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix}$ here because we consider $|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ to be ground (vacant) state, and $|1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ to be excited (occupied) state.

Beware of type-stability!

If you want to keep type stability, it is recommended to use fdestroy(Val(N), j) instead of fdestroy(N, j). See this link and the related Section about type stability for more details.

source
QuantumToolbox.fcreateFunction
fcreate(N::Union{Int,Val}, j::Int)

Construct a fermionic creation operator acting on the j-th site, where the fock space has totally N-sites:

Here, we use the Jordan-Wigner transformation, namely

\[\hat{d}^\dagger_j = \hat{\sigma}_z^{\otimes j-1} \otimes \hat{\sigma}_{-} \otimes \hat{\mathbb{1}}^{\otimes N-j}\]

The site index j should satisfy: 1 ≤ j ≤ N.

Note that we put $\hat{\sigma}_{-} = \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$ here because we consider $|0\rangle = \begin{pmatrix} 1 \\ 0 \end{pmatrix}$ to be ground (vacant) state, and $|1\rangle = \begin{pmatrix} 0 \\ 1 \end{pmatrix}$ to be excited (occupied) state.

Beware of type-stability!

If you want to keep type stability, it is recommended to use fcreate(Val(N), j) instead of fcreate(N, j). See this link and the related Section about type stability for more details.

source
QuantumToolbox.tunnelingFunction
tunneling(N::Int, m::Int=1; sparse::Union{Bool,Val{<:Bool}}=Val(false))

Generate a tunneling operator defined as:

\[\sum_{n=0}^{N-m} | n \rangle\langle n+m | + | n+m \rangle\langle n |,\]

where $N$ is the number of basis states in the Hilbert space, and $m$ is the number of excitations in tunneling event.

If sparse=true, the operator is returned as a sparse matrix, otherwise a dense matrix is returned.

Beware of type-stability!

If you want to keep type stability, it is recommended to use tunneling(N, m, Val(sparse)) instead of tunneling(N, m, sparse). See this link and the related Section about type stability for more details.

source
QuantumToolbox.qftFunction
qft(dimensions)

Generates a discrete Fourier transform matrix $\hat{F}_N$ for Quantum Fourier Transform (QFT) with given argument dimensions.

The dimensions can be either the following types:

  • dimensions::Int: Number of basis states in the Hilbert space.
  • dimensions::Union{AbstractVector{Int},Tuple}: list of dimensions representing the each number of basis in the subsystems.

$N$ represents the total dimension, and therefore the matrix is defined as

\[\hat{F}_N = \frac{1}{\sqrt{N}}\begin{bmatrix} 1 & 1 & 1 & 1 & \cdots & 1\\ 1 & \omega & \omega^2 & \omega^3 & \cdots & \omega^{N-1}\\ 1 & \omega^2 & \omega^4 & \omega^6 & \cdots & \omega^{2(N-1)}\\ 1 & \omega^3 & \omega^6 & \omega^9 & \cdots & \omega^{3(N-1)}\\ \vdots & \vdots & \vdots & \vdots & \ddots & \vdots\\ 1 & \omega^{N-1} & \omega^{2(N-1)} & \omega^{3(N-1)} & \cdots & \omega^{(N-1)(N-1)} -\end{bmatrix},\]

where $\omega = \exp(\frac{2 \pi i}{N})$.

Beware of type-stability!

It is highly recommended to use qft(dimensions) with dimensions as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.eyeFunction
eye(N::Int; type=Operator, dims=nothing)

Identity operator $\hat{\mathbb{1}}$ with size N.

It is also possible to specify the list of Hilbert dimensions dims if different subsystems are present.

Note that type can only be either Operator or SuperOperator

source
QuantumToolbox.projectionFunction
projection(N::Int, i::Int, j::Int)

Generates the projection operator $\hat{O} = \dyad{i}{j}$ with Hilbert space dimension N.

source
QuantumToolbox.commutatorFunction
commutator(A::QuantumObject, B::QuantumObject; anti::Bool=false)

Return the commutator (or anti-commutator) of the two QuantumObject:

  • commutator (anti=false): $\hat{A}\hat{B}-\hat{B}\hat{A}$
  • anticommutator (anti=true): $\hat{A}\hat{B}+\hat{B}\hat{A}$

Note that A and B must be Operator

source
QuantumToolbox.spreFunction
spre(A::QuantumObject, Id_cache=I(size(A,1)))

Returns the SuperOperator form of A acting on the left of the density matrix operator: $\mathcal{O} \left(\hat{A}\right) \left[ \hat{\rho} \right] = \hat{A} \hat{\rho}$.

Since the density matrix is vectorized in OperatorKet form: $|\hat{\rho}\rangle\rangle$, this SuperOperator is always a matrix $\hat{\mathbb{1}} \otimes \hat{A}$, namely

\[\mathcal{O} \left(\hat{A}\right) \left[ \hat{\rho} \right] = \hat{\mathbb{1}} \otimes \hat{A} ~ |\hat{\rho}\rangle\rangle\]

(see the section in documentation: Superoperators and Vectorized Operators for more details)

The optional argument Id_cache can be used to pass a precomputed identity matrix. This can be useful when the same function is applied multiple times with a known Hilbert space dimension.

source
QuantumToolbox.spostFunction
spost(B::QuantumObject, Id_cache=I(size(B,1)))

Returns the SuperOperator form of B acting on the right of the density matrix operator: $\mathcal{O} \left(\hat{B}\right) \left[ \hat{\rho} \right] = \hat{\rho} \hat{B}$.

Since the density matrix is vectorized in OperatorKet form: $|\hat{\rho}\rangle\rangle$, this SuperOperator is always a matrix $\hat{B}^T \otimes \hat{\mathbb{1}}$, namely

\[\mathcal{O} \left(\hat{B}\right) \left[ \hat{\rho} \right] = \hat{B}^T \otimes \hat{\mathbb{1}} ~ |\hat{\rho}\rangle\rangle\]

(see the section in documentation: Superoperators and Vectorized Operators for more details)

The optional argument Id_cache can be used to pass a precomputed identity matrix. This can be useful when the same function is applied multiple times with a known Hilbert space dimension.

source
QuantumToolbox.sprepostFunction
sprepost(A::QuantumObject, B::QuantumObject)

Returns the SuperOperator form of A and B acting on the left and right of the density matrix operator, respectively: $\mathcal{O} \left( \hat{A}, \hat{B} \right) \left[ \hat{\rho} \right] = \hat{A} \hat{\rho} \hat{B}$.

Since the density matrix is vectorized in OperatorKet form: $|\hat{\rho}\rangle\rangle$, this SuperOperator is always a matrix $\hat{B}^T \otimes \hat{A}$, namely

\[\mathcal{O} \left(\hat{A}, \hat{B}\right) \left[ \hat{\rho} \right] = \hat{B}^T \otimes \hat{A} ~ |\hat{\rho}\rangle\rangle = \textrm{spre}(\hat{A}) * \textrm{spost}(\hat{B}) ~ |\hat{\rho}\rangle\rangle\]

(see the section in documentation: Superoperators and Vectorized Operators for more details)

See also spre and spost.

source
QuantumToolbox.lindblad_dissipatorFunction
lindblad_dissipator(O::QuantumObject, Id_cache=I(size(O,1))

Returns the Lindblad SuperOperator defined as

\[\mathcal{D} \left( \hat{O} \right) \left[ \hat{\rho} \right] = \frac{1}{2} \left( 2 \hat{O} \hat{\rho} \hat{O}^\dagger - -\hat{O}^\dagger \hat{O} \hat{\rho} - \hat{\rho} \hat{O}^\dagger \hat{O} \right)\]

The optional argument Id_cache can be used to pass a precomputed identity matrix. This can be useful when the same function is applied multiple times with a known Hilbert space dimension.

See also spre and spost.

source

Synonyms of functions for Qobj

QuantumToolbox.QobjFunction
Qobj(A::AbstractArray; type::QuantumObjectType, dims::Vector{Int})

Generate QuantumObject

Note that this functions is same as QuantumObject(A; type=type, dims=dims)

source
QuantumToolbox.matrix_elementFunction
matrix_element(i::QuantumObject, A::QuantumObject j::QuantumObject)

Compute the generalized dot product dot(i, A*j) between three QuantumObject: $\langle i | \hat{A} | j \rangle$

Note that this function is same as dot(i, A, j)

Supports the following inputs:

source
QuantumToolbox.tensorFunction
tensor(A::QuantumObject, B::QuantumObject, ...)

Returns the Kronecker product $\hat{A} \otimes \hat{B} \otimes \cdots$.

Note that this function is same as kron(A, B, ...)

Examples

julia> x = sigmax()
+\end{bmatrix},\]

where $\omega = \exp(\frac{2 \pi i}{N})$.

Beware of type-stability!

It is highly recommended to use qft(dimensions) with dimensions as Tuple or SVector to keep type stability. See the related Section about type stability for more details.

source
QuantumToolbox.eyeFunction
eye(N::Int; type=Operator, dims=nothing)

Identity operator $\hat{\mathbb{1}}$ with size N.

It is also possible to specify the list of Hilbert dimensions dims if different subsystems are present.

Note that type can only be either Operator or SuperOperator

source
QuantumToolbox.projectionFunction
projection(N::Int, i::Int, j::Int)

Generates the projection operator $\hat{O} = \dyad{i}{j}$ with Hilbert space dimension N.

source
QuantumToolbox.commutatorFunction
commutator(A::QuantumObject, B::QuantumObject; anti::Bool=false)

Return the commutator (or anti-commutator) of the two QuantumObject:

  • commutator (anti=false): $\hat{A}\hat{B}-\hat{B}\hat{A}$
  • anticommutator (anti=true): $\hat{A}\hat{B}+\hat{B}\hat{A}$

Note that A and B must be Operator

source
QuantumToolbox.spreFunction
spre(A::QuantumObject, Id_cache=I(size(A,1)))

Returns the SuperOperator form of A acting on the left of the density matrix operator: $\mathcal{O} \left(\hat{A}\right) \left[ \hat{\rho} \right] = \hat{A} \hat{\rho}$.

Since the density matrix is vectorized in OperatorKet form: $|\hat{\rho}\rangle\rangle$, this SuperOperator is always a matrix $\hat{\mathbb{1}} \otimes \hat{A}$, namely

\[\mathcal{O} \left(\hat{A}\right) \left[ \hat{\rho} \right] = \hat{\mathbb{1}} \otimes \hat{A} ~ |\hat{\rho}\rangle\rangle\]

(see the section in documentation: Superoperators and Vectorized Operators for more details)

The optional argument Id_cache can be used to pass a precomputed identity matrix. This can be useful when the same function is applied multiple times with a known Hilbert space dimension.

source
QuantumToolbox.spostFunction
spost(B::QuantumObject, Id_cache=I(size(B,1)))

Returns the SuperOperator form of B acting on the right of the density matrix operator: $\mathcal{O} \left(\hat{B}\right) \left[ \hat{\rho} \right] = \hat{\rho} \hat{B}$.

Since the density matrix is vectorized in OperatorKet form: $|\hat{\rho}\rangle\rangle$, this SuperOperator is always a matrix $\hat{B}^T \otimes \hat{\mathbb{1}}$, namely

\[\mathcal{O} \left(\hat{B}\right) \left[ \hat{\rho} \right] = \hat{B}^T \otimes \hat{\mathbb{1}} ~ |\hat{\rho}\rangle\rangle\]

(see the section in documentation: Superoperators and Vectorized Operators for more details)

The optional argument Id_cache can be used to pass a precomputed identity matrix. This can be useful when the same function is applied multiple times with a known Hilbert space dimension.

source
QuantumToolbox.sprepostFunction
sprepost(A::QuantumObject, B::QuantumObject)

Returns the SuperOperator form of A and B acting on the left and right of the density matrix operator, respectively: $\mathcal{O} \left( \hat{A}, \hat{B} \right) \left[ \hat{\rho} \right] = \hat{A} \hat{\rho} \hat{B}$.

Since the density matrix is vectorized in OperatorKet form: $|\hat{\rho}\rangle\rangle$, this SuperOperator is always a matrix $\hat{B}^T \otimes \hat{A}$, namely

\[\mathcal{O} \left(\hat{A}, \hat{B}\right) \left[ \hat{\rho} \right] = \hat{B}^T \otimes \hat{A} ~ |\hat{\rho}\rangle\rangle = \textrm{spre}(\hat{A}) * \textrm{spost}(\hat{B}) ~ |\hat{\rho}\rangle\rangle\]

(see the section in documentation: Superoperators and Vectorized Operators for more details)

See also spre and spost.

source
QuantumToolbox.lindblad_dissipatorFunction
lindblad_dissipator(O::QuantumObject, Id_cache=I(size(O,1))

Returns the Lindblad SuperOperator defined as

\[\mathcal{D} \left( \hat{O} \right) \left[ \hat{\rho} \right] = \frac{1}{2} \left( 2 \hat{O} \hat{\rho} \hat{O}^\dagger - +\hat{O}^\dagger \hat{O} \hat{\rho} - \hat{\rho} \hat{O}^\dagger \hat{O} \right)\]

The optional argument Id_cache can be used to pass a precomputed identity matrix. This can be useful when the same function is applied multiple times with a known Hilbert space dimension.

See also spre and spost.

source

Synonyms of functions for Qobj

QuantumToolbox.QobjFunction
Qobj(A::AbstractArray; type::QuantumObjectType, dims::Vector{Int})

Generate QuantumObject

Note that this functions is same as QuantumObject(A; type=type, dims=dims)

source
QuantumToolbox.matrix_elementFunction
matrix_element(i::QuantumObject, A::QuantumObject j::QuantumObject)

Compute the generalized dot product dot(i, A*j) between three QuantumObject: $\langle i | \hat{A} | j \rangle$

Note that this function is same as dot(i, A, j)

Supports the following inputs:

source
QuantumToolbox.tensorFunction
tensor(A::QuantumObject, B::QuantumObject, ...)

Returns the Kronecker product $\hat{A} \otimes \hat{B} \otimes \cdots$.

Note that this function is same as kron(A, B, ...)

Examples

julia> x = sigmax()
 Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
 2×2 SparseMatrixCSC{ComplexF64, Int64} with 2 stored entries:
      ⋅      1.0+0.0im
@@ -260,7 +260,7 @@
      ⋅          ⋅          ⋅             ⋅          ⋅          ⋅
      ⋅          ⋅      1.0+0.0im  …      ⋅          ⋅          ⋅
      ⋅      1.0+0.0im      ⋅             ⋅          ⋅          ⋅
- 1.0+0.0im      ⋅          ⋅             ⋅          ⋅          ⋅
source
QuantumToolbox.:⊗Function
⊗(A::QuantumObject, B::QuantumObject)

Returns the Kronecker product $\hat{A} \otimes \hat{B}$.

Note that this function is same as kron(A, B)

Examples

julia> a = destroy(20)
+ 1.0+0.0im      ⋅          ⋅             ⋅          ⋅          ⋅
source
QuantumToolbox.:⊗Function
⊗(A::QuantumObject, B::QuantumObject)

Returns the Kronecker product $\hat{A} \otimes \hat{B}$.

Note that this function is same as kron(A, B)

Examples

julia> a = destroy(20)
 Quantum Object:   type=Operator   dims=[20]   size=(20, 20)   ishermitian=false
 20×20 SparseMatrixCSC{ComplexF64, Int64} with 19 stored entries:
 ⠈⠢⡀⠀⠀⠀⠀⠀⠀⠀
@@ -292,7 +292,7 @@
 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⠀⠀⠀⠀⠀
 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⠀⠀⠀
 ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⡀⠀
-⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠦
source
QuantumToolbox.qeyeFunction
qeye(N::Int; type=Operator, dims=nothing)

Identity operator $\hat{\mathbb{1}}$ with size N.

It is also possible to specify the list of Hilbert dimensions dims if different subsystems are present.

Note that this function is same as eye(N, type=type, dims=dims), and type can only be either Operator or SuperOperator

source

Time evolution

QuantumToolbox.TimeEvolutionSolType
struct TimeEvolutionSol

A structure storing the results and some information from solving time evolution.

Fields (Attributes)

  • times::AbstractVector: The time list of the evolution.
  • states::Vector{QuantumObject}: The list of result states.
  • expect::Matrix: The expectation values corresponding to each time point in times.
  • retcode: The return code from the solver.
  • alg: The algorithm which is used during the solving process.
  • abstol::Real: The absolute tolerance which is used during the solving process.
  • reltol::Real: The relative tolerance which is used during the solving process.
source
QuantumToolbox.TimeEvolutionMCSolType
struct TimeEvolutionMCSol

A structure storing the results and some information from solving quantum trajectories of the Monte Carlo wave function time evolution.

Fields (Attributes)

  • ntraj::Int: Number of trajectories
  • times::AbstractVector: The time list of the evolution.
  • states::Vector{Vector{QuantumObject}}: The list of result states in each trajectory.
  • expect::Matrix: The expectation values (averaging all trajectories) corresponding to each time point in times.
  • expect_all::Array: The expectation values corresponding to each trajectory and each time point in times
  • jump_times::Vector{Vector{Real}}: The time records of every quantum jump occurred in each trajectory.
  • jump_which::Vector{Vector{Int}}: The indices of the jump operators in c_ops that describe the corresponding quantum jumps occurred in each trajectory.
  • converged::Bool: Whether the solution is converged or not.
  • alg: The algorithm which is used during the solving process.
  • abstol::Real: The absolute tolerance which is used during the solving process.
  • reltol::Real: The relative tolerance which is used during the solving process.
source
QuantumToolbox.TimeEvolutionSSESolType
struct TimeEvolutionSSESol

A structure storing the results and some information from solving trajectories of the Stochastic Shrodinger equation time evolution.

Fields (Attributes)

  • ntraj::Int: Number of trajectories
  • times::AbstractVector: The time list of the evolution.
  • states::Vector{Vector{QuantumObject}}: The list of result states in each trajectory.
  • expect::Matrix: The expectation values (averaging all trajectories) corresponding to each time point in times.
  • expect_all::Array: The expectation values corresponding to each trajectory and each time point in times
  • converged::Bool: Whether the solution is converged or not.
  • alg: The algorithm which is used during the solving process.
  • abstol::Real: The absolute tolerance which is used during the solving process.
  • reltol::Real: The relative tolerance which is used during the solving process.
source
QuantumToolbox.sesolveProblemFunction
sesolveProblem(H::QuantumObject,
+⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠦
source
QuantumToolbox.qeyeFunction
qeye(N::Int; type=Operator, dims=nothing)

Identity operator $\hat{\mathbb{1}}$ with size N.

It is also possible to specify the list of Hilbert dimensions dims if different subsystems are present.

Note that this function is same as eye(N, type=type, dims=dims), and type can only be either Operator or SuperOperator

source

Time evolution

QuantumToolbox.TimeEvolutionSolType
struct TimeEvolutionSol

A structure storing the results and some information from solving time evolution.

Fields (Attributes)

  • times::AbstractVector: The time list of the evolution.
  • states::Vector{QuantumObject}: The list of result states.
  • expect::Matrix: The expectation values corresponding to each time point in times.
  • retcode: The return code from the solver.
  • alg: The algorithm which is used during the solving process.
  • abstol::Real: The absolute tolerance which is used during the solving process.
  • reltol::Real: The relative tolerance which is used during the solving process.
source
QuantumToolbox.TimeEvolutionMCSolType
struct TimeEvolutionMCSol

A structure storing the results and some information from solving quantum trajectories of the Monte Carlo wave function time evolution.

Fields (Attributes)

  • ntraj::Int: Number of trajectories
  • times::AbstractVector: The time list of the evolution.
  • states::Vector{Vector{QuantumObject}}: The list of result states in each trajectory.
  • expect::Matrix: The expectation values (averaging all trajectories) corresponding to each time point in times.
  • expect_all::Array: The expectation values corresponding to each trajectory and each time point in times
  • jump_times::Vector{Vector{Real}}: The time records of every quantum jump occurred in each trajectory.
  • jump_which::Vector{Vector{Int}}: The indices of the jump operators in c_ops that describe the corresponding quantum jumps occurred in each trajectory.
  • converged::Bool: Whether the solution is converged or not.
  • alg: The algorithm which is used during the solving process.
  • abstol::Real: The absolute tolerance which is used during the solving process.
  • reltol::Real: The relative tolerance which is used during the solving process.
source
QuantumToolbox.TimeEvolutionSSESolType
struct TimeEvolutionSSESol

A structure storing the results and some information from solving trajectories of the Stochastic Shrodinger equation time evolution.

Fields (Attributes)

  • ntraj::Int: Number of trajectories
  • times::AbstractVector: The time list of the evolution.
  • states::Vector{Vector{QuantumObject}}: The list of result states in each trajectory.
  • expect::Matrix: The expectation values (averaging all trajectories) corresponding to each time point in times.
  • expect_all::Array: The expectation values corresponding to each trajectory and each time point in times
  • converged::Bool: Whether the solution is converged or not.
  • alg: The algorithm which is used during the solving process.
  • abstol::Real: The absolute tolerance which is used during the solving process.
  • reltol::Real: The relative tolerance which is used during the solving process.
source
QuantumToolbox.sesolveProblemFunction
sesolveProblem(H::QuantumObject,
     ψ0::QuantumObject,
     tlist::AbstractVector;
     alg::OrdinaryDiffEqAlgorithm=Tsit5()
@@ -300,7 +300,7 @@
     H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
     params::NamedTuple=NamedTuple(),
     progress_bar::Union{Val,Bool}=Val(true),
-    kwargs...)

Generates the ODEProblem for the Schrödinger time evolution of a quantum system:

\[\frac{\partial}{\partial t} |\psi(t)\rangle = -i \hat{H} |\psi(t)\rangle\]

Arguments

  • H::QuantumObject: The Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: The initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: The time list of the evolution.
  • alg::OrdinaryDiffEqAlgorithm: The algorithm used for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: The list of operators to be evaluated during the evolution.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: The time-dependent Hamiltonian of the system. If nothing, the Hamiltonian is time-independent.
  • params::NamedTuple: The parameters of the system.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: The keyword arguments passed to the ODEProblem constructor.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob: The ODEProblem for the Schrödinger time evolution of the system.
source
QuantumToolbox.mesolveProblemFunction
mesolveProblem(H::QuantumObject,
+    kwargs...)

Generates the ODEProblem for the Schrödinger time evolution of a quantum system:

\[\frac{\partial}{\partial t} |\psi(t)\rangle = -i \hat{H} |\psi(t)\rangle\]

Arguments

  • H::QuantumObject: The Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: The initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: The time list of the evolution.
  • alg::OrdinaryDiffEqAlgorithm: The algorithm used for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: The list of operators to be evaluated during the evolution.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: The time-dependent Hamiltonian of the system. If nothing, the Hamiltonian is time-independent.
  • params::NamedTuple: The parameters of the system.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: The keyword arguments passed to the ODEProblem constructor.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob: The ODEProblem for the Schrödinger time evolution of the system.
source
QuantumToolbox.mesolveProblemFunction
mesolveProblem(H::QuantumObject,
     ψ0::QuantumObject,
     tlist::AbstractVector, 
     c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
@@ -309,7 +309,7 @@
     H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
     params::NamedTuple=NamedTuple(),
     progress_bar::Union{Val,Bool}=Val(true),
-    kwargs...)

Generates the ODEProblem for the master equation time evolution of an open quantum system:

\[\frac{\partial \hat{\rho}(t)}{\partial t} = -i[\hat{H}, \hat{\rho}(t)] + \sum_n \mathcal{D}(\hat{C}_n) [\hat{\rho}(t)]\]

where

\[\mathcal{D}(\hat{C}_n) [\hat{\rho}(t)] = \hat{C}_n \hat{\rho}(t) \hat{C}_n^\dagger - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n \hat{\rho}(t) - \frac{1}{2} \hat{\rho}(t) \hat{C}_n^\dagger \hat{C}_n\]

Arguments

  • H::QuantumObject: The Hamiltonian $\hat{H}$ or the Liouvillian of the system.
  • ψ0::QuantumObject: The initial state of the system.
  • tlist::AbstractVector: The time list of the evolution.
  • c_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm=Tsit5(): The algorithm used for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the operators for which the expectation values are calculated.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing: The time-dependent Hamiltonian or Liouvillian.
  • params::NamedTuple=NamedTuple(): The parameters of the time evolution.
  • progress_bar::Union{Val,Bool}=Val(true): Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: The keyword arguments for the ODEProblem.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob::ODEProblem: The ODEProblem for the master equation time evolution.
source
QuantumToolbox.mcsolveProblemFunction
mcsolveProblem(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
+    kwargs...)

Generates the ODEProblem for the master equation time evolution of an open quantum system:

\[\frac{\partial \hat{\rho}(t)}{\partial t} = -i[\hat{H}, \hat{\rho}(t)] + \sum_n \mathcal{D}(\hat{C}_n) [\hat{\rho}(t)]\]

where

\[\mathcal{D}(\hat{C}_n) [\hat{\rho}(t)] = \hat{C}_n \hat{\rho}(t) \hat{C}_n^\dagger - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n \hat{\rho}(t) - \frac{1}{2} \hat{\rho}(t) \hat{C}_n^\dagger \hat{C}_n\]

Arguments

  • H::QuantumObject: The Hamiltonian $\hat{H}$ or the Liouvillian of the system.
  • ψ0::QuantumObject: The initial state of the system.
  • tlist::AbstractVector: The time list of the evolution.
  • c_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm=Tsit5(): The algorithm used for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the operators for which the expectation values are calculated.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing: The time-dependent Hamiltonian or Liouvillian.
  • params::NamedTuple=NamedTuple(): The parameters of the time evolution.
  • progress_bar::Union{Val,Bool}=Val(true): Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: The keyword arguments for the ODEProblem.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob::ODEProblem: The ODEProblem for the master equation time evolution.
source
QuantumToolbox.mcsolveProblemFunction
mcsolveProblem(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
     ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
     tlist::AbstractVector,
     c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
@@ -318,7 +318,7 @@
     H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
     params::NamedTuple=NamedTuple(),
     jump_callback::TJC=ContinuousLindbladJumpCallback(),
-    kwargs...)

Generates the ODEProblem for a single trajectory of the Monte Carlo wave function time evolution of an open quantum system.

Given a system Hamiltonian $\hat{H}$ and a list of collapse (jump) operators $\{\hat{C}_n\}_n$, the evolution of the state $|\psi(t)\rangle$ is governed by the Schrodinger equation:

\[\frac{\partial}{\partial t} |\psi(t)\rangle= -i \hat{H}_{\textrm{eff}} |\psi(t)\rangle\]

with a non-Hermitian effective Hamiltonian:

\[\hat{H}_{\textrm{eff}} = \hat{H} - \frac{i}{2} \sum_n \hat{C}_n^\dagger \hat{C}_n.\]

To the first-order of the wave function in a small time $\delta t$, the strictly negative non-Hermitian portion in $\hat{H}_{\textrm{eff}}$ gives rise to a reduction in the norm of the wave function, namely

\[\langle \psi(t+\delta t) | \psi(t+\delta t) \rangle = 1 - \delta p,\]

where

\[\delta p = \delta t \sum_n \langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle\]

is the corresponding quantum jump probability.

If the environmental measurements register a quantum jump, the wave function undergoes a jump into a state defined by projecting $|\psi(t)\rangle$ using the collapse operator $\hat{C}_n$ corresponding to the measurement, namely

\[| \psi(t+\delta t) \rangle = \frac{\hat{C}_n |\psi(t)\rangle}{ \sqrt{\langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle} }\]

Arguments

  • H::QuantumObject: Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: Initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • c_ops::Union{Nothing,AbstractVector,Tuple}: List of collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • seeds::Union{Nothing, Vector{Int}}: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
  • jump_callback::LindbladJumpCallbackType: The Jump Callback type: Discrete or Continuous.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob::ODEProblem: The ODEProblem for the Monte Carlo wave function time evolution.
source
QuantumToolbox.mcsolveEnsembleProblemFunction
mcsolveEnsembleProblem(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
+    kwargs...)

Generates the ODEProblem for a single trajectory of the Monte Carlo wave function time evolution of an open quantum system.

Given a system Hamiltonian $\hat{H}$ and a list of collapse (jump) operators $\{\hat{C}_n\}_n$, the evolution of the state $|\psi(t)\rangle$ is governed by the Schrodinger equation:

\[\frac{\partial}{\partial t} |\psi(t)\rangle= -i \hat{H}_{\textrm{eff}} |\psi(t)\rangle\]

with a non-Hermitian effective Hamiltonian:

\[\hat{H}_{\textrm{eff}} = \hat{H} - \frac{i}{2} \sum_n \hat{C}_n^\dagger \hat{C}_n.\]

To the first-order of the wave function in a small time $\delta t$, the strictly negative non-Hermitian portion in $\hat{H}_{\textrm{eff}}$ gives rise to a reduction in the norm of the wave function, namely

\[\langle \psi(t+\delta t) | \psi(t+\delta t) \rangle = 1 - \delta p,\]

where

\[\delta p = \delta t \sum_n \langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle\]

is the corresponding quantum jump probability.

If the environmental measurements register a quantum jump, the wave function undergoes a jump into a state defined by projecting $|\psi(t)\rangle$ using the collapse operator $\hat{C}_n$ corresponding to the measurement, namely

\[| \psi(t+\delta t) \rangle = \frac{\hat{C}_n |\psi(t)\rangle}{ \sqrt{\langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle} }\]

Arguments

  • H::QuantumObject: Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: Initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • c_ops::Union{Nothing,AbstractVector,Tuple}: List of collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • seeds::Union{Nothing, Vector{Int}}: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
  • jump_callback::LindbladJumpCallbackType: The Jump Callback type: Discrete or Continuous.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob::ODEProblem: The ODEProblem for the Monte Carlo wave function time evolution.
source
QuantumToolbox.mcsolveEnsembleProblemFunction
mcsolveEnsembleProblem(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
     ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
     tlist::AbstractVector,
     c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
@@ -332,7 +332,7 @@
     prob_func::Function=_mcsolve_prob_func,
     output_func::Function=_mcsolve_output_func,
     progress_bar::Union{Val,Bool}=Val(true),
-    kwargs...)

Generates the EnsembleProblem of ODEProblems for the ensemble of trajectories of the Monte Carlo wave function time evolution of an open quantum system.

Given a system Hamiltonian $\hat{H}$ and a list of collapse (jump) operators $\{\hat{C}_n\}_n$, the evolution of the state $|\psi(t)\rangle$ is governed by the Schrodinger equation:

\[\frac{\partial}{\partial t} |\psi(t)\rangle= -i \hat{H}_{\textrm{eff}} |\psi(t)\rangle\]

with a non-Hermitian effective Hamiltonian:

\[\hat{H}_{\textrm{eff}} = \hat{H} - \frac{i}{2} \sum_n \hat{C}_n^\dagger \hat{C}_n.\]

To the first-order of the wave function in a small time $\delta t$, the strictly negative non-Hermitian portion in $\hat{H}_{\textrm{eff}}$ gives rise to a reduction in the norm of the wave function, namely

\[\langle \psi(t+\delta t) | \psi(t+\delta t) \rangle = 1 - \delta p,\]

where

\[\delta p = \delta t \sum_n \langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle\]

is the corresponding quantum jump probability.

If the environmental measurements register a quantum jump, the wave function undergoes a jump into a state defined by projecting $|\psi(t)\rangle$ using the collapse operator $\hat{C}_n$ corresponding to the measurement, namely

\[| \psi(t+\delta t) \rangle = \frac{\hat{C}_n |\psi(t)\rangle}{ \sqrt{\langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle} }\]

Arguments

  • H::QuantumObject: Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: Initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • c_ops::Union{Nothing,AbstractVector,Tuple}: List of collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • seeds::Union{Nothing, Vector{Int}}: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
  • ntraj::Int: Number of trajectories to use.
  • ensemble_method: Ensemble method to use.
  • jump_callback::LindbladJumpCallbackType: The Jump Callback type: Discrete or Continuous.
  • prob_func::Function: Function to use for generating the ODEProblem.
  • output_func::Function: Function to use for generating the output of a single trajectory.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob::EnsembleProblem with ODEProblem: The Ensemble ODEProblem for the Monte Carlo wave function time evolution.
source
QuantumToolbox.ssesolveProblemFunction
ssesolveProblem(H::QuantumObject,
+    kwargs...)

Generates the EnsembleProblem of ODEProblems for the ensemble of trajectories of the Monte Carlo wave function time evolution of an open quantum system.

Given a system Hamiltonian $\hat{H}$ and a list of collapse (jump) operators $\{\hat{C}_n\}_n$, the evolution of the state $|\psi(t)\rangle$ is governed by the Schrodinger equation:

\[\frac{\partial}{\partial t} |\psi(t)\rangle= -i \hat{H}_{\textrm{eff}} |\psi(t)\rangle\]

with a non-Hermitian effective Hamiltonian:

\[\hat{H}_{\textrm{eff}} = \hat{H} - \frac{i}{2} \sum_n \hat{C}_n^\dagger \hat{C}_n.\]

To the first-order of the wave function in a small time $\delta t$, the strictly negative non-Hermitian portion in $\hat{H}_{\textrm{eff}}$ gives rise to a reduction in the norm of the wave function, namely

\[\langle \psi(t+\delta t) | \psi(t+\delta t) \rangle = 1 - \delta p,\]

where

\[\delta p = \delta t \sum_n \langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle\]

is the corresponding quantum jump probability.

If the environmental measurements register a quantum jump, the wave function undergoes a jump into a state defined by projecting $|\psi(t)\rangle$ using the collapse operator $\hat{C}_n$ corresponding to the measurement, namely

\[| \psi(t+\delta t) \rangle = \frac{\hat{C}_n |\psi(t)\rangle}{ \sqrt{\langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle} }\]

Arguments

  • H::QuantumObject: Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: Initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • c_ops::Union{Nothing,AbstractVector,Tuple}: List of collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • seeds::Union{Nothing, Vector{Int}}: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
  • ntraj::Int: Number of trajectories to use.
  • ensemble_method: Ensemble method to use.
  • jump_callback::LindbladJumpCallbackType: The Jump Callback type: Discrete or Continuous.
  • prob_func::Function: Function to use for generating the ODEProblem.
  • output_func::Function: Function to use for generating the output of a single trajectory.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob::EnsembleProblem with ODEProblem: The Ensemble ODEProblem for the Monte Carlo wave function time evolution.
source
QuantumToolbox.ssesolveProblemFunction
ssesolveProblem(H::QuantumObject,
     ψ0::QuantumObject,
     tlist::AbstractVector;
     sc_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
@@ -344,7 +344,7 @@
     ```
 
 where 
-    \]

math K = \hat{H} + i \sumn \left(\frac{ej} Cn - \frac{1}{2} \sum{j} Cn^\dagger Cn - \frac{ej^2}{8}\right), math Mn = Cn - \frac{en}{2}, andmath en = \langle Cn + C_n^\dagger \rangle. ```

Above, C_n is the n-th collapse operator and dW_j(t) is the real Wiener increment associated to C_n.

Arguments

  • H::QuantumObject: The Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: The initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: The time list of the evolution.
  • sc_ops::Union{Nothing,AbstractVector,Tuple}=nothing: List of stochastic collapse operators $\{\hat{C}_n\}_n$.
  • alg::StochasticDiffEqAlgorithm: The algorithm used for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of operators to be evaluated during the evolution.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: The time-dependent Hamiltonian of the system. If nothing, the Hamiltonian is time-independent.
  • params::NamedTuple: The parameters of the system.
  • kwargs...: The keyword arguments passed to the SDEProblem constructor.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-2 and abstol=1e-2.
  • For more details about alg please refer to DifferentialEquations.jl (SDE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob: The SDEProblem for the Stochastic Schrödinger time evolution of the system.
source
QuantumToolbox.ssesolveEnsembleProblemFunction
ssesolveEnsembleProblem(H::QuantumObject,
+    \]

math K = \hat{H} + i \sumn \left(\frac{ej} Cn - \frac{1}{2} \sum{j} Cn^\dagger Cn - \frac{ej^2}{8}\right), math Mn = Cn - \frac{en}{2}, andmath en = \langle Cn + C_n^\dagger \rangle. ```

Above, C_n is the n-th collapse operator and dW_j(t) is the real Wiener increment associated to C_n.

Arguments

  • H::QuantumObject: The Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: The initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: The time list of the evolution.
  • sc_ops::Union{Nothing,AbstractVector,Tuple}=nothing: List of stochastic collapse operators $\{\hat{C}_n\}_n$.
  • alg::StochasticDiffEqAlgorithm: The algorithm used for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of operators to be evaluated during the evolution.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: The time-dependent Hamiltonian of the system. If nothing, the Hamiltonian is time-independent.
  • params::NamedTuple: The parameters of the system.
  • kwargs...: The keyword arguments passed to the SDEProblem constructor.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-2 and abstol=1e-2.
  • For more details about alg please refer to DifferentialEquations.jl (SDE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob: The SDEProblem for the Stochastic Schrödinger time evolution of the system.
source
QuantumToolbox.ssesolveEnsembleProblemFunction
ssesolveEnsembleProblem(H::QuantumObject,
     ψ0::QuantumObject,
     tlist::AbstractVector;
     sc_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
@@ -361,7 +361,7 @@
     ```
 
 where 
-    \]

math K = \hat{H} + i \sumn \left(\frac{ej} Cn - \frac{1}{2} \sum{j} Cn^\dagger Cn - \frac{ej^2}{8}\right), math Mn = Cn - \frac{en}{2}, andmath en = \langle Cn + C_n^\dagger \rangle. ```

Above, C_n is the n-th collapse operator and dW_j(t) is the real Wiener increment associated to C_n.

Arguments

  • H::QuantumObject: The Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: The initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: The time list of the evolution.
  • sc_ops::Union{Nothing,AbstractVector,Tuple}=nothing: List of stochastic collapse operators $\{\hat{C}_n\}_n$.
  • alg::StochasticDiffEqAlgorithm: The algorithm used for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of operators to be evaluated during the evolution.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: The time-dependent Hamiltonian of the system. If nothing, the Hamiltonian is time-independent.
  • params::NamedTuple: The parameters of the system.
  • ntraj::Int: Number of trajectories to use.
  • ensemble_method: Ensemble method to use.
  • prob_func::Function: Function to use for generating the SDEProblem.
  • output_func::Function: Function to use for generating the output of a single trajectory.
  • progress_bar::Union{Val,Bool}: Whether to show a progress bar.
  • kwargs...: The keyword arguments passed to the SDEProblem constructor.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-2 and abstol=1e-2.
  • For more details about alg please refer to DifferentialEquations.jl (SDE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob::EnsembleProblem with SDEProblem: The Ensemble SDEProblem for the Stochastic Shrödinger time evolution.
source
QuantumToolbox.lr_mesolveProblemFunction
lr_mesolveProblem(H, z, B, tlist, c_ops; e_ops=(), f_ops=(), opt=LRMesolveOptions(), kwargs...) where T
+    \]

math K = \hat{H} + i \sumn \left(\frac{ej} Cn - \frac{1}{2} \sum{j} Cn^\dagger Cn - \frac{ej^2}{8}\right), math Mn = Cn - \frac{en}{2}, andmath en = \langle Cn + C_n^\dagger \rangle. ```

Above, C_n is the n-th collapse operator and dW_j(t) is the real Wiener increment associated to C_n.

Arguments

  • H::QuantumObject: The Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: The initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: The time list of the evolution.
  • sc_ops::Union{Nothing,AbstractVector,Tuple}=nothing: List of stochastic collapse operators $\{\hat{C}_n\}_n$.
  • alg::StochasticDiffEqAlgorithm: The algorithm used for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of operators to be evaluated during the evolution.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: The time-dependent Hamiltonian of the system. If nothing, the Hamiltonian is time-independent.
  • params::NamedTuple: The parameters of the system.
  • ntraj::Int: Number of trajectories to use.
  • ensemble_method: Ensemble method to use.
  • prob_func::Function: Function to use for generating the SDEProblem.
  • output_func::Function: Function to use for generating the output of a single trajectory.
  • progress_bar::Union{Val,Bool}: Whether to show a progress bar.
  • kwargs...: The keyword arguments passed to the SDEProblem constructor.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-2 and abstol=1e-2.
  • For more details about alg please refer to DifferentialEquations.jl (SDE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • prob::EnsembleProblem with SDEProblem: The Ensemble SDEProblem for the Stochastic Shrödinger time evolution.
source
QuantumToolbox.lr_mesolveProblemFunction
lr_mesolveProblem(H, z, B, tlist, c_ops; e_ops=(), f_ops=(), opt=LRMesolveOptions(), kwargs...) where T
 Formulates the ODEproblem for the low-rank time evolution of the system. The function is called by lr_mesolve.
 
 Parameters
@@ -383,7 +383,7 @@
 opt : LRMesolveOptions
     The options of the problem.
 kwargs : NamedTuple
-    Additional keyword arguments for the ODEProblem.
source
QuantumToolbox.sesolveFunction
sesolve(H::QuantumObject,
     ψ0::QuantumObject,
     tlist::AbstractVector;
     alg::OrdinaryDiffEqAlgorithm=Tsit5(),
@@ -391,7 +391,7 @@
     H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
     params::NamedTuple=NamedTuple(),
     progress_bar::Union{Val,Bool}=Val(true),
-    kwargs...)

Time evolution of a closed quantum system using the Schrödinger equation:

\[\frac{\partial}{\partial t} |\psi(t)\rangle = -i \hat{H} |\psi(t)\rangle\]

Arguments

  • H::QuantumObject: The Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: The initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • sol::TimeEvolutionSol: The solution of the time evolution. See also TimeEvolutionSol
source
QuantumToolbox.mesolveFunction
mesolve(H::QuantumObject,
+    kwargs...)

Time evolution of a closed quantum system using the Schrödinger equation:

\[\frac{\partial}{\partial t} |\psi(t)\rangle = -i \hat{H} |\psi(t)\rangle\]

Arguments

  • H::QuantumObject: The Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: The initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • sol::TimeEvolutionSol: The solution of the time evolution. See also TimeEvolutionSol
source
QuantumToolbox.mesolveFunction
mesolve(H::QuantumObject,
     ψ0::QuantumObject,
     tlist::AbstractVector, 
     c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
@@ -400,7 +400,7 @@
     H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
     params::NamedTuple=NamedTuple(),
     progress_bar::Union{Val,Bool}=Val(true),
-    kwargs...)

Time evolution of an open quantum system using Lindblad master equation:

\[\frac{\partial \hat{\rho}(t)}{\partial t} = -i[\hat{H}, \hat{\rho}(t)] + \sum_n \mathcal{D}(\hat{C}_n) [\hat{\rho}(t)]\]

where

\[\mathcal{D}(\hat{C}_n) [\hat{\rho}(t)] = \hat{C}_n \hat{\rho}(t) \hat{C}_n^\dagger - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n \hat{\rho}(t) - \frac{1}{2} \hat{\rho}(t) \hat{C}_n^\dagger \hat{C}_n\]

Arguments

  • H::QuantumObject: The Hamiltonian $\hat{H}$ or the Liouvillian of the system.
  • ψ0::QuantumObject: The initial state of the system.
  • tlist::AbstractVector: The time list of the evolution.
  • c_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Named Tuple of parameters to pass to the solver.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • sol::TimeEvolutionSol: The solution of the time evolution. See also TimeEvolutionSol
source
QuantumToolbox.mcsolveFunction
mcsolve(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
+    kwargs...)

Time evolution of an open quantum system using Lindblad master equation:

\[\frac{\partial \hat{\rho}(t)}{\partial t} = -i[\hat{H}, \hat{\rho}(t)] + \sum_n \mathcal{D}(\hat{C}_n) [\hat{\rho}(t)]\]

where

\[\mathcal{D}(\hat{C}_n) [\hat{\rho}(t)] = \hat{C}_n \hat{\rho}(t) \hat{C}_n^\dagger - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n \hat{\rho}(t) - \frac{1}{2} \hat{\rho}(t) \hat{C}_n^\dagger \hat{C}_n\]

Arguments

  • H::QuantumObject: The Hamiltonian $\hat{H}$ or the Liouvillian of the system.
  • ψ0::QuantumObject: The initial state of the system.
  • tlist::AbstractVector: The time list of the evolution.
  • c_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Named Tuple of parameters to pass to the solver.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

  • sol::TimeEvolutionSol: The solution of the time evolution. See also TimeEvolutionSol
source
QuantumToolbox.mcsolveFunction
mcsolve(H::QuantumObject{<:AbstractArray{T1},OperatorQuantumObject},
     ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
     tlist::AbstractVector,
     c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
@@ -416,7 +416,7 @@
     output_func::Function = _mcsolve_dispatch_output_func(ensemble_method),
     progress_bar::Union{Val,Bool} = Val(true),
     kwargs...,
-)

Time evolution of an open quantum system using quantum trajectories.

Given a system Hamiltonian $\hat{H}$ and a list of collapse (jump) operators $\{\hat{C}_n\}_n$, the evolution of the state $|\psi(t)\rangle$ is governed by the Schrodinger equation:

\[\frac{\partial}{\partial t} |\psi(t)\rangle= -i \hat{H}_{\textrm{eff}} |\psi(t)\rangle\]

with a non-Hermitian effective Hamiltonian:

\[\hat{H}_{\textrm{eff}} = \hat{H} - \frac{i}{2} \sum_n \hat{C}_n^\dagger \hat{C}_n.\]

To the first-order of the wave function in a small time $\delta t$, the strictly negative non-Hermitian portion in $\hat{H}_{\textrm{eff}}$ gives rise to a reduction in the norm of the wave function, namely

\[\langle \psi(t+\delta t) | \psi(t+\delta t) \rangle = 1 - \delta p,\]

where

\[\delta p = \delta t \sum_n \langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle\]

is the corresponding quantum jump probability.

If the environmental measurements register a quantum jump, the wave function undergoes a jump into a state defined by projecting $|\psi(t)\rangle$ using the collapse operator $\hat{C}_n$ corresponding to the measurement, namely

\[| \psi(t+\delta t) \rangle = \frac{\hat{C}_n |\psi(t)\rangle}{ \sqrt{\langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle} }\]

Arguments

  • H::QuantumObject: Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: Initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • c_ops::Union{Nothing,AbstractVector,Tuple}: List of collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • seeds::Union{Nothing, Vector{Int}}: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
  • ntraj::Int: Number of trajectories to use.
  • ensemble_method: Ensemble method to use.
  • jump_callback::LindbladJumpCallbackType: The Jump Callback type: Discrete or Continuous.
  • prob_func::Function: Function to use for generating the ODEProblem.
  • output_func::Function: Function to use for generating the output of a single trajectory.
  • kwargs...: Additional keyword arguments to pass to the solver.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.

Notes

  • ensemble_method can be one of EnsembleThreads(), EnsembleSerial(), EnsembleDistributed()
  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

source
QuantumToolbox.ssesolveFunction
ssesolve(H::QuantumObject,
+)

Time evolution of an open quantum system using quantum trajectories.

Given a system Hamiltonian $\hat{H}$ and a list of collapse (jump) operators $\{\hat{C}_n\}_n$, the evolution of the state $|\psi(t)\rangle$ is governed by the Schrodinger equation:

\[\frac{\partial}{\partial t} |\psi(t)\rangle= -i \hat{H}_{\textrm{eff}} |\psi(t)\rangle\]

with a non-Hermitian effective Hamiltonian:

\[\hat{H}_{\textrm{eff}} = \hat{H} - \frac{i}{2} \sum_n \hat{C}_n^\dagger \hat{C}_n.\]

To the first-order of the wave function in a small time $\delta t$, the strictly negative non-Hermitian portion in $\hat{H}_{\textrm{eff}}$ gives rise to a reduction in the norm of the wave function, namely

\[\langle \psi(t+\delta t) | \psi(t+\delta t) \rangle = 1 - \delta p,\]

where

\[\delta p = \delta t \sum_n \langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle\]

is the corresponding quantum jump probability.

If the environmental measurements register a quantum jump, the wave function undergoes a jump into a state defined by projecting $|\psi(t)\rangle$ using the collapse operator $\hat{C}_n$ corresponding to the measurement, namely

\[| \psi(t+\delta t) \rangle = \frac{\hat{C}_n |\psi(t)\rangle}{ \sqrt{\langle \psi(t) | \hat{C}_n^\dagger \hat{C}_n | \psi(t) \rangle} }\]

Arguments

  • H::QuantumObject: Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: Initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • c_ops::Union{Nothing,AbstractVector,Tuple}: List of collapse operators $\{\hat{C}_n\}_n$.
  • alg::OrdinaryDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • seeds::Union{Nothing, Vector{Int}}: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
  • ntraj::Int: Number of trajectories to use.
  • ensemble_method: Ensemble method to use.
  • jump_callback::LindbladJumpCallbackType: The Jump Callback type: Discrete or Continuous.
  • prob_func::Function: Function to use for generating the ODEProblem.
  • output_func::Function: Function to use for generating the output of a single trajectory.
  • kwargs...: Additional keyword arguments to pass to the solver.
  • progress_bar::Union{Val,Bool}: Whether to show the progress bar. Using non-Val types might lead to type instabilities.

Notes

  • ensemble_method can be one of EnsembleThreads(), EnsembleSerial(), EnsembleDistributed()
  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-6 and abstol=1e-8.
  • For more details about alg please refer to DifferentialEquations.jl (ODE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

source
QuantumToolbox.ssesolveFunction
ssesolve(H::QuantumObject,
     ψ0::QuantumObject{<:AbstractArray{T2},KetQuantumObject},
     tlist::AbstractVector,
     sc_ops::Union{Nothing, AbstractVector}=nothing;
@@ -433,7 +433,7 @@
     ```
 
 where 
-    \]

math K = \hat{H} + i \sumn \left(\frac{ej} Cn - \frac{1}{2} \sum{j} Cn^\dagger Cn - \frac{ej^2}{8}\right), math Mn = Cn - \frac{en}{2}, andmath en = \langle Cn + C_n^\dagger \rangle. ```

Above, C_n is the n-th collapse operator and dW_j(t) is the real Wiener increment associated to C_n.

Arguments

  • H::QuantumObject: Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: Initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • sc_ops::Union{Nothing,AbstractVector,Tuple}=nothing: List of stochastic collapse operators $\{\hat{C}_n\}_n$.
  • alg::StochasticDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • seeds::Union{Nothing, Vector{Int}}: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
  • ntraj::Int: Number of trajectories to use.
  • ensemble_method: Ensemble method to use.
  • prob_func::Function: Function to use for generating the SDEProblem.
  • output_func::Function: Function to use for generating the output of a single trajectory.
  • progress_bar::Union{Val,Bool}: Whether to show a progress bar.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • ensemble_method can be one of EnsembleThreads(), EnsembleSerial(), EnsembleDistributed()
  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-2 and abstol=1e-2.
  • For more details about alg please refer to DifferentialEquations.jl (SDE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

source
QuantumToolbox.dfd_mesolveFunction
dfd_mesolve(H::Function, ψ0::QuantumObject,
+    \]

math K = \hat{H} + i \sumn \left(\frac{ej} Cn - \frac{1}{2} \sum{j} Cn^\dagger Cn - \frac{ej^2}{8}\right), math Mn = Cn - \frac{en}{2}, andmath en = \langle Cn + C_n^\dagger \rangle. ```

Above, C_n is the n-th collapse operator and dW_j(t) is the real Wiener increment associated to C_n.

Arguments

  • H::QuantumObject: Hamiltonian of the system $\hat{H}$.
  • ψ0::QuantumObject: Initial state of the system $|\psi(0)\rangle$.
  • tlist::AbstractVector: List of times at which to save the state of the system.
  • sc_ops::Union{Nothing,AbstractVector,Tuple}=nothing: List of stochastic collapse operators $\{\hat{C}_n\}_n$.
  • alg::StochasticDiffEqAlgorithm: Algorithm to use for the time evolution.
  • e_ops::Union{Nothing,AbstractVector,Tuple}: List of operators for which to calculate expectation values.
  • H_t::Union{Nothing,Function,TimeDependentOperatorSum}: Time-dependent part of the Hamiltonian.
  • params::NamedTuple: Dictionary of parameters to pass to the solver.
  • seeds::Union{Nothing, Vector{Int}}: List of seeds for the random number generator. Length must be equal to the number of trajectories provided.
  • ntraj::Int: Number of trajectories to use.
  • ensemble_method: Ensemble method to use.
  • prob_func::Function: Function to use for generating the SDEProblem.
  • output_func::Function: Function to use for generating the output of a single trajectory.
  • progress_bar::Union{Val,Bool}: Whether to show a progress bar.
  • kwargs...: Additional keyword arguments to pass to the solver.

Notes

  • ensemble_method can be one of EnsembleThreads(), EnsembleSerial(), EnsembleDistributed()
  • The states will be saved depend on the keyword argument saveat in kwargs.
  • If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). You can also specify e_ops and saveat separately.
  • The default tolerances in kwargs are given as reltol=1e-2 and abstol=1e-2.
  • For more details about alg please refer to DifferentialEquations.jl (SDE Solvers)
  • For more details about kwargs please refer to DifferentialEquations.jl (Keyword Arguments)

Returns

source
QuantumToolbox.dfd_mesolveFunction
dfd_mesolve(H::Function, ψ0::QuantumObject,
     t_l::AbstractVector, c_ops::Function, maxdims::AbstractVector,
     dfd_params::NamedTuple=NamedTuple();
     alg::OrdinaryDiffEqAlgorithm=Tsit5(),
@@ -441,7 +441,7 @@
     H_t::Union{Nothing,Function,TimeDependentOperatorSum}=nothing,
     params::NamedTuple=NamedTuple(),
     tol_list::Vector{<:Number}=fill(1e-8, length(maxdims)),
-    kwargs...)

Time evolution of an open quantum system using master equation, dynamically changing the dimension of the Hilbert subspaces.

Notes

source
QuantumToolbox.dsf_mesolveFunction
dsf_mesolve(H::Function,
     ψ0::QuantumObject,
     t_l::AbstractVector, c_ops::Function,
     op_list::Vector{TOl},
@@ -453,7 +453,7 @@
     params::NamedTuple=NamedTuple(),
     δα_list::Vector{<:Number}=fill(0.2, length(op_list)),
     krylov_dim::Int=max(6, min(10, cld(length(ket2dm(ψ0).data), 4))),
-    kwargs...)

Time evolution of an open quantum system using master equation and the Dynamical Shifted Fock algorithm.

Notes

source
QuantumToolbox.dsf_mcsolveFunction
dsf_mcsolve(H::Function,
     ψ0::QuantumObject,
     t_l::AbstractVector, c_ops::Function,
     op_list::Vector{TOl},
@@ -469,7 +469,7 @@
     jump_callback::LindbladJumpCallbackType=ContinuousLindbladJumpCallback(),
     krylov_dim::Int=max(6, min(10, cld(length(ket2dm(ψ0).data), 4))),
     progress_bar::Union{Bool,Val} = Val(true)
-    kwargs...)

Time evolution of a quantum system using the Monte Carlo wave function method and the Dynamical Shifted Fock algorithm.

Notes

source
QuantumToolbox.lr_mesolveFunction
lr_mesolve(prob::ODEProblem; kwargs...)
 Solves the ODEProblem formulated by lr_mesolveProblem. The function is called by lr_mesolve.
 
 Parameters
@@ -477,13 +477,13 @@
 prob : ODEProblem
     The ODEProblem formulated by lr_mesolveProblem.
 kwargs : NamedTuple
-    Additional keyword arguments for the ODEProblem.
source
QuantumToolbox.liouvillianFunction
liouvillian(H::QuantumObject, c_ops::Union{Nothing,AbstractVector,Tuple}=nothing, Id_cache=I(prod(H.dims)))

Construct the Liouvillian SuperOperator for a system Hamiltonian $\hat{H}$ and a set of collapse operators $\{\hat{C}_n\}_n$:

\[\mathcal{L} [\cdot] = -i[\hat{H}, \cdot] + \sum_n \mathcal{D}(\hat{C}_n) [\cdot]\]

where

\[\mathcal{D}(\hat{C}_n) [\cdot] = \hat{C}_n [\cdot] \hat{C}_n^\dagger - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n [\cdot] - \frac{1}{2} [\cdot] \hat{C}_n^\dagger \hat{C}_n\]

The optional argument Id_cache can be used to pass a precomputed identity matrix. This can be useful when the same function is applied multiple times with a known Hilbert space dimension.

See also spre, spost, and lindblad_dissipator.

source
QuantumToolbox.liouvillian_generalizedFunction
liouvillian_generalized(H::QuantumObject, fields::Vector, 
-T_list::Vector; N_trunc::Int=size(H,1), tol::Float64=0.0, σ_filter::Union{Nothing, Real}=nothing)

Constructs the generalized Liouvillian for a system coupled to a bath of harmonic oscillators.

See, e.g., Settineri, Alessio, et al. "Dissipation and thermal noise in hybrid quantum systems in the ultrastrong-coupling regime." Physical Review A 98.5 (2018): 053834.

source
QuantumToolbox.liouvillianFunction
liouvillian(H::QuantumObject, c_ops::Union{Nothing,AbstractVector,Tuple}=nothing, Id_cache=I(prod(H.dims)))

Construct the Liouvillian SuperOperator for a system Hamiltonian $\hat{H}$ and a set of collapse operators $\{\hat{C}_n\}_n$:

\[\mathcal{L} [\cdot] = -i[\hat{H}, \cdot] + \sum_n \mathcal{D}(\hat{C}_n) [\cdot]\]

where

\[\mathcal{D}(\hat{C}_n) [\cdot] = \hat{C}_n [\cdot] \hat{C}_n^\dagger - \frac{1}{2} \hat{C}_n^\dagger \hat{C}_n [\cdot] - \frac{1}{2} [\cdot] \hat{C}_n^\dagger \hat{C}_n\]

The optional argument Id_cache can be used to pass a precomputed identity matrix. This can be useful when the same function is applied multiple times with a known Hilbert space dimension.

See also spre, spost, and lindblad_dissipator.

source
QuantumToolbox.liouvillian_generalizedFunction
liouvillian_generalized(H::QuantumObject, fields::Vector, 
+T_list::Vector; N_trunc::Int=size(H,1), tol::Float64=0.0, σ_filter::Union{Nothing, Real}=nothing)

Constructs the generalized Liouvillian for a system coupled to a bath of harmonic oscillators.

See, e.g., Settineri, Alessio, et al. "Dissipation and thermal noise in hybrid quantum systems in the ultrastrong-coupling regime." Physical Review A 98.5 (2018): 053834.

source
QuantumToolbox.steadystateFunction
steadystate(
     H::QuantumObject,
     c_ops::Union{Nothing,AbstractVector,Tuple} = nothing;
     solver::SteadyStateSolver = SteadyStateDirectSolver(),
     kwargs...
-)

Solve the stationary state based on different solvers.

Parameters

  • H::QuantumObject: The Hamiltonian or the Liouvillian of the system.
  • c_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the collapse operators.
  • solver::SteadyStateSolver=SteadyStateDirectSolver(): see documentation Solving for Steady-State Solutions for different solvers.
  • kwargs...: The keyword arguments for the solver.
source
steadystate(
+)

Solve the stationary state based on different solvers.

Parameters

  • H::QuantumObject: The Hamiltonian or the Liouvillian of the system.
  • c_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the collapse operators.
  • solver::SteadyStateSolver=SteadyStateDirectSolver(): see documentation Solving for Steady-State Solutions for different solvers.
  • kwargs...: The keyword arguments for the solver.
source
steadystate(
     H::QuantumObject,
     ψ0::QuantumObject,
     tspan::Real = Inf,
@@ -492,7 +492,7 @@
     reltol::Real = 1.0e-8,
     abstol::Real = 1.0e-10,
     kwargs...
-)

Solve the stationary state based on time evolution (ordinary differential equations; OrdinaryDiffEq.jl) with a given initial state.

The termination condition of the stationary state $|\rho\rangle\rangle$ is that either the following condition is true:

\[\lVert\frac{\partial |\hat{\rho}\rangle\rangle}{\partial t}\rVert \leq \textrm{reltol} \times\lVert\frac{\partial |\hat{\rho}\rangle\rangle}{\partial t}+|\hat{\rho}\rangle\rangle\rVert\]

or

\[\lVert\frac{\partial |\hat{\rho}\rangle\rangle}{\partial t}\rVert \leq \textrm{abstol}\]

Parameters

  • H::QuantumObject: The Hamiltonian or the Liouvillian of the system.
  • ψ0::QuantumObject: The initial state of the system.
  • tspan::Real=Inf: The final time step for the steady state problem.
  • c_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the collapse operators.
  • solver::SteadyStateODESolver=SteadyStateODESolver(): see SteadyStateODESolver for more details.
  • reltol::Real=1.0e-8: Relative tolerance in steady state terminate condition and solver adaptive timestepping.
  • abstol::Real=1.0e-10: Absolute tolerance in steady state terminate condition and solver adaptive timestepping.
  • kwargs...: The keyword arguments for the ODEProblem.
source
QuantumToolbox.steadystate_floquetFunction
steadystate_floquet(
+)

Solve the stationary state based on time evolution (ordinary differential equations; OrdinaryDiffEq.jl) with a given initial state.

The termination condition of the stationary state $|\rho\rangle\rangle$ is that either the following condition is true:

\[\lVert\frac{\partial |\hat{\rho}\rangle\rangle}{\partial t}\rVert \leq \textrm{reltol} \times\lVert\frac{\partial |\hat{\rho}\rangle\rangle}{\partial t}+|\hat{\rho}\rangle\rangle\rVert\]

or

\[\lVert\frac{\partial |\hat{\rho}\rangle\rangle}{\partial t}\rVert \leq \textrm{abstol}\]

Parameters

  • H::QuantumObject: The Hamiltonian or the Liouvillian of the system.
  • ψ0::QuantumObject: The initial state of the system.
  • tspan::Real=Inf: The final time step for the steady state problem.
  • c_ops::Union{Nothing,AbstractVector,Tuple}=nothing: The list of the collapse operators.
  • solver::SteadyStateODESolver=SteadyStateODESolver(): see SteadyStateODESolver for more details.
  • reltol::Real=1.0e-8: Relative tolerance in steady state terminate condition and solver adaptive timestepping.
  • abstol::Real=1.0e-10: Absolute tolerance in steady state terminate condition and solver adaptive timestepping.
  • kwargs...: The keyword arguments for the ODEProblem.
source
QuantumToolbox.steadystate_floquetFunction
steadystate_floquet(
     H_0::QuantumObject{MT,OpType1},
     H_p::QuantumObject{<:AbstractArray,OpType2},
     H_m::QuantumObject{<:AbstractArray,OpType3},
@@ -516,7 +516,7 @@
 \vdots \\
 \hat{\rho}_{n_{\textrm{max}}-1} \\
 \hat{\rho}_{n_{\textrm{max}}}
-\end{pmatrix}\]

This will allow to simultaneously obtain all the $\hat{\rho}_n$.

In the case of SSFloquetEffectiveLiouvillian, instead, the effective Liouvillian is calculated using the matrix continued fraction method.

different return

The two solvers returns different objects. The SSFloquetLinearSystem returns a list of QuantumObject, containing the density matrices for each Fourier component ($\hat{\rho}_{-n}$, with $n$ from $0$ to $n_\textrm{max}$), while the SSFloquetEffectiveLiouvillian returns only $\hat{\rho}_0$.

Arguments

  • H_0::QuantumObject: The Hamiltonian or the Liouvillian of the undriven system.
  • H_p::QuantumObject: The Hamiltonian or the Liouvillian of the part of the drive that oscillates as $e^{i \omega t}$.
  • H_m::QuantumObject: The Hamiltonian or the Liouvillian of the part of the drive that oscillates as $e^{-i \omega t}$.
  • ωd::Number: The frequency of the drive.
  • c_ops::Union{Nothing,AbstractVector} = nothing: The optional collapse operators.
  • n_max::Integer = 2: The number of Fourier components to consider.
  • tol::R = 1e-8: The tolerance for the solver.
  • solver::FSolver = SSFloquetLinearSystem: The solver to use.
  • kwargs...: Additional keyword arguments to be passed to the solver.
source
QuantumToolbox.SteadyStateLinearSolverType
SteadyStateLinearSolver(alg = KrylovJL_GMRES(), Pl = nothing, Pr = nothing)

A solver which solves steadystate by finding the inverse of Liouvillian SuperOperator using the algorithms given in LinearSolve.jl.

Parameters

source

Correlations and Spectrum

QuantumToolbox.correlation_3op_2tFunction
correlation_3op_2t(H::QuantumObject,
+\end{pmatrix}\]

This will allow to simultaneously obtain all the $\hat{\rho}_n$.

In the case of SSFloquetEffectiveLiouvillian, instead, the effective Liouvillian is calculated using the matrix continued fraction method.

different return

The two solvers returns different objects. The SSFloquetLinearSystem returns a list of QuantumObject, containing the density matrices for each Fourier component ($\hat{\rho}_{-n}$, with $n$ from $0$ to $n_\textrm{max}$), while the SSFloquetEffectiveLiouvillian returns only $\hat{\rho}_0$.

Arguments

  • H_0::QuantumObject: The Hamiltonian or the Liouvillian of the undriven system.
  • H_p::QuantumObject: The Hamiltonian or the Liouvillian of the part of the drive that oscillates as $e^{i \omega t}$.
  • H_m::QuantumObject: The Hamiltonian or the Liouvillian of the part of the drive that oscillates as $e^{-i \omega t}$.
  • ωd::Number: The frequency of the drive.
  • c_ops::Union{Nothing,AbstractVector} = nothing: The optional collapse operators.
  • n_max::Integer = 2: The number of Fourier components to consider.
  • tol::R = 1e-8: The tolerance for the solver.
  • solver::FSolver = SSFloquetLinearSystem: The solver to use.
  • kwargs...: Additional keyword arguments to be passed to the solver.
source
QuantumToolbox.SteadyStateLinearSolverType
SteadyStateLinearSolver(alg = KrylovJL_GMRES(), Pl = nothing, Pr = nothing)

A solver which solves steadystate by finding the inverse of Liouvillian SuperOperator using the algorithms given in LinearSolve.jl.

Parameters

source

Correlations and Spectrum

QuantumToolbox.correlation_3op_2tFunction
correlation_3op_2t(H::QuantumObject,
     ψ0::QuantumObject,
     t_l::AbstractVector,
     τ_l::AbstractVector,
@@ -524,7 +524,7 @@
     B::QuantumObject,
     C::QuantumObject,
     c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
-    kwargs...)

Returns the two-times correlation function of three operators $\hat{A}$, $\hat{B}$ and $\hat{C}$: $\expval{\hat{A}(t) \hat{B}(t + \tau) \hat{C}(t)}$

for a given initial state $\ket{\psi_0}$.

source
QuantumToolbox.correlation_2op_2tFunction
correlation_2op_2t(H::QuantumObject,
+    kwargs...)

Returns the two-times correlation function of three operators $\hat{A}$, $\hat{B}$ and $\hat{C}$: $\expval{\hat{A}(t) \hat{B}(t + \tau) \hat{C}(t)}$

for a given initial state $\ket{\psi_0}$.

source
QuantumToolbox.correlation_2op_2tFunction
correlation_2op_2t(H::QuantumObject,
     ψ0::QuantumObject,
     t_l::AbstractVector,
     τ_l::AbstractVector,
@@ -532,20 +532,20 @@
     B::QuantumObject,
     c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
     reverse::Bool=false,
-    kwargs...)

Returns the two-times correlation function of two operators $\hat{A}$ and $\hat{B}$ at different times: $\expval{\hat{A}(t + \tau) \hat{B}(t)}$.

When reverse=true, the correlation function is calculated as $\expval{\hat{A}(t) \hat{B}(t + \tau)}$.

source
QuantumToolbox.correlation_2op_1tFunction
correlation_2op_1t(H::QuantumObject,
+    kwargs...)

Returns the two-times correlation function of two operators $\hat{A}$ and $\hat{B}$ at different times: $\expval{\hat{A}(t + \tau) \hat{B}(t)}$.

When reverse=true, the correlation function is calculated as $\expval{\hat{A}(t) \hat{B}(t + \tau)}$.

source
QuantumToolbox.correlation_2op_1tFunction
correlation_2op_1t(H::QuantumObject,
     ψ0::QuantumObject,
     τ_l::AbstractVector,
     A::QuantumObject,
     B::QuantumObject,
     c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
     reverse::Bool=false,
-    kwargs...)

Returns the one-time correlation function of two operators $\hat{A}$ and $\hat{B}$ at different times $\expval{\hat{A}(\tau) \hat{B}(0)}$.

When reverse=true, the correlation function is calculated as $\expval{\hat{A}(0) \hat{B}(\tau)}$.

source
QuantumToolbox.spectrumFunction
spectrum(H::QuantumObject,
+    kwargs...)

Returns the one-time correlation function of two operators $\hat{A}$ and $\hat{B}$ at different times $\expval{\hat{A}(\tau) \hat{B}(0)}$.

When reverse=true, the correlation function is calculated as $\expval{\hat{A}(0) \hat{B}(\tau)}$.

source
QuantumToolbox.spectrumFunction
spectrum(H::QuantumObject,
     ω_list::AbstractVector,
     A::QuantumObject{<:AbstractArray{T2},OperatorQuantumObject},
     B::QuantumObject{<:AbstractArray{T3},OperatorQuantumObject},
     c_ops::Union{Nothing,AbstractVector,Tuple}=nothing;
     solver::MySolver=ExponentialSeries(),
-    kwargs...)

Returns the emission spectrum

\[S(\omega) = \int_{-\infty}^\infty \expval{\hat{A}(\tau) \hat{B}(0)} e^{-i \omega \tau} d \tau\]

source

Metrics

QuantumToolbox.entropy_vnFunction
entropy_vn(ρ::QuantumObject; base::Int=0, tol::Real=1e-15)

Calculates the Von Neumann entropy $S = - \Tr \left[ \hat{\rho} \log \left( \hat{\rho} \right) \right]$ where $\hat{\rho}$ is the density matrix of the system.

The base parameter specifies the base of the logarithm to use, and when using the default value 0, the natural logarithm is used. The tol parameter describes the absolute tolerance for detecting the zero-valued eigenvalues of the density matrix $\hat{\rho}$.

Examples

Pure state:

julia> ψ = fock(2,0)
+    kwargs...)

Returns the emission spectrum

\[S(\omega) = \int_{-\infty}^\infty \expval{\hat{A}(\tau) \hat{B}(0)} e^{-i \omega \tau} d \tau\]

source

Metrics

QuantumToolbox.entropy_vnFunction
entropy_vn(ρ::QuantumObject; base::Int=0, tol::Real=1e-15)

Calculates the Von Neumann entropy $S = - \Tr \left[ \hat{\rho} \log \left( \hat{\rho} \right) \right]$ where $\hat{\rho}$ is the density matrix of the system.

The base parameter specifies the base of the logarithm to use, and when using the default value 0, the natural logarithm is used. The tol parameter describes the absolute tolerance for detecting the zero-valued eigenvalues of the density matrix $\hat{\rho}$.

Examples

Pure state:

julia> ψ = fock(2,0)
 Quantum Object:   type=Ket   dims=[2]   size=(2,)
 2-element Vector{ComplexF64}:
  1.0 + 0.0im
@@ -565,8 +565,8 @@
      ⋅      0.5-0.0im
 
 julia> entropy_vn(ρ, base=2)
-1.0
source
QuantumToolbox.entanglementFunction
entanglement(QO::QuantumObject, sel::Union{Int,AbstractVector{Int},Tuple})

Calculates the entanglement by doing the partial trace of QO, selecting only the dimensions with the indices contained in the sel vector, and then using the Von Neumann entropy entropy_vn.

source
QuantumToolbox.fidelityFunction
fidelity(ρ::QuantumObject, σ::QuantumObject)

Calculate the fidelity of two QuantumObject: $F(\hat{\rho}, \hat{\sigma}) = \textrm{Tr} \sqrt{\sqrt{\hat{\rho}} \hat{\sigma} \sqrt{\hat{\rho}}}$

Here, the definition is from Nielsen & Chuang, "Quantum Computation and Quantum Information". It is the square root of the fidelity defined in R. Jozsa, Journal of Modern Optics, 41:12, 2315 (1994).

Note that ρ and σ must be either Ket or Operator.

source

Miscellaneous

QuantumToolbox.wignerFunction
wigner(state::QuantumObject, xvec::AbstractVector, yvec::AbstractVector; g::Real=√2,
-    solver::WignerSolver=WignerLaguerre())

Generates the Wigner quasipropability distribution of state at points xvec + 1im * yvec. The g parameter is a scaling factor related to the value of $\hbar$ in the commutation relation $[x, y] = i \hbar$ via $\hbar=2/g^2$ giving the default value $\hbar=1$.

The solver parameter can be either WignerLaguerre() or WignerClenshaw(). The former uses the Laguerre polynomial expansion of the Wigner function, while the latter uses the Clenshaw algorithm. The Laguerre expansion is faster for sparse matrices, while the Clenshaw algorithm is faster for dense matrices. The WignerLaguerre solver has an optional parallel parameter which defaults to true and uses multithreading to speed up the calculation.

source
QuantumToolbox.negativityFunction
negativity(ρ::QuantumObject, subsys::Int; logarithmic::Bool=false)

Compute the negativity $N(\hat{\rho}) = \frac{\Vert \hat{\rho}^{\Gamma}\Vert_1 - 1}{2}$ where $\hat{\rho}^{\Gamma}$ is the partial transpose of $\hat{\rho}$ with respect to the subsystem, and $\Vert \hat{X} \Vert_1=\textrm{Tr}\sqrt{\hat{X}^\dagger \hat{X}}$ is the trace norm.

Arguments

  • ρ::QuantumObject: The density matrix (ρ.type must be OperatorQuantumObject).
  • subsys::Int: an index that indicates which subsystem to compute the negativity for.
  • logarithmic::Bool: choose whether to calculate logarithmic negativity or not. Default as false

Returns

  • N::Real: The value of negativity.

Examples

julia> Ψ = bell_state(0, 0)
+1.0
source
QuantumToolbox.entanglementFunction
entanglement(QO::QuantumObject, sel::Union{Int,AbstractVector{Int},Tuple})

Calculates the entanglement by doing the partial trace of QO, selecting only the dimensions with the indices contained in the sel vector, and then using the Von Neumann entropy entropy_vn.

source
QuantumToolbox.fidelityFunction
fidelity(ρ::QuantumObject, σ::QuantumObject)

Calculate the fidelity of two QuantumObject: $F(\hat{\rho}, \hat{\sigma}) = \textrm{Tr} \sqrt{\sqrt{\hat{\rho}} \hat{\sigma} \sqrt{\hat{\rho}}}$

Here, the definition is from Nielsen & Chuang, "Quantum Computation and Quantum Information". It is the square root of the fidelity defined in R. Jozsa, Journal of Modern Optics, 41:12, 2315 (1994).

Note that ρ and σ must be either Ket or Operator.

source

Miscellaneous

QuantumToolbox.wignerFunction
wigner(state::QuantumObject, xvec::AbstractVector, yvec::AbstractVector; g::Real=√2,
+    solver::WignerSolver=WignerLaguerre())

Generates the Wigner quasipropability distribution of state at points xvec + 1im * yvec. The g parameter is a scaling factor related to the value of $\hbar$ in the commutation relation $[x, y] = i \hbar$ via $\hbar=2/g^2$ giving the default value $\hbar=1$.

The solver parameter can be either WignerLaguerre() or WignerClenshaw(). The former uses the Laguerre polynomial expansion of the Wigner function, while the latter uses the Clenshaw algorithm. The Laguerre expansion is faster for sparse matrices, while the Clenshaw algorithm is faster for dense matrices. The WignerLaguerre solver has an optional parallel parameter which defaults to true and uses multithreading to speed up the calculation.

source
QuantumToolbox.negativityFunction
negativity(ρ::QuantumObject, subsys::Int; logarithmic::Bool=false)

Compute the negativity $N(\hat{\rho}) = \frac{\Vert \hat{\rho}^{\Gamma}\Vert_1 - 1}{2}$ where $\hat{\rho}^{\Gamma}$ is the partial transpose of $\hat{\rho}$ with respect to the subsystem, and $\Vert \hat{X} \Vert_1=\textrm{Tr}\sqrt{\hat{X}^\dagger \hat{X}}$ is the trace norm.

Arguments

  • ρ::QuantumObject: The density matrix (ρ.type must be OperatorQuantumObject).
  • subsys::Int: an index that indicates which subsystem to compute the negativity for.
  • logarithmic::Bool: choose whether to calculate logarithmic negativity or not. Default as false

Returns

  • N::Real: The value of negativity.

Examples

julia> Ψ = bell_state(0, 0)
 Quantum Object:   type=Ket   dims=[2, 2]   size=(4,)
 4-element Vector{ComplexF64}:
  0.7071067811865475 + 0.0im
@@ -583,7 +583,7 @@
  0.5+0.0im  0.0+0.0im  0.0+0.0im  0.5+0.0im
 
 julia> negativity(ρ, 2)
-0.4999999999999998
source

Linear Maps

QuantumToolbox.AbstractLinearMapType
AbstractLinearMap{T, TS}

Represents a general linear map with element type T and size TS.

Overview

A linear map is a transformation L that satisfies:

  • Additivity: math L(u + v) = L(u) + L(v)
  • Homogeneity: math L(cu) = cL(u)

It is typically represented as a matrix with dimensions given by size, and this abtract type helps to define this map when the matrix is not explicitly available.

Methods

  • Base.eltype(A): Returns the element type T.
  • Base.size(A): Returns the size A.size.
  • Base.size(A, i): Returns the i-th dimension.

Example

As an example, we now define the linear map used in the eigsolve_al function for Arnoldi-Lindblad eigenvalue solver:

struct ArnoldiLindbladIntegratorMap{T,TS,TI} <: AbstractLinearMap{T,TS}
+0.4999999999999998
source

Linear Maps

QuantumToolbox.AbstractLinearMapType
AbstractLinearMap{T, TS}

Represents a general linear map with element type T and size TS.

Overview

A linear map is a transformation L that satisfies:

  • Additivity: math L(u + v) = L(u) + L(v)
  • Homogeneity: math L(cu) = cL(u)

It is typically represented as a matrix with dimensions given by size, and this abtract type helps to define this map when the matrix is not explicitly available.

Methods

  • Base.eltype(A): Returns the element type T.
  • Base.size(A): Returns the size A.size.
  • Base.size(A, i): Returns the i-th dimension.

Example

As an example, we now define the linear map used in the eigsolve_al function for Arnoldi-Lindblad eigenvalue solver:

struct ArnoldiLindbladIntegratorMap{T,TS,TI} <: AbstractLinearMap{T,TS}
     elty::Type{T}
     size::TS
     integrator::TI
@@ -593,15 +593,15 @@
     reinit!(A.integrator, x)
     solve!(A.integrator)
     return copyto!(y, A.integrator.u)
-end

where integrator is the ODE integrator for the time-evolution. In this way, we can diagonalize this linear map using the eigsolve function.

source

Utility functions

QuantumToolbox.gaussianFunction
gaussian(x::Number, μ::Number, σ::Number)

Returns the gaussian function $\exp \left[- \frac{(x - \mu)^2}{2 \sigma^2} \right]$, where $\mu$ and $\sigma^2$ are the mean and the variance respectively.

source
QuantumToolbox.n_thermalFunction
n_thermal(ω::Real, ω_th::Real)

Return the number of photons in thermal equilibrium for an harmonic oscillator mode with frequency $\omega$, at the temperature described by $\omega_{\textrm{th}} \equiv k_B T / \hbar$:

\[n(\omega, \omega_{\textrm{th}}) = \frac{1}{e^{\omega/\omega_{\textrm{th}}} - 1},\]

where $\hbar$ is the reduced Planck constant, and $k_B$ is the Boltzmann constant.

source
QuantumToolbox.PhysicalConstantsConstant
const PhysicalConstants

A NamedTuple which stores some constant values listed in CODATA recommended values of the fundamental physical constants: 2022

The current stored constants are:

  • c : (exact) speed of light in vacuum with unit $[\textrm{m}\cdot\textrm{s}^{-1}]$
  • G : Newtonian constant of gravitation with unit $[\textrm{m}^3\cdot\textrm{kg}^{−1}\cdot\textrm{s}^{−2}]$
  • h : (exact) Planck constant with unit $[\textrm{J}\cdot\textrm{s}]$
  • ħ : reduced Planck constant with unit $[\textrm{J}\cdot\textrm{s}]$
  • e : (exact) elementary charge with unit $[\textrm{C}]$
  • μ0 : vacuum magnetic permeability with unit $[\textrm{N}\cdot\textrm{A}^{-2}]$
  • ϵ0 : vacuum electric permittivity with unit $[\textrm{F}\cdot\textrm{m}^{-1}]$
  • k : (exact) Boltzmann constant with unit $[\textrm{J}\cdot\textrm{K}^{-1}]$
  • NA : (exact) Avogadro constant with unit $[\textrm{mol}^{-1}]$

Examples

julia> PhysicalConstants.ħ
-1.0545718176461565e-34
source
QuantumToolbox.convert_unitFunction
convert_unit(value::Real, unit1::Symbol, unit2::Symbol)

Convert the energy value from unit1 to unit2. The unit1 and unit2 can be either the following Symbol:

  • :J : Joule
  • :eV : electron volt
  • :meV : milli-electron volt
  • :MHz : Mega-Hertz multiplied by Planck constant $h$
  • :GHz : Giga-Hertz multiplied by Planck constant $h$
  • :K : Kelvin multiplied by Boltzmann constant $k$
  • :mK : milli-Kelvin multiplied by Boltzmann constant $k$

Note that we use the values stored in PhysicalConstants to do the conversion.

Examples

julia> convert_unit(1, :eV, :J)
+end

where integrator is the ODE integrator for the time-evolution. In this way, we can diagonalize this linear map using the eigsolve function.

source

Utility functions

QuantumToolbox.gaussianFunction
gaussian(x::Number, μ::Number, σ::Number)

Returns the gaussian function $\exp \left[- \frac{(x - \mu)^2}{2 \sigma^2} \right]$, where $\mu$ and $\sigma^2$ are the mean and the variance respectively.

source
QuantumToolbox.n_thermalFunction
n_thermal(ω::Real, ω_th::Real)

Return the number of photons in thermal equilibrium for an harmonic oscillator mode with frequency $\omega$, at the temperature described by $\omega_{\textrm{th}} \equiv k_B T / \hbar$:

\[n(\omega, \omega_{\textrm{th}}) = \frac{1}{e^{\omega/\omega_{\textrm{th}}} - 1},\]

where $\hbar$ is the reduced Planck constant, and $k_B$ is the Boltzmann constant.

source
QuantumToolbox.PhysicalConstantsConstant
const PhysicalConstants

A NamedTuple which stores some constant values listed in CODATA recommended values of the fundamental physical constants: 2022

The current stored constants are:

  • c : (exact) speed of light in vacuum with unit $[\textrm{m}\cdot\textrm{s}^{-1}]$
  • G : Newtonian constant of gravitation with unit $[\textrm{m}^3\cdot\textrm{kg}^{−1}\cdot\textrm{s}^{−2}]$
  • h : (exact) Planck constant with unit $[\textrm{J}\cdot\textrm{s}]$
  • ħ : reduced Planck constant with unit $[\textrm{J}\cdot\textrm{s}]$
  • e : (exact) elementary charge with unit $[\textrm{C}]$
  • μ0 : vacuum magnetic permeability with unit $[\textrm{N}\cdot\textrm{A}^{-2}]$
  • ϵ0 : vacuum electric permittivity with unit $[\textrm{F}\cdot\textrm{m}^{-1}]$
  • k : (exact) Boltzmann constant with unit $[\textrm{J}\cdot\textrm{K}^{-1}]$
  • NA : (exact) Avogadro constant with unit $[\textrm{mol}^{-1}]$

Examples

julia> PhysicalConstants.ħ
+1.0545718176461565e-34
source
QuantumToolbox.convert_unitFunction
convert_unit(value::Real, unit1::Symbol, unit2::Symbol)

Convert the energy value from unit1 to unit2. The unit1 and unit2 can be either the following Symbol:

  • :J : Joule
  • :eV : electron volt
  • :meV : milli-electron volt
  • :MHz : Mega-Hertz multiplied by Planck constant $h$
  • :GHz : Giga-Hertz multiplied by Planck constant $h$
  • :K : Kelvin multiplied by Boltzmann constant $k$
  • :mK : milli-Kelvin multiplied by Boltzmann constant $k$

Note that we use the values stored in PhysicalConstants to do the conversion.

Examples

julia> convert_unit(1, :eV, :J)
 1.602176634e-19
 
 julia> convert_unit(1, :GHz, :J)
 6.62607015e-25
 
 julia> convert_unit(1, :meV, :mK)
-11604.518121550082
source
QuantumToolbox._calculate_expectation!Function
_calculate_expectation!(p,z,B,idx) where T
 Calculates the expectation values and function values of the operators and functions in p.e_ops and p.f_ops, respectively, and stores them in p.expvals and p.funvals.
 The function is called by the callback _save_affect_lr_mesolve!.
 
@@ -614,7 +614,7 @@
 B : AbstractMatrix{T}
     The B matrix.
 idx : Integer
-    The index of the current time step.
source
QuantumToolbox._adjM_condition_variationalFunction
_adjM_condition_variational(u, t, integrator) where T
 Condition for the dynamical rank adjustment based on the leakage out of the low-rank manifold.
 
 Parameters
@@ -624,14 +624,14 @@
 t : Real
     The current time.
 integrator : ODEIntegrator
-    The integrator of the problem.
source
QuantumToolbox._adjM_affect!Function
_adjM_affect!(integrator)
 Affect function for the dynamical rank adjustment. It increases the rank of the low-rank manifold by one, and updates the matrices accordingly.
 If Δt>0, it rewinds the integrator to the previous time step.
 
 Parameters
 ----------
 integrator : ODEIntegrator
-    The integrator of the problem.
source
QuantumToolbox._adjM_condition_ratioFunction
_adjM_condition_ratio(u, t, integrator) where T
 Condition for the dynamical rank adjustment based on the ratio between the smallest and largest eigenvalues of the density matrix.
 The spectrum of the density matrix is calculated efficiently using the properties of the SVD decomposition of the matrix.
 
@@ -642,7 +642,7 @@
 t : Real
     The current time.
 integrator : ODEIntegrator
-    The integrator of the problem.
source
QuantumToolbox._pinv!Function
_pinv!(A, T1, T2; atol::Real=0.0, rtol::Real=(eps(real(float(oneunit(T))))*min(size(A)...))*iszero(atol)) where T
+    The integrator of the problem.
source
QuantumToolbox._pinv!Function
_pinv!(A, T1, T2; atol::Real=0.0, rtol::Real=(eps(real(float(oneunit(T))))*min(size(A)...))*iszero(atol)) where T
 Computes the pseudo-inverse of a matrix A, and stores it in T1. If T2 is provided, it is used as a temporary matrix. 
 The algorithm is based on the SVD decomposition of A, and is taken from the Julia package LinearAlgebra.
 The difference with respect to the original function is that the cutoff is done with a smooth function instead of a step function.
@@ -657,7 +657,7 @@
 atol : Real
     Absolute tolerance for the calculation of the pseudo-inverse.   
 rtol : Real
-    Relative tolerance for the calculation of the pseudo-inverse.
source
QuantumToolbox.dBdz!Function
dBdz!(du, u, p, t) where T
 Dynamical evolution equations for the low-rank manifold. The function is called by the ODEProblem.
 
 Parameters
@@ -669,4 +669,4 @@
 p : NamedTuple
     The parameters of the problem.
 t : Real
-    The current time.
source
+ The current time.source diff --git a/dev/index.html b/dev/index.html index 68f81ada..d22bd36f 100644 --- a/dev/index.html +++ b/dev/index.html @@ -31,4 +31,4 @@ c_ops = [sqrt(γ) * a_gpu] e_ops = [a_gpu' * a_gpu] -sol = mesolve(H_gpu, ψ0_gpu, tlist, c_ops, e_ops = e_ops) +sol = mesolve(H_gpu, ψ0_gpu, tlist, c_ops, e_ops = e_ops) diff --git a/dev/qutip_differences/index.html b/dev/qutip_differences/index.html index 60cb6c08..ce193ca3 100644 --- a/dev/qutip_differences/index.html +++ b/dev/qutip_differences/index.html @@ -1,2 +1,2 @@ -Key differences from QuTiP · QuantumToolbox.jl
+Key differences from QuTiP · QuantumToolbox.jl
diff --git a/dev/tutorials/logo/bd1c4db3.svg b/dev/tutorials/logo/460466ec.svg similarity index 99% rename from dev/tutorials/logo/bd1c4db3.svg rename to dev/tutorials/logo/460466ec.svg index f648ea9b..336d14a8 100644 --- a/dev/tutorials/logo/bd1c4db3.svg +++ b/dev/tutorials/logo/460466ec.svg @@ -1,7 +1,7 @@ - + - + diff --git a/dev/tutorials/logo/a6daf944.svg b/dev/tutorials/logo/79a81d5f.svg similarity index 99% rename from dev/tutorials/logo/a6daf944.svg rename to dev/tutorials/logo/79a81d5f.svg index b125e363..ba289b6a 100644 --- a/dev/tutorials/logo/a6daf944.svg +++ b/dev/tutorials/logo/79a81d5f.svg @@ -5,12 +5,12 @@ width="180mm" height="25mm" viewBox="0 0 100 1" stroke="none" preserveAspectRatio="none" shape-rendering="crispEdges"> - - + diff --git a/dev/tutorials/logo/index.html b/dev/tutorials/logo/index.html index 0be857a2..7169254c 100644 --- a/dev/tutorials/logo/index.html +++ b/dev/tutorials/logo/index.html @@ -105,7 +105,7 @@ cmap1 = cgrad(vcat(fill(julia_blue, n_repeats), fill(julia_green, n_repeats))) cmap2 = cgrad(vcat(fill(julia_blue, n_repeats), fill(julia_red, n_repeats))) -cmap3 = cgrad(vcat(fill(julia_blue, n_repeats), fill(julia_purple, n_repeats)))Example block output

Normalizing the Wigner function and applying the custom colormap

The colormaps require the input to be in the range $[0, 1]$. We normalize the Wigner function such that the maximum value is $1$and the zeros are set to $0.5$.

vmax = maximum(wig)
+cmap3 = cgrad(vcat(fill(julia_blue, n_repeats), fill(julia_purple, n_repeats)))
Example block output

Normalizing the Wigner function and applying the custom colormap

The colormaps require the input to be in the range $[0, 1]$. We normalize the Wigner function such that the maximum value is $1$and the zeros are set to $0.5$.

vmax = maximum(wig)
 wig_normalized = wig ./ (vmax * 2) .+ 1 / 2

And we now apply this custom colormap to make an image (a Matrix{RGBAf}).

img = set_color_julia.(X, Y, wig_normalized, α1, α2, α3, Ref(cmap1), Ref(cmap2), Ref(cmap3), δ)
500×500 Array{RGBA{Float32},2} with eltype ColorTypes.RGBA{Float32}:
  RGBA{Float32}(0.523498,0.311502,0.523505,6.26417f-6)   …  RGBA{Float32}(0.417504,0.366499,0.772491,6.26426f-6)
  RGBA{Float32}(0.523498,0.311502,0.523505,7.01657f-6)      RGBA{Float32}(0.417504,0.366499,0.772491,7.01667f-6)
@@ -132,4 +132,4 @@
 hidespines!(ax)
 hidexdecorations!(ax)
 hideydecorations!(ax)
-fig
Example block output

Conclusion

This tutorial demonstrates how to generate the QuantumToolbox.jl logo using the package itself and Makie.jl for visualization. The logo is a visualization of the Wigner function of a triangular cat state, with a custom colormap that highlights the different coherent states with colors matching the Julia logo.

+figExample block output

Conclusion

This tutorial demonstrates how to generate the QuantumToolbox.jl logo using the package itself and Makie.jl for visualization. The logo is a visualization of the Wigner function of a triangular cat state, with a custom colormap that highlights the different coherent states with colors matching the Julia logo.

diff --git a/dev/tutorials/lowrank/index.html b/dev/tutorials/lowrank/index.html index 9288e13b..bb6ba3eb 100644 --- a/dev/tutorials/lowrank/index.html +++ b/dev/tutorials/lowrank/index.html @@ -124,4 +124,4 @@ hlines!(ax2, [Strue], color = :blue, linestyle = :dash, linewidth = 2, label = L"S^{\,\mathrm{true}}_{\mathrm{ss}}") axislegend(ax2, position = :rb) -figExample block output +figExample block output diff --git a/dev/type_stability/index.html b/dev/type_stability/index.html index 7c580227..e40ac63e 100644 --- a/dev/type_stability/index.html +++ b/dev/type_stability/index.html @@ -76,13 +76,13 @@ └── return %24

While in the last example of the foo function we got a weak form of type instability, returning a Union{Int, Float64}, in this case the return type of bar is Any, meaning that the compiler doesn't know anything about the return type. Thus, this function has nothing different from a dynamically typed language like Python. We can benchmark the performance of bar using the BenchmarkTools.jl package:

using BenchmarkTools
 
 @benchmark bar(3.2)
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
- Range (minmax):  42.248 μs 33.398 ms   GC (min … max): 0.00% … 99.69%
- Time  (median):     62.156 μs                GC (median):    0.00%
- Time  (mean ± σ):   62.181 μs ± 333.582 μs   GC (mean ± σ):  5.35% ±  1.00%
+ Range (minmax):  42.319 μs 35.699 ms   GC (min … max): 0.00% … 99.69%
+ Time  (median):     62.185 μs                GC (median):    0.00%
+ Time  (mean ± σ):   62.080 μs ± 356.618 μs   GC (mean ± σ):  5.73% ±  1.00%
 
-    ▁▃                               ▄ ▇▁                      
-  ▃▄██▄▂▂▂▂▂▂▁▂▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▂▂▃▄▃██▇██▄▃▂▃▂▂▂▂▂▂▂▂▃▂▃▃▂▂▂▂ ▃
-  42.2 μs         Histogram: frequency by time           75 μs <
+  ▁▅ ▆▇▆▂         ▁      ▂▄▅█▅▁       ▁▂▂▁                   ▂
+  ███████▆▄▄▇▅▆▆▄███▇▆▅▄▂███████▇▆▅▆▆█████▇▇▇▆▅▅▄▅▃▄▂▄▄▃▄▅▃▅ █
+  42.3 μs       Histogram: log(frequency) by time      87.3 μs <
 
  Memory estimate: 46.88 KiB, allocs estimate: 3000.

Here we see a lot of memory allocations and low performances in general. To fix this, we can declare a const (constant) variable instead:

const z = 2.4
 
@@ -95,13 +95,13 @@
 end
 
 @benchmark bar(3.2)
BenchmarkTools.Trial: 10000 samples with 57 evaluations.
- Range (minmax):  868.807 ns 1.685 μs   GC (min … max): 0.00% … 0.00%
+ Range (minmax):  868.807 ns 1.226 μs   GC (min … max): 0.00% … 0.00%
  Time  (median):     869.684 ns               GC (median):    0.00%
- Time  (mean ± σ):   877.253 ns ± 32.278 ns   GC (mean ± σ):  0.00% ± 0.00%
+ Time  (mean ± σ):   876.598 ns ± 29.747 ns   GC (mean ± σ):  0.00% ± 0.00%
 
-   ▃▁                                                ▁▂       ▁
-  ▄██▅█▅▅▄▁▅▇▆▅▄▃▄▁▁▁▃▁▁▁▁▁▃▁▁▁▃▁▁▁▁▃▁▁▁▁▁▁▁▁▁▁▁▄▅▄████▇▇▄▆▅ █
-  869 ns        Histogram: log(frequency) by time      1.01 μs <
+                                                       ▁▁▁    ▁
+  ▅▄▄▅▄▅▁▄▃▁▃▅▆▇▆▄▄▄▁▁▄▁▃▁▁▁▃▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▃▃▇█████▆ █
+  869 ns        Histogram: log(frequency) by time         1 μs <
 
  Memory estimate: 0 bytes, allocs estimate: 0.

And we can see that the performance has improved significantly. Hence, we highly recommend using global variables as const, but only when truly necessary. This choice is problem-dependent, but in the case of QuantumToolbox.jl, this can be applied for example in the case of defining the Hilbert space dimensions, static parameters, or the system operators.

Although it is always a good practice to avoid such kind of type instabilities, in the actual implementation of QuantumToolbox.jl (where we mainly deal with linear algebra operations), the compiler may perform only a few runtime dispatches, and the performance penalty may be negligible compared to the heavy linear algebra operations.

Vectors vs Tuples vs StaticArrays

Julia has many ways to represent arrays or lists of general objects. The most common are Vectors and Tuples. The former is a dynamic array that can change its size at runtime, while the latter is a fixed-size array that is immutable, and where the type of each element is already known at compile time. For example:

v1 = [1, 2, 3] # Vector of Int64
 v2 = [1.0 + 2.0im, 3.0 + 4.0im] # Vector of ComplexF64
@@ -219,22 +219,22 @@
  %24 = (%21)(%22, %23)::SVector{6, Int64}
  %25 = Core._apply_iterate(Base.iterate, %18, %20, %24)::Array{Float64, 6}
 └──       return %25

Finally, let's look at the benchmarks

@benchmark reshape_operator_data($[2, 2, 2])
BenchmarkTools.Trial: 10000 samples with 9 evaluations.
- Range (minmax):  2.923 μs 24.915 μs   GC (min … max): 0.00% … 0.00%
- Time  (median):     3.026 μs                GC (median):    0.00%
- Time  (mean ± σ):   3.117 μs ± 722.291 ns   GC (mean ± σ):  0.00% ± 0.00%
+ Range (minmax):  2.927 μs 37.213 μs   GC (min … max): 0.00% … 0.00%
+ Time  (median):     3.410 μs                GC (median):    0.00%
+ Time  (mean ± σ):   3.543 μs ± 952.652 ns   GC (mean ± σ):  0.00% ± 0.00%
 
-  ▂▆██▆▅▃▂▂▁                             ▁▁                 ▂
-  ████████████▇▆▇▆▆▅▅▄▄▅▁▄▅▁▄▅▄▃▄▅▄▃▄▅▄▆▇█████▇▇▆▆▆▅▅▅▃▅▄▆▅ █
-  2.92 μs      Histogram: log(frequency) by time      4.58 μs <
+   ▆█▃                                                     
+  ▄███▆▃▄▄▂▁▅█▆▃█▅▃▂▃▃▂▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂▃▃▂▁▁ ▂
+  2.93 μs         Histogram: frequency by time        5.42 μs <
 
- Memory estimate: 1.69 KiB, allocs estimate: 32.
@benchmark reshape_operator_data($((2, 2, 2)))
BenchmarkTools.Trial: 10000 samples with 501 evaluations.
- Range (minmax):  216.214 ns114.984 μs   GC (min … max):  0.00% … 87.21%
- Time  (median):     240.400 ns                GC (median):     0.00%
- Time  (mean ± σ):   393.581 ns ±   1.702 μs   GC (mean ± σ):  17.31% ±  7.60%
+ Memory estimate: 1.69 KiB, allocs estimate: 32.
@benchmark reshape_operator_data($((2, 2, 2)))
BenchmarkTools.Trial: 10000 samples with 540 evaluations.
+ Range (minmax):  206.033 ns121.036 μs   GC (min … max):  0.00% … 85.75%
+ Time  (median):     228.009 ns                GC (median):     0.00%
+ Time  (mean ± σ):   379.335 ns ±   1.741 μs   GC (mean ± σ):  17.88% ±  7.72%
 
-   ▆█▁                                          ▁                
-  ▄███▅▄▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▁▂▁▁▁▁▂▁▂▂▂▂▂▂▄██▄▄▄▃▂▂▂▂▂▂▂▂▂ ▃
-  216 ns           Histogram: frequency by time          554 ns <
+  ▃█▇▅▄▃▂▂▁▁▁                                ▄▆▆▅▄▄▃▁          ▂
+  ██████████████▇▇▇▆▆▅▆▆▆▆▆▆▄▄▃▅▃▄▃▃▁▁▁▃▇█▆██████████▇▆▇▅▆▅▅▆ █
+  206 ns        Histogram: log(frequency) by time        549 ns <
 
  Memory estimate: 672 bytes, allocs estimate: 3.

Which is an innocuous but huge difference in terms of performance. Hence, we highly recommend using Tuple or SVector when defining the dimensions of a user-defined QuantumObject.

The use of Val in some QuantumToolbox.jl functions

In some functions of QuantumToolbox.jl, you may find the use of the Val type in the arguments. This is a trick to pass a value at compile time, and it is very useful to avoid type instabilities. Let's make a very simple example, where we want to create a Fock state $|j\rangle$ of a given dimension N, and we give the possibility to create it as a sparse or dense vector. At first, we can write the function without using Val:

function my_fock(N::Int, j::Int = 0; sparse::Bool = false)
     if sparse
@@ -360,4 +360,4 @@
 9 ──       Core.Const(:(Base.kwerr(@_2, @_3, N, j)))
 10 ┄ %22 = Main.var"Main".:(var"#my_fock_good#2")::Core.Const(Main.var"Main".var"#my_fock_good#2")
  %23 = (%22)(%14, @_3, N, j)::QuantumObject{Vector{ComplexF64}, KetQuantumObject, 1}
-└───       return %23

This is exactly how the current fock function is implemented in QuantumToolbox.jl. There are many other functions that support this feature, and we highly recommend using it when necessary.

Conclusions

In this page, we have seen the importance of type stability in Julia, and how to write efficient code in the context of QuantumToolbox.jl. We have seen that the internal structure of the QuantumObject type is already optimized for the compiler, and we have seen some practical examples of how to write efficient code. We have seen that the use of Vector should be avoided when the elements don't have the same type, and that the use of Tuple or SVector is highly recommended when the size of the array is known at compile time. Finally, we have seen the use of Val to pass values at compile time, to avoid type instabilities in some functions. ```

+└─── return %23

This is exactly how the current fock function is implemented in QuantumToolbox.jl. There are many other functions that support this feature, and we highly recommend using it when necessary.

Conclusions

In this page, we have seen the importance of type stability in Julia, and how to write efficient code in the context of QuantumToolbox.jl. We have seen that the internal structure of the QuantumObject type is already optimized for the compiler, and we have seen some practical examples of how to write efficient code. We have seen that the use of Vector should be avoided when the elements don't have the same type, and that the use of Tuple or SVector is highly recommended when the size of the array is known at compile time. Finally, we have seen the use of Val to pass values at compile time, to avoid type instabilities in some functions. ```

diff --git a/dev/users_guide/QuantumObject/QuantumObject/index.html b/dev/users_guide/QuantumObject/QuantumObject/index.html index 9b94165c..ba0ea512 100644 --- a/dev/users_guide/QuantumObject/QuantumObject/index.html +++ b/dev/users_guide/QuantumObject/QuantumObject/index.html @@ -15,23 +15,23 @@ 1×5 Matrix{Int64}: 1 2 3 4 5
Qobj(rand(4, 4))
Quantum Object:   type=Operator   dims=[4]   size=(4, 4)   ishermitian=false
 4×4 Matrix{Float64}:
- 0.268196  0.577308  0.372022   0.576563
- 0.99848   0.17705   0.545039   0.399674
- 0.628395  0.16861   0.0871626  0.858373
- 0.205869  0.267449  0.594707   0.129399
M = rand(ComplexF64, 4, 4)
+ 0.376097   0.339407  0.711709  0.177918
+ 0.849273   0.237375  0.70415   0.5814
+ 0.0578508  0.573821  0.336461  0.106293
+ 0.111099   0.402826  0.578785  0.972006
M = rand(ComplexF64, 4, 4)
 Qobj(M, dims = [2, 2])  # dims as Vector
 Qobj(M, dims = (2, 2))  # dims as Tuple (recommended)
 Qobj(M, dims = SVector(2, 2)) # dims as StaticArrays.SVector (recommended)
Quantum Object:   type=Operator   dims=[2, 2]   size=(4, 4)   ishermitian=false
 4×4 Matrix{ComplexF64}:
-  0.742982+0.87522im     0.29608+0.0547151im  …  0.0166791+0.864257im
- 0.0907405+0.47559im   0.0591446+0.12542im        0.801753+0.468609im
-  0.263007+0.569723im   0.488979+0.558677im        0.06575+0.609603im
-  0.289291+0.986032im   0.244244+0.957594im       0.643845+0.0436477im
Beware of type-stability!

Please note that here we put the dims as a tuple (2, 2). Although it supports also Vector type (dims = [2, 2]), it is recommended to use Tuple or SVector from StaticArrays.jl to improve performance. For a brief explanation on the impact of the type of dims, see the Section The Importance of Type-Stability.

Qobj(rand(4, 4), type = SuperOperator)
Quantum Object:   type=SuperOperator   dims=[2]   size=(4, 4)
+ 0.333694+0.522368im  0.582353+0.783106im  …  0.0394823+0.312317im
+ 0.696745+0.142597im  0.350463+0.379062im     0.0152648+0.279959im
+ 0.130929+0.660809im  0.936997+0.53106im       0.392154+0.239747im
+ 0.792887+0.67784im   0.263074+0.239789im      0.576661+0.988962im
Beware of type-stability!

Please note that here we put the dims as a tuple (2, 2). Although it supports also Vector type (dims = [2, 2]), it is recommended to use Tuple or SVector from StaticArrays.jl to improve performance. For a brief explanation on the impact of the type of dims, see the Section The Importance of Type-Stability.

Qobj(rand(4, 4), type = SuperOperator)
Quantum Object:   type=SuperOperator   dims=[2]   size=(4, 4)
 4×4 Matrix{Float64}:
- 0.904218  0.0604136  0.767822  0.688544
- 0.671863  0.661226   0.936203  0.925649
- 0.111051  0.51045    0.504489  0.936576
- 0.204872  0.954388   0.891436  0.893697
Difference between `dims` and `size`

Notice that type, dims, and size will change according to the input data. Although dims and size appear to be the same, dims keep tracking the dimension of individual Hilbert spaces of a multipartite system, while size does not. We refer the reader to the section Tensor Products and Partial Traces for more information.

States and operators

Manually specifying the data for each quantum object is inefficient. Even more so when most objects correspond to commonly used types such as the ladder operators of a harmonic oscillator, the Pauli spin operators for a two-level system, or state vectors such as Fock states. Therefore, QuantumToolbox includes predefined functions to construct variety of states and operators (you can click the function links and see the corresponding docstring):

States

Operators

As an example, we give the output for a few of these functions:

basis(5, 3)
Quantum Object:   type=Ket   dims=[5]   size=(5,)
+ 0.541353  0.630843  0.704105    0.188801
+ 0.564731  0.610416  0.415571    0.25438
+ 0.257467  0.181084  0.369582    0.372197
+ 0.291741  0.632516  0.00991309  0.323133
Difference between `dims` and `size`

Notice that type, dims, and size will change according to the input data. Although dims and size appear to be the same, dims keep tracking the dimension of individual Hilbert spaces of a multipartite system, while size does not. We refer the reader to the section Tensor Products and Partial Traces for more information.

States and operators

Manually specifying the data for each quantum object is inefficient. Even more so when most objects correspond to commonly used types such as the ladder operators of a harmonic oscillator, the Pauli spin operators for a two-level system, or state vectors such as Fock states. Therefore, QuantumToolbox includes predefined functions to construct variety of states and operators (you can click the function links and see the corresponding docstring):

States

Operators

As an example, we give the output for a few of these functions:

basis(5, 3)
Quantum Object:   type=Ket   dims=[5]   size=(5,)
 5-element Vector{ComplexF64}:
  0.0 + 0.0im
  0.0 + 0.0im
@@ -145,4 +145,4 @@
 3×3 Matrix{Int64}:
   4   5   6
   8  10  12
- 12  15  18

Of course, if you switch the order of multiplication, it becomes inner product $\langle v | u \rangle$:

v' * u
32
+ 12 15 18

Of course, if you switch the order of multiplication, it becomes inner product $\langle v | u \rangle$:

v' * u
32
diff --git a/dev/users_guide/QuantumObject/QuantumObject_functions/index.html b/dev/users_guide/QuantumObject/QuantumObject_functions/index.html index 4b600f1b..3a8cf752 100644 --- a/dev/users_guide/QuantumObject/QuantumObject_functions/index.html +++ b/dev/users_guide/QuantumObject/QuantumObject_functions/index.html @@ -94,4 +94,4 @@ -0.698381+0.0im -0.132457+0.0im -0.0891762+0.0im -0.606281+0.0im 0.596321+0.0im -0.648729+0.0im -0.0633045+0.0im -0.430387+0.0im -0.186568+0.0im -0.268811+0.0im -0.0354544+0.0im -0.241044+0.0im - 0.0+0.0im 0.0+0.0im 0.989355+0.0im -0.145521-0.0im + 0.0+0.0im 0.0+0.0im 0.989355+0.0im -0.145521-0.0im diff --git a/dev/users_guide/extensions/cuda/index.html b/dev/users_guide/extensions/cuda/index.html index d694f0cd..182955bb 100644 --- a/dev/users_guide/extensions/cuda/index.html +++ b/dev/users_guide/extensions/cuda/index.html @@ -35,4 +35,4 @@ 1.0+0.0im ⋅
cu(M; word_size = 32)
Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
 2×2 CuSparseMatrixCSC{ComplexF32, Int32} with 2 stored entries:
      ⋅      1.0+0.0im
- 1.0+0.0im      ⋅    
+ 1.0+0.0im ⋅ diff --git a/dev/users_guide/states_and_operators/index.html b/dev/users_guide/states_and_operators/index.html index 06de5a33..6cbf4704 100644 --- a/dev/users_guide/states_and_operators/index.html +++ b/dev/users_guide/states_and_operators/index.html @@ -294,4 +294,4 @@ 1.0+0.0im ⋅ ⋅ 0.550671+0.0im ⋅ -0.641938-0.192987im ⋅ ⋅ ⋅ ⋅ -0.641938+0.192987im ⋅ - ⋅ ⋅ ⋅ 0.449329+0.0im

See the section Time Evolution and Quantum System Dynamics for more details.

+ ⋅ ⋅ ⋅ 0.449329+0.0im

See the section Time Evolution and Quantum System Dynamics for more details.

diff --git a/dev/users_guide/steadystate/75fdeca2.svg b/dev/users_guide/steadystate/88a0c87d.svg similarity index 81% rename from dev/users_guide/steadystate/75fdeca2.svg rename to dev/users_guide/steadystate/88a0c87d.svg index 7d13cf1d..3d1b1247 100644 --- a/dev/users_guide/steadystate/75fdeca2.svg +++ b/dev/users_guide/steadystate/88a0c87d.svg @@ -2,282 +2,279 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -287,427 +284,427 @@ - - - - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - + + + - - - - + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + diff --git a/dev/users_guide/steadystate/index.html b/dev/users_guide/steadystate/index.html index bafc3615..37ce6b5e 100644 --- a/dev/users_guide/steadystate/index.html +++ b/dev/users_guide/steadystate/index.html @@ -55,4 +55,4 @@ lines!(ax, tlist, exp_ss .* ones(length(tlist)), label = "Steady State", linewidth = 2, color = :red) axislegend(ax, position = :rt) -figExample block output

Calculate steady state for periodically driven systems

See the docstring of steadystate_floquet for more details.

+figExample block output

Calculate steady state for periodically driven systems

See the docstring of steadystate_floquet for more details.

diff --git a/dev/users_guide/tensor/index.html b/dev/users_guide/tensor/index.html index ac54fdf6..780b8f54 100644 --- a/dev/users_guide/tensor/index.html +++ b/dev/users_guide/tensor/index.html @@ -130,4 +130,4 @@ 0.25+0.0im 0.25+0.0im 0.25+0.0im 0.25+0.0im
ptrace(ρT, 1)
Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
 2×2 Matrix{ComplexF64}:
  0.5+0.0im  0.5+0.0im
- 0.5+0.0im  0.5+0.0im
+ 0.5+0.0im 0.5+0.0im diff --git a/dev/users_guide/time_evolution/intro/index.html b/dev/users_guide/time_evolution/intro/index.html index 61ac569a..f913e9c5 100644 --- a/dev/users_guide/time_evolution/intro/index.html +++ b/dev/users_guide/time_evolution/intro/index.html @@ -1,2 +1,2 @@ -Introduction · QuantumToolbox.jl

Time Evolution and Quantum System Dynamics

Table of contents

Introduction

Although in some cases, we want to find the stationary states of a quantum system, often we are interested in the dynamics: how the state of a system or an ensemble of systems evolves with time. QuantumToolbox provides many ways to model dynamics.

There are two kinds of quantum systems: open systems that interact with a larger environment and closed systems that do not. In a closed system, the state can be described by a state vector. When we are modeling an open system, or an ensemble of systems, the use of the density matrix is mandatory.

The following table lists the solvers provided by QuantumToolbox for dynamic quantum systems and the corresponding type of solution returned by the solver:

EquationFunction CallProblemReturned Solution
Unitary evolution, Schrödinger equationsesolvesesolveProblemTimeEvolutionSol
Lindblad master eqn. or Von Neuman eqn.mesolvemesolveProblemTimeEvolutionSol
Monte Carlo evolutionmcsolvemcsolveProblem mcsolveEnsembleProblemTimeEvolutionMCSol
Stochastic Schrödinger equationssesolvessesolveProblem ssesolveEnsembleProblemTimeEvolutionSSESol
Solving dynamics with pre-defined problems

QuantumToolbox provides two different methods to solve the dynamics. One can use the function calls listed above by either taking all the operators (like Hamiltonian and collapse operators, etc.) as inputs directly, or generating the problems by yourself and take it as an input of the function call, e.g., sesolve(prob).

+Introduction · QuantumToolbox.jl

Time Evolution and Quantum System Dynamics

Table of contents

Introduction

Although in some cases, we want to find the stationary states of a quantum system, often we are interested in the dynamics: how the state of a system or an ensemble of systems evolves with time. QuantumToolbox provides many ways to model dynamics.

There are two kinds of quantum systems: open systems that interact with a larger environment and closed systems that do not. In a closed system, the state can be described by a state vector. When we are modeling an open system, or an ensemble of systems, the use of the density matrix is mandatory.

The following table lists the solvers provided by QuantumToolbox for dynamic quantum systems and the corresponding type of solution returned by the solver:

EquationFunction CallProblemReturned Solution
Unitary evolution, Schrödinger equationsesolvesesolveProblemTimeEvolutionSol
Lindblad master eqn. or Von Neuman eqn.mesolvemesolveProblemTimeEvolutionSol
Monte Carlo evolutionmcsolvemcsolveProblem mcsolveEnsembleProblemTimeEvolutionMCSol
Stochastic Schrödinger equationssesolvessesolveProblem ssesolveEnsembleProblemTimeEvolutionSSESol
Solving dynamics with pre-defined problems

QuantumToolbox provides two different methods to solve the dynamics. One can use the function calls listed above by either taking all the operators (like Hamiltonian and collapse operators, etc.) as inputs directly, or generating the problems by yourself and take it as an input of the function call, e.g., sesolve(prob).

diff --git a/dev/users_guide/time_evolution/mcsolve/index.html b/dev/users_guide/time_evolution/mcsolve/index.html index 5b9dbf5b..d175f98e 100644 --- a/dev/users_guide/time_evolution/mcsolve/index.html +++ b/dev/users_guide/time_evolution/mcsolve/index.html @@ -1,2 +1,2 @@ -Monte-Carlo Solver · QuantumToolbox.jl
+Monte-Carlo Solver · QuantumToolbox.jl
diff --git a/dev/users_guide/time_evolution/mesolve/index.html b/dev/users_guide/time_evolution/mesolve/index.html index efa57f06..84ae15a6 100644 --- a/dev/users_guide/time_evolution/mesolve/index.html +++ b/dev/users_guide/time_evolution/mesolve/index.html @@ -1,2 +1,2 @@ -Lindblad Master Equation Solver · QuantumToolbox.jl +Lindblad Master Equation Solver · QuantumToolbox.jl diff --git a/dev/users_guide/time_evolution/sesolve/index.html b/dev/users_guide/time_evolution/sesolve/index.html index 026692bd..2d1ff782 100644 --- a/dev/users_guide/time_evolution/sesolve/index.html +++ b/dev/users_guide/time_evolution/sesolve/index.html @@ -1,2 +1,2 @@ -Schrödinger Equation Solver · QuantumToolbox.jl +Schrödinger Equation Solver · QuantumToolbox.jl diff --git a/dev/users_guide/time_evolution/solution/index.html b/dev/users_guide/time_evolution/solution/index.html index cab7a169..ccbd99f6 100644 --- a/dev/users_guide/time_evolution/solution/index.html +++ b/dev/users_guide/time_evolution/solution/index.html @@ -32,4 +32,4 @@ Quantum Object: type=Ket dims=[2] size=(2,) 2-element Vector{ComplexF64}: 0.28366218546240907 + 0.0im - -0.9589242745990754 + 0.0im

Here, the solution contains only one (final) state. Because the states will be saved depend on the keyword argument saveat in kwargs. If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). One can also specify e_ops and saveat separately.

Some other solvers can have other output.

Multiple trajectories solution

This part is still under construction, please visit API first.

+ -0.9589242745990754 + 0.0im

Here, the solution contains only one (final) state. Because the states will be saved depend on the keyword argument saveat in kwargs. If e_ops is empty, the default value of saveat=tlist (saving the states corresponding to tlist), otherwise, saveat=[tlist[end]] (only save the final state). One can also specify e_ops and saveat separately.

Some other solvers can have other output.

Multiple trajectories solution

This part is still under construction, please visit API first.

diff --git a/dev/users_guide/time_evolution/stochastic/index.html b/dev/users_guide/time_evolution/stochastic/index.html index ca7d9a16..a303af03 100644 --- a/dev/users_guide/time_evolution/stochastic/index.html +++ b/dev/users_guide/time_evolution/stochastic/index.html @@ -1,2 +1,2 @@ -Stochastic Solver · QuantumToolbox.jl +Stochastic Solver · QuantumToolbox.jl diff --git a/dev/users_guide/time_evolution/time_dependent/index.html b/dev/users_guide/time_evolution/time_dependent/index.html index 3d18530f..9573b33f 100644 --- a/dev/users_guide/time_evolution/time_dependent/index.html +++ b/dev/users_guide/time_evolution/time_dependent/index.html @@ -1,2 +1,2 @@ -Solving Problems with Time-dependent Hamiltonians · QuantumToolbox.jl +Solving Problems with Time-dependent Hamiltonians · QuantumToolbox.jl