Hilbert spaces, states and linear operators

Ordered set of compound indices

KeldyshED.Hilbert.SetOfIndicesType

Mapping from a compound operator index IndicesType to a linear integer index. It provides a dictionary-like iteration interface, supports indexed read-only access, functions keys(), values() and pairs(), as well as the operator in.

Fields

  • map_index_n::DataStructures.SortedDict{Vector{Union{Int64, String}}, Int64}: The IndicesType -> linear index map
source
Base.insert!Method
insert!(
    soi::KeldyshED.Hilbert.SetOfIndices,
    indices::Vector{Union{Int64, String}}
) -> DataStructures.SortedDict{Vector{Union{Int64, String}}, Int64, Base.Order.ForwardOrdering}

Insert a new compound operator index indices into soi.

source
Base.insert!Method
insert!(
    soi::KeldyshED.Hilbert.SetOfIndices,
    indices...
) -> DataStructures.SortedDict{Vector{Union{Int64, String}}, Int64, Base.Order.ForwardOrdering}

Insert a new compound operator index built out of arguments indices... into soi.

source
KeldyshED.Hilbert.matching_indicesFunction
matching_indices(
    soi_from::KeldyshED.Hilbert.SetOfIndices,
    soi_to::KeldyshED.Hilbert.SetOfIndices
) -> Vector{Int64}

For each compound index in the set soi_from, find the linear index of that compound index within soi_to and collect the found linear indices.

source

Full Hilbert spaces and their subspaces

KeldyshED.Hilbert.FockStateType
primitive type UInt64 <: Unsigned 64

Fermionic Fock state encoded as a sequence of zeros (unoccupied single-particle states) and ones (occupied states) in the binary representation of an integer.

source
KeldyshED.Hilbert.translateFunction
translate(
    fs::UInt64,
    bit_map::Vector{Int64};
    reverse
) -> UInt64

Reshuffle single-particle states (bits) of a Fock state fs according to a given map bit_map. bit_map is understood as a reverse map if reverse = true.

source
KeldyshED.Hilbert.FullHilbertSpaceType

A Hilbert space spanned by all fermionic Fock states generated by a given set of creation/annihilation operators. This type supports vector-like iteration over Fock states, read-only indexed access and the operator in.

Fields

  • soi::KeldyshED.Hilbert.SetOfIndices: Set of compound operator indices used to generate this space

  • dim::UInt64: Dimension of the space

source
KeldyshED.Hilbert.FullHilbertSpaceMethod
FullHilbertSpace(
    soi::KeldyshED.Hilbert.SetOfIndices
) -> KeldyshED.Hilbert.FullHilbertSpace

Make a Hilbert space generated by creation/annihilation operators carrying compound indices from a given set soi.

source
Base.getindexMethod
getindex(
    fhs::KeldyshED.Hilbert.FullHilbertSpace,
    soi_indices::Set{Vector{Union{Int64, String}}}
) -> UInt64

Return the Fock state $|\psi\rangle \propto c^\dagger_i c^\dagger_j c^\dagger_k \ldots |0\rangle$, where the compound indices $i,j,k,\ldots$ form a given set soi_indices and the creation operators act in a Hilbert space fhs.

source
KeldyshED.Hilbert.:⊗Method
⊗(
    H_A::KeldyshED.Hilbert.FullHilbertSpace,
    H_B::KeldyshED.Hilbert.FullHilbertSpace
) -> KeldyshED.Hilbert.FullHilbertSpace

Construct a direct product of full Hilbert spaces $H_A \otimes H_B$ under the assumption that the sets of indices generating $H_A$ and $H_B$ are disjoint.

source
Base.:/Method
/(
    H_AB::KeldyshED.Hilbert.FullHilbertSpace,
    H_A::KeldyshED.Hilbert.FullHilbertSpace
) -> KeldyshED.Hilbert.FullHilbertSpace

Construct a quotient space $H_{AB} / H_A$ under the assumption that the sets of indices generating $H_{AB}$ and $H_A$ satisfy $soi(H_A) \subseteq soi(H_{AB})$.

source
KeldyshED.Hilbert.product_basis_mapFunction
product_basis_map(
    H_A::KeldyshED.Hilbert.FullHilbertSpace,
    H_B::KeldyshED.Hilbert.FullHilbertSpace,
    H_AB::KeldyshED.Hilbert.FullHilbertSpace
) -> Matrix{Int64}

Given three Hilbert spaces $H_A$, $H_B$ and $H_{AB}$, construct all product Fock states $|\psi\rangle_{AB} = |\psi\rangle_A ⊗ |\psi\rangle_B$, where $|\psi\rangle_A ∈ H_A, |\psi\rangle_B ∈ H_B, |\psi\rangle_{AB} ∈ H_{AB}$. Return a mapping (an integer-valued matrix) $i, j \mapsto k$, where $i$, $j$ and $k$ are linear indices of $|\psi\rangle_A$, $|\psi\rangle_B$ and $|\psi\rangle_{AB}$ within their respective spaces.

Sets of indices $soi(H_A)$, $soi(H_B)$ must be disjoint and satisfy $soi(H_A) \subseteq soi(H_{AB})$, $soi(H_B) \subseteq soi(H_{AB})$.

source
KeldyshED.Hilbert.factorized_basis_mapFunction
factorized_basis_map(
    H_AB::KeldyshED.Hilbert.FullHilbertSpace,
    H_A::KeldyshED.Hilbert.FullHilbertSpace
) -> Vector{Tuple{Int64, Int64}}

Given a Hilbert space $H_{AB}$ and its divisor $H_A$, factorize all Fock states $|\psi\rangle_{AB} \in H_{AB}$ into a direct product $|\psi\rangle_A \otimes |\psi\rangle_B$, where $|\psi\rangle_A \in H_A$, $|\psi\rangle_B \in H_{AB} / H_A$. Return a mapping (a vector of integer pairs) $k \mapsto (i, j)$, where $i$, $j$ and $k$ are linear indices of $|\psi\rangle_A$, $|\psi\rangle_B$ and $|\psi\rangle_{AB}$ within their respective spaces.

Sets of indices $soi(H_{AB})$, $soi(H_A)$ must satisfy $soi(H_A) \subseteq soi(H_{AB})$.

source
KeldyshED.Hilbert.HilbertSubspaceType

Subspace of a Hilbert space, as a list of basis Fock states.

This type supports vector-like iteration over Fock states, read-only indexed access and the operator in.

Fields

  • fock_states::Vector{UInt64}: List of all Fock states spanning the space

  • fock_to_index::Dict{UInt64, Int64}: Reverse map to quickly find the index of a basis Fock state

source
Base.insert!Method
insert!(
    hss::KeldyshED.Hilbert.HilbertSubspace,
    fs::UInt64
) -> Int64

Insert a basis Fock state fs into a subspace hss.

source
KeldyshED.Hilbert.getstateindexFunction
getstateindex(
    fhs::KeldyshED.Hilbert.FullHilbertSpace,
    fs::UInt64
) -> Int64

Find the index of a given Fock state fs within a full Hilbert space fhs.

source
getstateindex(
    hss::KeldyshED.Hilbert.HilbertSubspace,
    fs::UInt64
) -> Int64

Find the index of a given Fock state fs within a subspace hss.

source

Quantum states

KeldyshED.Hilbert.StateVectorType

Quantum state in a Hilbert space/subspace implemented as a vector of amplitudes.

The amplitudes can be accessed using the indexing interface and iterated over. States support addition/subtraction and multiplication/division by a constant scalar.

Fields

  • hs::KeldyshED.Hilbert.HilbertSpace: Hilbert space this state belongs to

  • amplitudes::Vector: Amplitudes of basis states contributing to this state

source
KeldyshED.Hilbert.StateVectorMethod
StateVector{HSType, S}(hs::HSType) where {HSType, S}

Create a vector-based state in a Hilbert space/subspace hs with all amplitudes set to zero.

source
KeldyshED.Hilbert.StateDictType

Quantum state in a Hilbert space/subspace implemented as a (sparse) dictionary of amplitudes.

The amplitudes can be accessed using the indexing interface and iterated over. States support addition/subtraction and multiplication/division by a constant scalar.

Fields

  • hs::KeldyshED.Hilbert.HilbertSpace: Hilbert space this state belongs to

  • amplitudes::Dict{Int64}: Non-vanishing amplitudes of basis states contributing to this state. Each element of this dictionary is a pair (index of the basis state within hs, amplitude).

source
KeldyshED.Hilbert.StateDictMethod
StateDict{HSType, S}(hs::HSType) where {HSType, S}

Create a dictionary-based state in a Hilbert space/subspace hs with zero non-vanishing amplitudes.

source
Base.similarFunction
similar(
    sv::KeldyshED.Hilbert.StateVector{HSType, S}
) -> KeldyshED.Hilbert.StateVector

Create a vector-based state similar to sv with all amplitudes set to zero.

source
similar(
    sd::KeldyshED.Hilbert.StateDict{HSType, S}
) -> KeldyshED.Hilbert.StateDict

Create a dictionary-based state similar to sd with zero non-vanishing amplitudes.

source
KeldyshED.Hilbert.dotFunction
dot(
    sv1::KeldyshED.Hilbert.StateVector,
    sv2::KeldyshED.Hilbert.StateVector
) -> Any

Compute the scalar product of two vector-based states sv1 and sv2.

source
dot(
    sd1::KeldyshED.Hilbert.StateDict{HSType, S},
    sd2::KeldyshED.Hilbert.StateDict{HSType, S}
) -> Any

Compute the scalar product of two dictionary-based states sd1 and sd2.

source
KeldyshED.Hilbert.projectFunction
project(
    sv::KeldyshED.Hilbert.StateVector{HSType, S},
    target_space
) -> KeldyshED.Hilbert.StateVector

Project a vector-based state sv from one Hilbert space onto another Hilbert space/subspace target_space.

source
project(
    sd::KeldyshED.Hilbert.StateDict{HSType, S},
    target_space
) -> KeldyshED.Hilbert.StateVector

Project a dictionary-based state sd from one Hilbert space onto another Hilbert space/subspace target_space.

source
Base.showMethod
show(io::IO, sv::KeldyshED.Hilbert.StateVector{HSType, S})

Print a vector-based state.

source
Base.showMethod
show(io::IO, sd::KeldyshED.Hilbert.StateDict{HSType, S})

Print a dictionary-based state.

source

Operators acting in Hilbert spaces

KeldyshED.Hilbert.OperatorMethod
Operator{HSType, S}(op_expr::OperatorExpr{S}, soi::SetOfIndices) where {HSType, S}

Make a linear operator acting on a Hilbert space/subspace out of a polynomial expression op_expr. The set soi is used to establish a correspondence between compound indices of creation/annihilation operators met in op_expr and the single-particle states – bits of FockState.

source
Base.:*Method
*(
    op::KeldyshED.Hilbert.Operator,
    st::KeldyshED.Hilbert.State
) -> Any

Act with an operator op on a state st and return the resulting state.

source

Space autopartition algorithm

KeldyshED.Hilbert.SpacePartitionType

Partition of a Hilbert space into a set of disjoint subspaces invariant under action of a given Hermitian operator (Hamiltonian).

A detailed description of the algorithm can be found in Section 4.2 of Computer Physics Communications 200, March 2016, 274-284.

SpacePartition supports iteration over pairs (index of a basis state of the Hilbert space, index of the invariant subspace that state belongs to).

Fields

  • hs::KeldyshED.Hilbert.HilbertSpace: Full Hilbert space subject to partitioning

  • subspaces::DataStructures.IntDisjointSets: Disjoint set of subspaces

  • root_to_index::Dict{Int64, Int64}: Map root index to subspace index

  • matrix_elements::SparseArrays.SparseMatrixCSC{ScalarType, Int64} where ScalarType<:Number: Matrix elements of the Hamiltonian

source
KeldyshED.Hilbert.SpacePartitionMethod
SpacePartition{HSType, S}(hs::HSType,
                          H::OperatorType,
                          store_matrix_elements::Bool = true) where {
    HSType <: HilbertSpace, S <: Number, OperatorType <: Operator}

Create a SpacePartition structure by performing Phase I of the automatic partitioning algorithm, i.e. discovering the invariant subspaces of the Hermitian operator H acting on the Hilbert space hs.

If store_matrix_elements = true, the field matrix_elements of the created structure contains a sparse-matrix representation of H.

source
KeldyshED.Hilbert.merge_subspaces!Function
merge_subspaces!(sp, op)
merge_subspaces!(sp, op, store_matrix_elements)

Merge some of the invariant subspaces in sp to ensure that the resulting subspaces are also invariant w.r.t. a given operator op.

If store_matrix_elements = true, a sparse-matrix representation of op is returned.

source
merge_subspaces!(sp, Cd, C)
merge_subspaces!(sp, Cd, C, store_matrix_elements)

Perform Phase II of the automatic partition algorithm.

Merge some of the invariant subspaces in sp to ensure that a given operator Cd and its Hermitian conjugate C generate only one-to-one connections between the subspaces.

If store_matrix_elements = true, a tuple of two sparse matrices representing Cd and C is returned.

source
Base.getindexMethod
getindex(
    sp::KeldyshED.Hilbert.SpacePartition,
    index
) -> Int64

Find the invariant subspace within a partition sp, the state with a given index belongs to.

source