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; kwargs...)Compute the correlation length of a given InfiniteMPS based on the next-to-leading eigenvalue of the transfer matrix. The kwargs are passed to transfer_spectrum, and can for example be used to target the correlation length in a specific sector.
MPSKit.marek_gap Function
Given an InfiniteMPS, compute the gap ϵ for the asymptotics of the transfer matrix, as well as the Marek gap δ as a scaling measure of the bond dimension.
MPSKit.transfer_spectrum Function
transfer_spectrum(above::InfiniteMPS; below=above, tol=Defaults.tol, num_vals=20,
sector=leftunit(above))Calculate the partial spectrum of the left mixed transfer matrix corresponding to the overlap of a given above state and a below state. The sector keyword argument can be used to specify a non-trivial total charge for the transfer matrix eigenvectors. Specifically, an auxiliary space ℂ[typeof(sector)](sector => 1)' will be added to the domain of each eigenvector. The tol and num_vals keyword arguments are passed to KrylovKit.eigsolve
MPSKit.transferplot Function
transferplot(above, below = above; sectors = [], 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 = []: vector of sectors for which to compute the spectrum.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.
–>