OpIDSum
For some systems constructing the OpSum can actually be the bottleneck of MPO construction. OpIDSum plays the same roll as OpSum but in a much more efficient manner. To specify an operator in a term of an OpSum you specify a string (the operator's name) and a site index, whereas to specify an operator in a term of an OpIDSum you specify an OpID which contains an operator index and a site. The operator index is the index of the operator in the provided basis for the site. The remainder of the information about what the operator actually is, is kept in an OpCacheVec.
ITensorMPOConstruction.OpID — Type
OpID{Ti}Compact identifier for an operator stored in an OpCacheVec.
Type Parameters
Ti: The integer type used to store both the operator ID and site.
Fields:
id: index of the operator within the cache for siten.n: site number on which the operator acts.
The zero value OpID(0, 0) is used internally as padding for unused slots in fixed-width storage.
ITensorMPOConstruction.OpIDSum — Type
OpIDSum{N,C,Ti}(max_terms, op_cache_vec, f; abs_tol=0) -> OpIDSum{N,C,Ti}Create an empty OpIDSum with capacity for max_terms terms.
OpIDSum is a compact representation of an operator sum whose terms are stored as fixed-width tuples of OpID values together with scalar coefficients.
Type Parameters:
N: The maximum number of onsite operators per term, i.e. the weight of the operator.C: The scalar coefficient type.Ti: The integer type used to identify both an operator and the sites.
Fields:
terms: A 2D view of the terms comprising the operator.scalars: A vector containing the coefficient for each term.num_terms: An atomic holding the current number of terms in the operator.op_cache_vec: The cache that defines the operators acting on each site.abs_tol: When adding terms to the operator, terms with coefficients smaller than this are dropped.modify!: A function which can modify a term in-place after callingadd!.
OpIDSum{N,C,Ti}(max_terms, op_cache_vec; abs_tol=0) -> OpIDSum{N,C,Ti}Create an empty OpIDSum with capacity for max_terms terms.
Terms with abs(scalar) <= abs_tol are ignored when added.
ITensorMPS.add! — Function
add!(os::OpIDSum, scalar::Number, ops) -> NothingAppend a term (defined by ops) to os. This function is thread-safe.
Identity operators (id == 1) are removed before storage, remaining operators are sorted by site with the appropriate fermionic permutation sign, and the term-modification callback associated with os is applied. Terms below os.abs_tol are skipped. Importantly, the sorting is stable.
add!(os::OpIDSum, scalar::Number, ops::OpID...) -> NothingVararg convenience method for add!.
ITensorMPOConstruction.OpInfo — Type
OpInfoCached metadata for a single local operator on a given site.
Fields:
matrix: dense matrix representation of the operator.is_fermionic: whether the operator has an odd fermion parity.qn_flux: the quantum-number flux carried by the operator.
ITensorMPOConstruction.OpCacheVec — Type
OpCacheVecA type alias for a map from site index, and operator index to OpInfo.
ITensorMPOConstruction.to_OpCacheVec — Function
to_OpCacheVec(sites::Vector{<:Index}, ops::OpCacheVec) -> OpCacheVecValidate and return a precomputed operator cache.
The length of sites must match the length of ops and the first operator for every site must be the identity.
to_OpCacheVec(sites::Vector{<:Index}, ops::Vector{Vector{String}}) -> OpCacheVecBuild an OpCacheVec from operator names for each site.
ops[n] is the ordered list of operator names available on site n, and the first entry for every site must be "I", which is reserved for the identity.
to_OpCacheVec(sites::Vector{<:Index}, ::Nothing) -> NothingPass through nothing for call sites where an optional operator cache is allowed.
Base.length — Function
length(os::OpIDSum) -> IntReturn the number of terms currently stored in os.
Base.eachindex — Function
eachindex(os::OpIDSum) -> UnitRange{Int}Return the valid term indices of os.
Base.getindex — Function
getindex(os::OpIDSum, i::Integer)Return the pair (scalar, ops) for the ith term of os, where ops is a view into the fixed-width OpID storage for that term.
ITensors.flux — Function
ITensors.flux(ops::NTuple{N,OpID}, n::Int, op_cache_vec::OpCacheVec) where {N} -> QNReturn the total quantum-number flux contributed by operators in ops on sites >= n, using the cached operator metadata in op_cache_vec.