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
expectation_value(ψ, O, [environments]) -> val
expectation_value(ψ, inds => O) -> val
expectation_value(ψ, (mpo, site => O), [environments]) -> valCompute 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 valueO::Union{AbstractMPO, Pair, AbstractTensorMap}: the operator to compute the expectation value of. This can either be anAbstractMPO, a pair of indices and local operator, or a local MPO tensor represented as aAbstractTensorMap.environments::AbstractMPSEnvironments: the environments to use for the calculation. If not given, they will be calculated. Depending on the type ofO, these will be the environments of the operatorOor the MPOmpo.
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> ψ = 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.0Multiline 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
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.
Convergence diagnostics
MPSKit.variance Function
variance(state, hamiltonian, [envs = environments(state, hamiltonian, state)])Compute the variance of the energy of the state with respect to the Hamiltonian.
sourceVariance 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
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.
MPSKit.marek_gap Function
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.
MPSKit.transfer_spectrum Function
transfer_spectrum(above::InfiniteMPS, [below = above], [alg]; howmany = 20, kwargs...)
-> TensorKit.SectorVectorCalculate 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 ofabove.alg: the eigensolver algorithm specification, resolved per sector viaMatrixAlgebraKit.select_algorithm. This can be a KrylovKit algorithm instance (used verbatim for every sector), aMatrixAlgebraKit.DefaultAlgorithmorNamedTuplebundling keyword arguments, ornothing(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 singleInt, which is used for every sector of the transfer space, or anAbstractDict/iterable ofsector => countpairs 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 (seekrylovdimbelow).oversampling_factor = 1: proportionality factor between the Krylov dimension and the number of values requested in a sector (seekrylovdimbelow).krylovdim: the Krylov dimension of the eigensolver. Unless given explicitly, this is chosen adaptively per sector asmax(Defaults.krylovdim, ceil(Int, oversampling_factor * howmany) + oversampling), wherehowmanyis the number of values requested in that sector.kwargs...: further keyword arguments (e.g.tol,maxiter) are forwarded toMatrixAlgebraKit.default_algorithmto build the eigensolver. Passing eigensolver keyword arguments whenalgis an algorithm instance is not allowed, and will result in an error.
MPSKit.transferplot Function
transferplot(above, below = above; sectors = nothing, transferkwargs = (;)[, kwargs...])Plot the partial transfer matrix spectrum of two InfiniteMPS's.
Arguments
above::InfiniteMPS: above mps fortransfer_spectrum.below::InfiniteMPS = above: below mps fortransfer_spectrum.
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 totransfer_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.
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
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.
MPSKit.entanglement_spectrum Function
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.
MPSKit.entanglementplot Function
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 betweensiteandsite + 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.
<!– Maintainer notes:
Symbols included:
expectation_value,correlator,variance,correlation_length,marek_gap,transfer_spectrum,transferplot,entropy,entanglement_spectrum,entanglementplot.The
# TODO: fix environmentsconcern onexpectation_value(::MultilineMPS, ::MultilineMPO)(src/algorithms/expval.jl) and the unresolved-issue comment onvariance(::InfiniteQP, ::InfiniteMPOHamiltonian)(src/algorithms/toolbox.jl) are now surfaced to readers via!!! warningadmonitions above. Remove those warnings once the underlying source issues are resolved.
–>