Hilbert spaces, states and linear operators
KeldyshED.Hilbert — Module
This module defines types of Hilbert spaces, state vectors and linear operators acting in these spaces. It also implements the space autopartition algorithm described in [Computer Physics Communications 200, March 2016, 274-284 (section 4.2)] (https://doi.org/10.1016/j.cpc.2015.10.023).
Ordered set of compound indices
KeldyshED.Hilbert.SetOfIndices — Type
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}: TheIndicesType-> linear index map
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.
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.
KeldyshED.Hilbert.reversemap — Method
reversemap(
soi::KeldyshED.Hilbert.SetOfIndices
) -> Vector{Vector{Union{Int64, String}}}
Build and return the reverse map Int -> IndicesType out of a SetOfIndices object.
KeldyshED.Hilbert.matching_indices — Function
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.
Full Hilbert spaces and their subspaces
KeldyshED.Hilbert.FockState — Type
primitive type UInt64 <: Unsigned 64Fermionic Fock state encoded as a sequence of zeros (unoccupied single-particle states) and ones (occupied states) in the binary representation of an integer.
KeldyshED.Hilbert.translate — Function
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.
KeldyshED.Hilbert.HilbertSpace — Type
Abstract supertype for Hilbert space types.
KeldyshED.Hilbert.FullHilbertSpace — Type
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 spacedim::UInt64: Dimension of the space
KeldyshED.Hilbert.FullHilbertSpace — Method
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.
Base.getindex — Method
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.
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.
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})$.
KeldyshED.Hilbert.product_basis_map — Function
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})$.
KeldyshED.Hilbert.factorized_basis_map — Function
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})$.
KeldyshED.Hilbert.HilbertSubspace — Type
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 spacefock_to_index::Dict{UInt64, Int64}: Reverse map to quickly find the index of a basis Fock state
Base.insert! — Method
insert!(
hss::KeldyshED.Hilbert.HilbertSubspace,
fs::UInt64
) -> Int64
Insert a basis Fock state fs into a subspace hss.
KeldyshED.Hilbert.getstateindex — Function
getstateindex(
fhs::KeldyshED.Hilbert.FullHilbertSpace,
fs::UInt64
) -> Int64
Find the index of a given Fock state fs within a full Hilbert space fhs.
getstateindex(
hss::KeldyshED.Hilbert.HilbertSubspace,
fs::UInt64
) -> Int64
Find the index of a given Fock state fs within a subspace hss.
Quantum states
KeldyshED.Hilbert.State — Type
Abstract supertype of quantum state types
KeldyshED.Hilbert.StateVector — Type
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 toamplitudes::Vector: Amplitudes of basis states contributing to this state
KeldyshED.Hilbert.StateVector — Method
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.
KeldyshED.Hilbert.StateDict — Type
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 toamplitudes::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 withinhs, amplitude).
KeldyshED.Hilbert.StateDict — Method
StateDict{HSType, S}(hs::HSType) where {HSType, S}Create a dictionary-based state in a Hilbert space/subspace hs with zero non-vanishing amplitudes.
Base.similar — Function
similar(
sv::KeldyshED.Hilbert.StateVector{HSType, S}
) -> KeldyshED.Hilbert.StateVector
Create a vector-based state similar to sv with all amplitudes set to zero.
similar(
sd::KeldyshED.Hilbert.StateDict{HSType, S}
) -> KeldyshED.Hilbert.StateDict
Create a dictionary-based state similar to sd with zero non-vanishing amplitudes.
KeldyshED.Hilbert.dot — Function
dot(
sv1::KeldyshED.Hilbert.StateVector,
sv2::KeldyshED.Hilbert.StateVector
) -> Any
Compute the scalar product of two vector-based states sv1 and sv2.
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.
KeldyshED.Hilbert.project — Function
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.
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.
Operators acting in Hilbert spaces
KeldyshED.Hilbert.Operator — Type
Quantum-mechanical operator acting on states in a Hilbert space.
KeldyshED.Hilbert.Operator — Method
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] (@ref Main.KeldyshED.Operators.OperatorExpr) 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.
Space autopartition algorithm
KeldyshED.Hilbert.SpacePartition — Type
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] (https://doi.org/10.1016/j.cpc.2015.10.023).
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 partitioningsubspaces::DataStructures.IntDisjointSets: Disjoint set of subspacesroot_to_index::Dict{Int64, Int64}: Map root index to subspace indexmatrix_elements::SparseArrays.SparseMatrixCSC{ScalarType, Int64} where ScalarType<:Number: Matrix elements of the Hamiltonian
KeldyshED.Hilbert.SpacePartition — Method
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.
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.
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.
KeldyshED.Hilbert.numsubspaces — Function
numsubspaces(sp::KeldyshED.Hilbert.SpacePartition) -> Int64
Return the number of subspaces in a space partition sp.
Base.getindex — Method
getindex(
sp::KeldyshED.Hilbert.SpacePartition,
index
) -> Int64
Find the invariant subspace within a partition sp, the state with a given index belongs to.