Skip to content

Observables and analysis

Reference for extracting physical quantities and analysis diagnostics from an MPS. For a task-oriented walkthrough see the how-to guide Computing observables. The full, canonical docstrings for the whole package live in the Library index.

Expectation values

MPSKit.expectation_value Function
julia
expectation_value(ψ, O, [environments]) -> val
expectation_value(ψ, inds => O) -> val
expectation_value(ψ, (mpo, site => O), [environments]) -> val

Compute the expectation value of an operator O on a state ψ, normalized by ⟨ψ|ψ⟩. Optionally, it is possible to make the computations more efficient by also passing in previously calculated environments.

In general, the operator O may consist of an arbitrary MPO O <: AbstractMPO that acts on all sites, a local operator O = inds => operator acting on a subset of sites, or a local MPO tensor acting on a site within a network whose environment is determined by another MPO mpo. In the second case, inds is a tuple of indices that specify the sites on which the operator acts, while the operator is either a AbstractTensorMap or a FiniteMPO. In the latter case, the operator is a AbstractTensorMap that acts on the physical space of a single site.

Arguments

  • ψ::AbstractMPS: the state on which to compute the expectation value

  • O::Union{AbstractMPO, Pair, AbstractTensorMap}: the operator to compute the expectation value of. This can either be an AbstractMPO, a pair of indices and local operator, or a local MPO tensor represented as a AbstractTensorMap.

  • environments::AbstractMPSEnvironments: the environments to use for the calculation. If not given, they will be calculated. Depending on the type of O, these will be the environments of the operator O or the MPO mpo.

Returns

  • val::Number: the (normalized) expectation value ⟨ψ|O|ψ⟩ / ⟨ψ|ψ⟩.

Infinite operators

For an infinite state and an infinite operator (e.g. an InfiniteMPOHamiltonian), the return value is the total over one unit cell; divide by length(ψ) to obtain a per-site value.

Examples

julia
julia> ψ = FiniteMPS(ones(Float64, (ℂ^2)^4));

julia> S_x = TensorMap(Float64[0 1; 1 0], ℂ^2, ℂ^2);

julia> round(expectation_value(ψ, 2 => S_x))
1.0

julia> round(expectation_value(ψ, (2, 3) => S_x  S_x))
1.0
source

Multiline environments

The expectation_value(::MultilineMPS, ::MultilineMPO, envs...) method reuses the passed environments without recomputing them for the operator (see the # TODO: fix environments note in src/algorithms/expval.jl). Results along this code path should be cross-checked against an independent calculation until the environment handling is finalized.

Correlators

MPSKit.correlator Function
julia
correlator(ψ, O1, O2, i, j)
correlator(ψ, O12, i, j)

Compute the 2-point correlator <ψ|O1[i]O2[j]|ψ> for inserting O1 at i and O2 at j. Also accepts ranges for j. The sites must be ordered as i < j; other orderings throw an ArgumentError.

source

Convergence diagnostics

MPSKit.variance Function
julia
variance(state, hamiltonian, [envs = environments(state, hamiltonian, state)])

Compute the variance of the energy of the state with respect to the Hamiltonian.

source

Variance of infinite quasiparticle states

The variance(::InfiniteQP, ::InfiniteMPOHamiltonian, envs) method carries an unresolved implementation note in src/algorithms/toolbox.jl and may be unreliable. Verify its output before using it as a convergence diagnostic for quasiparticle states.

Transfer matrix and correlation length

MPSKit.correlation_length Function
julia
correlation_length(above::InfiniteMPS; sector = nothing, kwargs...)

Compute the correlation length of a given InfiniteMPS based on the next-to-leading eigenvalue of the transfer matrix.

By default this returns a TensorKit.SectorDict mapping each sector of the transfer spectrum to its correlation length. Passing a specific sector returns only that sector's correlation length as a scalar. The remaining kwargs are passed on to transfer_spectrum.

source
MPSKit.marek_gap Function
julia
marek_gap(above::InfiniteMPS; sector = nothing, kwargs...)

Compute the gap ϵ for the asymptotics of the transfer matrix, as well as the Marek gap δ as a scaling measure of the bond dimension, along with the associated angle θ.

By default this returns a TensorKit.SectorDict mapping each sector of the transfer spectrum to its (ϵ, δ, θ) triplet. Passing a specific sector returns only that sector's triplet. The remaining kwargs are passed on to transfer_spectrum.

source
MPSKit.transfer_spectrum Function
julia
transfer_spectrum(above::InfiniteMPS, [below = above], [alg]; howmany = 20, kwargs...)
    -> TensorKit.SectorVector

Calculate the partial spectrum of the left transfer matrix corresponding to the overlap of a given above state and a below state. The result is returned as a TensorKit.SectorVector, whose values can be inspected per sector by indexing, i.e. transfer_spectrum(above)[sector].

Arguments

  • above::InfiniteMPS: the state for the "above" leg of the mixed transfer matrix.

  • below::InfiniteMPS = above: the state for the "below" leg; defaults to the pure transfer matrix of above.

  • alg: the eigensolver algorithm specification, resolved per sector via MatrixAlgebraKit.select_algorithm. This can be a KrylovKit algorithm instance (used verbatim for every sector), a MatrixAlgebraKit.DefaultAlgorithm or NamedTuple bundling keyword arguments, or nothing (the default) to construct the eigensolver from the keyword arguments below.

Keyword Arguments

  • howmany = 20: the number of eigenvalues to compute. This can either be a single Int, which is used for every sector of the transfer space, or an AbstractDict/iterable of sector => count pairs to restrict the computation to specific sectors and request a different number of values per sector.

  • oversampling = 10: additive margin on the Krylov dimension beyond the number of values requested in a sector (see krylovdim below).

  • oversampling_factor = 1: proportionality factor between the Krylov dimension and the number of values requested in a sector (see krylovdim below).

  • krylovdim: the Krylov dimension of the eigensolver. Unless given explicitly, this is chosen adaptively per sector as max(Defaults.krylovdim, ceil(Int, oversampling_factor * howmany) + oversampling), where howmany is the number of values requested in that sector.

  • kwargs...: further keyword arguments (e.g. tol, maxiter) are forwarded to MatrixAlgebraKit.default_algorithm to build the eigensolver. Passing eigensolver keyword arguments when alg is an algorithm instance is not allowed, and will result in an error.

source
MPSKit.transferplot Function
julia
transferplot(above, below = above; sectors = nothing, transferkwargs = (;)[, kwargs...])

Plot the partial transfer matrix spectrum of two InfiniteMPS's.

Arguments

Keyword Arguments

  • sectors = nothing: restrict the spectrum to the given sectors; by default all sectors of the transfer space are included.

  • transferkwargs: kwargs for call to transfer_spectrum.

  • kwargs: other kwargs are passed on to the plotting backend.

  • thetaorigin = 0: origin of the angle range.

  • sector_formatter = string: how to convert sectors to strings.

Note

You will need to manually import Plots.jl to be able to use this function. MPSKit.jl defines its plots based on RecipesBase.jl, but the user still has to add using Plots to be able to actually produce the plots.

source

Entanglement

Entropy and entanglement spectrum are computed from the state's bond/gauge tensors. See the how-to Entanglement entropy and spectrum for worked recipes.

MPSKit.entropy Function
julia
entropy(state, [site::Int])
entropy(spectrum::SectorVector)

Calculate the von Neumann entanglement entropy. The entropy can be computed from either an MPS state or directly from an entanglement spectrum as obtained from entanglement_spectrum.

When called on an MPS with an integer site, the entropy is computed across the entanglement cut to the right of site site. For InfiniteMPS, omitting site returns a vector of entropies, one for each site. For FiniteMPS and WindowMPS, site is required.

source
MPSKit.entanglement_spectrum Function
julia
entanglement_spectrum(ψ, site::Int) -> SectorVector{T, sectortype(ψ), AbstractVector{T}}

Compute the entanglement spectrum at a given site, i.e. the singular values of the gauge matrix to the right of a given site. This is a vector containing the singular values. The contributions from specific sectors can be viewed by indexing accordingly, i.e. entanglement_spectrum(ψ, site)[sector].

For InfiniteMPS and WindowMPS the default value for site is 0.

For FiniteMPS no default value for site is given; it is up to the user to specify.

source
MPSKit.entanglementplot Function
julia
entanglementplot(state; site = 0[, kwargs...])

Plot the entanglement spectrum of a given MPS state.

Arguments

  • state: the MPS for which to compute the entanglement spectrum.

Keyword Arguments

  • site::Int = 0: MPS index for multisite unit cells. The spectrum is computed for the bond between site and site + 1.

  • expand_symmetry = false: add quantum dimension degeneracies.

  • sortby = maximum: the method of sorting the sectors.

  • sector_margin = 1 // 10: the amount of whitespace between sectors.

  • sector_formatter = string: how to convert sectors to strings.

  • kwargs...: other kwargs are passed on to the plotting backend.

Note

You will need to manually import Plots.jl to be able to use this function. MPSKit.jl defines its plots based on RecipesBase.jl, but the user still has to add using Plots to be able to actually produce the plots.

source

<!– Maintainer notes:

  • Symbols included: expectation_value, correlator, variance, correlation_length, marek_gap, transfer_spectrum, transferplot, entropy, entanglement_spectrum, entanglementplot.

  • The # TODO: fix environments concern on expectation_value(::MultilineMPS, ::MultilineMPO) (src/algorithms/expval.jl) and the unresolved-issue comment on variance(::InfiniteQP, ::InfiniteMPOHamiltonian) (src/algorithms/toolbox.jl) are now surfaced to readers via !!! warning admonitions above. Remove those warnings once the underlying source issues are resolved.

–>