API
Types
- General basis types. Specialized bases can be found in the section API: Quantum-systems.
QuantumInterface.Basis
— TypeAbstract 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.
QuantumInterface.GenericBasis
— TypeGenericBasis(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.
QuantumInterface.CompositeBasis
— TypeCompositeBasis(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.
- States
QuantumInterface.StateVector
— TypeAbstract 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.
QuantumOpticsBase.Bra
— TypeBra(b::Basis[, data])
Bra state defined by coefficients in respect to the basis.
QuantumOpticsBase.Ket
— TypeKet(b::Basis[, data])
Ket state defined by coefficients in respect to the given basis.
- General purpose QuantumOpticsBase. A few more specialized operators are implemented in API: Quantum-systems.
QuantumInterface.AbstractOperator
— TypeAbstract 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.
QuantumOpticsBase.DataOperator
— TypeAbstract 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.
QuantumOpticsBase.Operator
— TypeOperator{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).
QuantumOpticsBase.DenseOperator
— FunctionDenseOperator(b1[, b2, data])
Dense array implementation of Operator. Converts any given data to a dense Matrix
.
QuantumOpticsBase.SparseOperator
— FunctionSparseOperator(b1[, b2, data])
Sparse array implementation of Operator.
The matrix is stored as the julia built-in type SparseMatrixCSC
in the data
field.
QuantumOpticsBase.LazyTensor
— TypeLazyTensor(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.
QuantumOpticsBase.LazySum
— TypeLazySum([Tf,] [factors,] operators)
+API · QuantumOpticsBase.jl API
Types
- General basis types. Specialized bases can be found in the section API: Quantum-systems.
QuantumInterface.Basis
— TypeAbstract 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.
QuantumInterface.GenericBasis
— TypeGenericBasis(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.
QuantumInterface.CompositeBasis
— TypeCompositeBasis(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.
- States
QuantumInterface.StateVector
— TypeAbstract 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.
QuantumOpticsBase.Bra
— TypeBra(b::Basis[, data])
Bra state defined by coefficients in respect to the basis.
sourceQuantumOpticsBase.Ket
— TypeKet(b::Basis[, data])
Ket state defined by coefficients in respect to the given basis.
source- General purpose QuantumOpticsBase. A few more specialized operators are implemented in API: Quantum-systems.
QuantumInterface.AbstractOperator
— TypeAbstract 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.
QuantumOpticsBase.DataOperator
— TypeAbstract 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.
sourceQuantumOpticsBase.Operator
— TypeOperator{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).
sourceQuantumOpticsBase.DenseOperator
— FunctionDenseOperator(b1[, b2, data])
Dense array implementation of Operator. Converts any given data to a dense Matrix
.
sourceQuantumOpticsBase.SparseOperator
— FunctionSparseOperator(b1[, b2, data])
Sparse array implementation of Operator.
The matrix is stored as the julia built-in type SparseMatrixCSC
in the data
field.
sourceQuantumOpticsBase.LazyTensor
— TypeLazyTensor(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.
sourceQuantumOpticsBase.LazySum
— TypeLazySum([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 LazySum
s, such as summing many LazySum
s together.
To convert a vector-based LazySum
x
to use a tuple for operator storage, use LazySum(::Tuple, x)
.
sourceQuantumOpticsBase.LazyProduct
— TypeLazyProduct(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- Time-dependent operators.
QuantumOpticsBase.AbstractTimeDependentOperator
— TypeAbstractTimeDependentOperator{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.
sourceQuantumOpticsBase.TimeDependentSum
— TypeTimeDependentSum(lazysum, coeffs, init_time)
+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 LazySum
s, such as summing many LazySum
s together.
To convert a vector-based LazySum
x
to use a tuple for operator storage, use LazySum(::Tuple, x)
.
sourceQuantumOpticsBase.LazyProduct
— TypeLazyProduct(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- Time-dependent operators.
QuantumOpticsBase.AbstractTimeDependentOperator
— TypeAbstractTimeDependentOperator{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.
sourceQuantumOpticsBase.TimeDependentSum
— TypeTimeDependentSum(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:
QuantumOpticsBase.SuperOperator
— TypeSuperOperator <: AbstractSuperOperator
SuperOperator stored as representation, e.g. as a Matrix.
sourceQuantumOpticsBase.DenseSuperOperator
— FunctionDenseSuperOperator(b1[, b2, data])
-DenseSuperOperator([T=ComplexF64,], b1[, b2])
SuperOperator stored as dense matrix.
sourceQuantumOpticsBase.SparseSuperOperator
— FunctionSparseSuperOperator(b1[, b2, data])
-SparseSuperOperator([T=ComplexF64,], b1[, b2])
SuperOperator stored as sparse matrix.
sourceFunctions
- Functions to generate general states, operators and super-operators
QuantumOpticsBase.basisstate
— Functionbasisstate([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.
sourcebasisstate([T=ComplexF64,] mb::ManyBodyBasis, occupation::Vector)
Return a ket state where the system is in the state specified by the given occupation numbers.
sourceQuantumOpticsBase.sparsebasisstate
— Functionsparsebasisstate([T=ComplexF64, ]b, index)
Sparse version of basisstate
.
sourceQuantumInterface.identityoperator
— Functionidentityoperator(a::Basis[, b::Basis])
+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:
QuantumOpticsBase.SuperOperator
— TypeSuperOperator <: AbstractSuperOperator
SuperOperator stored as representation, e.g. as a Matrix.
sourceQuantumOpticsBase.DenseSuperOperator
— FunctionDenseSuperOperator(b1[, b2, data])
+DenseSuperOperator([T=ComplexF64,], b1[, b2])
SuperOperator stored as dense matrix.
sourceQuantumOpticsBase.SparseSuperOperator
— FunctionSparseSuperOperator(b1[, b2, data])
+SparseSuperOperator([T=ComplexF64,], b1[, b2])
SuperOperator stored as sparse matrix.
sourceFunctions
- Functions to generate general states, operators and super-operators
QuantumOpticsBase.basisstate
— Functionbasisstate([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.
sourcebasisstate([T=ComplexF64,] mb::ManyBodyBasis, occupation::Vector)
Return a ket state where the system is in the state specified by the given occupation numbers.
sourceQuantumOpticsBase.sparsebasisstate
— Functionsparsebasisstate([T=ComplexF64, ]b, index)
Sparse version of basisstate
.
sourceQuantumInterface.identityoperator
— Functionidentityoperator(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.
QuantumOpticsBase.diagonaloperator
— Functiondiagonaloperator(b::Basis)
Create a diagonal operator of type SparseOperator
.
sourceQuantumOpticsBase.randoperator
— Functionrandoperator([T=ComplexF64,] b1[, b2])
Calculate a random unnormalized dense operator.
sourceQuantumOpticsBase.spre
— Functionspre(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.
sourceQuantumOpticsBase.spost
— Functionspost(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.
sourceQuantumOpticsBase.sprepost
— Functionsprepost(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.
sourceQuantumOpticsBase.liouvillian
— Functionliouvillian(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 superQuantumOpticsBase.
QuantumInterface.samebases
— Functionsamebases(a, b)
Test if two objects have the same bases.
QuantumInterface.check_samebases
— Functioncheck_samebases(a, b)
Throw an IncompatibleBases
error if the objects don't have the same bases.
QuantumInterface.@samebases
— Macro@samebases
Macro to skip checks for same bases. Useful for *
, expect
and similar functions.
QuantumInterface.multiplicable
— Functionmultiplicable(a, b)
Check if two objects are multiplicable.
QuantumInterface.check_multiplicable
— Functioncheck_multiplicable(a, b)
Throw an IncompatibleBases
error if the objects are not multiplicable.
QuantumInterface.basis
— Functionbasis(a)
Return the basis of an object.
If it's ambiguous, e.g. if an operator has a different left and right basis, an IncompatibleBases
error is thrown.
QuantumInterface.dagger
— Functiondagger(x)
Hermitian conjugate.
sourceQuantumInterface.tensor
— Functiontensor(x, y, z...)
Tensor product of the given objects. Alternatively, the unicode symbol ⊗ (\otimes) can be used.
QuantumInterface.projector
— Methodprojector(a::Ket, b::Bra)
Projection operator $|a⟩⟨b|$.
sourceQuantumInterface.projector
— Methodprojector(a::Ket)
Projection operator $|a⟩⟨a|$.
sourceQuantumInterface.projector
— Methodprojector(a::Bra)
Projection operator $|a⟩⟨a|$.
sourceQuantumOpticsBase.sparseprojector
— Functionsparseprojector([T,] b1, b2)
Sparse version of projector
.
sourceQuantumInterface.dm
— Functiondm(a::StateVector)
Create density matrix $|a⟩⟨a|$. Same as projector(a)
.
sourceLinearAlgebra.norm
— Methodnorm(x::StateVector)
Norm of the given bra or ket state.
LinearAlgebra.tr
— Functiontr(x::AbstractOperator)
Trace of the given operator.
QuantumInterface.ptrace
— Functionptrace(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.
LinearAlgebra.normalize
— Methodnormalize(x::StateVector)
Return the normalized state so that norm(x)
is one.
LinearAlgebra.normalize
— Methodnormalize(op)
Return the normalized operator so that its tr(op)
is one.
LinearAlgebra.normalize!
— Methodnormalize!(x::StateVector)
In-place normalization of the given bra or ket so that norm(x)
is one.
LinearAlgebra.normalize!
— Methodnormalize!(op)
In-place normalization of the given operator so that its tr(x)
is one.
QuantumInterface.expect
— Functionexpect(index, op, state)
If an index
is given, it assumes that op
is defined in the subsystem specified by this number.
expect(op, state)
Expectation value of the given operator op
for the specified state
.
state
can either be a (density) operator or a ket.
sourceQuantumInterface.variance
— Functionvariance(index, op, state)
If an index
is given, it assumes that op
is defined in the subsystem specified by this number
variance(op, state)
Variance of the given operator op
for the specified state
.
state
can either be a (density) operator or a ket.
sourceQuantumInterface.embed
— Functionembed(basis1[, basis2], operators::Dict)
operators
is a dictionary Dict{Vector{Int}, AbstractOperator}
. The integer vector specifies in which subsystems the corresponding operator is defined.
embed(basis1[, basis2], indices::Vector, operators::Vector)
Tensor product of operators where missing indices are filled up with identity operators.
embed(basis1[, basis2], indices::Vector, op::AbstractOperator)
Embed operator acting on a joint Hilbert space where missing indices are filled up with identity operators.
sourceembed(basis_l::SumBasis, basis_r::SumBasis,
- index::Integer, operator)
Embed an operator defined on a single subspace specified by the index
into a SumBasis
.
sourceembed(basis_l::SumBasis, basis_r::SumBasis,
- indices, operator)
Embed an operator defined on multiple subspaces specified by the indices
into a SumBasis
.
sourceembed(basis_l::SumBasis, basis_r::SumBasis,
- indices, operators)
Embed a list of operators on subspaces specified by the indices
into a SumBasis
.
sourceQuantumInterface.permutesystems
— Functionpermutesystems(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]
.
Base.exp
— Methodexp(op::AbstractOperator)
Operator exponential.
- Conversion of operators
QuantumOpticsBase.dense
— Functiondense(op::AbstractOperator)
Convert an arbitrary Operator into a DenseOperator
.
sourceSparseArrays.sparse
— Methodsparse(op::AbstractOperator)
Convert an arbitrary operator into a sparse one.
See also: QuantumOpticsBase.SparseOperator
- Time-dependent operators.
QuantumOpticsBase.current_time
— Functioncurrent_time(op::AbstractOperator)
Returns the current time of the operator op
. If op
is not time-dependent, this throws an ArgumentError
.
sourceQuantumOpticsBase.static_operator
— Functionstatic_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
.
sourceQuantumOpticsBase.set_time!
— Functionset_time!(o::AbstractOperator, t::Number)
Sets the clock of an operator (see AbstractTimeDependentOperator
). If o
contains other operators (e.g. in case o
is a LazyOperator
), recursively calls set_time!
on those.
This does nothing in case o
is not time-dependent.
sourceQuantumOpticsBase.time_shift
— Functiontime_shift(op::TimeDependentSum, t0)
Shift (translate) a TimeDependentSum
op
forward in time (delaying its action) by t0
units, so that the coefficient functions of time f(t)
become f(t-t0)
. Return a new TimeDependentSum
.
sourceQuantumOpticsBase.time_stretch
— Functiontime_stretch(op::TimeDependentSum, Sfactor)
Stretch (in time) a TimeDependentSum
op
by a factor of Sfactor
(making it 'longer'), so that the coefficient functions of time f(t)
become f(t/Sfactor)
. Return a new TimeDependentSum
.
sourceQuantumOpticsBase.time_restrict
— Functiontime_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
.
sourceExceptions
QuantumInterface.IncompatibleBases
— TypeException that should be raised for an illegal algebraic operation.
Quantum systems
Fock
QuantumInterface.FockBasis
— TypeFockBasis(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
.
QuantumOpticsBase.number
— Methodnumber([T=ComplexF64,] b::FockBasis)
Number operator for the specified Fock space with optional data type T
.
sourceQuantumOpticsBase.destroy
— Methoddestroy([T=ComplexF64,] b::FockBasis)
Annihilation operator for the specified Fock space with optional data type T
.
sourceQuantumOpticsBase.create
— Methodcreate([T=ComplexF64,] b::FockBasis)
Creation operator for the specified Fock space with optional data type T
.
sourceQuantumOpticsBase.displace
— Functiondisplace([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.
sourceQuantumOpticsBase.displace_analytical
— Functiondisplace_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.
sourcedisplace_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
.
sourceQuantumOpticsBase.displace_analytical!
— Functiondisplace_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)
sourceQuantumOpticsBase.squeeze
— Functionsqueeze([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.
sourcesqueeze([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.
sourceQuantumOpticsBase.fockstate
— Functionfockstate([T=ComplexF64,] b::FockBasis, n)
Fock state $|n⟩$ for the specified Fock space.
sourceQuantumOpticsBase.coherentstate
— Functioncoherentstate([T=ComplexF64,] b::FockBasis, alpha)
Coherent state $|α⟩$ for the specified Fock space.
sourceQuantumOpticsBase.coherentstate!
— Functioncoherentstate!(ket::Ket, b::FockBasis, alpha)
Inplace creation of coherent state $|α⟩$ for the specified Fock space.
sourceCharge
QuantumOpticsBase.ChargeBasis
— TypeChargeBasis(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.
sourceQuantumOpticsBase.ShiftedChargeBasis
— TypeShiftedChargeBasis(nmin, nmax) <: Basis
Basis spanning nmin, ..., nmax
charge states. See ChargeBasis
.
sourceQuantumOpticsBase.chargeop
— Functionchargeop([T=ComplexF64,] b::ChargeBasis)
-chargeop([T=ComplexF64,] b::ShiftedChargeBasis)
Return diagonal charge operator $N$ for given ChargeBasis
or ShiftedChargeBasis
.
sourceQuantumOpticsBase.expiφ
— Functionexpiφ([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
.
sourceQuantumOpticsBase.cosφ
— Functioncosφ([T=ComplexF64,] b::ChargeBasis; k=1)
-cosφ([T=ComplexF64,] b::ShiftedChargeBasis; k=1)
Return operator $\cos(k φ)$ for given charge basis. See expiφ
.
sourceQuantumOpticsBase.sinφ
— Functionsinφ([T=ComplexF64,] b::ChargeBasis; k=1)
-sinφ([T=ComplexF64,] b::ShiftedChargeBasis; k=1)
Return operator $\sin(k φ)$ for given charge basis. See expiφ
.
sourceN-level
QuantumInterface.NLevelBasis
— TypeNLevelBasis(N)
Basis for a system consisting of N states.
QuantumOpticsBase.transition
— Methodtransition([T=ComplexF64,] b::NLevelBasis, to::Integer, from::Integer)
Transition operator $|\mathrm{to}⟩⟨\mathrm{from}|$.
sourceQuantumOpticsBase.nlevelstate
— Functionnlevelstate([T=ComplexF64,] b::NLevelBasis, n::Integer)
State where the system is completely in the n-th level.
sourceSpin
QuantumInterface.SpinBasis
— TypeSpinBasis(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.
QuantumOpticsBase.sigmax
— Functionsigmax([T=ComplexF64,] b::SpinBasis)
Pauli $σ_x$ operator for the given Spin basis.
sourceQuantumOpticsBase.sigmay
— Functionsigmay([T=ComplexF64,] b::SpinBasis)
Pauli $σ_y$ operator for the given Spin basis.
sourceQuantumOpticsBase.sigmaz
— Functionsigmaz([T=ComplexF64,] b::SpinBasis)
Pauli $σ_z$ operator for the given Spin basis.
sourceQuantumOpticsBase.sigmap
— Functionsigmap([T=ComplexF64,] b::SpinBasis)
Raising operator $σ_+$ for the given Spin basis.
sourceQuantumOpticsBase.sigmam
— Functionsigmam([T=ComplexF64,] b::SpinBasis)
Lowering operator $σ_-$ for the given Spin basis.
sourceQuantumOpticsBase.spinup
— Functionspinup([T=ComplexF64,] b::SpinBasis)
Spin up state for the given Spin basis.
sourceQuantumOpticsBase.spindown
— Functionspindown([T=ComplexF64], b::SpinBasis)
Spin down state for the given Spin basis.
sourceParticle
QuantumOpticsBase.PositionBasis
— TypePositionBasis(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$.
sourceQuantumOpticsBase.MomentumBasis
— TypeMomentumBasis(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$.
sourceQuantumOpticsBase.spacing
— Functionspacing(b::PositionBasis)
Difference between two adjacent points of the real space basis.
sourcespacing(b::MomentumBasis)
Momentum difference between two adjacent points of the momentum basis.
sourceQuantumOpticsBase.samplepoints
— Functionsamplepoints(b::PositionBasis)
x values of the real space basis.
sourcesamplepoints(b::MomentumBasis)
p values of the momentum basis.
sourceBase.position
— Methodposition([T=ComplexF64,] b::PositionBasis)
Position operator in real space.
sourceBase.position
— Methodposition([T=ComplexF64,] b:MomentumBasis)
Position operator in momentum space.
sourceQuantumOpticsBase.momentum
— Methodmomentum([T=ComplexF64,] b::PositionBasis)
Momentum operator in real space.
sourceQuantumOpticsBase.momentum
— Methodmomentum([T=ComplexF64,] b:MomentumBasis)
Momentum operator in momentum space.
sourceQuantumOpticsBase.potentialoperator
— Functionpotentialoperator([T=Float64,] b::PositionBasis, V(x))
Operator representing a potential $V(x)$ in real space.
sourcepotentialoperator([T=ComplexF64,] b::MomentumBasis, V(x))
Operator representing a potential $V(x)$ in momentum space.
sourcepotentialoperator([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)
).
sourceQuantumOpticsBase.gaussianstate
— Functiongaussianstate([T=ComplexF64,] b::PositionBasis, x0, p0, sigma)
+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.
QuantumOpticsBase.diagonaloperator
— Functiondiagonaloperator(b::Basis)
Create a diagonal operator of type SparseOperator
.
sourceQuantumOpticsBase.randoperator
— Functionrandoperator([T=ComplexF64,] b1[, b2])
Calculate a random unnormalized dense operator.
sourceQuantumOpticsBase.spre
— Functionspre(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.
sourceQuantumOpticsBase.spost
— Functionspost(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.
sourceQuantumOpticsBase.sprepost
— Functionsprepost(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.
sourceQuantumOpticsBase.liouvillian
— Functionliouvillian(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 superQuantumOpticsBase.
QuantumInterface.samebases
— Functionsamebases(a, b)
Test if two objects have the same bases.
QuantumInterface.check_samebases
— Functioncheck_samebases(a, b)
Throw an IncompatibleBases
error if the objects don't have the same bases.
QuantumInterface.@samebases
— Macro@samebases
Macro to skip checks for same bases. Useful for *
, expect
and similar functions.
QuantumInterface.multiplicable
— Functionmultiplicable(a, b)
Check if two objects are multiplicable.
QuantumInterface.check_multiplicable
— Functioncheck_multiplicable(a, b)
Throw an IncompatibleBases
error if the objects are not multiplicable.
QuantumInterface.basis
— Functionbasis(a)
Return the basis of an object.
If it's ambiguous, e.g. if an operator has a different left and right basis, an IncompatibleBases
error is thrown.
QuantumInterface.dagger
— Functiondagger(x)
Hermitian conjugate.
sourceQuantumInterface.tensor
— Functiontensor(x, y, z...)
Tensor product of the given objects. Alternatively, the unicode symbol ⊗ (\otimes) can be used.
QuantumInterface.projector
— Methodprojector(a::Ket, b::Bra)
Projection operator $|a⟩⟨b|$.
sourceQuantumInterface.projector
— Methodprojector(a::Ket)
Projection operator $|a⟩⟨a|$.
sourceQuantumInterface.projector
— Methodprojector(a::Bra)
Projection operator $|a⟩⟨a|$.
sourceQuantumOpticsBase.sparseprojector
— Functionsparseprojector([T,] b1, b2)
Sparse version of projector
.
sourceQuantumInterface.dm
— Functiondm(a::StateVector)
Create density matrix $|a⟩⟨a|$. Same as projector(a)
.
sourceLinearAlgebra.norm
— Methodnorm(x::StateVector)
Norm of the given bra or ket state.
LinearAlgebra.tr
— Functiontr(x::AbstractOperator)
Trace of the given operator.
QuantumInterface.ptrace
— Functionptrace(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.
LinearAlgebra.normalize
— Methodnormalize(x::StateVector)
Return the normalized state so that norm(x)
is one.
LinearAlgebra.normalize
— Methodnormalize(op)
Return the normalized operator so that its tr(op)
is one.
LinearAlgebra.normalize!
— Methodnormalize!(x::StateVector)
In-place normalization of the given bra or ket so that norm(x)
is one.
LinearAlgebra.normalize!
— Methodnormalize!(op)
In-place normalization of the given operator so that its tr(x)
is one.
QuantumInterface.expect
— Functionexpect(index, op, state)
If an index
is given, it assumes that op
is defined in the subsystem specified by this number.
expect(op, state)
Expectation value of the given operator op
for the specified state
.
state
can either be a (density) operator or a ket.
sourceQuantumInterface.variance
— Functionvariance(index, op, state)
If an index
is given, it assumes that op
is defined in the subsystem specified by this number
variance(op, state)
Variance of the given operator op
for the specified state
.
state
can either be a (density) operator or a ket.
sourceQuantumInterface.embed
— Functionembed(basis1[, basis2], operators::Dict)
operators
is a dictionary Dict{Vector{Int}, AbstractOperator}
. The integer vector specifies in which subsystems the corresponding operator is defined.
embed(basis1[, basis2], indices::Vector, operators::Vector)
Tensor product of operators where missing indices are filled up with identity operators.
embed(basis1[, basis2], indices::Vector, op::AbstractOperator)
Embed operator acting on a joint Hilbert space where missing indices are filled up with identity operators.
sourceembed(basis_l::SumBasis, basis_r::SumBasis,
+ index::Integer, operator)
Embed an operator defined on a single subspace specified by the index
into a SumBasis
.
sourceembed(basis_l::SumBasis, basis_r::SumBasis,
+ indices, operator)
Embed an operator defined on multiple subspaces specified by the indices
into a SumBasis
.
sourceembed(basis_l::SumBasis, basis_r::SumBasis,
+ indices, operators)
Embed a list of operators on subspaces specified by the indices
into a SumBasis
.
sourceQuantumInterface.permutesystems
— Functionpermutesystems(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]
.
Base.exp
— Methodexp(op::AbstractOperator)
Operator exponential.
- Conversion of operators
QuantumOpticsBase.dense
— Functiondense(op::AbstractOperator)
Convert an arbitrary Operator into a DenseOperator
.
sourceSparseArrays.sparse
— Methodsparse(op::AbstractOperator)
Convert an arbitrary operator into a sparse one.
See also: QuantumOpticsBase.SparseOperator
- Time-dependent operators.
QuantumOpticsBase.current_time
— Functioncurrent_time(op::AbstractOperator)
Returns the current time of the operator op
. If op
is not time-dependent, this throws an ArgumentError
.
sourceQuantumOpticsBase.static_operator
— Functionstatic_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
.
sourceQuantumOpticsBase.set_time!
— Functionset_time!(o::AbstractOperator, t::Number)
Sets the clock of an operator (see AbstractTimeDependentOperator
). If o
contains other operators (e.g. in case o
is a LazyOperator
), recursively calls set_time!
on those.
This does nothing in case o
is not time-dependent.
sourceQuantumOpticsBase.time_shift
— Functiontime_shift(op::TimeDependentSum, t0)
Shift (translate) a TimeDependentSum
op
forward in time (delaying its action) by t0
units, so that the coefficient functions of time f(t)
become f(t-t0)
. Return a new TimeDependentSum
.
sourceQuantumOpticsBase.time_stretch
— Functiontime_stretch(op::TimeDependentSum, Sfactor)
Stretch (in time) a TimeDependentSum
op
by a factor of Sfactor
(making it 'longer'), so that the coefficient functions of time f(t)
become f(t/Sfactor)
. Return a new TimeDependentSum
.
sourceQuantumOpticsBase.time_restrict
— Functiontime_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
.
sourceExceptions
QuantumInterface.IncompatibleBases
— TypeException that should be raised for an illegal algebraic operation.
Quantum systems
Fock
QuantumInterface.FockBasis
— TypeFockBasis(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
.
QuantumOpticsBase.number
— Methodnumber([T=ComplexF64,] b::FockBasis)
Number operator for the specified Fock space with optional data type T
.
sourceQuantumOpticsBase.destroy
— Methoddestroy([T=ComplexF64,] b::FockBasis)
Annihilation operator for the specified Fock space with optional data type T
.
sourceQuantumOpticsBase.create
— Methodcreate([T=ComplexF64,] b::FockBasis)
Creation operator for the specified Fock space with optional data type T
.
sourceQuantumOpticsBase.displace
— Functiondisplace([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.
sourceQuantumOpticsBase.displace_analytical
— Functiondisplace_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.
sourcedisplace_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
.
sourceQuantumOpticsBase.displace_analytical!
— Functiondisplace_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)
sourceQuantumOpticsBase.squeeze
— Functionsqueeze([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.
sourcesqueeze([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.
sourceQuantumOpticsBase.fockstate
— Functionfockstate([T=ComplexF64,] b::FockBasis, n)
Fock state $|n⟩$ for the specified Fock space.
sourceQuantumOpticsBase.coherentstate
— Functioncoherentstate([T=ComplexF64,] b::FockBasis, alpha)
Coherent state $|α⟩$ for the specified Fock space.
sourceQuantumOpticsBase.coherentstate!
— Functioncoherentstate!(ket::Ket, b::FockBasis, alpha)
Inplace creation of coherent state $|α⟩$ for the specified Fock space.
sourceCharge
QuantumOpticsBase.ChargeBasis
— TypeChargeBasis(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.
sourceQuantumOpticsBase.ShiftedChargeBasis
— TypeShiftedChargeBasis(nmin, nmax) <: Basis
Basis spanning nmin, ..., nmax
charge states. See ChargeBasis
.
sourceQuantumOpticsBase.chargeop
— Functionchargeop([T=ComplexF64,] b::ChargeBasis)
+chargeop([T=ComplexF64,] b::ShiftedChargeBasis)
Return diagonal charge operator $N$ for given ChargeBasis
or ShiftedChargeBasis
.
sourceQuantumOpticsBase.expiφ
— Functionexpiφ([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
.
sourceQuantumOpticsBase.cosφ
— Functioncosφ([T=ComplexF64,] b::ChargeBasis; k=1)
+cosφ([T=ComplexF64,] b::ShiftedChargeBasis; k=1)
Return operator $\cos(k φ)$ for given charge basis. See expiφ
.
sourceQuantumOpticsBase.sinφ
— Functionsinφ([T=ComplexF64,] b::ChargeBasis; k=1)
+sinφ([T=ComplexF64,] b::ShiftedChargeBasis; k=1)
Return operator $\sin(k φ)$ for given charge basis. See expiφ
.
sourceN-level
QuantumInterface.NLevelBasis
— TypeNLevelBasis(N)
Basis for a system consisting of N states.
QuantumOpticsBase.transition
— Methodtransition([T=ComplexF64,] b::NLevelBasis, to::Integer, from::Integer)
Transition operator $|\mathrm{to}⟩⟨\mathrm{from}|$.
sourceQuantumOpticsBase.nlevelstate
— Functionnlevelstate([T=ComplexF64,] b::NLevelBasis, n::Integer)
State where the system is completely in the n-th level.
sourceSpin
QuantumInterface.SpinBasis
— TypeSpinBasis(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.
QuantumOpticsBase.sigmax
— Functionsigmax([T=ComplexF64,] b::SpinBasis)
Pauli $σ_x$ operator for the given Spin basis.
sourceQuantumOpticsBase.sigmay
— Functionsigmay([T=ComplexF64,] b::SpinBasis)
Pauli $σ_y$ operator for the given Spin basis.
sourceQuantumOpticsBase.sigmaz
— Functionsigmaz([T=ComplexF64,] b::SpinBasis)
Pauli $σ_z$ operator for the given Spin basis.
sourceQuantumOpticsBase.sigmap
— Functionsigmap([T=ComplexF64,] b::SpinBasis)
Raising operator $σ_+$ for the given Spin basis.
sourceQuantumOpticsBase.sigmam
— Functionsigmam([T=ComplexF64,] b::SpinBasis)
Lowering operator $σ_-$ for the given Spin basis.
sourceQuantumOpticsBase.spinup
— Functionspinup([T=ComplexF64,] b::SpinBasis)
Spin up state for the given Spin basis.
sourceQuantumOpticsBase.spindown
— Functionspindown([T=ComplexF64], b::SpinBasis)
Spin down state for the given Spin basis.
sourceParticle
QuantumOpticsBase.PositionBasis
— TypePositionBasis(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$.
sourceQuantumOpticsBase.MomentumBasis
— TypeMomentumBasis(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$.
sourceQuantumOpticsBase.spacing
— Functionspacing(b::PositionBasis)
Difference between two adjacent points of the real space basis.
sourcespacing(b::MomentumBasis)
Momentum difference between two adjacent points of the momentum basis.
sourceQuantumOpticsBase.samplepoints
— Functionsamplepoints(b::PositionBasis)
x values of the real space basis.
sourcesamplepoints(b::MomentumBasis)
p values of the momentum basis.
sourceBase.position
— Methodposition([T=ComplexF64,] b::PositionBasis)
Position operator in real space.
sourceBase.position
— Methodposition([T=ComplexF64,] b:MomentumBasis)
Position operator in momentum space.
sourceQuantumOpticsBase.momentum
— Methodmomentum([T=ComplexF64,] b::PositionBasis)
Momentum operator in real space.
sourceQuantumOpticsBase.momentum
— Methodmomentum([T=ComplexF64,] b:MomentumBasis)
Momentum operator in momentum space.
sourceQuantumOpticsBase.potentialoperator
— Functionpotentialoperator([T=Float64,] b::PositionBasis, V(x))
Operator representing a potential $V(x)$ in real space.
sourcepotentialoperator([T=ComplexF64,] b::MomentumBasis, V(x))
Operator representing a potential $V(x)$ in momentum space.
sourcepotentialoperator([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)
).
sourceQuantumOpticsBase.gaussianstate
— Functiongaussianstate([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.
sourceQuantumOpticsBase.FFTOperator
— TypeFFTOperator
Abstract type for all implementations of FFT operators.
sourceQuantumOpticsBase.FFTOperators
— TypeFFTOperators
Operator performing a fast fourier transformation when multiplied with a state that is a Ket or an Operator.
sourceQuantumOpticsBase.FFTKets
— TypeFFTKets
Operator that can only perform fast fourier transformations on Kets. This is much more memory efficient when only working with Kets.
sourceQuantumOpticsBase.transform
— Functiontransform(b1::MomentumBasis, b2::PositionBasis)
-transform(b1::PositionBasis, b2::MomentumBasis)
Transformation operator between position basis and momentum basis.
sourcetransform(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.
sourcetransform([S=ComplexF64, ]b1::PositionBasis, b2::FockBasis; x0=1)
+ \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.
sourceQuantumOpticsBase.FFTOperator
— TypeFFTOperator
Abstract type for all implementations of FFT operators.
sourceQuantumOpticsBase.FFTOperators
— TypeFFTOperators
Operator performing a fast fourier transformation when multiplied with a state that is a Ket or an Operator.
sourceQuantumOpticsBase.FFTKets
— TypeFFTKets
Operator that can only perform fast fourier transformations on Kets. This is much more memory efficient when only working with Kets.
sourceQuantumOpticsBase.transform
— Functiontransform(b1::MomentumBasis, b2::PositionBasis)
+transform(b1::PositionBasis, b2::MomentumBasis)
Transformation operator between position basis and momentum basis.
sourcetransform(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.
sourcetransform([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)\]
sourceSubspace bases
QuantumOpticsBase.SubspaceBasis
— TypeSubspaceBasis(basisstates)
A basis describing a subspace embedded a higher dimensional Hilbert space.
sourceQuantumOpticsBase.orthonormalize
— Functionorthonormalize(b::SubspaceBasis)
Orthonormalize the basis states of the given SubspaceBasis
A modified Gram-Schmidt process is used.
sourceQuantumInterface.projector
— Methodprojector([T,] b1, b2)
Projection operator between subspaces and superspaces or between two subspaces.
sourceMany-body
QuantumOpticsBase.ManyBodyBasis
— TypeManyBodyBasis(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.
sourceQuantumOpticsBase.fermionstates
— Functionfermionstates([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.
sourceQuantumOpticsBase.bosonstates
— Functionbosonstates([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.
sourceQuantumOpticsBase.number
— Methodnumber([T=ComplexF64,] mb::ManyBodyBasis, index)
Particle number operator for the i-th mode of the many-body basis b
.
sourceQuantumOpticsBase.number
— Methodnumber([T=ComplexF64,] mb::ManyBodyBasis)
Total particle number operator.
sourceQuantumOpticsBase.destroy
— Methoddestroy([T=ComplexF64,] mb::ManyBodyBasis, index)
Annihilation operator for the i-th mode of the many-body basis b
.
sourceQuantumOpticsBase.create
— Methodcreate([T=ComplexF64,] mb::ManyBodyBasis, index)
Creation operator for the i-th mode of the many-body basis b
.
sourceQuantumOpticsBase.transition
— Methodtransition([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}$.
sourceQuantumOpticsBase.manybodyoperator
— Functionmanybodyoperator(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.
sourceQuantumOpticsBase.onebodyexpect
— Functiononebodyexpect(op, state)
Expectation value of the one-body operator op
in respect to the many-body state
.
sourceDirect sum
QuantumInterface.SumBasis
— TypeSumBasis(b1, b2...)
Similar to CompositeBasis
but for the directsum
(⊕)
QuantumInterface.directsum
— Functiondirectsum(b1::Basis, b2::Basis)
Construct the SumBasis
out of two sub-bases.
directsum(x::Ket, y::Ket)
Construct a spinor via the directsum
of two Ket
s. 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!
sourcedirectsum(x::DataOperator, y::DataOperator)
Compute the direct sum of two operators. The result is an operator on the corresponding SumBasis
.
sourceQuantumOpticsBase.LazyDirectSum
— TypeLazyDirectSum <: AbstractOperator
Lazy implementation of directsum
sourceQuantumOpticsBase.getblock
— Functiongetblock(x::Ket{<:SumBasis}, i)
For a Ket
defined on a SumBasis
, get the state as it is defined on the ith sub-basis.
sourcegetblock(op::Operator{<:SumBasis,<:SumBasis}, i, j)
Get the sub-basis operator corresponding to the block (i,j)
of op
.
sourceQuantumOpticsBase.setblock!
— Functionsetblock!(x::Ket{<:SumBasis}, val::Ket, i)
Set the data of x
on the ith sub-basis equal to the data of val
.
sourcesetblock!(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
.
sourceMetrics
QuantumOpticsBase.tracenorm
— Functiontracenorm(rho)
Trace norm of rho
.
It is defined as
\[T(ρ) = Tr\{\sqrt{ρ^† ρ}\}.\]
Depending if rho
is hermitian either tracenorm_h
or tracenorm_nh
is called.
sourceQuantumOpticsBase.tracenorm_h
— Functiontracenorm_h(rho)
Trace norm of rho
.
It uses the identity
\[T(ρ) = Tr\{\sqrt{ρ^† ρ}\} = \sum_i |λ_i|\]
where $λ_i$ are the eigenvalues of rho
.
sourceQuantumOpticsBase.tracenorm_nh
— Functiontracenorm_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
.
sourceQuantumOpticsBase.tracedistance
— Functiontracedistance(rho, sigma)
Trace distance between rho
and sigma
.
It is defined as
\[T(ρ,σ) = \frac{1}{2} Tr\{\sqrt{(ρ - σ)^† (ρ - σ)}\}.\]
It calls tracenorm
which in turn either uses tracenorm_h
or tracenorm_nh
depending if $ρ-σ$ is hermitian or not.
sourceQuantumOpticsBase.tracedistance_h
— Functiontracedistance_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
.
sourceQuantumOpticsBase.tracedistance_nh
— Functiontracedistance_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
.
sourceQuantumOpticsBase.entropy_vn
— Functionentropy_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.
sourceQuantumOpticsBase.entropy_renyi
— Functionentropy_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(ρ^α))\]
sourceQuantumOpticsBase.fidelity
— Functionfidelity(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}|ψ⟩⟨ψ|$.
sourceQuantumOpticsBase.ptranspose
— Functionptranspose(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.
sourceQuantumOpticsBase.PPT
— FunctionPPT(rho, index)
Peres-Horodecki criterion of partial transpose.
sourceQuantumOpticsBase.negativity
— Functionnegativity(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.
sourceQuantumOpticsBase.logarithmic_negativity
— Functionlogarithmic_negativity(rho, index)
The logarithmic negativity of a density matrix ρ is defined as
\[N(ρ) = \log₂\|ρᵀ\|,\]
where ρᵀ
is the partial transpose.
sourceQuantumOpticsBase.entanglement_entropy
— Functionentanglement_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).
sourceQuantumOpticsBase.avg_gate_fidelity
— Functionavg_gate_fidelity(x, y)
The average gate fidelity between two superoperators x and y.
sourceState definitions
QuantumOpticsBase.randstate
— Functionrandstate([T=ComplexF64,] basis)
Calculate a random normalized ket state.
sourceQuantumOpticsBase.thermalstate
— Functionthermalstate(H,T)
Thermal state $exp(-H/T)/Tr[exp(-H/T)]$.
sourceQuantumOpticsBase.coherentthermalstate
— Functioncoherentthermalstate([C=ComplexF64,] basis::FockBasis,H,T,alpha)
Coherent thermal state $D(α)exp(-H/T)/Tr[exp(-H/T)]D^†(α)$.
sourceQuantumOpticsBase.phase_average
— Functionphase_average(rho)
Returns the phase-average of $ρ$ containing only the diagonal elements.
sourceQuantumOpticsBase.passive_state
— Functionpassive_state(rho,IncreasingEigenenergies=true)
Passive state $π$ of $ρ$. IncreasingEigenenergies=true means that higher indices correspond to higher energies.
sourcePauli
QuantumInterface.PauliBasis
— TypePauliBasis(num_qubits::Int)
Basis for an N-qubit space where num_qubits
specifies the number of qubits. The dimension of the basis is 2²ᴺ.
QuantumOpticsBase.PauliTransferMatrix
— TypeBase class for Pauli transfer matrix classes.
sourceQuantumOpticsBase.DensePauliTransferMatrix
— TypeDensePauliTransferMatrix(B1, B2, data)
DensePauliTransferMatrix stored as a dense matrix.
sourceQuantumOpticsBase.ChiMatrix
— TypeBase class for χ (process) matrix classes.
sourceQuantumOpticsBase.DenseChiMatrix
— TypeDenseChiMatrix(b, b, data)
DenseChiMatrix stored as a dense matrix.
sourcePrinting
QuantumOpticsBase.set_printing
— FunctionQuantumOptics.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.
sourceLazyTensor functions
QuantumOpticsBase.lazytensor_enable_cache
— Functionlazytensor_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.
sourceQuantumOpticsBase.lazytensor_disable_cache
— Functionlazytensor_disable_cache()
Disable the cache for further use but does not clear its current contents. Also see lazytensor_clear_cache()
sourceQuantumOpticsBase.lazytensor_cachesize
— Functionlazytensor_cachesize()
Return the current memory size (in bytes) of all the objects in the cache.
sourceQuantumOpticsBase.lazytensor_clear_cache
— Functionlazytensor_clear_cache()
Clear the current contents of the cache.
sourceSettings
This document was generated with Documenter.jl on Saturday 10 August 2024. Using Julia version 1.10.4.
+ \frac{1}{\sqrt{2^n n!}} H_n\left(\frac{x}{x_0}\right)\]
Subspace bases
QuantumOpticsBase.SubspaceBasis
— TypeSubspaceBasis(basisstates)
A basis describing a subspace embedded a higher dimensional Hilbert space.
QuantumOpticsBase.orthonormalize
— Functionorthonormalize(b::SubspaceBasis)
Orthonormalize the basis states of the given SubspaceBasis
A modified Gram-Schmidt process is used.
QuantumInterface.projector
— Methodprojector([T,] b1, b2)
Projection operator between subspaces and superspaces or between two subspaces.
Many-body
QuantumOpticsBase.ManyBodyBasis
— TypeManyBodyBasis(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.
QuantumOpticsBase.fermionstates
— Functionfermionstates([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.
QuantumOpticsBase.bosonstates
— Functionbosonstates([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.
QuantumOpticsBase.number
— Methodnumber([T=ComplexF64,] mb::ManyBodyBasis, index)
Particle number operator for the i-th mode of the many-body basis b
.
QuantumOpticsBase.number
— Methodnumber([T=ComplexF64,] mb::ManyBodyBasis)
Total particle number operator.
QuantumOpticsBase.destroy
— Methoddestroy([T=ComplexF64,] mb::ManyBodyBasis, index)
Annihilation operator for the i-th mode of the many-body basis b
.
QuantumOpticsBase.create
— Methodcreate([T=ComplexF64,] mb::ManyBodyBasis, index)
Creation operator for the i-th mode of the many-body basis b
.
QuantumOpticsBase.transition
— Methodtransition([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}$.
QuantumOpticsBase.manybodyoperator
— Functionmanybodyoperator(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.
QuantumOpticsBase.onebodyexpect
— Functiononebodyexpect(op, state)
Expectation value of the one-body operator op
in respect to the many-body state
.
Direct sum
QuantumInterface.SumBasis
— TypeSumBasis(b1, b2...)
Similar to CompositeBasis
but for the directsum
(⊕)
QuantumInterface.directsum
— Functiondirectsum(b1::Basis, b2::Basis)
Construct the SumBasis
out of two sub-bases.
directsum(x::Ket, y::Ket)
Construct a spinor via the directsum
of two Ket
s. 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!
directsum(x::DataOperator, y::DataOperator)
Compute the direct sum of two operators. The result is an operator on the corresponding SumBasis
.
QuantumOpticsBase.LazyDirectSum
— TypeLazyDirectSum <: AbstractOperator
Lazy implementation of directsum
QuantumOpticsBase.getblock
— Functiongetblock(x::Ket{<:SumBasis}, i)
For a Ket
defined on a SumBasis
, get the state as it is defined on the ith sub-basis.
getblock(op::Operator{<:SumBasis,<:SumBasis}, i, j)
Get the sub-basis operator corresponding to the block (i,j)
of op
.
QuantumOpticsBase.setblock!
— Functionsetblock!(x::Ket{<:SumBasis}, val::Ket, i)
Set the data of x
on the ith sub-basis equal to the data of val
.
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
.
Metrics
QuantumOpticsBase.tracenorm
— Functiontracenorm(rho)
Trace norm of rho
.
It is defined as
\[T(ρ) = Tr\{\sqrt{ρ^† ρ}\}.\]
Depending if rho
is hermitian either tracenorm_h
or tracenorm_nh
is called.
QuantumOpticsBase.tracenorm_h
— Functiontracenorm_h(rho)
Trace norm of rho
.
It uses the identity
\[T(ρ) = Tr\{\sqrt{ρ^† ρ}\} = \sum_i |λ_i|\]
where $λ_i$ are the eigenvalues of rho
.
QuantumOpticsBase.tracenorm_nh
— Functiontracenorm_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
.
QuantumOpticsBase.tracedistance
— Functiontracedistance(rho, sigma)
Trace distance between rho
and sigma
.
It is defined as
\[T(ρ,σ) = \frac{1}{2} Tr\{\sqrt{(ρ - σ)^† (ρ - σ)}\}.\]
It calls tracenorm
which in turn either uses tracenorm_h
or tracenorm_nh
depending if $ρ-σ$ is hermitian or not.
QuantumOpticsBase.tracedistance_h
— Functiontracedistance_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
.
QuantumOpticsBase.tracedistance_nh
— Functiontracedistance_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
.
QuantumOpticsBase.entropy_vn
— Functionentropy_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.
QuantumOpticsBase.entropy_renyi
— Functionentropy_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(ρ^α))\]
QuantumOpticsBase.fidelity
— Functionfidelity(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}|ψ⟩⟨ψ|$.
QuantumOpticsBase.ptranspose
— Functionptranspose(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.
QuantumOpticsBase.PPT
— FunctionPPT(rho, index)
Peres-Horodecki criterion of partial transpose.
QuantumOpticsBase.negativity
— Functionnegativity(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.
QuantumOpticsBase.logarithmic_negativity
— Functionlogarithmic_negativity(rho, index)
The logarithmic negativity of a density matrix ρ is defined as
\[N(ρ) = \log₂\|ρᵀ\|,\]
where ρᵀ
is the partial transpose.
QuantumOpticsBase.entanglement_entropy
— Functionentanglement_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).
QuantumOpticsBase.avg_gate_fidelity
— Functionavg_gate_fidelity(x, y)
The average gate fidelity between two superoperators x and y.
State definitions
QuantumOpticsBase.randstate
— Functionrandstate([T=ComplexF64,] basis)
Calculate a random normalized ket state.
QuantumOpticsBase.thermalstate
— Functionthermalstate(H,T)
Thermal state $exp(-H/T)/Tr[exp(-H/T)]$.
QuantumOpticsBase.coherentthermalstate
— Functioncoherentthermalstate([C=ComplexF64,] basis::FockBasis,H,T,alpha)
Coherent thermal state $D(α)exp(-H/T)/Tr[exp(-H/T)]D^†(α)$.
QuantumOpticsBase.phase_average
— Functionphase_average(rho)
Returns the phase-average of $ρ$ containing only the diagonal elements.
QuantumOpticsBase.passive_state
— Functionpassive_state(rho,IncreasingEigenenergies=true)
Passive state $π$ of $ρ$. IncreasingEigenenergies=true means that higher indices correspond to higher energies.
Pauli
QuantumInterface.PauliBasis
— TypePauliBasis(num_qubits::Int)
Basis for an N-qubit space where num_qubits
specifies the number of qubits. The dimension of the basis is 2²ᴺ.
QuantumOpticsBase.PauliTransferMatrix
— TypeBase class for Pauli transfer matrix classes.
QuantumOpticsBase.DensePauliTransferMatrix
— TypeDensePauliTransferMatrix(B1, B2, data)
DensePauliTransferMatrix stored as a dense matrix.
QuantumOpticsBase.ChiMatrix
— TypeBase class for χ (process) matrix classes.
QuantumOpticsBase.DenseChiMatrix
— TypeDenseChiMatrix(b, b, data)
DenseChiMatrix stored as a dense matrix.
Printing
QuantumOpticsBase.set_printing
— FunctionQuantumOptics.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 totrue
, the output shown in the REPL will exhibit the correct order.rounding_tol=1e-17
: Tolerance for floating point errors shown in the output.
LazyTensor functions
QuantumOpticsBase.lazytensor_enable_cache
— Functionlazytensor_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.
QuantumOpticsBase.lazytensor_disable_cache
— Functionlazytensor_disable_cache()
Disable the cache for further use but does not clear its current contents. Also see lazytensor_clear_cache()
QuantumOpticsBase.lazytensor_cachesize
— Functionlazytensor_cachesize()
Return the current memory size (in bytes) of all the objects in the cache.
QuantumOpticsBase.lazytensor_clear_cache
— Functionlazytensor_clear_cache()
Clear the current contents of the cache.