API

Quantum-objects

Types

QuantumInterface.BasisType

Abstract base class for all specialized bases.

The Basis class is meant to specify a basis of the Hilbert space of the studied system. Besides basis specific information all subclasses must implement a shape variable which indicates the dimension of the used Hilbert space. For a spin-1/2 Hilbert space this would be the vector [2]. A system composed of two spins would then have a shape vector [2 2].

Composite systems can be defined with help of the CompositeBasis class.

source
QuantumInterface.GenericBasisType
GenericBasis(N)

A general purpose basis of dimension N.

Should only be used rarely since it defeats the purpose of checking that the bases of state vectors and operators are correct for algebraic operations. The preferred way is to specify special bases for different systems.

source
QuantumInterface.CompositeBasisType
CompositeBasis(b1, b2...)

Basis for composite Hilbert spaces.

Stores the subbases in a vector and creates the shape vector directly from the shape vectors of these subbases. Instead of creating a CompositeBasis directly tensor(b1, b2...) or b1 ⊗ b2 ⊗ … can be used.

source
  • States
QuantumInterface.StateVectorType

Abstract base class for Bra and Ket states.

The state vector class stores the coefficients of an abstract state in respect to a certain basis. These coefficients are stored in the data field and the basis is defined in the basis field.

source
QuantumOpticsBase.LazyKetType
LazyKet(b, kets)

Lazy implementation of a tensor product of kets.

The subkets are stored in the kets field. The main purpose of such a ket are simple computations for large product states, such as expectation values. It's used to compute numeric initial states in QuantumCumulants.jl (see QuantumCumulants.initial_values).

source
  • General purpose operators. A few more specialized operators are implemented in API: Quantum-systems.
QuantumInterface.AbstractOperatorType

Abstract base class for all operators.

All deriving operator classes have to define the fields basis_l and basis_r defining the left and right side bases.

For fast time evolution also at least the function mul!(result::Ket,op::AbstractOperator,x::Ket,alpha,beta) should be implemented. Many other generic multiplication functions can be defined in terms of this function and are provided automatically.

source
QuantumOpticsBase.DataOperatorType

Abstract type for operators with a data field.

This is an abstract type for operators that have a direct matrix representation stored in their .data field.

source
QuantumOpticsBase.OperatorType
Operator{BL,BR,T} <: DataOperator{BL,BR}

Operator type that stores the representation of an operator on the Hilbert spaces given by BL and BR (e.g. a Matrix).

source
QuantumOpticsBase.SparseOperatorFunction
SparseOperator(b1[, b2, data])

Sparse array implementation of Operator.

The matrix is stored as the julia built-in type SparseMatrixCSC in the data field.

source
QuantumOpticsBase.LazyTensorType
LazyTensor(b1[, b2], indices, operators[, factor=1])

Lazy implementation of a tensor product of operators.

The suboperators are stored in the operators field. The indices field specifies in which subsystem the corresponding operator lives. Note that these must be sorted. Additionally, a factor is stored in the factor field which allows for fast multiplication with numbers.

source
QuantumOpticsBase.LazySumType
LazySum([Tf,] [factors,] operators)
LazySum([Tf,] basis_l, basis_r, [factors,] [operators])
LazySum(::Tuple, x::LazySum)

Lazy evaluation of sums of operators.

All operators have to be given in respect to the same bases. The field factors accounts for an additional multiplicative factor for each operator stored in the operators field.

The factor type Tf can be specified to avoid having to infer it from the factors and operators themselves. All factors will be converted to type Tf.

The operators will be kept as is. It can be, for example, a Tuple or a Vector of operators. Using a Tuple is recommended for runtime performance of operator-state operations, such as simulating time evolution. A Vector can reduce compile-time overhead when doing arithmetic on LazySums, such as summing many LazySums together.

To convert a vector-based LazySum x to use a tuple for operator storage, use LazySum(::Tuple, x).

source
QuantumOpticsBase.LazyProductType
LazyProduct(operators[, factor=1])
LazyProduct(op1, op2...)

Lazy evaluation of products of operators.

The factors of the product are stored in the operators field. Additionally a complex factor is stored in the factor field which allows for fast multiplication with numbers.

source
QuantumOpticsBase.AbstractTimeDependentOperatorType
AbstractTimeDependentOperator{BL,BR} <: AbstractOperator{BL,BR}

Abstract type providing a time-dependent operator interface. Time-dependent operators have internal "clocks" that can be addressed with set_time! and current_time. A shorthand op(t), equivalent to set_time!(copy(op), t), is available for brevity.

A time-dependent operator is always concrete-valued according to the current time of its internal clock.

source
QuantumOpticsBase.TimeDependentSumType
TimeDependentSum(lazysum, coeffs, init_time)
TimeDependentSum(::Type{Tf}, basis_l, basis_r; init_time=0.0)
TimeDependentSum([::Type{Tf},] [basis_l,] [basis_r,] coeffs, operators; init_time=0.0)
TimeDependentSum([::Type{Tf},] coeff1=>op1, coeff2=>op2, ...; init_time=0.0)
TimeDependentSum(::Tuple, op::TimeDependentSum)

Lazy sum of operators with time-dependent coefficients. Wraps a LazySum lazysum, adding a current_time (or operator "clock") and a means of specifying time coefficients as functions of time (or numbers).

The coefficient type Tf may be specified explicitly. Time-dependent coefficients will be converted to this type on evaluation.

source
  • Super operators:

Functions

  • Functions to generate general states, operators and super-operators
QuantumOpticsBase.basisstateFunction
basisstate([T=ComplexF64, ]b, index)

Basis vector specified by index as ket state.

For a composite system index can be a vector which then creates a tensor product state $|i_1⟩⊗|i_2⟩⊗…⊗|i_n⟩$ of the corresponding basis states.

source
basisstate([T=ComplexF64,] mb::ManyBodyBasis, occupation::Vector)

Return a ket state where the system is in the state specified by the given occupation numbers.

source
QuantumInterface.identityoperatorFunction
identityoperator(a::Basis[, b::Basis])
identityoperator(::Type{<:AbstractOperator}, a::Basis[, b::Basis])
identityoperator(::Type{<:Number}, a::Basis[, b::Basis])
identityoperator(::Type{<:AbstractOperator}, ::Type{<:Number}, a::Basis[, b::Basis])

Return an identityoperator in the given bases. One can optionally specify the container type which has to a subtype of AbstractOperator as well as the number type to be used in the identity matrix.

source
QuantumOpticsBase.spreFunction
spre(op)

Create a super-operator equivalent for right side operator multiplication.

For operators $A$, $B$ the relation

\[ \mathrm{spre}(A) B = A B\]

holds. op can be a dense or a sparse operator.

source
QuantumOpticsBase.spostFunction
spost(op)

Create a super-operator equivalent for left side operator multiplication.

For operators $A$, $B$ the relation

\[ \mathrm{spost}(A) B = B A\]

holds. op can be a dense or a sparse operator.

source
QuantumOpticsBase.sprepostFunction
sprepost(op)

Create a super-operator equivalent for left and right side operator multiplication.

For operators $A$, $B$, $C$ the relation

\[ \mathrm{sprepost}(A, B) C = A C B\]

holds. A ond B can be dense or a sparse operators.

source
QuantumOpticsBase.liouvillianFunction
liouvillian(H, J; rates, Jdagger)

Create a super-operator equivalent to the master equation so that $\dot ρ = S ρ$.

The super-operator $S$ is defined by

\[S ρ = -\frac{i}{ħ} [H, ρ] + \sum_i J_i ρ J_i^† - \frac{1}{2} J_i^† J_i ρ - \frac{1}{2} ρ J_i^† J_i\]

Arguments

  • H: Hamiltonian.
  • J: Vector containing the jump operators.
  • rates: Vector or matrix specifying the coefficients for the jump operators.
  • Jdagger: Vector containing the hermitian conjugates of the jump operators. If they are not given they are calculated automatically.
source
  • As far as it makes sense the same functions are implemented for bases, states, operators and superoperators.
QuantumInterface.tensorFunction
tensor(x, y, z...)

Tensor product of the given objects. Alternatively, the unicode symbol ⊗ (\otimes) can be used.

source
QuantumInterface.ptraceFunction
ptrace(a, indices)

Partial trace of the given basis, state or operator.

The indices argument, which can be a single integer or a vector of integers, specifies which subsystems are traced out. The number of indices has to be smaller than the number of subsystems, i.e. it is not allowed to perform a full trace.

source
QuantumInterface.expectFunction
expect(index, op, state)

If an index is given, it assumes that op is defined in the subsystem specified by this number.

source
expect(op, state)

Expectation value of the given operator op for the specified state.

state can either be a (density) operator or a ket.

source
QuantumInterface.varianceFunction
variance(index, op, state)

If an index is given, it assumes that op is defined in the subsystem specified by this number

source
variance(op, state)

Variance of the given operator op for the specified state.

state can either be a (density) operator or a ket.

source
QuantumInterface.embedFunction
embed(basis1[, basis2], operators::Dict)

operators is a dictionary Dict{Vector{Int}, AbstractOperator}. The integer vector specifies in which subsystems the corresponding operator is defined.

source
embed(basis1[, basis2], indices::Vector, operators::Vector)

Tensor product of operators where missing indices are filled up with identity operators.

source
embed(basis1[, basis2], indices::Vector, op::AbstractOperator)

Embed operator acting on a joint Hilbert space where missing indices are filled up with identity operators.

source
embed(basis_l::SumBasis, basis_r::SumBasis,
           index::Integer, operator)

Embed an operator defined on a single subspace specified by the index into a SumBasis.

source
embed(basis_l::SumBasis, basis_r::SumBasis,
            indices, operator)

Embed an operator defined on multiple subspaces specified by the indices into a SumBasis.

source
embed(basis_l::SumBasis, basis_r::SumBasis,
           indices, operators)

Embed a list of operators on subspaces specified by the indices into a SumBasis.

source
QuantumInterface.permutesystemsFunction
permutesystems(a, perm)

Change the ordering of the subsystems of the given object.

For a permutation vector [2,1,3] and a given object with basis [b1, b2, b3] this function results in [b2, b1, b3].

source
Base.expMethod
exp(op::AbstractOperator)

Operator exponential.

source
LinearAlgebra.mul!Function
mul!(Y::DataOperator,A::AbstractOperator,B::DataOperator,alpha,beta) -> Y
mul!(Y::StateVector,A::AbstractOperator,B::StateVector,alpha,beta) -> Y

Fast in-place multiplication of operators/state vectors. Updates Y as Y = alpha*A*B + beta*Y. In most cases, the call gets forwarded to Julia's 5-arg mul! implementation on the underlying data. See also LinearAlgebra.mul!.

source
  • Conversion of operators
SparseArrays.sparseMethod
sparse(op::AbstractOperator)

Convert an arbitrary operator into a sparse one.

See also: QuantumOpticsBase.SparseOperator

source
QuantumOpticsBase.current_timeFunction
current_time(op::AbstractOperator)

Returns the current time of the operator op. If op is not time-dependent, this throws an ArgumentError.

source
QuantumOpticsBase.time_restrictFunction
time_restrict(op::TimeDependentSum, t_from, t_to)
time_restrict(op::TimeDependentSum, t_to)

Restrict a TimeDependentSum op to the time window t_from <= t < t_to, forcing it to be exactly zero outside that range of times. If t_from is not provided, it is assumed to be zero. Return a new TimeDependentSum.

source
QuantumOpticsBase.static_operatorFunction
static_operator(op::AbstractOperator)

Returns a static (not time dependent) representation of op the current time. This strips the time-dependence and can be used to obtain a non-lazy matrix representation of the operator.

For example: sparse(static_operator(op(t)) return a sparse-matrix representation of op at time t.

source

Exceptions

Quantum systems

Fock

QuantumInterface.FockBasisType
FockBasis(N,offset=0)

Basis for a Fock space where N specifies a cutoff, i.e. what the highest included fock state is. Similarly, the offset defines the lowest included fock state (default is 0). Note that the dimension of this basis is N+1-offset.

source
QuantumOpticsBase.destroyMethod
destroy([T=ComplexF64,] b::FockBasis)

Annihilation operator for the specified Fock space with optional data type T.

source
QuantumOpticsBase.createMethod
create([T=ComplexF64,] b::FockBasis)

Creation operator for the specified Fock space with optional data type T.

source
QuantumOpticsBase.displaceFunction
displace([T=ComplexF64,] b::FockBasis, alpha)

Displacement operator $D(α)=\exp{\left(α\hat{a}^\dagger-α^*\hat{a}\right)}$ for the specified Fock space with optional data type T, computed as the matrix exponential of finite-dimensional (truncated) creation and annihilation operators.

source
QuantumOpticsBase.displace_analyticalFunction
displace_analytical(alpha::Number, n::Integer, m::Integer)

Get a specific matrix element of the (analytical) displacement operator in the Fock basis: Dmn = ⟨n|D̂(α)|m⟩. The precision used for computation is based on the type of alpha. If alpha is a Float64, ComplexF64, or Int, the computation will be carried out at double precision.

source
displace_analytical(b::FockBasis, alpha::Number)
displace_analytical(::Type{T}, b::FockBasis, alpha::Number)

Get the "analytical" displacement operator, whose matrix elements match (up to numerical imprecision) those of the exact infinite-dimensional displacement operator. This is different to the result of displace(..., alpha), which computes the matrix exponential exp(alpha * a' - conj(alpha) * a) using finite-dimensional (truncated) creation and annihilation operators a' and a.

source
QuantumOpticsBase.displace_analytical!Function
displace_analytical!(op, alpha::Number)

Overwrite, in place, the matrix elements of the FockBasis operator op, so that it is equal to displace_analytical(eltype(op), basis(op), alpha)

source
QuantumOpticsBase.squeezeFunction
squeeze([T=ComplexF64,] b::SpinBasis, z)

Squeezing operator $S(z)=\exp{\left(\frac{z^*\hat{J_-}^2 - z\hat{J}_+}{2 N}\right)}$ for the specified Spin-$N/2$ basis with optional data type T, computed as the matrix exponential. Too large squeezing ($|z| > \sqrt{N}$) will create an oversqueezed state.

source
squeeze([T=ComplexF64,] b::FockBasis, z)

Squeezing operator $S(z)=\exp{\left(\frac{z^*\hat{a}^2-z\hat{a}^{\dagger2}}{2}\right)}$ for the specified Fock space with optional data type T, computed as the matrix exponential of finite-dimensional (truncated) creation and annihilation operators.

source

Phase space

QuantumOpticsBase.qfuncFunction
qfunc(a, α)
qfunc(a, x, y)
qfunc(a, xvec, yvec)

Husimi Q representation $⟨α|ρ|α⟩/π$ for the given state or operator a. The function can either be evaluated on one point α or on a grid specified by the vectors xvec and yvec. Note that conversion from x and y to α is done via the relation $α = \frac{1}{\sqrt{2}}(x + i y)$.

source
QuantumOpticsBase.wignerFunction
wigner(a, α)
wigner(a, x, y)
wigner(a, xvec, yvec)

Wigner function for the given state or operator a. The function can either be evaluated on one point α or on a grid specified by the vectors xvec and yvec. Note that conversion from x and y to α is done via the relation $α = \frac{1}{\sqrt{2}}(x + i y)$.

source
QuantumOpticsBase.coherentspinstateFunction
coherentspinstate(b::SpinBasis, θ::Real, ϕ::Real)

A coherent spin state |θ,ϕ⟩ is analogous to the coherent state of the linear harmonic oscillator. Coherent spin states represent a collection of identical two-level systems and can be described by two angles θ and ϕ (although this parametrization is not unique), similarly to a qubit on the Bloch sphere.

source
QuantumOpticsBase.qfuncsu2Function
qfuncsu2(ket,Ntheta;Nphi=2Ntheta)
qfuncsu2(rho,Ntheta;Nphi=2Ntheta)

Husimi Q SU(2) representation $⟨θ,ϕ|ρ|θ,ϕ⟩/π$ for the given state.

The function calculates the SU(2) Husimi representation of a state on the generalised bloch sphere (0 < θ < π and 0 < ϕ < 2 π) with a given resolution (Ntheta, Nphi).

qfuncsu2(rho,θ,ϕ)
qfuncsu2(ket,θ,ϕ)

This version calculates the Husimi Q SU(2) function at a position given by θ and ϕ.

source
QuantumOpticsBase.wignersu2Function
wignersu2(ket,Ntheta;Nphi=2Ntheta)
wignersu2(rho,Ntheta;Nphi=2Ntheta)

Wigner SU(2) representation for the given state with a resolution (Ntheta, Nphi).

The function calculates the SU(2) Wigner representation of a state on the generalised bloch sphere (0 < θ < π and 0 < ϕ < 2 π) with a given resolution by decomposing the state into the basis of spherical harmonics.

wignersu2(rho,θ,ϕ)
wignersu2(ket,θ,ϕ)

This version calculates the Wigner SU(2) function at a position given by θ and ϕ

source
QuantumOptics.ylmFunction
ylm(l::Integer,m::Integer,theta::Real,phi::Real)

Spherical harmonics Y(l,m)(θ,ϕ) where l ∈ N, m = -l,-l+1,...,l-1,l, θ ∈ [0,π], and ϕ ∈ [0,2π).

This function calculates the value of Y(l,m) spherical harmonic at position θ and ϕ.

source

N-level

QuantumOpticsBase.transitionMethod
transition([T=ComplexF64,] b::NLevelBasis, to::Integer, from::Integer)

Transition operator $|\mathrm{to}⟩⟨\mathrm{from}|$.

source

Spin

QuantumInterface.SpinBasisType
SpinBasis(n)

Basis for spin-n particles.

The basis can be created for arbitrary spinnumbers by using a rational number, e.g. SpinBasis(3//2). The Pauli operators are defined for all possible spin numbers.

source

Particle

QuantumOpticsBase.PositionBasisType
PositionBasis(xmin, xmax, Npoints)
PositionBasis(b::MomentumBasis)

Basis for a particle in real space.

For simplicity periodic boundaries are assumed which means that the rightmost point defined by xmax is not included in the basis but is defined to be the same as xmin.

When a MomentumBasis is given as argument the exact values of $x_{min}$ and $x_{max}$ are due to the periodic boundary conditions more or less arbitrary and are chosen to be $-\pi/dp$ and $\pi/dp$ with $dp=(p_{max}-p_{min})/N$.

source
QuantumOpticsBase.MomentumBasisType
MomentumBasis(pmin, pmax, Npoints)
MomentumBasis(b::PositionBasis)

Basis for a particle in momentum space.

For simplicity periodic boundaries are assumed which means that pmax is not included in the basis but is defined to be the same as pmin.

When a PositionBasis is given as argument the exact values of $p_{min}$ and $p_{max}$ are due to the periodic boundary conditions more or less arbitrary and are chosen to be $-\pi/dx$ and $\pi/dx$ with $dx=(x_{max}-x_{min})/N$.

source
QuantumOpticsBase.spacingFunction
spacing(b::PositionBasis)

Difference between two adjacent points of the real space basis.

source
spacing(b::MomentumBasis)

Momentum difference between two adjacent points of the momentum basis.

source
Base.positionMethod
position([T=ComplexF64,] b::PositionBasis)

Position operator in real space.

source
Base.positionMethod
position([T=ComplexF64,] b:MomentumBasis)

Position operator in momentum space.

source
QuantumOpticsBase.potentialoperatorFunction
potentialoperator([T=Float64,] b::PositionBasis, V(x))

Operator representing a potential $V(x)$ in real space.

source
potentialoperator([T=ComplexF64,] b::MomentumBasis, V(x))

Operator representing a potential $V(x)$ in momentum space.

source
potentialoperator([T=Float64,] b::CompositeBasis, V(x, y, z, ...))

Operator representing a potential $V$ in more than one dimension.

Arguments

  • b: Composite basis consisting purely either of PositionBasis or MomentumBasis. Note, that calling this with a composite basis in momentum space might consume a large amount of memory.
  • V: Function describing the potential. ATTENTION: The number of arguments accepted by V must match the spatial dimension. Furthermore, the order of the arguments has to match that of the order of the tensor product of bases (e.g. if b=bx⊗by⊗bz, then V(x,y,z)).
source
QuantumOpticsBase.gaussianstateFunction
gaussianstate([T=ComplexF64,] b::PositionBasis, x0, p0, sigma)
gaussianstate([T=ComplexF64,] b::MomentumBasis, x0, p0, sigma)

Create a Gaussian state around x0 andp0 with width sigma.

In real space the gaussian state is defined as

\[\Psi(x) = \frac{1}{\pi^{1/4}\sqrt{\sigma}} e^{i p_0 (x-\frac{x_0}{2}) - \frac{(x-x_0)^2}{2 \sigma^2}}\]

and is connected to the momentum space definition

\[\Psi(p) = \frac{\sqrt{\sigma}}{\pi^{1/4}} e^{-i x_0 (p-\frac{p_0}{2}) - \frac{1}{2}(p-p_0)^2 \sigma^2}\]

via a Fourier-transformation

\[\Psi(p) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^{\infty} e^{-ipx}\Psi(x) \mathrm{d}x\]

The state has the properties

  • $⟨p⟩ = p_0$
  • $⟨x⟩ = x_0$
  • $\mathrm{Var}(x) = \frac{σ^2}{2}$
  • $\mathrm{Var}(p) = \frac{1}{2 σ^2}$

Due to the numerically necessary discretization additional scaling factors $\sqrt{Δx}$ and $\sqrt{Δp}$ are used so that $\langle x_i|Ψ\rangle = \sqrt{Δ x} Ψ(x_i)$ and $\langle p_i|Ψ\rangle = \sqrt{Δ p} Ψ(p_i)$ so that the resulting Ket state is normalized.

source
QuantumOpticsBase.FFTKetsType
FFTKets

Operator that can only perform fast fourier transformations on Kets. This is much more memory efficient when only working with Kets.

source
QuantumOpticsBase.transformFunction
transform(b1::MomentumBasis, b2::PositionBasis)
transform(b1::PositionBasis, b2::MomentumBasis)

Transformation operator between position basis and momentum basis.

source
transform(b1::CompositeBasis, b2::CompositeBasis)

Transformation operator between two composite bases. Each of the bases has to contain bases of type PositionBasis and the other one a corresponding MomentumBasis.

source
transform([S=ComplexF64, ]b1::PositionBasis, b2::FockBasis; x0=1)
transform([S=ComplexF64, ]b1::FockBasis, b2::PositionBasis; x0=1)

Transformation operator between position basis and fock basis.

The coefficients are connected via the relation

\[ψ(x_i) = \sum_{n=0}^N ⟨x_i|n⟩ ψ_n\]

where $⟨x_i|n⟩$ is the value of the n-th eigenstate of a particle in a harmonic trap potential at position $x$, i.e.:

\[⟨x_i|n⟩ = π^{-\frac{1}{4}} \frac{e^{-\frac{1}{2}\left(\frac{x}{x_0}\right)^2}}{\sqrt{x_0}} \frac{1}{\sqrt{2^n n!}} H_n\left(\frac{x}{x_0}\right)\]

source

Charge

QuantumOpticsBase.ChargeBasisType
ChargeBasis(ncut) <: Basis

Basis spanning -ncut, ..., ncut charge states, which are the fourier modes (irreducible representations) of a continuous U(1) degree of freedom, truncated at ncut.

The charge basis is a natural representation for circuit-QED elements such as the "transmon", which has a hamiltonian of the form

b = ChargeBasis(ncut)
H = 4E_C * (n_g * identityoperator(b) + chargeop(b))^2 - E_J * cosφ(b)

with energies periodic in the charge offset n_g. See e.g. https://arxiv.org/abs/2005.12667.

source
QuantumOpticsBase.expiφFunction
expiφ([T=ComplexF64,] b::ChargeBasis, k=1)
expiφ([T=ComplexF64,] b::ShiftedChargeBasis, k=1)

Return operator $\exp(i k φ)$ for given ChargeBasis or ShiftedChargeBasis, representing the continous U(1) degree of freedom conjugate to the charge. This is a "shift" operator that shifts the charge by k.

source
QuantumOpticsBase.cosφFunction
cosφ([T=ComplexF64,] b::ChargeBasis; k=1)
cosφ([T=ComplexF64,] b::ShiftedChargeBasis; k=1)

Return operator $\cos(k φ)$ for given charge basis. See expiφ.

source
QuantumOpticsBase.sinφFunction
sinφ([T=ComplexF64,] b::ChargeBasis; k=1)
sinφ([T=ComplexF64,] b::ShiftedChargeBasis; k=1)

Return operator $\sin(k φ)$ for given charge basis. See expiφ.

source

Subspace bases

Many-body

QuantumOpticsBase.ManyBodyBasisType
ManyBodyBasis(b, occupations)

Basis for a many body system.

The basis has to know the associated one-body basis b and which occupation states should be included. The occupations_hash is used to speed up checking if two many-body bases are equal.

source
QuantumOpticsBase.fermionstatesFunction
fermionstates([T, ]Nmodes, Nparticles)
fermionstates([T, ]b, Nparticles)

Generate all fermionic occupation states for N-particles in M-modes. Nparticles can be a vector to define a Hilbert space with variable particle number. T is the type of the occupation states - default is OccupationNumbers{FermionStatistics,Int}, but can be any occupations type.

source
QuantumOpticsBase.bosonstatesFunction
bosonstates([T, ]Nmodes, Nparticles)
bosonstates([T, ]b, Nparticles)

Generate all bosonic occupation states for N-particles in M-modes. Nparticles can be a vector to define a Hilbert space with variable particle number. T is the type of the occupation states - default is OccupationNumbers{BosonStatistics,Int}, but can be any occupations type.

source
QuantumOpticsBase.numberMethod
number([T=ComplexF64,] mb::ManyBodyBasis, index)

Particle number operator for the i-th mode of the many-body basis b.

source
QuantumOpticsBase.destroyMethod
destroy([T=ComplexF64,] mb::ManyBodyBasis, index)

Annihilation operator for the i-th mode of the many-body basis b.

source
QuantumOpticsBase.createMethod
create([T=ComplexF64,] mb::ManyBodyBasis, index)

Creation operator for the i-th mode of the many-body basis b.

source
QuantumOpticsBase.transitionMethod
transition([T=ComplexF64,] mb::ManyBodyBasis, to, from)

Operator $|\mathrm{to}⟩⟨\mathrm{from}|$ transferring particles between modes.

Note that to and from can be collections of indices. The resulting operator in this case will be equal to $\ldots a^\dagger_{to_2} a^\dagger_{to_1} \ldots a_{from_2} a_{from_1}$.

source
QuantumOpticsBase.manybodyoperatorFunction
manybodyoperator(mb::ManyBodyBasis, op)

Create the many-body operator from the given one-body operator op.

The given operator can either be a one-body operator or a two-body interaction. Higher order interactions are at the moment not implemented.

The mathematical formalism for the one-body case is described by

\[X = \sum_{ij} a_i^† a_j ⟨u_i| x | u_j⟩\]

and for the interaction case by

\[X = \sum_{ijkl} a_i^† a_j^† a_k a_l ⟨u_i|⟨u_j| x |u_k⟩|u_l⟩\]

where $X$ is the N-particle operator, $x$ is the one-body operator and $|u⟩$ are the one-body states associated to the different modes of the N-particle basis.

source

Direct sum

QuantumInterface.directsumFunction
directsum(b1::Basis, b2::Basis)

Construct the SumBasis out of two sub-bases.

source
directsum(x::Ket, y::Ket)

Construct a spinor via the directsum of two Kets. The result is a Ket with data given by [x.data;y.data] and its basis given by the corresponding SumBasis. NOTE: The resulting state is not normalized!

source
directsum(x::DataOperator, y::DataOperator)

Compute the direct sum of two operators. The result is an operator on the corresponding SumBasis.

source
QuantumOpticsBase.getblockFunction
getblock(x::Ket{<:SumBasis}, i)

For a Ket defined on a SumBasis, get the state as it is defined on the ith sub-basis.

source
getblock(op::Operator{<:SumBasis,<:SumBasis}, i, j)

Get the sub-basis operator corresponding to the block (i,j) of op.

source
QuantumOpticsBase.setblock!Function
setblock!(x::Ket{<:SumBasis}, val::Ket, i)

Set the data of x on the ith sub-basis equal to the data of val.

source
setblock!(op::DataOperator{<:SumBasis,<:SumBasis}, val::DataOperator, i, j)

Set the data of op corresponding to the block (i,j) equal to the data of val.

source

Metrics

QuantumOpticsBase.tracenorm_hFunction
tracenorm_h(rho)

Trace norm of rho.

It uses the identity

\[T(ρ) = Tr\{\sqrt{ρ^† ρ}\} = \sum_i |λ_i|\]

where $λ_i$ are the eigenvalues of rho.

source
QuantumOpticsBase.tracenorm_nhFunction
tracenorm_nh(rho)

Trace norm of rho.

Note that in this case rho doesn't have to be represented by a square matrix (i.e. it can have different left-hand and right-hand bases).

It uses the identity

\[ T(ρ) = Tr\{\sqrt{ρ^† ρ}\} = \sum_i σ_i\]

where $σ_i$ are the singular values of rho.

source
QuantumOpticsBase.tracedistance_hFunction
tracedistance_h(rho, sigma)

Trace distance between rho and sigma.

It uses the identity

\[T(ρ,σ) = \frac{1}{2} Tr\{\sqrt{(ρ - σ)^† (ρ - σ)}\} = \frac{1}{2} \sum_i |λ_i|\]

where $λ_i$ are the eigenvalues of rho - sigma.

source
QuantumOpticsBase.tracedistance_nhFunction
tracedistance_nh(rho, sigma)

Trace distance between rho and sigma.

Note that in this case rho and sigma don't have to be represented by square matrices (i.e. they can have different left-hand and right-hand bases).

It uses the identity

\[ T(ρ,σ) = \frac{1}{2} Tr\{\sqrt{(ρ - σ)^† (ρ - σ)}\} = \frac{1}{2} \sum_i σ_i\]

where $σ_i$ are the singular values of rho - sigma.

source
QuantumOpticsBase.entropy_vnFunction
entropy_vn(rho)

Von Neumann entropy of a density matrix.

The Von Neumann entropy of a density operator is defined as

\[S(ρ) = -Tr(ρ \log(ρ)) = -\sum_n λ_n\log(λ_n)\]

where $λ_n$ are the eigenvalues of the density matrix $ρ$, $\log$ is the natural logarithm and $0\log(0) ≡ 0$.

Arguments

  • rho: Density operator of which to calculate Von Neumann entropy.
  • tol=1e-15: Tolerance for rounding errors in the computed eigenvalues.
source
QuantumOpticsBase.entropy_renyiFunction
entropy_renyi(rho, α::Integer=2)

Renyi α-entropy of a density matrix, where r α≥0, α≂̸1.

The Renyi α-entropy of a density operator is defined as

\[S_α(ρ) = 1/(1-α) \log(Tr(ρ^α))\]

source
QuantumOpticsBase.fidelityFunction
fidelity(rho, sigma)

Fidelity of two density operators.

The fidelity of two density operators $ρ$ and $σ$ is defined by

\[F(ρ, σ) = Tr\left(\sqrt{\sqrt{ρ}σ\sqrt{ρ}}\right),\]

where $\sqrt{ρ}=\sum_n\sqrt{λ_n}|ψ⟩⟨ψ|$.

source
QuantumOpticsBase.ptransposeFunction
ptranspose(rho, indices)

Partial transpose of rho with respect to subsystem specified by indices.

The indices argument can be a single integer or a collection of integers.

source
QuantumOpticsBase.negativityFunction
negativity(rho, index)

Negativity of rho with respect to subsystem index.

The negativity of a density matrix ρ is defined as

\[N(ρ) = \frac{\|ρᵀ\|-1}{2},\]

where ρᵀ is the partial transpose.

source
QuantumOpticsBase.entanglement_entropyFunction
entanglement_entropy(state, partition, [entropy_fun=entropy_vn])

Computes the entanglement entropy of state between the list of sites partition and the rest of the system. The state must be defined in a composite basis.

If state isa AbstractOperator the operator-space entanglement entropy is computed, which has the property

entanglement_entropy(dm(ket)) = 2 * entanglement_entropy(ket)

By default the computed entropy is the Von-Neumann entropy, but a different function can be provided (for example to compute the entanglement-renyi entropy).

source

Time-evolution

Schroedinger

QuantumOptics.timeevolution.schroedingerFunction
timeevolution.schroedinger(tspan, psi0, H; fout)

Integrate Schroedinger equation to evolve states or compute propagators.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • psi0: Initial state vector (can be a bra or a ket) or an Operator from some basis to the basis of the Hamiltonian (psi0.basis_l == basis(H)).
  • H: Arbitrary operator specifying the Hamiltonian.
  • fout=nothing: If given, this function fout(t, psi) is called every time an output should be displayed. ATTENTION: The state psi is neither normalized nor permanent! It is still in use by the ode solver and therefore must not be changed.
source
QuantumOptics.timeevolution.schroedinger_dynamicFunction
timeevolution.schroedinger_dynamic(tspan, psi0, f; fout)

Integrate time-dependent Schroedinger equation to evolve states or compute propagators.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.

  • psi0: Initial state vector (can be a bra or a ket) or an Operator from some basis to the basis of the Hamiltonian (psi0.basis_l == basis(H)).

  • f: Function f(t, psi) -> H returning the time and or state dependent Hamiltonian.

  • fout=nothing: If given, this function fout(t, psi) is called every time an output should be displayed. ATTENTION: The state psi is neither normalized nor permanent! It is still in use by the ode solver and therefore must not be changed.

    timeevolution.schroedinger_dynamic(tspan, psi0, H::AbstractTimeDependentOperator; fout)

Instead of a function f, this takes a time-dependent operator H.

source

Master

QuantumOptics.timeevolution.masterFunction
timeevolution.master(tspan, rho0, H, J; <keyword arguments>)

Time-evolution according to a master equation.

There are two implementations for integrating the master equation:

  • master_h: Usual formulation of the master equation.
  • master_nh: Variant with non-hermitian Hamiltonian.

For dense arguments the master function calculates the non-hermitian Hamiltonian and then calls master_nh which is slightly faster.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • rho0: Initial density operator. Can also be a state vector which is automatically converted into a density operator.
  • H: Arbitrary operator specifying the Hamiltonian.
  • J: Vector containing all jump operators which can be of any arbitrary operator type.
  • rates=nothing: Vector or matrix specifying the coefficients (decay rates) for the jump operators. If nothing is specified all rates are assumed to be 1.
  • Jdagger=dagger.(J): Vector containing the hermitian conjugates of the jump operators. If they are not given they are calculated automatically.
  • fout=nothing: If given, this function fout(t, rho) is called every time an output should be displayed. ATTENTION: The given state rho is not permanent! It is still in use by the ode solver and therefore must not be changed.
  • kwargs...: Further arguments are passed on to the ode solver.
source
timeevolution.master(tspan, rho0, L; <keyword arguments>)

Time-evolution according to a master equation with a Liouvillian superoperator L.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • rho0: Initial density operator. Can also be a state vector which is automatically converted into a density operator.
  • L: Superoperator defining the right-hand-side of the master equation.
  • fout=nothing: If given, this function fout(t, rho) is called every time an output should be displayed. ATTENTION: The given state rho is not permanent! It is still in use by the ode solver and therefore must not be changed.
  • kwargs...: Further arguments are passed on to the ode solver.

See also: master_dynamic

source
QuantumOptics.timeevolution.master_nhFunction
timeevolution.master_nh(tspan, rho0, H, J; <keyword arguments>)

Integrate the master equation with dmaster_nh as derivative function.

In this case the given Hamiltonian is assumed to be the non-hermitian version:

\[H_{nh} = H - \frac{i}{2} \sum_k J^†_k J_k\]

Further information can be found at master.

source
QuantumOptics.timeevolution.master_dynamicFunction
timeevolution.master_dynamic(tspan, rho0, f; <keyword arguments>)

Time-evolution according to a master equation with a dynamic Hamiltonian and J.

There are two implementations for integrating the master equation with dynamic operators:

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.

  • rho0: Initial density operator. Can also be a state vector which is automatically converted into a density operator.

  • f: Function f(t, rho) -> (H, J, Jdagger) or f(t, rho) -> (H, J, Jdagger, rates)

  • rates=nothing: Vector or matrix specifying the coefficients (decay rates) for the jump operators. If nothing is specified all rates are assumed to be 1.

  • fout=nothing: If given, this function fout(t, rho) is called every time an output should be displayed. ATTENTION: The given state rho is not permanent! It is still in use by the ode solver and therefore must not be changed.

  • kwargs...: Further arguments are passed on to the ode solver.

    timeevolution.master_dynamic(tspan, rho0, H::AbstractTimeDependentOperator, J; <keyword arguments>)

This version takes the Hamiltonian H and jump operators J as time-dependent operators. The jump operators may be <: AbstractTimeDependentOperator or other types of operator.

source
QuantumOptics.timeevolution.master_nh_dynamicFunction
timeevolution.master_dynamic(tspan, rho0, f; <keyword arguments>)

Time-evolution according to a master equation with a dynamic non-hermitian Hamiltonian and J.

In this case the given Hamiltonian is assumed to be the non-hermitian version.

\[H_{nh} = H - \frac{i}{2} \sum_k J^†_k J_k\]

The given function can either be of the form f(t, rho) -> (Hnh, Hnhdagger, J, Jdagger) or f(t, rho) -> (Hnh, Hnhdagger, J, Jdagger, rates) For further information look at master_dynamic.

timeevolution.master_dynamic(tspan, rho0, Hnh::AbstractTimeDependentOperator, J; <keyword arguments>)

This version takes the non-hermitian Hamiltonian Hnh and jump operators J as time-dependent operators. The jump operators may be <: AbstractTimeDependentOperator or other types of operator.

source

Monte Carlo wave function

QuantumOptics.timeevolution.mcwfFunction
mcwf(tspan, psi0, H, J; <keyword arguments>)

Integrate the master equation using the MCWF method.

There are two implementations for integrating the non-hermitian schroedinger equation:

  • mcwf_h: Usual formulation with Hamiltonian + jump operators

separately.

  • mcwf_nh: Variant with non-hermitian Hamiltonian.

The mcwf function takes a normal Hamiltonian, calculates the non-hermitian Hamiltonian and then calls mcwf_nh which is slightly faster.

Arguments

  • tspan: Vector specifying the points of time for which output should

be displayed.

  • psi0: Initial state vector.
  • H: Arbitrary Operator specifying the Hamiltonian.
  • J: Vector containing all jump operators which can be of any arbitrary

operator type.

  • seed=rand(): Seed used for the random number generator.
  • rates=ones(): Vector of decay rates.
  • fout: If given, this function fout(t, psi) is called every time an

output should be displayed. ATTENTION: The state psi is neither normalized nor permanent! It is still in use by the ode solve and therefore must not be changed.

  • Jdagger=dagger.(J): Vector containing the hermitian conjugates of the jump

operators. If they are not given they are calculated automatically.

  • display_beforeevent=false: fout is called before every jump.
  • display_afterevent=false: fout is called after every jump.
  • rng_state=nothing: An optional timeevolution.JumpRNGState, providing the RNG and an initial jump threshold. If provided,seed` is ignored.
  • display_jumps=false: If set to true, an additional list of times and indices

is returned. These correspond to the times at which a jump occured and the index of the jump operators with which the jump occured, respectively.

  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.timeevolution.mcwf_nhFunction
mcwf_nh(tspan, rho0, Hnh, J; <keyword arguments>)

Calculate MCWF trajectory where the Hamiltonian is given in non-hermitian form.

\[H_{nh} = H - \frac{i}{2} \sum_k J^†_k J_k\]

For more information see: mcwf

source
QuantumOptics.timeevolution.mcwf_dynamicFunction
mcwf_dynamic(tspan, psi0, f; <keyword arguments>)

Integrate the master equation using the MCWF method with dynamic Hamiltonian and Jump operators.

The mcwf function takes a normal Hamiltonian, calculates the non-hermitian Hamiltonian and then calls mcwf_nh which is slightly faster.

Arguments

  • tspan: Vector specifying the points of time for which output should

be displayed.

  • psi0: Initial state vector.
  • f: Function f(t, psi) -> (H, J, Jdagger) or f(t, psi) -> (H, J, Jdagger, rates) that returns the time-dependent Hamiltonian and Jump operators.
  • seed=rand(): Seed used for the random number generator.
  • rates=ones(): Vector of decay rates.
  • fout: If given, this function fout(t, psi) is called every time an

output should be displayed. ATTENTION: The state psi is neither normalized nor permanent! It is still in use by the ode solve and therefore must not be changed.

  • display_beforeevent=false: fout is called before every jump.
  • display_afterevent=false: fout is called after every jump.
  • rng_state=nothing: An optional timeevolution.JumpRNGState, providing the RNG and an initial jump threshold. If provided,seed` is ignored.
  • display_jumps=false: If set to true, an additional list of times and indices

is returned. These correspond to the times at which a jump occured and the index of the jump operators with which the jump occured, respectively.

  • kwargs...: Further arguments are passed on to the ode solver.

    mcwf_dynamic(tspan, psi0, H::AbstractTimeDependentOperator, J; <keyword arguments>)

This version takes the Hamiltonian H and jump operators J as time-dependent operators. The jump operators may be <: AbstractTimeDependentOperator or other types of operator.

source
QuantumOptics.timeevolution.mcwf_nh_dynamicFunction
mcwf_nh_dynamic(tspan, rho0, f; <keyword arguments>)
mcwf_nh_dynamic(tspan, rho0, Hnh::AbstractTimeDependentOperator, J; <keyword arguments>)

Calculate MCWF trajectory where the dynamic Hamiltonian is given in non-hermitian form.

For more information see: mcwf_dynamic

source
QuantumOptics.timeevolution.diagonaljumpsFunction
diagonaljumps(rates, J)

Diagonalize jump operators.

The given matrix rates of decay rates is diagonalized and the corresponding set of jump operators is calculated.

Arguments

  • rates: Matrix of decay rates.
  • J: Vector of jump operators.
source

Bloch-Redfield master

QuantumOptics.timeevolution.bloch_redfield_tensorFunction
bloch_redfield_tensor(H, a_ops; J=[], use_secular=true, secular_cutoff=0.1)

Create the super-operator for the Bloch-Redfield master equation such that $\dot ρ = R ρ$ based on the QuTiP implementation.

See QuTiP's documentation (http://qutip.org/docs/latest/guide/dynamics/dynamics-bloch-redfield.html) for more information and a brief derivation.

Arguments

  • H: Hamiltonian.
  • a_ops: Nested list of [interaction operator, callback function] pairs for the Bloch-Redfield type processes where the callback function describes the environment spectrum for the corresponding interaction operator. The spectral functions must take the angular frequency as their only argument.
  • J=[]: Vector containing the jump operators for the Linblad type processes (optional).
  • use_secular=true: Specify whether or not to use the secular approximation.
  • secular_cutoff=0.1: Cutoff to allow a degree of partial secularization. Terms are discarded if they are greater than (dw_min * secular cutoff) where dw_min is the smallest (non-zero) difference between any two eigenenergies of H. This argument is only taken into account if use_secular=true.
source
QuantumOptics.timeevolution.master_bloch_redfieldFunction
timeevolution.master_bloch_redfield(tspan, rho0, R, H; <keyword arguments>)

Time-evolution according to a Bloch-Redfield master equation.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • rho0: Initial density operator. Can also be a state vector which is automatically converted into a density operator.
  • H: Arbitrary operator specifying the Hamiltonian.
  • R: Bloch-Redfield tensor describing the time-evolution $\dot ρ = R ρ$ (see timeevolution.bloch_redfield_tensor).
  • fout=nothing: If given, this function fout(t, rho) is called every time an output should be displayed. ATTENTION: The given state rho is not permanent! It is still in use by the ode solver and therefore must not be changed.
  • kwargs...: Further arguments are passed on to the ode solver.
source

Spectral analysis

QuantumOptics.eigenstatesFunction
eigenstates(op::Operator[, n::Int; warning=true, kw...])

Calculate the lowest n eigenvalues and their corresponding eigenstates. By default n is equal to the matrix size for dense matrices; for sparse matrices the default value is 6.

This is just a thin wrapper around julia's LinearArgebra.eigen and KrylovKit.eigsolve functions. Which of them is used depends on the type of the given operator. If more control about the way the calculation is done is needed, use the method instance with DiagStrategy (see below).

NOTE: Especially for small systems full diagonalization with Julia's eigen function is often more desirable. You can convert a sparse operator A to a dense one using dense(A).

If the given operator is non-hermitian a warning is given. This behavior can be turned off using the keyword warning=false.

Optional arguments

  • n: It can be a keyword argument too!
  • v0: The starting vector for Arnoldi-like iterative methods.
  • krylovdim: The upper bound for dimenstion count of the emerging Krylov space.
source
eigenstates(op::Operator, ds::DiagStrategy[; warning=true, kw...])

Calculate the lowest eigenvalues and their corresponding eigenstates of the op operator using the ds diagonalization strategy. The kw... arguments can be passed to the exact function that does the diagonalization (like KrylovKit.eigsolve).

source
QuantumOptics.eigenenergiesFunction
eigenenergies(op::AbstractOperator[, n::Int; warning=true, kwargs...])

Calculate the lowest n eigenvalues of given operator.

If the given operator is non-hermitian a warning is given. This behavior can be turned off using the keyword warning=false.

See eigenstates for more info.

source
QuantumOptics.simdiagFunction
simdiag(ops; atol, rtol)

Simultaneously diagonalize commuting Hermitian operators specified in ops.

This is done by diagonalizing the sum of the operators. The eigenvalues are computed by $a = ⟨ψ|A|ψ⟩$ and it is checked whether the eigenvectors fulfill the equation $A|ψ⟩ = a|ψ⟩$.

Arguments

  • ops: Vector of sparse or dense operators.
  • atol=1e-14: kwarg of Base.isapprox specifying the tolerance of the approximate check
  • rtol=1e-14: kwarg of Base.isapprox specifying the tolerance of the approximate check

Returns

  • evals_sorted: Vector containing all vectors of the eigenvalues sorted by the eigenvalues of the first operator.
  • v: Common eigenvectors.
source

Steady-states

QuantumOptics.steadystate.masterFunction
steadystate.master(H, J; <keyword arguments>)

Calculate steady state using long time master equation evolution.

Arguments

  • H: Arbitrary operator specifying the Hamiltonian.
  • J: Vector containing all jump operators which can be of any arbitrary operator type.
  • rho0=dm(basisstate(b)): Initial density operator. If not given the $|0⟩⟨0|$ state in respect to the choosen basis is used.
  • tol=1e-3: Tracedistance used as termination criterion.
  • hmin=1e-7: Minimal time step used in the time evolution.
  • rates=ones(N): Vector or matrix specifying the coefficients for the jump operators.
  • Jdagger=dagger.(Jdagger): Vector containing the hermitian conjugates of the jump operators. If they are not given they are calculated automatically.
  • fout=nothing: If given this function fout(t, rho) is called every time an output should be displayed. To limit copying to a minimum the given density operator rho is further used and therefore must not be changed.
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.steadystate.eigenvectorFunction
steadystate.eigenvector(L)
steadystate.eigenvector(H, J)

Find steady state by calculating the eigenstate with eigenvalue 0 of the Liouvillian matrix L, if it exists.

Keyword arguments:

  • tol = 1e-9: Check abs(eigenvalue) < tol to determine zero eigenvalue.
  • nev = 2: Number of calculated eigenvalues. If nev > 1 it is checked if there is only one eigenvalue with real part 0. No checks for nev = 1: use if faster or for avoiding convergence errors of eigs. Changing nev thus only makes sense when using SparseSuperOperator.
  • which = :LR: Find eigenvalues with largest real part. Keyword for eigs function (ineffective for DenseSuperOperator).
  • kwargs...: Keyword arguments for the Julia eigen or eigs function.
source
QuantumOptics.steadystate.liouvillianspectrumFunction
steadystate.liouvillianspectrum(L)
steadystate.liouvillianspectrum(H, J)

Calculate eigenspectrum of the Liouvillian matrix L. The eigenvalues and -states are sorted according to the absolute value of the eigenvalues.

Keyword arguments:

  • nev = min(10, length(L.basis_r[1])*length(L.basis_r[2])): Number of eigenvalues.
  • which = :LR: Find eigenvalues with largest real part. Keyword for eigs function (ineffective for DenseSuperOperator).
  • kwargs...: Keyword arguments for the Julia eigen or eigens function.
source
QuantumOptics.steadystate.iterativeFunction
iterative(H, J, [method!], args...; [log=false], kwargs...) -> rho[, log]

Compute the steady state density matrix of master equation defined by a Hamiltonian and a set of jump operators by solving L rho = 0 via an iterative method provided as argument.

Arguments

  • rho0: Initial density matrix. Note that this gets mutated in-place.
  • H: Operator specifying the Hamiltonian.
  • J: Vector containing all jump operators.
  • method!: The iterative method to be used. Defaults to IterativeSolvers.bicgstabl!.
  • rates=nothing: Vector or matrix specifying the coefficients (decay rates) for the jump operators. If nothing is specified all rates are assumed to be 1.
  • Jdagger=dagger.(J): Vector containing the hermitian conjugates of the jump operators. If they are not given they are calculated automatically.
  • rho0=nothing: Initial density operator.
  • args...: Further arguments are passed on to the iterative solver.
  • kwargs...: Further keyword arguments are passed on to the iterative solver.

See also: iterative!

Credit for this implementation goes to Z. Denis and F. Vicentini. See also https://github.com/Z-Denis/SteadyState.jl

source
QuantumOptics.steadystate.iterative!Function
iterative!(rho0, H, J, [method!], args...; [log=false], kwargs...) -> rho[, log]

Compute the steady state density matrix of master equation defined by a Hamiltonian and a set of jump operators by solving L rho = 0 via an iterative method provided as argument.

Arguments

  • rho0: Initial density matrix. Note that this gets mutated in-place.
  • H: Operator specifying the Hamiltonian.
  • J: Vector containing all jump operators.
  • method!: The iterative method to be used. Defaults to IterativeSolvers.bicgstabl!.
  • rates=nothing: Vector or matrix specifying the coefficients (decay rates) for the jump operators. If nothing is specified all rates are assumed to be 1.
  • Jdagger=dagger.(J): Vector containing the hermitian conjugates of the jump operators. If they are not given they are calculated automatically.
  • args...: Further arguments are passed on to the iterative solver.
  • kwargs...: Further keyword arguments are passed on to the iterative solver.

See also: iterative

Credit for this implementation goes to Z. Denis and F. Vicentini. See also https://github.com/Z-Denis/SteadyState.jl

source

Time correlations

QuantumOptics.timecorrelations.correlationFunction
timecorrelations.correlation([tspan, ]rho0, H, J, A, B; <keyword arguments>)

Calculate two time correlation values $⟨A(t)B(0)⟩$.

The calculation is done by multiplying the initial density operator with $B$ performing a time evolution according to a master equation and then calculating the expectation value $\mathrm{Tr} \{A ρ\}$

Without the tspan argument the points in time are chosen automatically from the ode solver and the final time is determined by the steady state termination criterion specified in steadystate.master.

Arguments

  • tspan: Points of time at which the correlation should be calculated.
  • rho0: Initial density operator.
  • H: Operator specifying the Hamiltonian.
  • J: Vector of jump operators.
  • A: Operator at time t.
  • B: Operator at time t=0.
  • rates=ones(N): Vector or matrix specifying the coefficients (decay rates) for the jump operators.
  • Jdagger=dagger.(J): Vector containing the hermitian conjugates of the jump
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.timecorrelations.spectrumFunction
timecorrelations.spectrum([omega_samplepoints,] H, J, op; <keyword arguments>)

Calculate spectrum as Fourier transform of a correlation function

This is done with the Wiener-Khinchin theorem

\[S(ω, t) = 2\Re\left\{\int_0^{∞} dτ e^{-iωτ}⟨A^†(t+τ)A(t)⟩\right\}\]

The argument omega_samplepoints gives the list of frequencies where $S(ω)$ is caclulated. A corresponding list of times is calculated internally by means of a inverse discrete frequency fourier transform. If not given, the steady-state is computed before calculating the auto-correlation function.

Without the omega_samplepoints arguments the frequencies are chosen automatically.

Arguments

  • omega_samplepoints: List of frequency points at which the spectrum is calculated.
  • H: Operator specifying the Hamiltonian.
  • J: Vector of jump operators.
  • op: Operator for which the auto-correlation function is calculated.
  • rho0: Initial density operator.
  • tol=1e-4: Tracedistance used as termination criterion.
  • rates=ones(N): Vector or matrix specifying the coefficients for the jump operators.
  • Jdagger=dagger.(J): Vector containing the hermitian conjugates of the jump operators. If they are not given they are calculated automatically.
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.timecorrelations.correlation2spectrumFunction
timecorrelations.correlation2spectrum(tspan, corr; normalize_spec)

Calculate spectrum as Fourier transform of a correlation function with a given correlation function.

Arguments

  • tspan: List of time points corresponding to the correlation function.
  • corr: Correlation function of which the Fourier transform is to be calculated.
  • normalize_spec: Specify if spectrum should be normalized to its maximum.
source
QuantumOptics.timecorrelations.correlation_dynamicFunction
timecorrelations.correlation_dynamic(tspan, rho0, f, A, B; <keyword arguments>)

Calculate two time correlation values $⟨A(t)B(0)⟩$ for time-dependent Liouvillian

The calculation is done by multiplying the initial density operator with $B$ performing a time evolution according to a master equation and then calculating the expectation value $\mathrm{Tr} \{A ρ\}$

Arguments

  • tspan: Points of time at which the correlation should be calculated.
  • rho0: Initial density operator.
  • f: Function f(t, rho) -> (H, J, Jdagger) or f(t, rho) -> (H, J, Jdagger, rates)
  • A: Operator at time t.
  • B: Operator at time t=0.
  • rates=ones(N): Vector or matrix specifying the coefficients (decay rates) for the jump operators.
  • kwargs...: Further arguments are passed on to the ode solver.
source

Semi-classical

QuantumOptics.semiclassical.StateType

Semi-classical state.

It consists of a quantum part, which is either a Ket or a DenseOperator and a classical part that is specified as a complex vector of arbitrary length.

source
QuantumOptics.semiclassical.schroedinger_dynamicFunction
semiclassical.schroedinger_dynamic(tspan, state0, fquantum, fclassical[; fout, ...])

Integrate time-dependent Schrödinger equation coupled to a classical system.

Arguments

  • tspan: Vector specifying the points of time for which the output should be displayed.
  • psi0: Initial semi-classical state semiclassical.State.
  • fquantum: Function f(t, psi, u) -> H returning the time and or state dependent Hamiltonian.
  • fclassical!: Function f!(du, u, psi, t) calculating the possibly time and state dependent derivative of the classical equations and storing it in the vector du.
  • fout=nothing: If given, this function fout(t, state) is called every time an output should be displayed. ATTENTION: The given state is neither normalized nor permanent!
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.semiclassical.master_dynamicFunction
semiclassical.master_dynamic(tspan, state0, fquantum, fclassical!; <keyword arguments>)

Integrate time-dependent master equation coupled to a classical system.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • rho0: Initial semi-classical state semiclassical.State.
  • fquantum: Function f(t, rho, u) -> (H, J, Jdagger) returning the time and/or state dependent Hamiltonian and Jump operators.
  • fclassical!: Function f!(du, u, rho, t) calculating the possibly time and state dependent derivative of the classical equations and storing it in the complex vector du.
  • fout=nothing: If given, this function fout(t, state) is called every time an output should be displayed. ATTENTION: The given state is not permanent!
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.semiclassical.mcwf_dynamicFunction
semiclassical.mcwf_dynamic(tspan, psi0, fquantum, fclassical!, fjump_classical!; <keyword arguments>)

Calculate MCWF trajectories coupled to a classical system. NOTE: The quantum state with which fquantum and fclassical! are called is NOT NORMALIZED. Make sure to take this into account when computing expectation values!

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • psi0: Initial semi-classical state semiclassical.State featuring a Ket(@ref).
  • fquantum: Function f(t, psi, u) -> (H, J, Jdagger) returning the time and/or state dependent Hamiltonian and Jump operators.
  • fclassical!: Function f!(du, u, psi, t) calculating the possibly time and state dependent derivative of the classical equations and storing it in the complex vector du.
  • fjump_classical!: Function f(t, psi, u, i) performing a classical jump when a quantum jump of the i-th jump operator occurs.
  • fout=nothing: If given, this function fout(t, state) is called every time an output should be displayed. ATTENTION: The given state is not permanent!
  • display_beforeevent: Choose whether or not an additional point should be saved before a jump occurs. Default is false.
  • display_afterevent: Choose whether or not an additional point should be saved after a jump occurs. Default is false.
  • display_jumps=false: If set to true, an additional list of times and indices is returned. These correspond to the times at which a jump occured and the index of the jump operators with which the jump occured, respectively.
  • kwargs...: Further arguments are passed on to the ode solver.
source

Stochastics

QuantumOptics.stochastic.schroedingerFunction
stochastic.schroedinger(tspan, state0, H, Hs[; fout, ...])

Integrate stochastic Schrödinger equation.

Arguments

  • tspan: Vector specifying the points of time for which the output should be displayed.
  • psi0: Initial state as Ket.
  • H: Deterministic part of the Hamiltonian.
  • Hs: Stochastic part(s) of the Hamiltonian (either an operator or a vector of operators).
  • fout=nothing: If given, this function fout(t, state) is called every time an output should be displayed. ATTENTION: The given state is neither normalized nor permanent!
  • normalize_state=false: Specify whether or not to normalize the state after each time step taken by the solver.
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.stochastic.schroedinger_dynamicFunction
stochastic.schroedinger_dynamic(tspan, state0, fdeterm, fstoch[; fout, ...])

Integrate stochastic Schrödinger equation with dynamic Hamiltonian.

Arguments

  • tspan: Vector specifying the points of time for which the output should be displayed.
  • psi0: Initial state.
  • fdeterm: Function f(t, psi, u) -> H returning the deterministic (time- or state-dependent) part of the Hamiltonian.
  • fstoch: Function f(t, psi, u, du) -> Hs returning a vector that contains the stochastic terms of the Hamiltonian.
  • fout=nothing: If given, this function fout(t, state) is called every time an output should be displayed. ATTENTION: The given state is neither normalized nor permanent!
  • noise_processes=0: Number of distinct white-noise processes in the equation. This number has to be equal to the total number of noise operators returned by fstoch. If unset, the number is calculated automatically from the function output. NOTE: Set this number if you want to avoid an initial calculation of the function output!
  • normalize_state=false: Specify whether or not to normalize the state after each time step taken by the solver.
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.stochastic.homodyne_carmichaelFunction
stochastic.homodyne_carmichael(H0, C, theta)

Helper function that defines the functions needed to compute homodyne detection trajectories according to Carmichael with stochastic.schroedinger_dynamic.

Arguments

  • H0: The deterministic, time-independent system Hamiltonian.
  • C: Collapse operator (or vector of operators) of the detected output channel(s).
  • theta: The phase difference between the local oscillator and the signal field. Defines the operator of the measured quadrature as $X_\theta = C e^{-i\theta} + C^\dagger e^{i\theta}$. Needs to be a vector of the same length as C if C is a vector.
  • normalize_expect=true: Specifiy whether or not to normalize the state vector when the expectation value in the nonlinear term is calculated. NOTE: should only be set to false if the state is guaranteed to be normalized, e.g. by setting normalize_state=true in stochastic.schroedinger_dynamic.

Returns (fdeterm, fstoch), where fdeterm(t, psi) -> H and fstoch(t, psi) -> Hs are functions returning the deterministic and stochastic part of the Hamiltonian required for calling stochastic.schroedinger_dynamic.

The deterministic and stochastic parts of the Hamiltonian are constructed as

\[H_{det} = H_0 + H_{nl},\]

where

\[H_{nl} = iCe^{-i\theta} \langle X_\theta \rangle - \frac{i}{2} C^\dagger C,\]

and

\[H_s = iCe^{-i\theta}.\]

source
QuantumOptics.stochastic.masterFunction
stochastic.master(tspan, rho0, H, J, C; <keyword arguments>)

Time-evolution according to a stochastic master equation.

For dense arguments the master function calculates the non-hermitian Hamiltonian and then calls master_nh which is slightly faster.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • rho0: Initial density operator. Can also be a state vector which is automatically converted into a density operator.
  • H: Deterministic part of the Hamiltonian.
  • J: Vector containing all deterministic jump operators which can be of any arbitrary operator type.
  • C: Vector containing the stochastic operators for a superoperator of the form C[i]*rho + rho*Cdagger[i].
  • rates=nothing: Vector or matrix specifying the coefficients (decay rates) for the jump operators. If nothing is specified all rates are assumed to be 1.
  • Jdagger=dagger.(J): Vector containing the hermitian conjugates of the jump operators. If they are not given they are calculated automatically.
  • fout=nothing: If given, this function fout(t, rho) is called every time an output should be displayed. ATTENTION: The given state rho is not permanent! It is still in use by the ode solver and therefore must not be changed.
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.stochastic.master_dynamicFunction
stochastic.master_dynamic(tspan, rho0, fdeterm, fstoch; <keyword arguments>)

Time-evolution according to a stochastic master equation with a dynamic Hamiltonian and J.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • rho0: Initial density operator. Can also be a state vector which is automatically converted into a density operator.
  • fdeterm: Function f(t, rho) -> (H, J, Jdagger) or f(t, rho) -> (H, J, Jdagger, rates) giving the deterministic part of the master equation.
  • fstoch: Function f(t, rho) -> (C, Cdagger) giving the stochastic superoperator of the form C[i]*rho + rho*Cdagger[i].
  • rates=nothing: Vector or matrix specifying the coefficients (decay rates) for the jump operators. If nothing is specified all rates are assumed to be 1.
  • fout=nothing: If given, this function fout(t, rho) is called every time an output should be displayed. ATTENTION: The given state rho is not permanent! It is still in use by the ode solver and therefore must not be changed.
  • noise_processes=0: Number of distinct white-noise processes in the equation. This number has to be equal to the total number of noise operators returned by fstoch and all optional functions. If unset, the number is calculated automatically from the function outputs. NOTE: Set this number if you want to avoid an initial calculation of function outputs!
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.stochastic.schroedinger_semiclassicalFunction
stochastic.schroedinger_semiclassical(tspan, state0, fquantum, fclassical![; fout, ...])

Integrate time-dependent Schrödinger equation coupled to a classical system.

Arguments

  • tspan: Vector specifying the points of time for which the output should be displayed.
  • state0: Initial semi-classical state semiclassical.State.
  • fquantum: Function f(t, psi, u) -> H returning the time and or state dependent Hamiltonian.
  • fclassical!: Function f!(du, u, psi ,t) calculating the possibly time and state dependent derivative of the classical equations and storing it in the vector du.
  • fstoch_quantum=nothing: Function f(t, psi, u) -> Hs that returns a vector of operators corresponding to the stochastic terms of the Hamiltonian. NOTE: Either this function or fstoch_classical has to be defined.
  • fstoch_classical=nothing: Function f!(du, u, psi, t) that calculates the stochastic terms of the derivative du. NOTE: Either this function or fstoch_quantum has to be defined.
  • fout=nothing: If given, this function fout(t, state) is called every time an output should be displayed. ATTENTION: The given state is neither normalized nor permanent!
  • noise_processes=0: Number of distinct quantum noise processes in the equation. This number has to be equal to the total number of noise operators returned by fstoch. If unset, the number is calculated automatically from the function output. NOTE: Set this number if you want to avoid an initial calculation of the function output!
  • noise_prototype_classical=nothing: The equivalent of the optional argument noise_rate_prototype in StochasticDiffEq for the classical stochastic function fstoch_classical only. Must be set for non-diagonal classical noise or combinations of quantum and classical noise. See the documentation for details.
  • normalize_state=false: Specify whether or not to normalize the state after each time step taken by the solver.
  • kwargs...: Further arguments are passed on to the ode solver.
source
QuantumOptics.stochastic.master_semiclassicalFunction
stochastic.master_semiclassical(tspan, rho0, H, Hs, J; <keyword arguments>)

Time-evolution according to a stochastic master equation. For dense arguments the master function calculates the non-hermitian Hamiltonian and then calls master_nh which is slightly faster.

Arguments

  • tspan: Vector specifying the points of time for which output should be displayed.
  • rho0: Initial density operator. Can also be a state vector which is automatically converted into a density operator.
  • fquantum: Function f(t, rho, u) -> (H, J, Jdagger) or f(t, rho, u) -> (H, J, Jdagger, rates) giving the deterministic part of the master equation.
  • fclassical!: Function f!(du, u, rho, t) that calculates the classical derivatives du.
  • fstoch_quantum=nothing: Function f(t, rho, u) -> C, Cdagger that returns the stochastic operator for the superoperator of the form C[i]*rho + rho*Cdagger[i].
  • fstoch_classical=nothing: Function f!(du, u, rho, t) that calculates the stochastic terms of the derivative du.
  • rates=nothing: Vector or matrix specifying the coefficients (decay rates) for the jump operators. If nothing is specified all rates are assumed to be 1.
  • fout=nothing: If given, this function fout(t, rho) is called every time an output should be displayed. ATTENTION: The given state rho is not permanent! It is still in use by the ode solver and therefore must not be changed.
  • noise_processes=0: Number of distinct quantum noise processes in the equation. This number has to be equal to the total number of noise operators returned by fstoch. If unset, the number is calculated automatically from the function output. NOTE: Set this number if you want to avoid an initial calculation of the function output!
  • noise_prototype_classical=nothing: The equivalent of the optional argument noise_rate_prototype in StochasticDiffEq for the classical stochastic function fstoch_classical only. Must be set for non-diagonal classical noise or combinations of quantum and classical noise. See the documentation for details.
  • kwargs...: Further arguments are passed on to the ode solver.
source

State definitions

QuantumOpticsBase.passive_stateFunction
passive_state(rho,IncreasingEigenenergies=true)

Passive state $π$ of $ρ$. IncreasingEigenenergies=true means that higher indices correspond to higher energies.

source

Pauli

QuantumInterface.PauliBasisType
PauliBasis(num_qubits::Int)

Basis for an N-qubit space where num_qubits specifies the number of qubits. The dimension of the basis is 2²ᴺ.

source

Printing

QuantumOpticsBase.set_printingFunction
QuantumOptics.set_printing(; standard_order, rounding_tol)

Set options for REPL output.

Arguments

  • standard_order=false: For performance reasons, the order of the tensor product is inverted, i.e. tensor(a, b)=kron(b, a). When changing this to true, the output shown in the REPL will exhibit the correct order.
  • rounding_tol=1e-17: Tolerance for floating point errors shown in the output.
source

LazyTensor functions

QuantumOpticsBase.lazytensor_enable_cacheFunction
lazytensor_enable_cache(; maxsize::Int = ..., maxrelsize::Real = ...)

(Re)-enable the cache for further use; set the maximal size maxsize (as number of bytes) or relative size maxrelsize, as a fraction between 0 and 1, resulting in maxsize = floor(Int, maxrelsize * Sys.total_memory()). Default value is maxsize = 2^32 bytes, which amounts to 4 gigabytes of memory.

source