Library documentation
MPSKit.QP Type
QP{S, T1, T2}Union of the quasiparticle excitation ansätze LeftGaugedQP and RightGaugedQP. It is used for dispatch and to share their gauge-independent interface; it is not a concrete type and cannot be constructed on its own. The internal aliases FiniteQP and InfiniteQP further restrict the ground-state type to FiniteMPS or InfiniteMPS respectively.
MPSKit.WI Constant
const WI = TaylorCluster(; N = 1, extension = false, compression = false)First order Taylor expansion for a time-evolution MPO.
sourceMPSKit.AbstractMPO Type
abstract type AbstractMPO{O} <: AbstractVector{O} endAbstract supertype for Matrix Product Operators (MPOs).
sourceMPSKit.AbstractMPSEnvironments Type
abstract type AbstractEnvironments endAbstract supertype for all environment types.
sourceMPSKit.Algorithm Type
abstract type AlgorithmAbstract supertype for all algorithm structs. These can be thought of as NamedTuples that hold the settings for a given algorithm, which can be used for dispatch. Additionally, the constructors can be used to provide default values and input sanitation.
MPSKit.BUG Type
struct BUG{A, O, G, F, B} <: MPSKit.AlgorithmSingle-site time-evolution algorithm for finite MPS, based on the Basis-Update & Galerkin (BUG) integrator, an unconventional robust integrator for dynamical low-rank approximation with an observed second-order convergence.
Unlike TDVP, BUG advances both the basis (K-step) and the core (Galerkin C-step) tensors forward in time, with no backward-in-time substep. This makes it a more natural choice for imaginary-time (dissipative) evolution, where the backward core step of the conventional projector-splitting integrator TDVP can become unstable for large timesteps.
Fields
integrator::Any: algorithm used in the exponential solversalg_orth::Any: algorithm used to orthonormalize the augmented basis[U₀ │ K₁]after each local updatealg_gauge::Any: factorization used to gauge and truncate the bond ahead of each local updatefinalize::Any: callback function applied after each iteration, of signaturefinalize(t, ψ, H, envs) -> ψ, envsbackend::Any: backend for tensor contractions and index manipulations
Algorithm
Each half-sweep visits every site in turn and, at each site, (i) splits off the bond ahead of it (in the sweep direction) with alg_gauge, truncating it back to trunc, (ii) evolves the connecting tensor over dt/2, and (iii) augments the basis with the new directions discovered by the evolved tensor (old basis first, [U₀ │ K₁], orthonormalized with alg_orth)
Notably, this last step does not include any truncation, and is meant to truncate the previous half-sweep's augmentation. As a result, a truncation scheme truncrank(D) will result in a final MPS of dimension 2D. To restore a maximal dimension of D, apply changebonds with an SvdCut algorithm.
Note
By default the state is not renormalized, as the (loss of) norm might accumulate useful information, such as the accumulated truncation error in real time, or the decaying weight in imaginary time. Pass normalize = true to timestep/time_evolve to renormalize after every half-sweep instead.
Tip
Pass a TimerOutputs.TimerOutput as timeroutput to timestep/timestep! to obtain a breakdown of the time spent in the three steps above (cut_bond, AC_integrate, augment) over all local updates.
References
sourceMPSKit.ChepigaAnsatz Type
struct ChepigaAnsatz{A<:KrylovKit.KrylovAlgorithm, B} <: MPSKit.AlgorithmSingle-site optimization algorithm for excitations on top of MPS groundstates.
Constructors
ChepigaAnsatz()
ChepigaAnsatz(; kwargs...)
ChepigaAnsatz(alg)Create a ChepigaAnsatz algorithm with the given eigensolver, or by passing the keyword arguments to Arnoldi.
Fields
alg::KrylovKit.KrylovAlgorithm: algorithm used for the eigenvalue solversbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of excitations.
References
sourceMPSKit.ChepigaAnsatz2 Type
struct ChepigaAnsatz2{A<:KrylovKit.KrylovAlgorithm, B} <: MPSKit.AlgorithmTwo-site optimization algorithm for excitations on top of MPS groundstates.
Constructors
ChepigaAnsatz2()
ChepigaAnsatz2(; kwargs...)
ChepigaAnsatz2(alg, trunc)Create a ChepigaAnsatz2 algorithm with the given eigensolver and truncation, or by passing the keyword arguments to Arnoldi.
Fields
alg::KrylovKit.KrylovAlgorithm: algorithm used for the eigenvalue solvers, defaults toArnoldi(; krylovdim = 30, tol = 1.0e-10, eager = true)trunc::Any: truncation strategy used when splitting the optimized two-site tensor, defaults tonotrunc()backend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of excitations.
References
sourceMPSKit.DDMRG_Flavour Type
abstract type DDMRG_FlavourAbstract supertype for the different flavours of dynamical DMRG.
sourceMPSKit.DMRG Type
struct DMRG{A, F, E, G, B} <: MPSKit.AlgorithmDensity Matrix Renormalization Group algorithm for finding the dominant eigenvector.
Each site update is, in order: (1) an optional bond expansion (alg_expand), (2) a single-site eigensolve, and (3) a gauge step (alg_gauge). With the defaults (alg_expand = nothing and alg_gauge = nothing, a non-truncating QR gauge derived from trunc = notrunc()) this is textbook single-site DMRG, which cannot change the bond dimension. Setting alg_expand to a bond-expansion algorithm (e.g. OptimalExpand, RandExpand, SketchedExpand) expands the bond with directions orthogonal to the current state ahead of each eigensolve, recovering Controlled Bond Expansion (CBE) DMRG. Setting alg_gauge to a bond-expanding gauge algorithm (e.g. DMRG3S) instead expands the bond as part of the gauge step, after the eigensolve. Either way, a truncating gauge (see below) is then desirable to cut the enlarged bond back down.
Choosing the gauge
By default, alg_gauge is built for you from trunc/alg_svd/alg_orth: trunc = notrunc() (the default) gives a QR decomposition (alg_orth, Householder by default), any other trunc gives a truncated SVD (alg_svd with that trunc).
DMRG() # QR gauge, no truncation
DMRG(; trunc = truncdim(50)) # truncated SVD gaugeTo use a bond-expanding gauge such as DMRG3S, pass it directly as alg_gauge; trunc etc. are still routed through to build the inner gauge it wraps, exactly as above:
DMRG(; alg_gauge = DMRG3S(0.1, ExponentialDecay(0.7)), trunc = truncdim(50))If alg_gauge is instead given with its inner gauge already set (e.g. DMRG3S(0.1, sched, some_gauge)), trunc/alg_svd/alg_orth must be left at their defaults — passing both is an error, since it leaves two conflicting sources for the same setting.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedalg_eigsolve::Any: algorithm used for the eigenvalue solversfinalize::Any: callback function applied after each iteration, of signaturefinalize(iter, ψ, H, envs) -> ψ, envsalg_expand::Any: algorithm used to expand the bond ahead of each local update, ornothingfor nonealg_gauge::Any: gauge algorithm applied after each local update:NoExpandfor a plain gauge step (a QR algorithm with no truncation, or a truncated SVD), or an algorithm that additionally expands the bond beforehand (e.g.DMRG3S)backend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of find_groundstate and approximate.
MPSKit.DMRG2 Type
struct DMRG2{A, G, F, B} <: MPSKit.AlgorithmTwo-site DMRG algorithm for finding the dominant eigenvector.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedalg_eigsolve::Any: algorithm used for the eigenvalue solversalg_gauge::Any: factorization used for the post-update gauge: a truncated SVD (alg_svdwithtrunc)finalize::Any: callback function applied after each iteration, of signaturefinalize(iter, ψ, H, envs) -> ψ, envsbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of find_groundstate and approximate.
MPSKit.DMRG3S Type
struct DMRG3S{N, S<:NoiseSchedule, A} <: MPSKit.AlgorithmGauge algorithm wrapper that, at every site update, injects a Hamiltonian-derived perturbation of the just-optimized tensor before gauging — the "strictly single-site DMRG with subspace expansion" scheme. This lets single-site DMRG introduce basis states/quantum-number sectors absent from the initial state, helping it escape local minima that plain single-site DMRG can get stuck in.
Constructors
DMRG3S(noise, schedule::NoiseSchedule)noise is the initial perturbation amplitude; schedule (see ExponentialDecay, Warmup) controls how it evolves across outer iterations, and once it decays to exactly zero the gauge step reverts to a plain gauge shift for the remainder of the run. The actual factorization used to gauge the expanded tensor is filled in by DMRG's constructor, not supplied here directly — see DMRG's docstring for the calling convention:
DMRG(; alg_gauge = DMRG3S(0.1, ExponentialDecay(0.7)), trunc = truncdim(50))A truncating trunc is strongly recommended alongside DMRG3S, to cut the perturbed bond back down each sweep — DMRG's constructor warns if none is given.
Fields
noise::Any: initial perturbation amplitude, beforescheduleis appliedschedule::NoiseSchedule:NoiseSchedulecontrolling how the amplitude evolves across outer iterationsalg_gauge::Any: factorization used to gauge the expanded tensor;nothinguntilDMRG's constructor fills it in
See also
Used as the alg_gauge argument of DMRG.
References
sourceMPSKit.DerivativeOperator Type
DerivativeOperatorAbstract supertype for derivative operators acting on MPS. These operators are used to represent the effective local operators obtained from taking the partial derivative of an MPS-MPO-MPS sandwich.
sourceMPSKit.DynamicalDMRG Type
struct DynamicalDMRG{F<:MPSKit.DDMRG_Flavour, S, B} <: MPSKit.AlgorithmA dynamical DMRG method for calculating dynamical properties and excited states, based on a variational principle for dynamical correlation functions.
Fields
flavour::MPSKit.DDMRG_Flavour: flavour of the algorithm to use, either of typeNaiveInvertorJeckelmannsolver::Any: algorithm used for the linear solverstol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of propagator.
References
sourceMPSKit.ExponentialDecay Type
ExponentialDecay(decay_rate; threshold = 0.0)Noise schedule that shrinks geometrically: noise -> noise * decay_rate^iter, snapped to exactly zero once it falls below threshold. Use decay_rate < 1 for a standalone DMRG3S run that gradually turns the expansion off as the state converges; a nonzero threshold avoids running the (cheap, but non-free) expansion step indefinitely on a noise amplitude too small to matter.
MPSKit.FiniteChainStyle Type
abstract type GeometryStyle
GeometryStyle(x)
GeometryStyle(::Type{T})Trait to describe the geometry of the input x or type T, which can be either
FiniteChainStyle(): object is defined on a finite chain;InfiniteChainStyle(): object is defined on an infinite chain.
MPSKit.FiniteEnvironments Type
struct FiniteEnvironments <: AbstractMPSEnvironmentsEnvironment manager for FiniteMPS and WindowMPS. This structure is responsible for automatically checking if the queried environment is still correctly cached and if not recalculates.
MPSKit.FiniteExcited Type
struct FiniteExcited{A} <: MPSKit.AlgorithmVariational optimization algorithm for excitations of finite MPS by minimizing the energy of
Fields
gsalg::Any: optimization algorithmweight::Float64: energy penalty for enforcing orthogonality with previous states
See also
Used as the algorithm argument of excitations.
MPSKit.FiniteMPO Type
FiniteMPO(Os::Vector{O}) -> FiniteMPO{O}
FiniteMPO(O::AbstractTensorMap{S, N, N}) where {S, N} -> FiniteMPO{O <: MPOTensor}Matrix Product Operator (MPO) acting on a finite tensor product space with a linear order.
sourceMPSKit.FiniteMPOHamiltonian Method
FiniteMPOHamiltonian(Ws::Vector{<:AbstractMatrix})Create a FiniteMPOHamiltonian from a vector of matrices, such that Ws[i][j, k] represents the operator at site i, left level j and right level k. Here, the entries can be either MPOTensor, Missing or Number.
MPSKit.FiniteMPS Type
struct FiniteMPS{A<:(TensorKit.AbstractTensorMap{T, S, N, 1} where {S, N, T}), B<:(TensorKit.AbstractTensorMap{T, S, 1, 1} where {S, T})} <: MPSKit.AbstractFiniteMPSType that represents a finite Matrix Product State.
Constructors
FiniteMPS(
[f, eltype], physicalspaces::Vector{<:Union{S, CompositeSpace{S}}},
maxvirtualspaces::Union{S, Vector{S}};
normalize = true, left = unitspace(S), right = unitspace(S)
) where {S <: ElementarySpace}
FiniteMPS(
[f, eltype], N::Int, physicalspace::Union{S, CompositeSpace{S}},
maxvirtualspaces::Union{S, Vector{S}};
normalize = true, left = unitspace(S), right = unitspace(S)
) where {S <: ElementarySpace}
FiniteMPS(As::Vector{<:GenericMPSTensor}; normalize = false, overwrite = false)Construct an MPS via a specification of physical and virtual spaces, or from a list of tensors As. All cases reduce to the latter. In particular, a state with a non-trivial total charge can be constructed by passing a non-trivially charged vector space as the left or right virtual spaces.
Arguments
As: vector of site tensorsf = rand: initializer function for the tensor dataeltype = ComplexF64: scalar type of the tensorsphysicalspaces: list of physical spacesN: number of sitesphysicalspace: local physical space, repeated for every sitemaxvirtualspaces: maximal virtual space(s), truncated to what symmetry allows
Keyword Arguments
normalize: normalize the constructed stateoverwrite = false: overwrite the given input tensorsleft = unitspace(S): left-most virtual spaceright = unitspace(S): right-most virtual space
Properties
AL: left-gauged MPS tensorsAR: right-gauged MPS tensorsAC: center-gauged MPS tensorsC: gauge (bond) tensorscenter: location of the gauge center
The center property returns a center::HalfInt that indicates the location of the MPS center:
isinteger(center)→centeris a whole number and indicates the location of the firstACtensor present in the underlyingψ.ACsfield.ishalfodd(center)→centeris a half-odd-integer, meaning that there are noACtensors, and indicating between which sites the bond tensor lives.
For example, mps.center = 7/2 means that the bond tensor is to the right of the 3rd site and can be accessed via mps.C[3].
Notes
By convention, we have that:
AL[i] * C[i]=AC[i]=C[i-1] * AR[i]AL[i]' * AL[i] = 1AR[i] * AR[i]' = 1
Examples
Building a 3-site spin-1/2 MPS from a dense array and checking that its left-gauged tensors are isometries (the state is kept in canonical form even though the raw data is not normalized):
julia> ψ = FiniteMPS(ones(Float64, (ℂ^2)^3));
julia> length(ψ)
3
julia> ψ.AL[1]' * ψ.AL[1] ≈ id(left_virtualspace(ψ, 2))
trueMPSKit.FunctionalSchedule Type
FunctionalSchedule(f) <: NoiseScheduleWrap an arbitrary callable f(noise, iter, ϵ) -> noise as a NoiseSchedule. Used internally by ∘ to compose schedules, but can also be constructed directly for ad hoc schedules that don't warrant their own named type.
MPSKit.GeometryStyle Type
abstract type GeometryStyle
GeometryStyle(x)
GeometryStyle(::Type{T})Trait to describe the geometry of the input x or type T, which can be either
FiniteChainStyle(): object is defined on a finite chain;InfiniteChainStyle(): object is defined on an infinite chain.
MPSKit.GradientGrassmann Type
struct GradientGrassmann{O<:OptimKit.OptimizationAlgorithm, F, B} <: MPSKit.AlgorithmVariational gradient-based optimization algorithm that keeps the MPS in left-canonical form, as points on a Grassmann manifold. The optimization is then a Riemannian gradient descent with a preconditioner to induce the metric from the Hilbert space inner product.
Constructors
GradientGrassmann(; kwargs...)Keyword Arguments
method = ConjugateGradient: instance of optimization algorithm, or type of optimization algorithm to constructfinalize!: finalizer algorithmtol = Defaults.tol: tolerance for convergence criteriummaxiter = Defaults.maxiter: maximum amount of iterationsverbosity = Defaults.verbosity - 1: level of information displaybackend = Defaults.backend(): backend for tensor contractions and index manipulations
Fields
method::OptimKit.OptimizationAlgorithm: optimization algorithmfinalize!::Any: callback function applied after each iteration, of signaturefinalize!(x, f, g, numiter) -> x, f, gbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of find_groundstate and leading_boundary.
References
sourceMPSKit.HamiltonianStyle Type
abstract type OperatorStyle
OperatorStyle(x)
OperatorStyle(::Type{T})Trait to describe the operator behavior of the input x or type T, which can be either
MPOStyle(): product of local factors;HamiltonianStyle(): sum of local terms.
MPSKit.IDMRG Type
struct IDMRG{A, B} <: MPSKit.AlgorithmSingle site infinite DMRG algorithm for finding the dominant eigenvector.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedalg_gauge::Any: algorithm used for gauging the MPSalg_eigsolve::Any: algorithm used for the eigenvalue solversbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of find_groundstate, leading_boundary, and approximate.
MPSKit.IDMRG2 Type
struct IDMRG2{A, S, B} <: MPSKit.AlgorithmTwo-site infinite DMRG algorithm for finding the dominant eigenvector.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedalg_gauge::Any: algorithm used for gauging the MPSalg_eigsolve::Any: algorithm used for the eigenvalue solversalg_svd::Any: algorithm used for the singular value decompositiontrunc::MatrixAlgebraKit.TruncationStrategy: algorithm used for truncation of the two-site updatebackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of find_groundstate, leading_boundary, and approximate.
MPSKit.InfiniteChainStyle Type
abstract type GeometryStyle
GeometryStyle(x)
GeometryStyle(::Type{T})Trait to describe the geometry of the input x or type T, which can be either
FiniteChainStyle(): object is defined on a finite chain;InfiniteChainStyle(): object is defined on an infinite chain.
MPSKit.InfiniteEnvironments Type
InfiniteEnvironments <: AbstractMPSEnvironmentsEnvironments for an infinite MPS-MPO-MPS combination. These solve the corresponding fixedpoint equations:
where T_LL and T_RR are the (regularized) transfer matrix operators on a give site for AL-O-AL and AR-O-AR respectively.
MPSKit.InfiniteMPO Type
InfiniteMPO(Os::PeriodicVector{O}) -> InfiniteMPO{O}Matrix Product Operator (MPO) acting on an infinite tensor product space with a linear order.
sourceMPSKit.InfiniteMPOHamiltonian Method
InfiniteMPOHamiltonian(Ws::Vector{<:AbstractMatrix})Create an InfiniteMPOHamiltonian from a vector of matrices, such that Ws[i][j, k] represents the operator at site i, left level j and right level k. Here, the entries can be either MPOTensor, Missing or Number.
MPSKit.InfiniteMPS Type
struct InfiniteMPS{A<:(TensorKit.AbstractTensorMap{T, S, N, 1} where {S, N, T}), B<:(TensorKit.AbstractTensorMap{T, S, 1, 1} where {S, T})} <: MPSKit.AbstractMPSType that represents an infinite Matrix Product State.
Constructors
InfiniteMPS(
[f, eltype], physicalspaces::Vector{<:Union{S, CompositeSpace{S}}},
virtualspaces::Vector{<:Union{S, CompositeSpace{S}}};
kwargs...
) where {S <: ElementarySpace}
InfiniteMPS(As::AbstractVector{<:GenericMPSTensor}; kwargs...)
InfiniteMPS(ALs::AbstractVector{<:GenericMPSTensor}, C₀::MPSBondTensor; kwargs...)Construct an MPS via a specification of physical and virtual spaces, or from a list of tensors As, or a list of left-gauged tensors ALs.
Arguments
As: vector of site tensorsALs: vector of left-gauged site tensorsC₀: initial gauge tensorf = rand: initializer function for the tensor dataeltype = ComplexF64: scalar type of the tensorsphysicalspaces: list of physical spacesvirtualspaces: list of virtual spaces
Keyword Arguments
tol: gauge fixing tolerancemaxiter: gauge fixing maximum iterations
Properties
AL: left-gauged MPS tensorsAR: right-gauged MPS tensorsAC: center-gauged MPS tensorsC: gauge (bond) tensors
Notes
By convention, we have that:
AL[i] * C[i]=AC[i]=C[i-1] * AR[i]AL[i]' * AL[i] = 1AR[i] * AR[i]' = 1
Examples
A one-site unit cell built from an explicit (V_left ⊗ P ← V_right) tensor. Here the bond dimension is one, so this is the |+⟩ product state, for which ⟨X⟩ = 1:
julia> A = TensorMap(ones(Float64, 2, 1), ℂ^1 ⊗ ℂ^2, ℂ^1);
julia> ψ = InfiniteMPS([A]);
julia> length(ψ)
1
julia> X = TensorMap(Float64[0 1; 1 0], ℂ^2, ℂ^2);
julia> round(real(expectation_value(ψ, 1 => X)); digits = 6)
1.0MPSKit.InfiniteQPEnvironments Type
InfiniteQPEnvironments <: AbstractMPSEnvironmentsEnvironments for an infinite QP-MPO-QP combination. These solve the corresponding fixedpoint equations:
where T_BL, T_BR, T_RL and T_LR are the (regularized) transfer matrix operators on a given site for B-O-AL, B-O-AR, AR-O-AL and AL-O-AR respectively.
MPSKit.Jeckelmann Type
struct Jeckelmann <: MPSKit.DDMRG_FlavourThe original flavour of dynamical DMRG, which minimizes functional (14) from Jeckelmann2002. Writing
which attains its minimum at
Together with equation (11) from that same paper we can determine the full propagator
Returns the approximation of
See also
NaiveInvert for a less costly but less accurate alternative.
References
sourceMPSKit.JordanMPOTensor Type
struct JordanMPOTensor{T<:Number, S, A<:DenseArray{T<:Number, 1}} <: BlockTensorKit.AbstractBlockTensorMap{T<:Number, S, 2, 2}A single tensor of a matrix product operator (MPO) in upper triangular (Jordan) block form, as used to represent the local tensors of an MPOHamiltonian. The virtual (row, column) structure is
where A is the bulk of interacting operators, C/B are the operators that start/finish an interaction, D is the on-site term, and the diagonal 1s are identities.
Type parameters
T <: Number: thescalartypeof the tensors.S: thespacetypeof the tensors.A <: DenseVector{T}: the storage type of the underlying tensors.
Properties
The reduced-leg A, B, C and D blocks are exposed as properties (W.A, W.B, W.C, W.D), reconstructed on demand from the stored tensors and scalars.
Notes
Rather than storing the dense block matrix, the genuine operators and the identities are kept separately:
tensors::SparseBlockTensorMapholds the non-identity operators over the full virtual space (soA,B,CandDall live at their(row, 1, 1, col)position).scalars::Dict{CartesianIndex{4}, T}holds the scalar multiples of the identity, keyed by their(row, 1, 1, col)virtual position; the diagonal corner1s are stored here as well.
An index is never present in both tensors and scalars. This keeps the ubiquitous identity blocks free of dense storage and lets identities be materialized lazily only when needed.
MPSKit.JordanMPO_AC2_Hamiltonian Type
JordanMPO_AC2_Hamiltonian{O1, O2, O3, O4}Efficient operator for representing the single-site derivative of a MPOHamiltonian sandwiched between two MPSs. In particular, this operator aims to make maximal use of the structure of the MPOHamiltonian to reduce the number of operations required to apply the operator to a tensor.
MPSKit.JordanMPO_AC_Hamiltonian Type
JordanMPO_AC_Hamiltonian{O1, O2, O3}Efficient operator for representing the single-site derivative of a MPOHamiltonian sandwiched between two MPSs. In particular, this operator aims to make maximal use of the structure of the MPOHamiltonian to reduce the number of operations required to apply the operator to a tensor.
MPSKit.LazySum Type
struct LazySum{O} <: AbstractArray{O, 1}Type that represents a lazy sum, i.e. explicit summation is only done when needed. This type is basically an AbstractVector with some extra functionality to calculate things efficiently.
Constructors
LazySum(x::Vector)
LazySum(ops::AbstractVector, fs::AbstractVector)Fields
ops::Vector: vector of summable objects
MPSKit.LeftCanonical Type
struct LeftCanonical <: MPSKit.AlgorithmAlgorithm for bringing an InfiniteMPS into the left-canonical form.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedalg_orth::Any: algorithm used for orthogonalization of the tensorsalg_eigsolve::Any: algorithm used for the eigensolvereig_miniter::Int64: minimal amount of iterations before using the eigensolver steps
See also
Used as the alg argument of gaugefix!.
MPSKit.LeftGaugedQP Type
struct LeftGaugedQP{S, T1, T2, E<:Number}Left-gauged quasiparticle excitation ansatz on top of a matrix product state ground state. The excitation is parametrized through the left-gauge nullspace of the ground-state tensors, and the object behaves as a vector so it can be handed directly to the iterative eigensolvers used by excitations.
For a FiniteMPS ground state this represents a finite (localized) quasiparticle; for an InfiniteMPS ground state it represents a momentum eigenstate with the given momentum. When left_gs !== right_gs the ansatz describes a domain wall between the two ground states.
Constructors
LeftGaugedQP(datfun, left_gs, right_gs = left_gs; sector, momentum = 0.0)These states are normally produced by excitations with a QuasiparticleAnsatz rather than constructed directly. When constructing manually, datfun initializes the variational tensors (e.g. rand/randn), sector selects the charge sector of the excitation, and momentum sets the momentum for infinite ground states.
Fields
left_gs,right_gs: the ground state(s) the excitation lives on; distinct values yield a domain wall.VLs: left-nullspace tensors of the ground-stateAL(satisfyingAL' * VL == 0).Xs: the variational parameters of the ansatz.momentum: the excitation momentum (used for infinite ground states).
See also
sourceMPSKit.MPO Type
struct MPO{TO, V <: AbstractVector{TO}} <: AbstractMPO{TO}Matrix Product Operator (MPO) acting on a tensor product space with a linear order.
See also: FiniteMPO, InfiniteMPO
MPSKit.MPODerivativeOperator Type
struct MPODerivativeOperator{L, O <: Tuple, R, B, A}Effective local operator obtained from taking the partial derivative of an MPS-MPO-MPS sandwich.
The backend and allocator fields are the ones used by the application of the operator. They default to DefaultBackend() and DefaultAllocator(), i.e. this operator does not hold on to any scratch space of its own unless it is explicitly given some.
MPSKit.MPOHamiltonian Type
struct MPOHamiltonian{TO<:JordanMPOTensor, V<:AbstractArray{TO<:JordanMPOTensor, 1}} <: AbstractMPO{TO<:JordanMPOTensor}MPO representation of a Hamiltonian. This is a specific form of an AbstractMPO, where all the sites are represented by an upper triangular block matrix of the following form:
where A, B, C, and D are MPOTensors, or (sparse) blocks thereof.
Constructors
The finite and infinite variants, FiniteMPOHamiltonian and InfiniteMPOHamiltonian, are constructed from a lattice of physical spaces together with a set of inds => operator pairs describing the local terms:
FiniteMPOHamiltonian(lattice::AbstractArray{<:VectorSpace}, local_operators...)
InfiniteMPOHamiltonian(lattice::AbstractArray{<:VectorSpace}, local_operators...)Properties
A: bulk block of interacting operators at each siteB: operators that finish an interactionC: operators that start an interactionD: on-site terms
Examples
A nearest-neighbour term is a two-element index tuple (i, i + 1) => O₁₂; an on-site term is a one-element tuple (i,) => O. For the finite variant the lattice lists every site; for the infinite variant it is a single unit cell and indices wrap around it periodically.
julia> X = TensorMap(Float64[0 1; 1 0], ℂ^2, ℂ^2);
julia> Hf = FiniteMPOHamiltonian(fill(ℂ^2, 3), ((i, i + 1) => X ⊗ X for i in 1:2));
julia> Hf isa FiniteMPOHamiltonian, length(Hf)
(true, 3)
julia> Hi = InfiniteMPOHamiltonian(fill(ℂ^2, 1), (1, 2) => X ⊗ X, (1,) => X);
julia> Hi isa InfiniteMPOHamiltonian, length(Hi)
(true, 1)See also
instantiate_operator is responsible for instantiating the local operators in a form that is compatible with this constructor.
MPSKit.MPOStyle Type
abstract type OperatorStyle
OperatorStyle(x)
OperatorStyle(::Type{T})Trait to describe the operator behavior of the input x or type T, which can be either
MPOStyle(): product of local factors;HamiltonianStyle(): sum of local terms.
MPSKit.MPOTensor Type
MPOTensor{S}Tensor type for representing local MPO tensors, with the index convention W ⊗ S ← N ⊗ E, where N, E, S and W denote the north, east, south and west virtual spaces respectively.
MPSKit.MixedCanonical Type
struct MixedCanonical <: MPSKit.AlgorithmAlgorithm for bringing an InfiniteMPS into the mixed-canonical form.
Fields
alg_leftcanonical::MPSKit.LeftCanonical: algorithm for bringing anInfiniteMPSinto left-canonical form.alg_rightcanonical::MPSKit.RightCanonical: algorithm for bringing anInfiniteMPSinto right-canonical form.order::Symbol: order in which to apply the canonicalizations, should be:L,:R,:LRor:RL
See also
Used as the alg argument of gaugefix!.
MPSKit.Multiline Type
struct Multiline{T}Object that represents multiple lines of objects of type T. Typically used to represent multiple lines of InfiniteMPS (MultilineMPS) or MPO (Multiline{<:AbstractMPO}).
Fields
data::PeriodicArray{T, 1}: the data of the multiline object
See also
sourceMPSKit.MultilineMPO Type
const MultilineMPO = Multiline{<:AbstractMPO}Type that represents multiple lines of MPO objects.
Constructors
MultilineMPO(mpos::AbstractVector{<:Union{SparseMPO, DenseMPO}})
MultilineMPO(Os::AbstractMatrix{<:MPOTensor})See also
sourceMPSKit.MultilineMPS Type
const MultilineMPS = Multiline{<:InfiniteMPS}Type that represents multiple lines of InfiniteMPS objects.
Constructors
MultilineMPS(mpss::AbstractVector{<:InfiniteMPS})
MultilineMPS(
[f, eltype], physicalspaces::Matrix{<:Union{S, CompositeSpace{S}}},
virtualspaces::Matrix{<:Union{S, CompositeSpace{S}}}
) where {S <: ElementarySpace}
MultilineMPS(As::AbstractMatrix{<:GenericMPSTensor}; kwargs...)
MultilineMPS(
ALs::AbstractMatrix{<:GenericMPSTensor},
C₀::AbstractVector{<:MPSBondTensor}; kwargs...
)Properties
AL: left-gauged MPS tensorsAR: right-gauged MPS tensorsAC: center-gauged MPS tensorsC: gauge (bond) tensors
See also
sourceMPSKit.MultipliedOperator Type
Structure representing a multiplied operator. Consists of
- An operator op (MPO, Hamiltonian, ...)
- An object f that gets multiplied with the operator (Number, function, ...)MPSKit.NaiveInvert Type
struct NaiveInvert <: MPSKit.DDMRG_FlavourAn alternative approach to the dynamical DMRG algorithm, without quadratic terms but with a less controlled approximation. This algorithm minimizes the following cost function
Returns the approximation of
See also
Jeckelmann for the original approach.
MPSKit.NoiseSchedule Type
NoiseScheduleSupertype for controlling how a bond-expansion algorithm's noise/perturbation amplitude evolves across DMRG sweeps. A schedule s is called as s(noise, iter, ϵ) -> noise, given the current noise amplitude, the outer iteration count, and the current global convergence error, and returns the amplitude to use for the next iteration. Schedules can be composed with ∘; see ExponentialDecay, Warmup, FunctionalSchedule.
MPSKit.OperatorStyle Type
abstract type OperatorStyle
OperatorStyle(x)
OperatorStyle(::Type{T})Trait to describe the operator behavior of the input x or type T, which can be either
MPOStyle(): product of local factors;HamiltonianStyle(): sum of local terms.
MPSKit.OptimalExpand Type
struct OptimalExpand{S, B} <: MPSKit.AlgorithmAn algorithm that expands the given mps as described in Zauner-Stauber et al. Phys. Rev. B 97 (2018), by selecting the dominant contributions of a two-site updated MPS tensor, orthogonal to the original ψ.
The expansion is state-preserving: the added directions are connected through a zero block, so that the expanded state represents the same physical state as the original one (as required for e.g. TDVP).
Note
trunc bounds how much is added to each bond, not the total bond dimension that is kept. It is applied to the two-site update projected onto the orthogonal complement of the current state, so truncrank(k) grows every bond by at most k — capped by the dimension of the local two-site complement, which is why a bond can grow by less than k, or not at all. The trunc of SvdCut, and of the drivers DMRG and TDVP, has the other meaning: it bounds what is kept.
Note
The projected block is normalized before the decomposition, so a value-based strategy (trunctol, truncerror) selects a fraction of the complement weight rather than an absolute error on the state, and the retained fraction does not shrink as the state converges. truncrank and truncspace are the strategies with a robust meaning here.
Note
changebonds! is only defined for FiniteMPS, and modifies both the state and its environment.
Fields
alg_svd::Any: algorithm used for the singular value decompositiontrunc::MatrixAlgebraKit.TruncationStrategy: truncation strategy selecting how many directions are added to each bond, rather than how much of the bond is keptbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of changebonds and changebonds!.
MPSKit.PeriodicArray Type
struct PeriodicArray{T, N} <: AbstractArray{T, N}Array wrapper with periodic boundary conditions.
Fields
data::Array{T, N}: the data of the array
Examples
A = PeriodicArray([1, 2, 3])
A[0], A[2], A[4]
# output
(3, 2, 1)A = PeriodicArray([1 2; 3 4])
A[-1, 1], A[1, 1], A[4, 5]
# output
(1, 1, 3)See also
PeriodicVector, PeriodicMatrix
MPSKit.PeriodicMatrix Type
PeriodicMatrix{T}Two-dimensional dense array with elements of type T and periodic boundary conditions. Alias for PeriodicArray{T, 2}.
MPSKit.PeriodicVector Type
PeriodicVector{T}One-dimensional dense array with elements of type T and periodic boundary conditions. Alias for PeriodicArray{T, 1}.
MPSKit.ProjectionDerivativeOperator Type
struct ProjectionDerivativeOperator{L, O <: Tuple, R, B, A}Effective local operator obtained from taking the partial derivative of the projector |ψ⟩⟨ψ| onto an MPS.
The backend and allocator fields are the ones used by the application of the operator. They default to DefaultBackend() and DefaultAllocator(), i.e. this operator does not hold on to any scratch space of its own unless it is explicitly given some.
MPSKit.QuasiparticleAnsatz Type
struct QuasiparticleAnsatz{A, E} <: MPSKit.AlgorithmOptimization algorithm for quasi-particle excitations on top of MPS groundstates.
Constructors
QuasiparticleAnsatz()
QuasiparticleAnsatz(; kwargs...)
QuasiparticleAnsatz(alg)Create a QuasiparticleAnsatz algorithm with the given eigensolver, or by passing the keyword arguments to Arnoldi.
Fields
alg::Any: algorithm used for the eigenvalue solversalg_environments::Any: algorithm used for the quasiparticle environments
See also
Used as the algorithm argument of excitations.
References
sourceMPSKit.RandExpand Type
struct RandExpand{S} <: MPSKit.AlgorithmAn algorithm that expands the bond dimension by adding random unitary vectors that are orthogonal to the existing state. This means that additional directions are added to AL and AR that are contained in the nullspace of both. Note that this happens in parallel, and therefore the expansion will never go beyond the local two-site subspace.
trunc bounds how much is added to each bond, not the total bond dimension that is kept, and it acts on a spectrum that carries no physical information: for an InfiniteMPS the weights are drawn uniformly at random, one per candidate direction, while for a FiniteMPS they are the singular values of a randomized two-site update restricted to the orthogonal complement. Only truncrank and truncspace therefore have a robust meaning — trunctol(; atol = x) keeps the directions whose random weight happens to exceed x. The trunc of SvdCut, and of the drivers DMRG and TDVP, has the other meaning: it bounds what is kept.
Note
The environments are not used here, but changebonds! modifies both the state and environment so they remain consistent.
Fields
alg_svd::Any: algorithm used for the singular value decompositiontrunc::MatrixAlgebraKit.TruncationStrategy: truncation strategy selecting how many directions are added to each bond, rather than how much of the bond is kept
See also
Used as the algorithm argument of changebonds and changebonds!.
MPSKit.RightCanonical Type
struct RightCanonical <: MPSKit.AlgorithmAlgorithm for bringing an InfiniteMPS into the right-canonical form.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedalg_orth::Any: algorithm used for orthogonalization of the tensorsalg_eigsolve::Any: algorithm used for the eigensolvereig_miniter::Int64: minimal amount of iterations before using the eigensolver steps
See also
Used as the alg argument of gaugefix!.
MPSKit.RightGaugedQP Type
struct RightGaugedQP{S, T1, T2, E<:Number}Right-gauged counterpart of LeftGaugedQP: the same quasiparticle excitation ansatz, but parametrized through the right-gauge nullspace of the ground-state tensors. It is most often obtained via convert(RightGaugedQP, ϕ) from a LeftGaugedQP rather than constructed directly.
Constructors
RightGaugedQP(datfun, left_gs, right_gs = left_gs; sector, momentum = 0.0)Fields
left_gs,right_gs: the ground state(s) the excitation lives on; distinct values yield a domain wall.Xs: the variational parameters of the ansatz.VRs: right-nullspace tensors of the ground-stateAR.momentum: the excitation momentum (used for infinite ground states).
See also
sourceMPSKit.SketchedExpand Type
struct SketchedExpand{S, B} <: MPSKit.AlgorithmAn algorithm that expands the bond dimension like OptimalExpand — selecting the dominant directions of the projected two-site update orthogonal to the current state — but at single-site cost using the randomized "shrewd selection" of Controlled Bond Expansion. A random sketch of the orthogonal complement is folded into the effective environment, collapsing the large bond before the two-site update is ever formed, and the dominant directions are read off a small singular value decomposition.
The state-preserving behaviour matches OptimalExpand.
Note
trunc bounds how much is added to each bond, not the total bond dimension that is kept: it sizes the sketch target Vk within the orthogonal complement (see sketch_space), so truncrank(k) aims to grow every bond by k, capped by the dimension of the local complement. Because that target space is selected from uniformly random weights rather than from a spectrum, its per-sector split is drawn at random rather than ordered by importance — unlike OptimalExpand, where the decomposition itself picks out the dominant sectors — so only truncrank and truncspace have a robust meaning here. The trunc of SvdCut, and of the drivers DMRG and TDVP, has the other meaning: it bounds what is kept.
Note
Only defined for FiniteMPS (through changebond!), so it can be used standalone or as the alg_expand strategy of DMRG. The reported ϵ_2site is a randomized estimate, and the folded application does not exploit JordanMPO sparsity.
Fields
alg_orth::Any: algorithm used to orthonormalize the sketched complement (passed as thealgofleft_orth!/right_orth!);nothingselects QR without oversampling and an SVD-based decomposition otherwisetrunc::MatrixAlgebraKit.TruncationStrategy: truncation strategy selecting how many directions are added to each bond, rather than how much of the bond is keptoversampling::Int64: number of extra sketch columns drawn beyond the target rank (range-finder oversampling)backend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of changebonds and changebonds!.
References
sourceMPSKit.SvdCut Type
struct SvdCut{S} <: MPSKit.AlgorithmAn algorithm that uses truncated SVD to change the bond dimension of a state or operator. This is achieved by a sweeping algorithm that locally performs (optimal) truncations in a gauged basis.
changedbonds! is only defined for FiniteMPS and FiniteMPO.
Fields
alg_svd::Any: algorithm used for the singular value decompositiontrunc::MatrixAlgebraKit.TruncationStrategy: algorithm used for truncation of the gauge tensors
See also
Used as the algorithm argument of changebonds and changebonds!.
References
sourceMPSKit.TDVP Type
struct TDVP{A, E, G, F, B} <: MPSKit.AlgorithmSingle site MPS time-evolution algorithm based on the Time-Dependent Variational Principle.
For finite MPS, setting alg_expand to a bond-expansion algorithm (e.g. OptimalExpand, SketchedExpand) expands the bond with directions orthogonal to the current state ahead of each local integration, recovering Controlled Bond Expansion (CBE) TDVP and lifting the fixed-bond limitation of plain single-site TDVP. A truncating trunc is then required to cut the enlarged bond back down (selecting the truncated-SVD gauge). The expansion is state-preserving, as required for a consistent time evolution.
Note
By default the norm is not preserved: neither the bond expansion nor the truncation renormalizes, so the state norm keeps useful information (the accumulated truncation error in real time, or the decaying weight in imaginary time). Pass normalize = true to timestep/time_evolve to renormalize at every step instead, like a ground-state search. This is independent of imaginary_evolution. CBE is only available for finite MPS.
Fields
integrator::Any: algorithm used in the exponential solverstolgauge::Float64: tolerance for gauging algorithmgaugemaxiter::Int64: maximal amount of iterations for gauging algorithmalg_expand::Any: algorithm used to expand the bond ahead of each local update, ornothingfor none (finite CBE-TDVP)alg_gauge::Any: factorization used for the post-update gauge: a QR algorithm (no truncation) or a truncated SVDfinalize::Any: callback function applied after each iteration, of signaturefinalize(t, ψ, H, envs) -> ψ, envsbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of timestep, timestep! and time_evolve.
References
sourceMPSKit.TDVP2 Type
struct TDVP2{A, S, F, B} <: MPSKit.AlgorithmTwo-site MPS time-evolution algorithm based on the Time-Dependent Variational Principle.
Fields
integrator::Any: algorithm used in the exponential solverstolgauge::Float64: tolerance for gauging algorithmgaugemaxiter::Int64: maximal amount of iterations for gauging algorithmalg_svd::Any: algorithm used for the singular value decompositiontrunc::MatrixAlgebraKit.TruncationStrategy: algorithm used for truncation of the two-site updatefinalize::Any: callback function applied after each iteration, of signaturefinalize(t, ψ, H, envs) -> ψ, envsbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of timestep, timestep! and time_evolve.
References
sourceMPSKit.TaylorCluster Type
struct TaylorCluster <: MPSKit.AlgorithmAlgorithm for constructing the Nth order time evolution MPO using the Taylor cluster expansion.
Fields
N::Int64: order of the Taylor expansionextension::Bool: include higher-order correctionscompression::Bool: approximate compression of corrections, accurate up to orderN
See also
Used as the algorithm argument of make_time_mpo.
References
sourceMPSKit.TimedOperator Type
Structure representing a time-dependent operator. Consists of
- An operator op (MPO, Hamiltonian, ...)
- An function f that gives the time-dependence according to op(t) = f(t)*opMPSKit.UnionAlg Type
struct UnionAlg{A, B} <: MPSKit.AlgorithmAlgorithm wrapper representing the sequential application of two algorithms, as produced by alg1 & alg2.
Fields
alg1::Any: first algorithmalg2::Any: second algorithm
See also
Used as the algorithm argument of find_groundstate and changebonds.
MPSKit.UntimedOperator Type
Structure representing a time-independent operator that will be multiplied with a constant coefficient. Consists of
- An operator (MPO, Hamiltonian, ...)
- A number f that gets multiplied with the operatorMPSKit.VOMPS Type
struct VOMPS{F, B} <: MPSKit.AlgorithmPower method algorithm for finding dominant eigenvectors of infinite MPOs. This method works by iteratively approximating the product of an operator and a state with a new state of the same bond dimension.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedalg_gauge::Any: algorithm used for gauging theInfiniteMPSalg_environments::Any: algorithm used for the MPS environmentsfinalize::Any: callback function applied after each iteration, of signaturefinalize(iter, ψ, H, envs) -> ψ, envsbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of leading_boundary and approximate.
References
sourceMPSKit.VUMPS Type
struct VUMPS{F, B} <: MPSKit.AlgorithmVariational optimization algorithm for uniform matrix product states, based on the combination of DMRG with matrix product state tangent space concepts.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal amount of iterationsverbosity::Int64: setting for how much information is displayedalg_gauge::Any: algorithm used for gauging theInfiniteMPSalg_eigsolve::Any: algorithm used for the eigenvalue solversalg_environments::Any: algorithm used for the MPS environmentsfinalize::Any: callback function applied after each iteration, of signaturefinalize(iter, ψ, H, envs) -> ψ, envsbackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of find_groundstate and leading_boundary.
References
MPSKit.VUMPSSvdCut Type
struct VUMPSSvdCut{B} <: MPSKit.AlgorithmAn algorithm that uses a two-site update step to change the bond dimension of a state.
Note
changebonds! is not defined.
Fields
alg_gauge::Any: algorithm used for gauging theInfiniteMPSalg_eigsolve::Any: algorithm used for the eigenvalue solversalg_svd::Any: algorithm used for the singular value decompositiontrunc::MatrixAlgebraKit.TruncationStrategy: algorithm used for truncation of the two-site updatebackend::Any: backend for tensor contractions and index manipulations
See also
Used as the algorithm argument of changebonds.
MPSKit.WII Type
struct WII <: MPSKit.AlgorithmGeneralization of the Euler approximation of the operator exponential for MPOs.
Fields
tol::Float64: tolerance for convergence criteriummaxiter::Int64: maximal number of iterations
See also
Used as the algorithm argument of make_time_mpo.
References
sourceMPSKit.Warmup Type
Warmup(iters::Int)Noise schedule that keeps the noise amplitude constant for the first iters outer iterations, then drops it to exactly zero. Useful composed with a decaying schedule (e.g. ExponentialDecay(0.7) ∘ Warmup(5)) to hold the perturbation at full strength for a few sweeps before starting to taper it off.
MPSKit.WindowArray Type
WindowArray{T} <: AbstractVector{T}A vector embedded in a periodic environment to the left and right, which can be accessed with arbitrary integer indices. The middle part is a regular Vector{T} and the left and right parts are PeriodicVector{T}s.
This vector inherits most of its properties from the middle part, including its length and axes. Nevertheless, indexing operations are overloaded to allow for out-of-bounds access, which is resolved by the periodic environments.
See also PeriodicVector.
MPSKit.WindowMPOHamiltonian Type
struct WindowMPOHamiltonian{O} <: AbstractMPO{O}The Hamiltonian counterpart of a WindowMPS: a finite region embedded between an infinite environment to the left and to the right. It consists of an infinite Hamiltonian to the left, a finite Hamiltonian in the middle, and an infinite Hamiltonian to the right.
Acts similar to just a finite Hamiltonian, but we "remember" the boundary Hamiltonians.
Constructors
WindowMPOHamiltonian(ham::InfiniteMPOHamiltonian, interval::UnitRange)Construct a WindowMPOHamiltonian by carving a finite interval out of an infinite Hamiltonian ham. The finite window consists of the sites in interval, while the left and right environments are copies of ham whose unit cells are circshifted so that they line up with the window boundaries.
Fields
left_ham::MPOHamiltonian{O, PeriodicVector{O}} where O: Hamiltonian acting on the infinite environment to the left of the windowfinite_ham::MPOHamiltonian{O, Vector{O}} where O: Hamiltonian acting on the finite windowright_ham::MPOHamiltonian{O, PeriodicVector{O}} where O: Hamiltonian acting on the infinite environment to the right of the window
MPSKit.WindowMPS Type
struct WindowMPS{A<:(TensorKit.AbstractTensorMap{T, S, N, 1} where {S, N, T}), B<:(TensorKit.AbstractTensorMap{T, S, 1, 1} where {S, T})} <: MPSKit.AbstractFiniteMPSType that represents a finite Matrix Product State embedded in an infinite Matrix Product State.
Constructors
WindowMPS(left_gs::InfiniteMPS, window_state::FiniteMPS, [right_gs::InfiniteMPS])
WindowMPS(left_gs::InfiniteMPS, window_tensors::AbstractVector, [right_gs::InfiniteMPS])
WindowMPS(
[f, eltype], physicalspaces::Vector{<:Union{S, CompositeSpace{S}}},
virtualspaces::Vector{<:Union{S, CompositeSpace{S}}}, left_gs::InfiniteMPS,
[right_gs::InfiniteMPS]
)
WindowMPS(
[f, eltype], physicalspaces::Vector{<:Union{S, CompositeSpace{S}}},
maxvirtualspace::S, left_gs::InfiniteMPS, [right_gs::InfiniteMPS]
)
WindowMPS(ψ::InfiniteMPS, L::Int)Construct a WindowMPS via a specification of left and right infinite environment, and either a window state or a vector of tensors to construct the window. Alternatively, it is possible to supply the same arguments as for the constructor of FiniteMPS, followed by a left (and right) environment to construct the WindowMPS in one step. Finally, a WindowMPS can be constructed from an InfiniteMPS by promoting a region of length L to a FiniteMPS.
Note
By default, the right environment is chosen to be equal to the left, however no copy is made. In this case, changing the left state will also affect the right state.
Properties
left_gs::InfiniteMPS: left infinite environmentwindow::FiniteMPS: finite window Matrix Product Stateright_gs::InfiniteMPS: right infinite environmentAL: left-gauged MPS tensorsAR: right-gauged MPS tensorsAC: center-gauged MPS tensorsC: gauge (bond) tensors
MPSKit.WindowMPS Method
WindowMPS(ψ::InfiniteMPS, L::Int)
WindowMPS(ψ::InfiniteMPS, interval::UnitRange)Construct a WindowMPS from an infinite MPS ψ by promoting the sites in interval (or 1:L) to the finite window while keeping ψ as the left and right infinite environments. The environment unit cells are circshifted so that they line up with the window boundaries.
MPSKit.Zipup Type
struct Zipup{U<:MatrixAlgebraKit.TruncatedAlgorithm, D<:Union{Nothing, MatrixAlgebraKit.TruncatedAlgorithm}} <: MPSKit.AlgorithmAlgorithm that approximates an open-boundary finite MPO-MPS product using a zip-up sweep, optionally followed by a zip-down sweep in the opposite direction. The MPO and MPS are contracted one site at a time, and the enlarged virtual bond is truncated immediately. The sweep direction is selected by left_to_right.
approximate((O, ϕ), alg::Zipup) -> ψ, ϵ
approximate!(ψ, (O, ϕ), alg::Zipup) -> ψ, ϵContrary to the variational algorithms, this algorithm requires no initial guess: the in-place version simply uses ψ as the destination of the sweep, overwriting its contents, and may alias ϕ. The out-of-place version allocates a destination with the promoted scalar type of O and ϕ. Both return the truncation error ϵ alongside the approximated state.
Constructors
Zipup(; trunc, alg_svd = Defaults.alg_svd(), left_to_right = true)
Zipup(alg_zipup, [alg_zipdown]; left_to_right = true)Create a Zipup algorithm with the given truncated gauge algorithm, or by passing a truncation scheme and singular value decomposition algorithm. The keyword trunc can be either one truncation strategy for a single zip-up sweep, or a tuple (zipup_trunc, zipdown_trunc) for a zip-up sweep followed by a zip-down sweep. Equivalently, one can pass the corresponding truncated gauge algorithms directly as alg_zipup and alg_zipdown. The keyword left_to_right selects the direction of the zip-up sweep, the zip-down sweep always running in the opposite direction.
Following Paeckel et al., if the desired final bond dimension is D, one can use a more permissive zip-up truncation, e.g. rank 2D with stricter tolerances, and use alg_zipdown to impose the final truncation.
Fields
alg_zipup::MatrixAlgebraKit.TruncatedAlgorithm: algorithm used for gauging and truncating the local tensors during the zip-up sweepalg_zipdown::Union{Nothing, MatrixAlgebraKit.TruncatedAlgorithm}: algorithm used for the final locally gauged truncation pass;nothingskips this passleft_to_right::Bool: iftrue, zip up from left to right and truncate from right to left, and vice versa
References
sourceBase.:∘ Method
s1::NoiseSchedule ∘ s2::NoiseScheduleCompose two noise schedules: s2 is applied first, and its result is fed through s1, i.e. (s1 ∘ s2)(noise, iter, ϵ) == s1(s2(noise, iter, ϵ), iter, ϵ) — the same convention as function composition in Base.
MPSKit.AC2 Function
AC2(ψ::AbstractMPS, i; kind = :ACAR)Obtain the two-site (center) gauge tensor at site i of the MPS ψ. If this hasn't been computed before, this can be computed as:
kind = :ACAR: AC[i] * AR[i+1]kind = :ALAC: AL[i] * AC[i+1]
MPSKit.AC2_hamiltonian Function
AC2_hamiltonian(site, below, operator, above, envs)Effective two-site local operator acting at site.
┌── ──┐
│ │ │ │
┌┴┐┌─┴─┐┌─┴─┐┌┴┐
│ ├┤ ├┤ ├┤ │
└┬┘└─┬─┘└─┬─┘└┬┘
│ │ │ │
└── ──┘See also AC2_projection.
MPSKit.AC2_projection Function
AC2_projection(site, below, operator, above, envs)Application of the effective two-site local operator at a given site.
┌──────┐
┌──┤ ├──┐
│ └┬────┬┘ │
┌┴┐┌─┴─┐┌─┴─┐┌┴┐
│ ├┤ ├┤ ├┤ │
└┬┘└─┬─┘└─┬─┘└┬┘
│ │ │ │
└── ──┘See also AC2_hamiltonian.
MPSKit.AC_hamiltonian Function
AC_hamiltonian(site, below, operator, above, envs)::DerivativeOperatorEffective one-site local operator acting at site.
┌─── ───┐
│ │ │
┌┴┐ ┌─┴─┐ ┌┴┐
│ ├─┤ ├─┤ │
└┬┘ └─┬─┘ └┬┘
│ │ │
└─── ───┘See also AC_projection.
MPSKit.AC_projection Function
AC_projection(site, below, operator, above, envs)Application of the effective one-site local operator at a given site.
┌───┐
┌──┤ ├──┐
│ └─┬─┘ │
┌┴┐ ┌─┴─┐ ┌┴┐
│ ├─┤ ├─┤ │
└┬┘ └─┬─┘ └┬┘
│ │ │
└── ──┘See also AC_hamiltonian.
MPSKit.C_hamiltonian Function
C_hamiltonian(site, below, operator, above, envs)::DerivativeOperatorEffective zero-site local operator acting at site.
┌─ ─┐
│ │
┌┴┐ ┌┴┐
│ ├───┤ │
└┬┘ └┬┘
│ │
└─ ─┘See also C_projection.
MPSKit.C_projection Function
C_projection(site, below, operator, above, envs)Application of the effective zero-site local operator at a given site.
┌─┐
┌─┤ ├─┐
│ └─┘ │
┌┴┐ ┌┴┐
│ ├───┤ │
└┬┘ └┬┘
│ │
└─ ─┘See also C_hamiltonian.
MPSKit._fuse_mpo_mps Method
Fuse the left and right virtual legs of the product of MPO-MPS tensors
┌---A---┐
1 --Fl | Fr-- 3 => A′[1 2; 3]
└---O---┘
|
2MPSKit._fuse_mpo_mps_left Method
Fuse the left virtual legs of the product of MPO-MPS tensors
┌---A--- 3
1 --Fl | => A′[1 2; 3 4]
└---O--- 4
|
2MPSKit._fuse_mpo_mps_right Method
Fuse the right virtual legs of the product of MPO-MPS tensors
1 --A---┐
| Fr-- 3 => A′[1 2; 3 4]
2 --O---┘
|
4MPSKit._gaugecenter Method
_gaugecenter(ψ::FiniteMPS)::HalfIntReturn the location of the MPS center.
center::HalfInt:
isinteger(center)→centeris a whole number and indicates the location of the firstACtensor present inψ.ACsishalfodd(center)→centeris a half-odd-integer, meaning that there are noACtensors, and indicating between which sites the bond tensor lives.
Examples
ψ = FiniteMPS(3, ℂ^2, ℂ^16)
ψ.center # returns 7/2, bond tensor is to the right of the 3rd site
ψ.AC[1] # moves center to first site
ψ.center # returns 1MPSKit.add_util_leg Method
add_util_leg(tensor::AbstractTensorMap{T, S, N1, N2}) where {T, S, N1, N2}
-> AbstractTensorMap{T, S, N1+1, N2+1}Add trivial one-dimensional utility spaces with trivial sector to the left and right of a given tensor map, i.e. as the first space of the codomain and the last space of the domain.
sourceMPSKit.approximate Function
approximate(ψ₀, (O, ψ), [environments]; kwargs...) -> (ψ, environments, ϵ)
approximate(ψ₀, (O, ψ), algorithm, [environments]) -> (ψ, environments, ϵ)
approximate!(ψ₀, (O, ψ), algorithm, [environments]) -> (ψ, environments, ϵ)
approximate(ψ₀, ψ, algorithm, [environments]) -> (ψ, environments, ϵ)
approximate!(ψ₀, ψ, algorithm, [environments]) -> (ψ, environments, ϵ)
approximate((O, ψ), algorithm) -> (ψ′, ϵ)
approximate!(ψ₀, (O, ψ), algorithm) -> (ψ, ϵ)Compute an approximation to the application of an operator O to the state ψ in the form of an MPS, using initial guess ψ₀. If only a state ψ is supplied instead of the (O, ψ) pair, ψ₀ is approximated directly to ψ (i.e. O is taken to be the identity).
Not every algorithm supports every combination of arguments below — see the per-algorithm notes at the end of this docstring before picking one.
Arguments
ψ₀::AbstractMPS: initial guess of the approximated state(O::AbstractMPO, ψ::AbstractMPS): operatorOand stateψto be approximatedψ::AbstractMPS: state to be approximated directly (without an operator)algorithm: approximation algorithm. See below for a list of available algorithms.[environments]: MPS environment manager
Keyword Arguments
The keyword-based call (no explicit algorithm) is a convenience method that picks an algorithm for you based on the type of ψ₀ (DMRG/DMRG2 for a finite MPS, VOMPS/IDMRG/ IDMRG2 for an infinite MPS) and only accepts the (O, ψ) tuple form of toapprox. Once you pass an explicit algorithm, keywords are no longer accepted here — configure the algorithm struct itself instead (e.g. DMRG(; tol, maxiter, verbosity)).
tol::Float64: tolerance for convergence criteriummaxiter::Int: maximum amount of iterationsverbosity::Int: display progress informationtrunc: if supplied, a truncated two-site sweep (DMRG2/IDMRG2) is prepended to refine the bond dimension before the single-site algorithm polishes the result.
Algorithms
Each algorithm below only supports a subset of the general interface. Check this table before picking one — in particular, note that only DMRG/DMRG2 accept a bare state ψ; the infinite algorithms always require an explicit (O, ψ) tuple, and VOMPS has no in-place approximate! at all. Zipup is a single sweep rather than an iterative optimization, so it uses no environments and returns (ψ, ϵ); its ψ₀ is a write destination, not an initial guess, and it may be omitted.
| Algorithm | Scheme | State ψ₀ | bare ψ allowed? | approximate! |
|---|---|---|---|---|
DMRG | single-site, fixes bond dim | AbstractFiniteMPS | ✅ | ✅ |
DMRG2 | two-site, truncates via trunc | AbstractFiniteMPS | ✅ | ✅ |
Zipup | streaming MPO-MPS compression | FiniteMPS destination, optional | ❌ (tuple only) | ✅ |
IDMRG | single-site, thermodynamic limit | InfiniteMPS / MultilineMPS | ❌ (tuple only) | ✅ |
IDMRG2 | two-site, thermodynamic limit, needs unit cell ≥ 2 | InfiniteMPS / MultilineMPS | ❌ (tuple only) | ✅ |
VOMPS | tangent-space truncation | InfiniteMPS / MultilineMPS | ❌ (tuple only) | ❌ (out-of-place only) |
InfiniteMPS/InfiniteMPO inputs are converted internally to MultilineMPS/MultilineMPO for IDMRG, IDMRG2, and VOMPS; you can also pass those types directly.
MPSKit.approximate! Function
approximate(ψ₀, (O, ψ), [environments]; kwargs...) -> (ψ, environments, ϵ)
approximate(ψ₀, (O, ψ), algorithm, [environments]) -> (ψ, environments, ϵ)
approximate!(ψ₀, (O, ψ), algorithm, [environments]) -> (ψ, environments, ϵ)
approximate(ψ₀, ψ, algorithm, [environments]) -> (ψ, environments, ϵ)
approximate!(ψ₀, ψ, algorithm, [environments]) -> (ψ, environments, ϵ)
approximate((O, ψ), algorithm) -> (ψ′, ϵ)
approximate!(ψ₀, (O, ψ), algorithm) -> (ψ, ϵ)Compute an approximation to the application of an operator O to the state ψ in the form of an MPS, using initial guess ψ₀. If only a state ψ is supplied instead of the (O, ψ) pair, ψ₀ is approximated directly to ψ (i.e. O is taken to be the identity).
Not every algorithm supports every combination of arguments below — see the per-algorithm notes at the end of this docstring before picking one.
Arguments
ψ₀::AbstractMPS: initial guess of the approximated state(O::AbstractMPO, ψ::AbstractMPS): operatorOand stateψto be approximatedψ::AbstractMPS: state to be approximated directly (without an operator)algorithm: approximation algorithm. See below for a list of available algorithms.[environments]: MPS environment manager
Keyword Arguments
The keyword-based call (no explicit algorithm) is a convenience method that picks an algorithm for you based on the type of ψ₀ (DMRG/DMRG2 for a finite MPS, VOMPS/IDMRG/ IDMRG2 for an infinite MPS) and only accepts the (O, ψ) tuple form of toapprox. Once you pass an explicit algorithm, keywords are no longer accepted here — configure the algorithm struct itself instead (e.g. DMRG(; tol, maxiter, verbosity)).
tol::Float64: tolerance for convergence criteriummaxiter::Int: maximum amount of iterationsverbosity::Int: display progress informationtrunc: if supplied, a truncated two-site sweep (DMRG2/IDMRG2) is prepended to refine the bond dimension before the single-site algorithm polishes the result.
Algorithms
Each algorithm below only supports a subset of the general interface. Check this table before picking one — in particular, note that only DMRG/DMRG2 accept a bare state ψ; the infinite algorithms always require an explicit (O, ψ) tuple, and VOMPS has no in-place approximate! at all. Zipup is a single sweep rather than an iterative optimization, so it uses no environments and returns (ψ, ϵ); its ψ₀ is a write destination, not an initial guess, and it may be omitted.
| Algorithm | Scheme | State ψ₀ | bare ψ allowed? | approximate! |
|---|---|---|---|---|
DMRG | single-site, fixes bond dim | AbstractFiniteMPS | ✅ | ✅ |
DMRG2 | two-site, truncates via trunc | AbstractFiniteMPS | ✅ | ✅ |
Zipup | streaming MPO-MPS compression | FiniteMPS destination, optional | ❌ (tuple only) | ✅ |
IDMRG | single-site, thermodynamic limit | InfiniteMPS / MultilineMPS | ❌ (tuple only) | ✅ |
IDMRG2 | two-site, thermodynamic limit, needs unit cell ≥ 2 | InfiniteMPS / MultilineMPS | ❌ (tuple only) | ✅ |
VOMPS | tangent-space truncation | InfiniteMPS / MultilineMPS | ❌ (tuple only) | ❌ (out-of-place only) |
InfiniteMPS/InfiniteMPO inputs are converted internally to MultilineMPS/MultilineMPO for IDMRG, IDMRG2, and VOMPS; you can also pass those types directly.
MPSKit.bond_type Method
bond_type(ψ::AbstractMPS)
bond_type(ψtype::Type{<:AbstractMPS})Return the type of the bond tensors of an AbstractMPS.
MPSKit.braille Method
braille(io::IO, H::Union{SparseMPO, MPOHamiltonian})
braille(H::Union{SparseMPO, MPOHamiltonian})Prints a compact, human-readable "braille" visualization of a sparseMPO or MPOHamiltonian. Each site of the MPO is represented as a block of Unicode braille characters, with sites separated by dashes. This visualization is useful for quickly inspecting the structure and sparsity pattern of MPOs.
Arguments
io::IO: The output stream to print to (e.g.,stdout).H::Union{SparseMPO, MPOHamiltonian}: TheSparseMPOorMPOHamiltonianto visualize.
If called without an io argument, output is printed to stdout.
MPSKit.calc_galerkin Method
calc_galerkin(below, operator, above, envs; kwargs...)
calc_galerkin(pos, below, operator, above, envs; kwargs...)Calculate the Galerkin error, which is the error between the solution of the original problem, and the solution of the problem projected on the tangent space. Concretely, this is the overlap of the current state with the single-site derivative, projected onto the nullspace of the current state:
Keyword Arguments
backend = DefaultBackend(): backend for the tensor contractions of the derivative.allocator = DefaultAllocator(): allocator serving their scratch space. A sweep that already holds one should pass it, rather than leaving this contraction to the garbage collector.
MPSKit.changebond Function
changebond(site, dir, ψ, [H], alg, [envs]) -> ψ
changebond!(site, dir, ψ, [H], alg, [envs]) -> ψExpand a single bond of ψ by adding directions orthogonal to the current state, keeping the state in mixed-canonical form around the expanded bond. The sweep direction dir is a Val(:right) or Val(:left) used for dispatch. For Val(:right) the bond (site, site + 1) is expanded on the right tensor (ψ.AR[site + 1]) with zero weight added at ψ.AC[site], so that a subsequent single-site optimization of site sees the new directions; for Val(:left) the mirror is applied to bond (site - 1, site).
See also changebonds, changebonds!.
MPSKit.changebond! Function
changebond(site, dir, ψ, [H], alg, [envs]) -> ψ
changebond!(site, dir, ψ, [H], alg, [envs]) -> ψExpand a single bond of ψ by adding directions orthogonal to the current state, keeping the state in mixed-canonical form around the expanded bond. The sweep direction dir is a Val(:right) or Val(:left) used for dispatch. For Val(:right) the bond (site, site + 1) is expanded on the right tensor (ψ.AR[site + 1]) with zero weight added at ψ.AC[site], so that a subsequent single-site optimization of site sees the new directions; for Val(:left) the mirror is applied to bond (site - 1, site).
See also changebonds, changebonds!.
MPSKit.changebonds Function
changebonds(ψ::AbstractMPS, H, alg, envs) -> ψ′, envs′
changebonds(ψ::AbstractMPS, alg) -> ψ′Change the bond dimension of ψ using the algorithm alg, and return the new ψ and the new envs. For AbstractInfiniteMPS, changebonds returns new environments without modifying the one provided. changedbonds! can modify both the provided state and environments, depending on the algorithm. For FiniteMPS, changebonds also modifies the environments.
See also: SvdCut, RandExpand, VUMPSSvdCut, OptimalExpand
Examples
Growing the bond dimension of a product state with OptimalExpand, which expands each bond with directions orthogonal to the current state (using the environments of H):
julia> Z = TensorMap(Float64[1 0; 0 -1], ℂ^2, ℂ^2);
julia> ψ = FiniteMPS(ones(Float64, (ℂ^2)^4));
julia> H = FiniteMPOHamiltonian(fill(ℂ^2, 4), ((i, i + 1) => Z ⊗ Z for i in 1:3));
julia> dim(left_virtualspace(ψ, 3))
1
julia> ψ′, envs = changebonds(ψ, H, OptimalExpand(; trunc = truncrank(4)));
julia> dim(left_virtualspace(ψ′, 3))
2Note
A bond is only expanded if there is something to expand it with. If the projection of the two-site update onto the orthogonal complement of the current state vanishes — for instance when the state is already an exact eigenstate of the local terms, or when the operator does not couple into a symmetry sector yet — that bond is left untouched. Replacing Z ⊗ Z by X ⊗ X above illustrates this: ones(Float64, (ℂ^2)^4) is an eigenstate of every X ⊗ X term, so every bond stays at dimension 1.
MPSKit.changebonds! Function
changebonds(ψ::AbstractMPS, H, alg, envs) -> ψ′, envs′
changebonds(ψ::AbstractMPS, alg) -> ψ′Change the bond dimension of ψ using the algorithm alg, and return the new ψ and the new envs. For AbstractInfiniteMPS, changebonds returns new environments without modifying the one provided. changedbonds! can modify both the provided state and environments, depending on the algorithm. For FiniteMPS, changebonds also modifies the environments.
See also: SvdCut, RandExpand, VUMPSSvdCut, OptimalExpand
Examples
Growing the bond dimension of a product state with OptimalExpand, which expands each bond with directions orthogonal to the current state (using the environments of H):
julia> Z = TensorMap(Float64[1 0; 0 -1], ℂ^2, ℂ^2);
julia> ψ = FiniteMPS(ones(Float64, (ℂ^2)^4));
julia> H = FiniteMPOHamiltonian(fill(ℂ^2, 4), ((i, i + 1) => Z ⊗ Z for i in 1:3));
julia> dim(left_virtualspace(ψ, 3))
1
julia> ψ′, envs = changebonds(ψ, H, OptimalExpand(; trunc = truncrank(4)));
julia> dim(left_virtualspace(ψ′, 3))
2Note
A bond is only expanded if there is something to expand it with. If the projection of the two-site update onto the orthogonal complement of the current state vanishes — for instance when the state is already an exact eigenstate of the local terms, or when the operator does not couple into a symmetry sector yet — that bond is left untouched. Replacing Z ⊗ Z by X ⊗ X above illustrates this: ones(Float64, (ℂ^2)^4) is an eigenstate of every X ⊗ X term, so every bond stays at dimension 1.
MPSKit.check_unambiguous_braiding Method
check_unambiguous_braiding(::Type{Bool}, V::VectorSpace)::Bool
check_unambiguous_braiding(V::VectorSpace)Verify that the braiding of a vector space is unambiguous. This is the case if the braiding is symmetric or if all sectors are trivial. The signature with Type{Bool} is used to check while the signature without is used to throw an error if the braiding is ambiguous.
MPSKit.correlation_length Method
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.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.
MPSKit.default_allocator Method
default_allocator(x, scheduler) -> allocatorThe allocator that serves the scratch space of local updates on x, for work scheduled with scheduler.
x is anything with a storagetype, typically the state being operated on. Host memory gets a TensorOperations.BufferAllocator, which serves intermediates from a reusable buffer, when a single task owns the allocator, and a TensorOperations.ManualAllocator, which mallocs and frees them one by one, when the allocator is shared between tasks - a buffer is not thread-safe, whereas a manual allocator holds no state at all. Any other storage type falls back on TensorOperations.DefaultAllocator, which allocates through the storage type itself and is therefore correct on any device, at the cost of leaving intermediates to the garbage collector.
Extend this function to serve a storage type that MPSKit does not know about. Dedicated scratch space can be turned off altogether with MPSKit.Defaults.set_buffering!.
Warning
An allocator obtained for a SerialScheduler must not be shared between tasks. Sites that spawn should pass the scheduler they spawn with, so that the allocator matches the concurrency.
MPSKit.eachsite Method
eachsite(state::AbstractMPS)Return an iterator over the sites of the MPS state.
MPSKit.entanglement_spectrum Function
entanglement_spectrum(ψ, site::Int) -> SectorVector{T, sectortype(ψ), AbstractVector{T}}Compute the entanglement spectrum across the cut that splits the chain between sites site and site + 1, i.e. the singular values of the gauge tensor ψ.C[site]. The contributions from specific sectors can be viewed by indexing accordingly, i.e. entanglement_spectrum(ψ, site)[sector].
site runs over 0:length(ψ). For FiniteMPS, 0 and length(ψ) are the cuts at the left and right edge of the chain. No default is given for FiniteMPS; it is up to the user to specify. For WindowMPS and InfiniteMPS, site defaults to 0.
MPSKit.entanglementplot Function
entanglementplot(state; site = 0[, kwargs...])Plot the entanglement spectrum (see 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.
MPSKit.entropy Method
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 for the bipartition that splits the chain between sites site and site + 1. site = 0 therefore denotes the cut to the left of the first site. For InfiniteMPS, omitting site returns a vector of entropies, one for each site. For FiniteMPS and WindowMPS, site is required.
MPSKit.environment_alg Method
environment_alg(below, operator, above; kwargs...)Determine an appropriate algorithm for computing the environments, based on the given kwargs....
MPSKit.environments Function
environments(below, operator, above, [alg]; kwargs...)
environments(below, above)Construct the environments for the operator sandwiched between the states below (bra) and above (ket). The keyword arguments or alg struct can be used to control the settings needed for computing the environments.
The two-argument form environments(below, above) (with two states) constructs the overlap environments, i.e. the operator-free environments between the bra below and the ket above.
Note
The operator form requires an explicit above; there is no two-argument environments(below, operator) shorthand. Because a two-argument call is the overlap form, the second argument cannot be disambiguated between a ket (overlap) and an operator — this is genuinely undecidable for density matrices, where states and operators share a representation.
MPSKit.exact_diagonalization Method
exact_diagonalization(
H::FiniteMPOHamiltonian;
sector = rightunit(H), num::Int = 1, which::Symbol = :SR,
alg = Defaults.alg_eigsolve(; dynamic_tols = false),
backend = Defaults.backend()
) -> vals, state_vecs, convhistUse KrylovKit.eigsolve to perform exact diagonalization on a FiniteMPOHamiltonian to find its eigenvectors as FiniteMPS of maximal rank, essentially equivalent to dense eigenvectors.
Arguments
H::FiniteMPOHamiltonian: the Hamiltonian to diagonalize.
Keyword Arguments
sector = rightunit(H): the total charge of the eigenvectors, which is chosen trivial by default.num::Int = 1: the number of eigenvectors to find.which::Symbol = :SR: the kind eigenvalues to find, seeKrylovKit.eigsolve.alg = Defaults.alg_eigsolve(; dynamic_tols = false): the diagonalization algorithm to use, seeKrylovKit.eigsolve.backend = Defaults.backend(): backend for tensor contractions and index manipulations.
Valid sector values
The total charge of the eigenvectors is imposed by adding a charged auxiliary space as the leftmost virtualspace of each eigenvector. Specifically, this is achieved by passing left = Vect[typeof(sector)](sector => 1) to the FiniteMPS constructor. As such, the only valid sector values (i.e. sector values for which the corresponding eigenstates have valid fusion channels) are those that occur in the dual of the fusion of all the physical spaces in the system.
MPSKit.excitations Function
excitations(
H, algorithm::QuasiparticleAnsatz, left_ψ::FiniteMPS, [left_environment],
[right_ψ::FiniteMPS], [right_environment]; kwargs...
) -> (energies, states)Create and optimize finite quasiparticle states.
Arguments
H::AbstractMPO: operator for which to find the excitationsalgorithm::QuasiparticleAnsatz: optimization algorithmleft_ψ::FiniteMPS: left ground state[left_environment]: left ground state environment[right_ψ::FiniteMPS]: right ground state[right_environment]: right ground state environment
Keyword Arguments
num::Int: number of excited states to computesector = leftunit(lmps): charge of the quasiparticle state
MPSKit.excitations Function
excitations(
H, algorithm::QuasiparticleAnsatz, ψ::FiniteQP, [left_environments],
[right_environments]; num = 1
) -> (energies, states)
excitations(
H, algorithm::QuasiparticleAnsatz, ψ::InfiniteQP, [left_environments],
[right_environments]; num = 1
) -> (energies, states)
excitations(
H, algorithm::FiniteExcited, ψs::NTuple{<:Any, <:FiniteMPS};
num = 1, init
) -> (energies, states)
excitations(
H, algorithm::ChepigaAnsatz, ψ::FiniteMPS, [envs];
num = 1, pos = length(ψ) ÷ 2
) -> (energies, states)
excitations(
H, algorithm::ChepigaAnsatz2, ψ::FiniteMPS, [envs];
num = 1, pos = length(ψ) ÷ 2
) -> (energies, states)Compute the first excited states and their energy gap above a ground state.
Arguments
H::AbstractMPO: operator for which to find the excitationsalgorithm: optimization algorithmψ::QP: initial quasiparticle guessψs::NTuple{N, <:FiniteMPS}:Nfirst excited states[left_environments]: left ground state environment[right_environments]: right ground state environment
Keyword Arguments
num::Int: number of excited states to computesolver: algorithm for the linear solver of the quasiparticle environmentsinit: initial excited state guess; defaults to a copy of the first state inψspos: position of perturbation
MPSKit.excitations Function
excitations(
H, algorithm::QuasiparticleAnsatz, momentum::Union{Number, Vector{<:Number}},
left_ψ::InfiniteMPS, [left_environment],
[right_ψ::InfiniteMPS], [right_environment];
kwargs...
) -> (energies, states)Create and optimize infinite quasiparticle states.
Arguments
H::AbstractMPO: operator for which to find the excitationsalgorithm::QuasiparticleAnsatz: optimization algorithmmomentum::Union{Number, Vector{<:Number}}: momentum or list of momentaleft_ψ::InfiniteMPS: left ground state[left_environment]: left ground state environment[right_ψ::InfiniteMPS]: right ground state[right_environment]: right ground state environment
Keyword Arguments
num::Int: number of excited states to computesolver: algorithm for the linear solver of the quasiparticle environmentssector = leftunit(left_ψ): charge of the quasiparticle stateparallel = true: enable multi-threading over different momenta
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.0MPSKit.fidelity_susceptibility Method
fidelity_susceptibility(
state::Union{FiniteMPS, InfiniteMPS}, H₀::T,
Vs::AbstractVector{T}, [henvs = environments(state, H₀, state)];
maxiter = Defaults.maxiter,
tol = Defaults.tol
) where {T <: MPOHamiltonian}Computes the fidelity susceptibility of a the ground state state of a base Hamiltonian H₀ with respect to a set of perturbing Hamiltonians Vs. Each of the perturbing Hamiltonians can be interpreted as corresponding to a tuning parameter
Returns a matrix containing the overlaps of the elementary excitations on top of state corresponding to each of the perturbing Hamiltonians.
MPSKit.find_groundstate Function
find_groundstate(ψ₀, H, [environments]; kwargs...) -> (ψ, environments, ϵ)
find_groundstate(ψ₀, H, algorithm, [environments]) -> (ψ, environments, ϵ)Compute the ground state for Hamiltonian H with initial guess ψ₀. If no algorithm is specified, one is selected automatically from the type of ψ₀ and the supplied keywords (see the automatic-selection notes below).
Arguments
ψ₀::AbstractMPS: initial guessH::AbstractMPO: operator for which to find the ground state[environments]: MPS environment manageralgorithm: optimization algorithm
Keyword Arguments
tol::Float64 = 1.0e-10: tolerance for the convergence criterionmaxiter::Int = 200: maximum number of iterationsverbosity::Int = 3: display progress informationtrunc = nothing: if supplied, a truncation strategy that enables bond-dimension growth through a two-site algorithm (see below)
Automatic algorithm selection
When no algorithm is passed, the choice depends on the type of ψ₀:
InfiniteMPS:VUMPS(with its tolerance floored at1e-4), refined byGradientGrassmannwhentol < 1e-4. Iftruncis given, anIDMRG2stage is prepended to grow the bond dimension.AbstractFiniteMPS:DMRG. Iftruncis given, aDMRG2stage is prepended to grow the bond dimension.
Because single-site DMRG preserves the bond dimension of ψ₀, passing a trunc (or an explicit two-site algorithm) is the usual way to converge from a low-bond-dimension initial guess such as a product state.
Returns
ψ::AbstractMPS: converged ground stateenvironments: environments corresponding to the converged stateϵ::Float64: final convergence error upon terminating the algorithm
Examples
Ground state of a 4-site transverse-field Ising chain, H = -∑ XₖXₖ₊₁ - ∑ Zₖ, starting from a product state and letting DMRG2 grow the bond dimension:
julia> X = TensorMap(Float64[0 1; 1 0], ℂ^2, ℂ^2);
julia> Z = TensorMap(Float64[1 0; 0 -1], ℂ^2, ℂ^2);
julia> L = 4; lattice = fill(ℂ^2, L);
julia> H = FiniteMPOHamiltonian(lattice, ((i, i + 1) => -(X ⊗ X) for i in 1:(L - 1))) +
FiniteMPOHamiltonian(lattice, ((i,) => -Z for i in 1:L));
julia> ψ₀ = FiniteMPS(ones(Float64, (ℂ^2)^L));
julia> ψ, envs, ϵ = find_groundstate(ψ₀, H; verbosity = 0, trunc = truncrank(16));
julia> round(real(expectation_value(ψ, H)); digits = 4)
-4.7588MPSKit.find_groundstate! Function
find_groundstate!(ψ, H, algorithm, [environments]) -> (ψ, environments, ϵ)In-place version of find_groundstate: optimize the finite MPS ψ for the Hamiltonian H, overwriting the input state instead of working on a copy. Currently supported for the finite-system algorithms DMRG and DMRG2.
Arguments
ψ::AbstractFiniteMPS: initial guess, mutated in placeH: operator for which to find the ground statealgorithm: optimization algorithm[environments]: MPS environment manager
Returns
ψ::AbstractFiniteMPS: converged ground stateenvironments: environments corresponding to the converged stateϵ::Float64: final convergence error upon terminating the algorithm
MPSKit.fixedpoint Method
fixedpoint(A, x₀, which::Symbol; kwargs...) -> val, vec, info
fixedpoint(A, x₀, which::Symbol, alg) -> val, vec, infoCompute the fixed point of a given linear operator A with initial guess x₀. The dominant eigenvector is assumed to be unique.
MPSKit.fuse_mul_mpo Method
fuse_mul_mpo(O1, O2)Compute the mpo tensor that arises from multiplying MPOs.
sourceMPSKit.gauge! Method
gauge!(ψ, pos, direction, AC, [alg]; normalize = false) -> ψ, ϵDirection-dispatching wrapper around left_gauge! / right_gauge!: gauge an updated center tensor AC at site pos and install it into ψ, shifting the gauge center past pos to the right for direction = Val(:right) and to the left for Val(:left). alg and normalize are forwarded unchanged, and the truncation error ϵ is returned as-is.
MPSKit.gauge2! Method
gauge2!(ψ, pos, direction, AC2, alg; normalize = false) -> ψ, ϵTwo-site analogue of gauge!: factor an updated two-site center tensor AC2 spanning sites pos and pos+1 with the truncated SVD alg and install the resulting canonical tensors into ψ in one step, shifting the gauge center past the bond. (To the right for direction = Val(:right), to the left for Val(:left)).
Returns the truncation error ϵ, the 2-norm of the discarded singular values. Pass normalize = true to renormalize the bond tensor, so ψ stays normalized after a local update that changed its norm.
MPSKit.gaugefix! Function
gaugefix!(ψ::InfiniteMPS, A, C₀; kwargs...) -> ψ
gaugefix!(ψ::InfiniteMPS, A, C₀, alg::Algorithm) -> ψBring an InfiniteMPS into a uniform gauge, using the specified algorithm.
MPSKit.infinite_temperature_density_matrix Method
infinite_temperature_density_matrix(H::MPOHamiltonian) -> MPOReturn the density matrix of the infinite temperature state for a given Hamiltonian. This is the identity matrix in the physical space, and the identity in the auxiliary space.
sourceMPSKit.instantiate_operator Method
instantiate_operator(state, O::Pair)
instantiate_operator(lattice::AbstractArray{<:VectorSpace}, O::Pair)Instantiate a local operator O for a state or lattice as a vector of MPO tensors, and a vector of linear site indices.
MPSKit.integrate Function
integrate(f, y₀, t, dt, alg) -> yIntegrate the differential equation dt starting from
Arguments
f: driving functiony₀: object to integratet::Number: starting time of time-stepdt::Number: time-step magnitudealg: integration scheme
MPSKit.isfullrank Method
isfullrank(A::GenericMPSTensor; side = :both)Determine whether the given tensor is full rank, i.e. whether both the map from the left virtual space and the physical space to the right virtual space, and the map from the right virtual space and the physical space to the left virtual space are injective.
sourceMPSKit.l_LL Method
l_LL(ψ, location)Left dominant eigenvector of the AL-AL transfermatrix.
MPSKit.l_LR Function
l_LR(ψ, location)Left dominant eigenvector of the AL-AR transfermatrix.
MPSKit.l_RL Function
l_RL(ψ, location)Left dominant eigenvector of the AR-AL transfermatrix.
MPSKit.l_RR Function
l_RR(ψ, location)Left dominant eigenvector of the AR-AR transfermatrix.
MPSKit.leading_boundary Function
leading_boundary(ψ₀, O, [environments]; kwargs...) -> (ψ, environments, ϵ)
leading_boundary(ψ₀, O, algorithm, environments) -> (ψ, environments, ϵ)Compute the leading boundary MPS for operator O with initial guess ψ. If not specified, an optimization algorithm will be attempted based on the supplied keywords.
Arguments
ψ₀::AbstractMPS: initial guessO::AbstractMPO: operator for which to find the leading_boundary[environments]: MPS environment manageralgorithm: optimization algorithm
Keyword Arguments
tol::Float64: tolerance for convergence criteriummaxiter::Int: maximum amount of iterationsverbosity::Int: display progress information
Returns
ψ::AbstractMPS: converged leading boundary MPSenvironments: environments corresponding to the converged boundaryϵ::Float64: final convergence error upon terminating the algorithm
MPSKit.left_gauge Function
left_gauge(AC, [alg]) -> AL, C, ϵ
right_gauge(AC, [alg]) -> C, AR, ϵFactor an updated center MPS tensor AC into left- or right-canonical form, AC ≈ AL * C (left, with AL left-isometric) or AC ≈ C * AR (right, with AR right-isometric), without modifying AC. right_gauge handles the MPS leg permutation internally, so AR is returned in standard MPS-tensor form.
alg selects the factorization and defaults to a (positive) QR/LQ center-move that preserves the virtual bond. Passing a TruncatedAlgorithm instead performs a truncated SVD may shrink the bond.
Also returns the truncation error ϵ: the 2-norm of the discarded singular values from the truncated SVD, or 0 for a norm-preserving QR/LQ gauge.
MPSKit.left_gauge! Function
left_gauge!(ψ, pos, AC, [alg]; normalize = false) -> ψ, ϵ
right_gauge!(ψ, pos, AC, [alg]; normalize = false) -> ψ, ϵGauge an updated center tensor AC at site pos and install it into ψ in one step: factor AC with left_gauge / right_gauge and write the canonical tensors back, shifting the gauge center past pos (to the right for left_gauge!, to the left for right_gauge!). alg is forwarded to left_gauge / right_gauge and hence may be a TruncatedAlgorithm to truncate the bond.
By default the factors are installed as-is. Pass normalize = true to renormalize the bond tensor, so ψ stays normalized after a local update that changed its norm.
Also returns the truncation error ϵ of the factorization: the 2-norm of the discarded singular values from a truncated SVD gauge, or 0 for a norm-preserving QR gauge.
MPSKit.left_virtualspace Function
left_virtualspace(ψ::AbstractMPS, [pos = 1:length(ψ)])Return the virtual space of the bond to the left of sites pos.
Warning
In rare cases, the gauge tensor on the virtual space might not be square, and as a result it cannot always be guaranteed that right_virtualspace(ψ, i - 1) == left_virtualspace(ψ, i)
MPSKit.leftenv Method
leftenv(envs, site, state)Return the left environment stored in envs at site for the given state: the contraction of everything to the left of site in the network the environments were built for. The result is gauge-compatible with the tensor of state at site and can be contracted onto it directly.
See also rightenv and environments.
MPSKit.make_time_mpo Function
make_time_mpo(H::MPOHamiltonian, dt::Number, alg; kwargs...) -> O::MPOConstruct an MPO that approximates
Keyword Arguments
imaginary_evolution::Bool = false: if true, the time evolution is done with an imaginary time step instead, (i.e. instead of ). This can be useful to compute the ground state of a Hamiltonian, or to compute finite-temperature properties of a system.
MPSKit.makefullrank! Method
makefullrank!(A::PeriodicVector{<:GenericMPSTensor}; alg = Defaults.alg_orth())Make the set of MPS tensors full rank by performing a series of orthogonalizations.
sourceMPSKit.marek_gap Method
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.matrix_contract Function
matrix_contract(
A::AbstractTensorMap, B::AbstractTensorMap{T, S, 1, 1}, i::Int,
α::Number = One(),
backend::AbstractBackend = DefaultBackend(), allocator = DefaultAllocator();
transpose::Bool = false
)Compute the tensor contraction α * A * B, where the (1, 1) - tensor B is attached to index i of A. Whenever transpose = true, this contraction (lazily) uses transpose(B) instead.
See also matrix_contract!.
MPSKit.matrix_contract! Function
matrix_contract!(
C::AbstractTensorMap, A::AbstractTensorMap, B::AbstractTensorMap{T, S, 1, 1}, i::Int,
α::Number = One(), β::Number = Zero(),
backend::AbstractBackend = DefaultBackend(), allocator = DefaultAllocator();
transpose::Bool = false
)Compute the tensor contraction C ← β * C + α * A * B, where the (1, 1) - tensor B is attached to index i of A, and the result is added into C. Whenever transpose = true, this contraction (lazily) uses transpose(B) instead.
See also matrix_contract.
MPSKit.max_Ds Method
max_Ds(ψ::FiniteMPS) -> Vector{Float64}Compute the dimension of the maximal virtual space at a given site.
sourceMPSKit.max_virtualspaces Method
max_virtualspaces(ψ::FiniteMPS)
max_virtualspaces(Ps::Vector{<:Union{S, CompositeSpace{S}}}; left = unitspace(S), right = unitspace(S))Compute the maximal virtual spaces of a given finite MPS or its physical spaces.
sourceMPSKit.multiply_neighbours Function
multiply_neighbours(mpo::FiniteMPO, i::Integer)
multiply_neighbours!(mpo::FiniteMPO, i::Integer)Construct the mpo of length length(mpo) - 1 which is formed by multiplying the operators on site i and i + 1.
MPSKit.multiply_neighbours! Function
multiply_neighbours(mpo::FiniteMPO, i::Integer)
multiply_neighbours!(mpo::FiniteMPO, i::Integer)Construct the mpo of length length(mpo) - 1 which is formed by multiplying the operators on site i and i + 1.
MPSKit.open_boundary_conditions Function
open_boundary_conditions(mpo::InfiniteMPOHamiltonian, L::Int) -> FiniteMPOHamiltonianConvert an infinite MPO into a finite MPO of length L, by applying open boundary conditions.
MPSKit.open_boundary_conditions Method
open_boundary_conditions(mpo::InfiniteMPO, L::Int) -> FiniteMPOConvert an infinite MPO into a finite MPO of length L, by applying open boundary conditions.
MPSKit.periodic_boundary_conditions Method
periodic_boundary_conditions(mpo::AbstractInfiniteMPO, L::Int)Convert an infinite MPO into a finite MPO of length L, by mapping periodic boundary conditions onto an open system.
MPSKit.physicalspace Function
physicalspace(ψ::AbstractMPS, [pos = 1:length(ψ)])Return the physical space of the site tensor at site i.
MPSKit.prepare_operator!! Method
prepare_operator!!(O) -> O′Given an operator, try to construct a more efficient representation of that operator. This typically consists of precomputing some parts of the application, and is expected to only pay off for repeated applications.
The backend and allocator to use are taken from O itself, which is where the resulting operator's own contractions will read them from as well.
MPSKit.project_complement! Method
project_complement!(Y, X) -> YIn-place projection of Y onto the orthogonal complement of the range of the left-isometry X (X' X = I): Y ← (I - X X') Y = Y - X (X' Y). Y is overwritten and returned.
See also project_complement_right!.
MPSKit.project_complement_right! Method
project_complement_right!(Y, X) -> YIn-place projection of Y onto the orthogonal complement of the co-range of the right-isometry X (X X' = I): Y ← Y (I - X' X) = Y - (Y X') X. Y is overwritten and returned.
See also project_complement!.
MPSKit.propagator Function
propagator(ψ₀::AbstractFiniteMPS, z::Number, H::MPOHamiltonian, alg::DynamicalDMRG; init = copy(ψ₀)) -> (g, ψ)Calculate the action of the propagator
Returns
g: approximation of the propagator matrix elementψ: MPS approximation of
MPSKit.r_LL Function
r_LL(ψ, location)Right dominant eigenvector of the AL-AL transfermatrix.
MPSKit.r_LR Function
r_LR(ψ, location)Right dominant eigenvector of the AL-AR transfermatrix.
MPSKit.r_RL Function
r_RL(ψ, location)Right dominant eigenvector of the AR-AL transfermatrix.
MPSKit.r_RR Method
r_RR(ψ, location)Right dominant eigenvector of the AR-AR transfermatrix.
MPSKit.regauge! Function
regauge!(AC::GenericMPSTensor, C::MPSBondTensor; alg) -> AL
regauge!(CL::MPSBondTensor, AC::GenericMPSTensor; alg) -> ARBring updated AC and C tensors back into a consistent set of left or right canonical tensors. This minimizes ∥AC_i - AL_i * C_i∥ or ∥AC_i - C_{i-1} * AR_i∥.
The alg is passed on to left_orth! and right_orth!, and can be used to control the kind of factorization used. By default, this is set to a (positive) QR/LQ, even though the optimal algorithm would use a polar decompositions instead, sacrificing a bit of performance for accuracy.
Note
Computing AL is slightly faster than AR, as it avoids an intermediate transposition.
MPSKit.resolve_environment_solver Method
resolve_environment_solver(alg, below, operator, above)Resolve an environment algorithm alg into a concrete iterative solver for the given problem. A KrylovKit algorithm is returned as-is; the DefaultAlgorithm/DynamicTol configuration wrappers are translated via environment_alg.
MPSKit.right_gauge Function
left_gauge(AC, [alg]) -> AL, C, ϵ
right_gauge(AC, [alg]) -> C, AR, ϵFactor an updated center MPS tensor AC into left- or right-canonical form, AC ≈ AL * C (left, with AL left-isometric) or AC ≈ C * AR (right, with AR right-isometric), without modifying AC. right_gauge handles the MPS leg permutation internally, so AR is returned in standard MPS-tensor form.
alg selects the factorization and defaults to a (positive) QR/LQ center-move that preserves the virtual bond. Passing a TruncatedAlgorithm instead performs a truncated SVD may shrink the bond.
Also returns the truncation error ϵ: the 2-norm of the discarded singular values from the truncated SVD, or 0 for a norm-preserving QR/LQ gauge.
MPSKit.right_gauge! Function
left_gauge!(ψ, pos, AC, [alg]; normalize = false) -> ψ, ϵ
right_gauge!(ψ, pos, AC, [alg]; normalize = false) -> ψ, ϵGauge an updated center tensor AC at site pos and install it into ψ in one step: factor AC with left_gauge / right_gauge and write the canonical tensors back, shifting the gauge center past pos (to the right for left_gauge!, to the left for right_gauge!). alg is forwarded to left_gauge / right_gauge and hence may be a TruncatedAlgorithm to truncate the bond.
By default the factors are installed as-is. Pass normalize = true to renormalize the bond tensor, so ψ stays normalized after a local update that changed its norm.
Also returns the truncation error ϵ of the factorization: the 2-norm of the discarded singular values from a truncated SVD gauge, or 0 for a norm-preserving QR gauge.
MPSKit.right_virtualspace Function
right_virtualspace(ψ::AbstractMPS, [pos = 1:length(ψ)])Return the virtual space of the bond to the right of site(s) pos.
Warning
In rare cases, the gauge tensor on the virtual space might not be square, and as a result it cannot always be guaranteed that right_virtualspace(ψ, i - 1) == left_virtualspace(ψ, i)
MPSKit.rightenv Method
rightenv(envs, site, state)Return the right environment stored in envs at site for the given state: the contraction of everything to the right of site in the network the environments were built for. The result is gauge-compatible with the tensor of state at site and can be contracted onto it directly.
See also leftenv and environments.
MPSKit.sample_space Method
sample_space(V, strategy)Sample basis states within a given V::VectorSpace by creating weights for each state that are distributed uniformly, and then truncating according to the given strategy.
MPSKit.set_AC_AR! Function
set_AL_AC!(ψ, site, AL, AC) -> ψ
set_AC_AR!(ψ, site, AC, AR) -> ψInstall a canonical tensor at site together with the neighbouring center tensor, in a single update: set_AL_AC! writes the left-isometric AL at site and the center tensor AC at site + 1, set_AC_AR! writes the right-isometric AR at site and the center tensor AC at site - 1. The gauge center therefore ends up at site + 1 and site - 1 respectively.
These are the pendants of ψ.AC[site] = (AL, C) / ψ.AC[site] = (C, AR) for algorithms that already know the next center tensor: they avoid materializing a bond tensor purely to keep ψ well-defined, and — unlike installing the canonical tensor on its own — they never leave ψ without a gauge center.
The isometric nature of AL/AR is not verified.
MPSKit.set_AL_AC! Function
set_AL_AC!(ψ, site, AL, AC) -> ψ
set_AC_AR!(ψ, site, AC, AR) -> ψInstall a canonical tensor at site together with the neighbouring center tensor, in a single update: set_AL_AC! writes the left-isometric AL at site and the center tensor AC at site + 1, set_AC_AR! writes the right-isometric AR at site and the center tensor AC at site - 1. The gauge center therefore ends up at site + 1 and site - 1 respectively.
These are the pendants of ψ.AC[site] = (AL, C) / ψ.AC[site] = (C, AR) for algorithms that already know the next center tensor: they avoid materializing a bond tensor purely to keep ψ well-defined, and — unlike installing the canonical tensor on its own — they never leave ψ without a gauge center.
The isometric nature of AL/AR is not verified.
MPSKit.set_canonical! Method
set_canonical!(ψ, site, direction, A, AC) -> ψDirection-dispatching wrapper around set_AL_AC!/set_AC_AR!: install the canonical tensor A at site — left-isometric for direction = Val(:right), right-isometric for Val(:left) — together with the center tensor AC at the next site in that direction, site + 1 or site - 1.
This is the pendant of gauge! for a sweep that already knows its next center tensor, and lets a sweep body be written once for both directions.
MPSKit.similar_scalartype Method
similar_scalartype(T::Type{<:AbstractTensorMap}, S::Type{<:Number})Tensor map type with the same space type and rank as T, but with scalar type S.
MPSKit.site_type Method
site_type(ψ::AbstractMPS)
site_type(ψtype::Type{<:AbstractMPS})Return the type of the site tensors of an AbstractMPS.
MPSKit.sketch_space Method
sketch_space(V, alg::SketchedExpand) -> Vℓ, VkThe random-sketch space Vℓ drawn from the complement V, together with its oversampling-free target Vk (selected by alg.trunc). Vℓ enlarges Vk by alg.oversampling extra directions (capped by V); the selection is truncated back to Vk.
MPSKit.swap Function
swap(mpo::FiniteMPO, i::Integer; inv::Bool = false, alg = Defaults.alg_svd(), trunc)
swap!(mpo::FiniteMPO, i::Integer; inv::Bool = false, alg = Defaults.alg_svd(), trunc)Compose the mpo with a swap gate applied to indices i and i + 1, effectively creating an operator that acts on the Hilbert spaces with those factors swapped. The keyword arguments alg and trunc can be used to control how the resulting tensor is truncated again.
MPSKit.swap! Function
swap(mpo::FiniteMPO, i::Integer; inv::Bool = false, alg = Defaults.alg_svd(), trunc)
swap!(mpo::FiniteMPO, i::Integer; inv::Bool = false, alg = Defaults.alg_svd(), trunc)Compose the mpo with a swap gate applied to indices i and i + 1, effectively creating an operator that acts on the Hilbert spaces with those factors swapped. The keyword arguments alg and trunc can be used to control how the resulting tensor is truncated again.
MPSKit.tensorexpr Method
tensorexpr(name, ind_out, [ind_in])Generates expressions for use within @tensor environments of the form name[ind_out...; ind_in].
MPSKit.time_evolve Function
time_evolve(ψ₀, H, t_span, alg, [envs]; kwargs...) -> (ψ, envs)
time_evolve!(ψ₀, H, t_span, alg, [envs]; kwargs...) -> (ψ₀, envs)Time-evolve the initial state ψ₀ with Hamiltonian H over a given time span by stepping through each of the time points obtained by iterating t_span.
Arguments
ψ₀::AbstractMPS: initial stateH::AbstractMPO: operator that generates the time evolution (can be time-dependent).t_span::AbstractVector{<:Number}: time points over which the time evolution is steppedalg: algorithm to use for the time evolution, e.g.TDVPorTDVP2.envs: MPS environment manager
Keyword Arguments
verbosity::Int = 0: verbosity level for loggingimaginary_evolution::Bool = false: if true, the time evolution is done with an imaginary time step instead, (i.e. instead of ). This can be useful to compute the ground state of a Hamiltonian, or to compute finite-temperature properties of a system.normalize::Bool = false: if true, the state is renormalized after every step, which can be useful to retain numerical stability when the norm loss is not information that is needed.
Returns
ψ: the time-stepped stateenvs: the updated environment manager
MPSKit.time_evolve! Function
time_evolve(ψ₀, H, t_span, alg, [envs]; kwargs...) -> (ψ, envs)
time_evolve!(ψ₀, H, t_span, alg, [envs]; kwargs...) -> (ψ₀, envs)Time-evolve the initial state ψ₀ with Hamiltonian H over a given time span by stepping through each of the time points obtained by iterating t_span.
Arguments
ψ₀::AbstractMPS: initial stateH::AbstractMPO: operator that generates the time evolution (can be time-dependent).t_span::AbstractVector{<:Number}: time points over which the time evolution is steppedalg: algorithm to use for the time evolution, e.g.TDVPorTDVP2.envs: MPS environment manager
Keyword Arguments
verbosity::Int = 0: verbosity level for loggingimaginary_evolution::Bool = false: if true, the time evolution is done with an imaginary time step instead, (i.e. instead of ). This can be useful to compute the ground state of a Hamiltonian, or to compute finite-temperature properties of a system.normalize::Bool = false: if true, the state is renormalized after every step, which can be useful to retain numerical stability when the norm loss is not information that is needed.
Returns
ψ: the time-stepped stateenvs: the updated environment manager
MPSKit.timestep Function
timestep(ψ₀, H, t, dt, alg, [envs]; kwargs...) -> (ψ, envs)
timestep!(ψ₀, H, t, dt, alg, [envs]; kwargs...) -> (ψ₀, envs)Time-step the state ψ₀ with Hamiltonian H over a given time step dt at time t, solving the Schroedinger equation:
Arguments
ψ₀::AbstractMPS: initial stateH::AbstractMPO: operator that generates the time evolution (can be time-dependent).t::Number: starting time of time-stepdt::Number: time-step magnitudealg: algorithm to use for the time evolution, e.g.TDVPorTDVP2.envs: MPS environment manager
Keyword Arguments
imaginary_evolution::Bool = false: if true, the time evolution is done with an imaginary time step instead, (i.e. instead of ). This can be useful to compute the ground state of a Hamiltonian, or to compute finite-temperature properties of a system.normalize::Bool = false: if true, the state is renormalized after every step, which can be useful to retain numerical stability when the norm loss is not information that is needed.
Returns
ψ: the time-stepped stateenvs: the updated environment manager
Examples
Real-time evolution of the |+···+⟩ product state under a transverse field H = ∑ Zₖ. Each spin precesses independently, so ⟨Xₖ(t)⟩ = cos(2t); after a step dt = 0.1 this is cos(0.2) ≈ 0.980067. The initial state must be complex, since real-time evolution multiplies by -i:
julia> X = TensorMap(ComplexF64[0 1; 1 0], ℂ^2, ℂ^2);
julia> Z = TensorMap(ComplexF64[1 0; 0 -1], ℂ^2, ℂ^2);
julia> ψ₀ = FiniteMPS(ones(ComplexF64, (ℂ^2)^4));
julia> H = FiniteMPOHamiltonian(fill(ℂ^2, 4), ((i,) => Z for i in 1:4));
julia> ψ, envs = timestep(ψ₀, H, 0.0, 0.1, TDVP());
julia> round(real(expectation_value(ψ, 2 => X)); digits = 6)
0.980067MPSKit.timestep! Function
timestep(ψ₀, H, t, dt, alg, [envs]; kwargs...) -> (ψ, envs)
timestep!(ψ₀, H, t, dt, alg, [envs]; kwargs...) -> (ψ₀, envs)Time-step the state ψ₀ with Hamiltonian H over a given time step dt at time t, solving the Schroedinger equation:
Arguments
ψ₀::AbstractMPS: initial stateH::AbstractMPO: operator that generates the time evolution (can be time-dependent).t::Number: starting time of time-stepdt::Number: time-step magnitudealg: algorithm to use for the time evolution, e.g.TDVPorTDVP2.envs: MPS environment manager
Keyword Arguments
imaginary_evolution::Bool = false: if true, the time evolution is done with an imaginary time step instead, (i.e. instead of ). This can be useful to compute the ground state of a Hamiltonian, or to compute finite-temperature properties of a system.normalize::Bool = false: if true, the state is renormalized after every step, which can be useful to retain numerical stability when the norm loss is not information that is needed.
Returns
ψ: the time-stepped stateenvs: the updated environment manager
Examples
Real-time evolution of the |+···+⟩ product state under a transverse field H = ∑ Zₖ. Each spin precesses independently, so ⟨Xₖ(t)⟩ = cos(2t); after a step dt = 0.1 this is cos(0.2) ≈ 0.980067. The initial state must be complex, since real-time evolution multiplies by -i:
julia> X = TensorMap(ComplexF64[0 1; 1 0], ℂ^2, ℂ^2);
julia> Z = TensorMap(ComplexF64[1 0; 0 -1], ℂ^2, ℂ^2);
julia> ψ₀ = FiniteMPS(ones(ComplexF64, (ℂ^2)^4));
julia> H = FiniteMPOHamiltonian(fill(ℂ^2, 4), ((i,) => Z for i in 1:4));
julia> ψ, envs = timestep(ψ₀, H, 0.0, 0.1, TDVP());
julia> round(real(expectation_value(ψ, 2 => X)); digits = 6)
0.980067MPSKit.transfer_left Method
transfer_left(v, A, Ā)apply a transfer matrix to the left.
┌─A─
-v │
└─Ā─MPSKit.transfer_right Method
transfer_right(v, A, Ā)apply a transfer matrix to the right.
─A─┐
│ v-
─Ā─┘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.
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.
sourceMPSKit.zip_left_right! Function
zip_left_right!(ψ, O, ϕ, alg_zipup, [alg_zipdown]) -> ψ, ϵ
zip_right_left!(ψ, O, ϕ, alg_zipup, [alg_zipdown]) -> ψ, ϵContract the MPO O with the MPS ϕ in a single sweep, truncating the enlarged virtual bond at every site with alg_zipup, and write the result into ψ. zip_left_right! zips up from left to right, zip_right_left! from right to left. Unless alg_zipdown is nothing, a second sweep in the opposite direction imposes a final truncation with alg_zipdown in a locally gauged basis, leaving the gauge center of ψ at the far end. The destination may alias ϕ.
Also returns the truncation error ϵ, the largest 2-norm of the discarded singular values over all bonds and both sweeps.
MPSKit.zip_right_left! Function
zip_left_right!(ψ, O, ϕ, alg_zipup, [alg_zipdown]) -> ψ, ϵ
zip_right_left!(ψ, O, ϕ, alg_zipup, [alg_zipdown]) -> ψ, ϵContract the MPO O with the MPS ϕ in a single sweep, truncating the enlarged virtual bond at every site with alg_zipup, and write the result into ψ. zip_left_right! zips up from left to right, zip_right_left! from right to left. Unless alg_zipdown is nothing, a second sweep in the opposite direction imposes a final truncation with alg_zipdown in a locally gauged basis, leaving the gauge center of ψ at the far end. The destination may alias ϕ.
Also returns the truncation error ϵ, the largest 2-norm of the discarded singular values over all bonds and both sweeps.