Solvers

Kernel Polynomial Method (KPM)

Conventions

  • Rescaled energies. The expansion runs on H̃ = (H − H.center)/H.scale, whose spectrum lies in (−1, 1); a physical energy ω enters as ω̃ = (ω − H.center)/H.scale.
  • Normalisation. With the convolution kernels (:jackson, :lorentz, :fejer, :dirichlet) every Hermitian KPM spectrum (LDOS, DOS, A(k, ω), exciton spectra, QPI) is divided by π²·Ncheb·√(1 − ω̃²). It is the spectral density per unit rescaled energy times 1/π: the LDOS of one state integrates to 1/π over ω̃. Multiply by π/H.scale for the density per unit physical energy. kernel = :hodc, where offered, carries the δ-function normalisation itself (one state integrates to 1; multiply by 1/H.scale), so switching between :hodc and a convolution kernel rescales the output by π. The reconstruction is spelled out in get_ldos_from_mun.
  • Jackson moments. kernel = :jackson with Ncheb moments uses the textbook Jackson kernel for Ncheb − 1 moments, whose weight on the last moment is zero, so its resolution is that of Ncheb − 1 moments. The non-Hermitian KPM and the low-rank cheb2d bubbles use the kernel for all N moments.
TensorBinding._dos_weight_matrix — Method
_dos_weight_matrix(Ncheb, ω_vals; kernel=:jackson, lambda=4.0, eta=0.0, m_order=4)
    -> (W::Matrix, denom::Vector)

Stochastic-DOS reconstruction weights W[n, iω] and per-ω normalisation denom[iω] for a given KPM kernel. The DOS is recovered from the (sample- averaged) Chebyshev moments μ_n as Σ_n W[n,iω] μ_n / denom[iω].

  • Convolution kernels (:jackson, :lorentz, :fejer, :dirichlet): W follows _kpm_weight_matrix and denom = π²·Ncheb·√(1−ω²), matching get_ldos_from_mun.
  • :hodc: the contour weights νₙ(ω) from get_hodc_weights already carry the full normalisation (denom = 1), matching get_ldos_hodc_from_mun. eta=0 falls back to 1/(Ncheb+1).

Entries with |ω| ≥ 1 are zeroed in W (outside the rescaled spectral support).

source
TensorBinding._kpm_energy_grid — Method
_kpm_energy_grid(H, Ncheb, ω_phys_vals; kernel=:jackson, lambda=4.0, eta=0.0,
                 m_order=4, allow_hodc=false) -> (ω_r, W, denom, valid)
_kpm_energy_grid(Ncheb, ω_r; <same keywords>)  -> (ω_r, W, denom, valid)

Everything an online KPM solver needs about its energies, before the recursion:

  • ω_r — the rescaled energies (_rescaled_energies(H, ω_phys_vals); the second method takes them already rescaled and returns them as given);
  • W[n, iω] — the weight of moment n-1 at ω_r[iω], zero for |ω_r| ≥ 1;
  • denom[iω] — the per-ω normalisation: the result is Σ_n W[n, iω] μ_n / denom[iω];
  • valid[iω] — abs(ω_r[iω]) < 1.0, the energies inside the spectral support.

For the convolution kernels (:jackson, :lorentz with lambda, :fejer, :dirichlet) W is _kpm_weight_matrix and denom = π²·Ncheb·√(1−ω²). allow_hodc=true also accepts kernel=:hodc (eta, m_order; eta=0 means 1/(Ncheb+1)), whose contour weights carry the normalisation (denom = 1); this is _dos_weight_matrix. With allow_hodc=false (the solvers without an HODC option) kernel=:hodc throws the unknown-kernel error of _kpm_kernel.

source
TensorBinding._kpm_weight_matrix — Method
_kpm_weight_matrix(Ncheb, ω_vals; kernel=:jackson, lambda=4.0) -> Matrix{Float64}

Precompute the full KPM weight matrix W[n, iω] for fast in-loop accumulation.

W[n, iω] = c_n · g_n · cos((n-1) · arccos(ω_iω))
  • c_n = 1 for n=1, c_n = 2 otherwise (Chebyshev expansion factor)
  • g_n = kernel damping: Jackson (default, finite-size ringing suppressed) or Lorentz (controlled width lambda, smoother tails)
  • Entries for |ω| ≥ 1 are set to zero (outside the spectral support)

Pre-computing W avoids recomputing cos((n-1)·arccos(ω)) inside the inner loop, which is called Ncheb × Nω times.

source
TensorBinding._reconstruct_ldos_moment_columns — Method
_reconstruct_ldos_moment_columns(moments, W, denom, valid)
    -> Matrix{Float64}

Reconstruct one LDOS column per column of raw Chebyshev moments. The weight matrix follows _dos_weight_matrix: W[n, iω] multiplies moment order n-1, and denom[iω] supplies the kernel-specific normalization. Invalid energies are returned as zero columns in energy space.

source
TensorBinding._rescaled_energies — Method
_rescaled_energies(H, ω_phys_vals) -> Vector

Physical energies mapped onto the Chebyshev interval, (ω − H.center) / H.scale element by element.

source
TensorBinding.KPM_Tn — Method
KPM_Tn(H_mpo::MPO, N::Int, sites; scale=nothing, center=0.0, identity_mpo=nothing,
       maxdim=40, dmrg_nsweeps=5, dmrg_maxdim=[10, 20, 40], dmrg_linkdim=4,
       cutoff=1e-8, verbose=true) -> (Tn_list, scale, center)

Build the list of Chebyshev MPOs T_n((H−center·I)/scale) for n = 0…N.

Scale / center arguments

  • If scale=nothing (default): spectral bounds estimated automatically via _estimate_spectral_bounds (two short DMRG runs with dmrg_nsweeps, dmrg_maxdim, dmrg_linkdim); the estimate replaces center too.
  • If scale is provided: used directly; center defaults to 0.0 but can be set explicitly for non-symmetric spectra.

Other keywords

  • identity_mpo : the MPO used as I (in the shift and as T_0). Default nothing = MPO(sites, "Id"); the TBHamiltonian method passes physical_projector(H).
  • maxdim, cutoff : truncation of each recursion step. Defaults 40, 1e-8.
  • verbose : print the bond dimension every 5 orders and at the last. Default true.

High-level overload

Pass a TBHamiltonian as the first argument to skip manual rescaling entirely: Tn, scale, center = KPM_Tn(H, Ncheb; maxdim=100) H.scale and H.center are computed lazily on the first call and cached.

Return value

Returns (Tn_list, scale, center). To convert a physical energy ω: ω_r = (ω − center) / scale ∈ (−1, 1)

source
TensorBinding.KPM_Tn — Method
KPM_Tn(H::TBHamiltonian, Ncheb::Int; mode=:mpo, psi0=nothing,
       maxdim=40, cutoff=1e-8, dmrg_nsweeps=5, dmrg_maxdim=[10, 20, 40],
       dmrg_linkdim=4, verbose=false)
    -> (Tn_list, scale, center)

High-level Chebyshev expansion for a TBHamiltonian.

Lazily determines H.scale and H.center via DMRG if not already set (the dmrg_* keywords, see _ensure_scale!), builds the rescaled Chebyshev list with physical_projector(H) as the identity, caches the result on H, and returns (Tn_list, H.scale, H.center). maxdim, cutoff and verbose are passed to the raw-MPO method (verbose defaults to false here).

mode keyword

modeWhat is cachedUsed by
:mpo (default)MPO list {T_n(H̃)} in H._tn_cacheget_ldos (mode=:diag, :mpo), get_ldos_spectrum, get_density(…; method=:kpm)
:mpsMPS list `{T_n(H̃)ψ₀⟩}inH.tnmps_cache`

mode=:mps requires psi0 (a reference MPS). The MPS pathway is more memory-efficient when a single reference state is sufficient.

Overview of the four KPM pathways

Pathway 1 — MPO × MPO cache  [legacy / rarely used]
  KPM_Tn(H, Ncheb; mode=:mpo)           # build and cache {T_n(H̃)} MPOs
  → get_ldos_spectrum(H, ωlist)          # all ω in one pass → Vector{MPS}
  → get_ldos(H, ω; mode=:diag)           # single ω → diagonal site-LDOS MPS
  → get_ldos(H, ω; mode=:mpo)            # single ω → full off-diagonal MPO

  ⚠ Bond dimension χ_T grows at each MPO × MPO step; memory scales as
  O(Ncheb × χ_T²).  Prefer Pathways 3 or 4 unless the cache is reused for
  multiple downstream calls.  Kept mainly for legacy compatibility.

Pathway 2 — MPS cache  [legacy / fixed reference state]
  KPM_Tn(H, Ncheb; mode=:mps, psi0=ψ₀)  # cache {T_n(H̃)|ψ₀⟩} MPS on H
  → get_ldos(H, ω; mode=:mps, psi0=ψ₀)  # μₙ = ⟨ψ₀|T_n(H̃)|ψ₀⟩ → scalar

  Propagates a single reference MPS and stores the full trajectory
  {|φ_n⟩ = T_n(H̃)|ψ₀⟩} for repeated re-use across many energy queries on the
  same state.  Kept for advanced workflows; the public LDOS helpers below avoid
  storing this cache.

Pathway 3 — Online MPO × MPO  [k-space and spatial spectral functions]
  get_bands(H, Ncheb, D, ωlist; …)       # k-resolved A(k,ω), QFT-conjugated
  get_ldos_spatial(H, Ncheb, ωlist; …)   # real-space LDOS heatmap (default mode)

  Runs the MPO × MPO Chebyshev recursion online with no prior KPM_Tn call;
  only 3 MPOs alive at a time (truncated after each step).  Preferred for
  computing band structures and spatial LDOS over many positions simultaneously.

Pathway 4 — Online MPO × MPS  [single-particle default, most memory-efficient]
  get_ldos_online(H, Ncheb, X, ωlist; …) # LDOS at one site, all ω
  get_ldos_spatial(H, Ncheb, ωlist; mode=:mps; …)  # per-position MPS recursion
  get_exciton_ldos_spatial(H, Ncheb, ωlist; …)      # bound-pair exciton LDOS
  get_exciton_ldos(H, X, ωlist; …)                  # one-position wrapper
  get_dos_stochastic(H, Ncheb, ωlist; …) # stochastic trace DOS

  Propagates MPS states rather than full MPOs: only 3 MPS alive per sample/site.
  For single-particle problems this is almost always the best choice —
  memory cost is O(χ_H × χ_ψ) instead of O(χ_T²).  get_dos_stochastic
  applies this with random initial states for a stochastic trace estimate.

All pathways share the same KPM kernel and normalization. Aux-DOF projection keywords (spin_proj, nambu_proj, layer_proj, sublat_proj and their sector selectors) are accepted by get_bands, get_ldos_spatial, get_ldos_online and get_dos_stochastic (Pathways 3 and 4). The cached Pathways 1 and 2 (get_ldos, get_ldos_spectrum) and the exciton LDOS do not expose them.

source
TensorBinding.KPM_Tn_mps — Method
KPM_Tn_mps(H_mpo::MPO, N::Int, psi0::MPS, sites; scale=nothing, center=0.0,
           identity_mpo=nothing, maxdim=40, dmrg_nsweeps=5,
           dmrg_maxdim=[10, 20, 40], dmrg_linkdim=4, cutoff=1e-8, verbose=true)
-> (Tn_mps_list, scale, center)
KPM_Tn_mps(H::TBHamiltonian, N::Int, psi0::MPS; maxdim=40, cutoff=1e-8,
           dmrg_nsweeps=5, dmrg_maxdim=[10, 20, 40], dmrg_linkdim=4,
           verbose=false)
-> (Tn_mps_list, H.scale, H.center)

MPS-based Chebyshev expansion. Instead of storing Chebyshev MPOs Tn(H) (as `KPMTn` does), this builds the projected MPS states

|φ_n⟩ = T_n((H − center·I)/scale) |ψ₀⟩,   n = 0 … N

via the three-term recurrence

|φ₀⟩ = |ψ₀⟩,   |φ₁⟩ = H̃|ψ₀⟩,   |φ_k⟩ = 2H̃|φ_{k-1}⟩ − |φ_{k-2}⟩.

This is more memory-efficient than the full MPO version when only a single reference state is needed (e.g. site-resolved LDoS). Moments and spectral weights are then obtained as inner(ref_mps, Tn_mps_list[n+1]).

psi0 is normalised internally. scale/center follow the same convention as KPM_Tn: if scale=nothing the spectral bounds are estimated via DMRG. identity_mpo, maxdim and cutoff are as in KPM_Tn; verbose prints the bond dimension every 10 orders and at the last. Returns (Tn_mps_list, scale, center) where Tn_mps_list[n+1] = |φ_n⟩.

The TBHamiltonian method fills H.scale/H.center on demand (_ensure_scale!), uses physical_projector(H) as the identity, stores the list in H._tn_mps_cache (with H._tn_Ncheb = N) and returns (Tn_mps_list, H.scale, H.center).

source
TensorBinding._chebyshev_step — Method
_chebyshev_step(H̃, T_n, T_nm1; apply_kwargs, add_kwargs, post_kwargs=(;), two=2,
                negone=nothing) -> T_{n+1}

One Chebyshev step T_{n+1} = +(two * apply(H̃, T_n; apply_kwargs...), -T_{n−1}; add_kwargs...), with negone * T_{n−1} for -T_{n−1} when negone is a number, then truncate!(T_{n+1}; post_kwargs...) unless post_kwargs is empty. The step of chebyshev_foreach; get_exciton_cheb_convergence_gpu calls it directly for its two recursions run in lockstep.

source
TensorBinding._run_kpm_mps! — Method
_run_kpm_mps!(Ham_n, psi0, Ncheb, W, valid, accum;
              weight=1.0, cutoff=1e-8, maxdim=100,
              verbose=false, label="") -> Int

Online MPS Chebyshev KPM recursion. Computes μ_n = ⟨psi0|T_n(Ham_n)|psi0⟩ for n = 1…Ncheb and accumulates W[n,iω] × μ_n × weight into accum[iω] for each valid energy index. Returns the maxlinkdim of the final state. The recursion is chebyshev_foreach with its MPS defaults (cutoff and maxdim on every product and sum). The GPU exciton LDOS and stochastic DOS call it with GPU tensors (Ham_n and psi0 uploaded, cutoff as a Float64).

source
TensorBinding._scaled_hamiltonian — Method
_scaled_hamiltonian(H_mpo::MPO, scale, center, identity::MPO; cutoff) -> MPO
_scaled_hamiltonian(H::TBHamiltonian; cutoff, identity=physical_projector(H)) -> MPO

The Chebyshev argument H̃ = (H − center·identity) / scale, computed as (1 / scale) * +(H_mpo, (-center) * identity; cutoff=cutoff): the shift is added with cutoff as the only truncation, then the sum is multiplied by 1 / scale.

The TBHamiltonian method uses H.mpo, H.scale, H.center and, as identity, physical_projector(H), the identity on the physical states: for a projected position space (Fibonacci & co.) the ambient MPO(H.sites, "Id") would shift the unphysical register states to −center/scale and give them Chebyshev weight. A caller that also needs the projector as T₀ builds it once and passes it as identity. The raw-MPO method takes the identity explicitly (MPO(sites, "Id") where no position space is known).

source
TensorBinding.chebyshev_foreach — Method
chebyshev_foreach(f!, H̃::MPO, T₀, N::Integer; maxdim, cutoff, T1=nothing,
                  apply_trunc=(:cutoff, :maxdim), add_trunc=(:cutoff, :maxdim),
                  post_trunc=(), two=2, negone=nothing) -> T_last

Run the Chebyshev recursion

T_{n+1} = 2 H̃ T_n − T_{n−1}

from T₀ and T₁, calling f!(n, T_n) for the orders n = 0, 1, …, N − 1, in that order, each as soon as T_n is built. With T₀ an MPO the terms are operators (the operator Chebyshev series T_n(H̃) for T₀ = I or physical_projector(H)); with T₀ an MPS they are the Chebyshev vectors T_n(H̃)|ψ₀⟩. The tensors stay on the device of H̃ and T₀ (CPU or GPU) with their element types; nothing is transferred.

T1 is T₁. By default it is apply(H̃, T₀) with the truncation of the step's product; the operator series pass T1 = H̃ (H̃ · I, no product). Orders 0 and 1 are always visited, also for N < 2. Returns the last term built: T_{N−1}, or T₁ when N ≤ 2.

Each later term is one step (_chebyshev_step), in this order:

T_{n+1} = +(two * apply(H̃, T_n; <apply_trunc>), -T_{n−1}; <add_trunc>)
truncate!(T_{n+1}; <post_trunc>)          # skipped when post_trunc = ()

where <…> passes the parameters named in the tuple, out of :cutoff and :maxdim, with the values of the cutoff and maxdim keywords; negone * T_{n−1} replaces -T_{n−1} when negone is a number. The callers differ in exactly these choices, and each keeps its own (so no result changes); "both" is (:cutoff, :maxdim), "typed" is T(2) and T(-1) for the GPU element type T:

callersapply_truncadd_truncpost_trunctwo, negone
KPM_Tn, KPM_Tn_gpu, get_ldos_spatial(mode=:mpo), get_bands, get_qpi(:cutoff,)(:maxdim,)(:cutoff,)2, nothing
get_dos_trace(:cutoff,)bothboth2, nothing
get_ldos_spatial_gpu, get_bands_gpubothboth(:cutoff,)typed
KPM_Tn_mps, _run_kpm_mps! (also behind the GPU exciton LDOS and stochastic DOS)bothboth()2, nothing
get_ldos_spatial_mps_gpu, the GPU NH stochastic tracebothboth()typed
the CPU NH KPM (nh_kpm_partials, _nh_*_online, _nh_kpm_mps_ldos)bothboth()2.0, nothing
the GPU NH diagonal tracesbothbothbothtyped

The partial recurrence of the NH KPM, P_k = 2S·T_{k−1} + 2A·P_{k−1} − P_{k−2}, is not a Chebyshev recursion: it rides on the T_n of this one inside f! (physics/nh/kpm.jl, gpu/nh.jl).

The recursion holds only the last two terms: it drops T_{n−1} before calling f!(n + 1, T_{n+1}), so a callback that frees GPU memory reclaims it. f! may keep T_n (the cached lists push it) but must not modify it.

source
TensorBinding._chebyshev_sum — Method
_chebyshev_sum(Tn, coeffs; maxdim, cutoff) -> MPO (or MPS)

Weighted sum Σ_n c_n·Tn[n] over n = 1:length(coeffs), truncated as it goes:

A = term(1);  for n ≥ 2:  A = +(A, term(n); maxdim);  A = truncate!(A; cutoff)

coeffs[n] is a number c (term Tn[n] * c) or a tuple of numbers (a, b, …), whose factors multiply the operator one at a time, left to right (((Tn[n] * a) * b) * …). A caller's 2 * T * g * k is the tuple (2, g, k): scalar products of an MPO/MPS scale one tensor in place, so the grouping of the factors, not only their product, fixes the floating-point result.

source
TensorBinding.get_density_from_Tn — Method
get_density_from_Tn(Tn_list, N; fermi=0, maxdim=40, cutoff=1e-8, kernel=:jackson,
                    lambda=4.0) -> MPO

The KPM density matrix θ(fermi − H̃), the projector onto the states below fermi, from a Chebyshev list Tn_list of the rescaled H̃ = (H − center)/scale, expanded with the first N terms. fermi is a rescaled energy in (−1, 1), not a physical one: pass (ϵF − H.center) / H.scale, as get_density does.

source
TensorBinding.get_ldos — Method
get_ldos(H::TBHamiltonian, ω_phys; mode=:diag, psi0=nothing, kernel=:jackson,
         lambda=4.0, eta=0.0, m_order=4, maxdim=40, cutoff=1e-8,
         zl=nothing, wl=nothing)

Compute the local density of states at physical energy ω_phys using the Chebyshev expansion cached in H by a prior KPM_Tn or KPM_Tn_mps call.

Modes

  • :mpo (legacy) — calls get_ldos_w_from_Tn and returns a full spectral-weight MPO at ω_phys. Requires KPM_Tn(H, N; mode=:mpo). Retains off-diagonal information; use when spatial correlations are needed.

  • :diag (default) — calls get_ldos_diag_from_Tn and returns an MPS encoding only the diagonal A(r, ω_phys) (nothing outside the spectral support). Requires KPM_Tn(H, N; mode=:mpo). Much cheaper than :mpo for typical LDOS use-cases; mirrors the get_bands momentum-space pattern. Use get_ldos_spectrum to compute all energies in a single pass. Use get_ldos_online to avoid storing the Tn cache entirely.

  • :mps — computes moments μₙ = ⟨ψ₀|φₙ⟩ from the MPS Chebyshev cache and calls get_ldos_from_mun, returning a Real. Requires KPM_Tn(H, N; mode=:mps, psi0=...) and the same psi0 here. Both normalise psi0, so the result is the LDOS of ψ₀/‖ψ₀‖ whatever the norm of psi0. Another psi0, also one that differs only by a global phase or lives on other site indices than H.sites, is an ArgumentError (up to v0.1.1 it returned the cross term ⟨ψ|T_n|ψ₀⟩ without an error).

Keywords

  • kernel, lambda — KPM kernel (:jackson, :lorentz with lambda, :fejer, :dirichlet; :hodc in modes :mpo and :mps only).
  • eta, m_order — HODC broadening and order; eta=0 means 1/(N+1). m_order is used in mode :mps; mode :mpo takes the HODC nodes zl, wl from compute_hodc_params instead.
  • maxdim, cutoff — truncation of the MPO/MPS sums (modes :diag, :mpo).

Physical energies are converted via E = (ω_phys − H.center) / H.scale.

Normalisation: the package's KPM convention (see get_ldos_from_mun): with the convolution kernels the result is the spectral density per unit rescaled energy E times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units. kernel=:hodc is normalised to 1 (multiply by 1/H.scale).

source
TensorBinding.get_ldos_diag_from_Tn — Method
get_ldos_diag_from_Tn(Tn_list, N::Int, ω_vals; kernel=:jackson, lambda=4.0,
                      maxdim=40, cutoff=1e-8)
    -> Vector{Union{Nothing, MPS}}

Compute site-resolved LDOS at every energy in ω_vals from a stored Chebyshev MPO list Tn_list, using the same online-accumulation + diagonal-extraction pattern as get_bands in momentum space.

At each Chebyshev step n, the diagonal of Tn_list[n] is extracted as an MPS via extract_diagonal_to_mps and its KPM-weighted contribution is accumulated into the LDOS for every energy point simultaneously — avoiding construction and storage of full weighted MPOs.

Returns a Vector of length length(ω_vals). Each entry is either:

  • an MPS encoding the site-resolved LDOS A(r, ω) at that (rescaled) energy, or
  • nothing for energies with |ω| ≥ 1 (outside the rescaled spectral support).

ω_vals must be rescaled energies in (−1, 1) — convert from physical units with E = (ω_phys − center) / scale. The legacy per-energy full-MPO path is still available via get_ldos_w_from_Tn.

source
TensorBinding.get_ldos_from_mun — Method
get_ldos_from_mun(mun_list, N::Int, E::Real; kernel=:jackson, lambda=4.0,
                  eta=1/(N+1), m_order=4) -> Real

Reconstruct the local spectral weight at rescaled energy E ∈ (−1, 1) from a list of Chebyshev moments μ_n = ⟨ψ₀|T_n(H̃)|ψ₀⟩ produced by KPM_Tn_mps.

Computes the KPM expansion of ⟨ψ₀|δ(E − H̃)|ψ₀⟩ with an extra factor 1/π:

A(E) ≈ [g₀μ₀ + 2 Σ_{n≥1} gₙ Tₙ(E) μₙ] / (π² √(1−E²))

where gₙ are the kernel damping weights normalised to g₀ = 1 (Jackson by default), so ∫ A dE = 1/π per state for these kernels. The :hodc weights carry the δ-function normalisation itself (∫ A dE = 1). With kernel=:jackson the last moment gets weight zero (the textbook Jackson kernel for N − 1 moments). Supported kernel values: :jackson, :lorentz (requires lambda), :fejer, :dirichlet, and :hodc, which hands over to get_ldos_hodc_from_mun with the contour broadening eta (default 1/(N+1)) and order m_order (default 4); eta and m_order are ignored by the other kernels. Returns 0 for |E| ≥ 1.

To convert a physical energy ω: E = (ω − center) / scale. To obtain the density of states per site, sum over all sites and divide by N.

source
TensorBinding.get_ldos_hodc_from_mun — Method
get_ldos_hodc_from_mun(mun_list, N::Int, E::Real; eta=0.02, m_order=4) -> Real

HODC (Higher-Order Delta Chebyshev) variant of get_ldos_from_mun. Uses a contour-based kernel that gives sharper spectral features than the Jackson kernel, at the cost of m_order extra parameters.

The HODC weights νₖ (from compute_hodc_params / get_hodc_weights) already carry the full KPM normalisation, including the factor 2 of the n ≥ 2 terms, so no extra denominator is needed:

A_hodc(E) ≈ Σ_{n≥1} νₙ μₙ

Returns 0 for |E| ≥ 1.

source
TensorBinding.get_ldos_spectrum — Method
get_ldos_spectrum(H::TBHamiltonian, ω_phys_vals; kernel=:jackson, lambda=4.0,
                  maxdim=40, cutoff=1e-8)
    -> Vector{Union{Nothing, MPS}}

Compute the site-resolved LDOS at all physical energies in ω_phys_vals in a single pass over the cached Chebyshev MPO list — the real-space equivalent of get_bands.

At each Chebyshev step the diagonal of T_n is extracted once and its weighted contribution is accumulated into every energy slot simultaneously, so the cost scales as O(Ncheb) MPO operations regardless of how many energy points are requested.

Returns Vector{Union{Nothing, MPS}} of length length(ω_phys_vals). Each MPS encodes the site-resolved LDOS A(r, ω) at the corresponding physical energy; entries are nothing for energies outside the spectral support.

Requires KPM_Tn(H, Ncheb; mode=:mpo) to have been called first.

Example

KPM_Tn(H, 200; mode=:mpo, maxdim=100)

ωlist    = range(-4.0, 4.0; length=200)
ldos_vec = get_ldos_spectrum(H, ωlist)

# Evaluate LDOS at site x=16 (0-indexed position 15) for each energy:
ldos_at_16 = [l === nothing ? 0.0 : eval_mps(l, 15) for l in ldos_vec]

Normalisation: the package's KPM convention (see get_ldos_from_mun): the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units.

source
TensorBinding.get_ldos_online — Method
get_ldos_online(H::TBHamiltonian, Ncheb::Int, X::Int, ω_phys_vals;
                kernel=:jackson, lambda=4.0, maxdim=100, cutoff=1e-8,
                verbose=false,
                nambu_proj=false, proj_nambu=nothing, spin_proj=false,
                proj_s=nothing, layer_proj=false, proj_layer=nothing,
                sublat_proj=false, proj_sl=nothing)
    -> Vector{Float64}

Online real-space LDOS at unit-cell position X for all physical energies in ω_phys_vals. Never stores more than 3 MPS simultaneously (no Chebyshev cache).

Algorithm: MPS Chebyshev recursion |φ_k⟩ = T_k(H̃)|X⟩ with moment accumulation μ_k = ⟨X|φ_k⟩. Auxiliary DOF sectors are summed by running the recursion once per requested sector.

X ∈ {1, …, H.N} is the 1-indexed unit-cell position.

Keywords

  • kernel, lambda — KPM kernel (:jackson, :lorentz with lambda, :fejer, :dirichlet).
  • maxdim, cutoff — truncation of each MPS recursion step.
  • verbose — print the bond dimension every 10 Chebyshev steps and at the last.

Auxiliary DOF projections (same interface as get_bands and get_ldos_spatial):

  • spin_proj, nambu_proj, layer_proj, sublat_proj — enable projection of the corresponding auxiliary DOF auto-detected from H. A DOF present on H is always projected: its flag is switched on automatically, with an info line.
  • proj_s, proj_nambu, proj_layer, proj_sl — sector selector: nothing sums all sectors of that DOF; an integer selects a single sector (1-based).
  • Contributions from all requested sectors are accumulated into a single result vector.

Returns Vector{Float64} of length Nω with 0.0 outside the spectral support.

Examples

ωlist = range(-3.0, 3.0; length=300)
ldos  = get_ldos_online(H, 200, 2^(H.L-1), ωlist)          # no aux DOF

# Spin-summed LDOS at site 16
ldos_tot = get_ldos_online(H_spin, 200, 16, ωlist; spin_proj=true)

# Spin-↑ LDOS only
ldos_up  = get_ldos_online(H_spin, 200, 16, ωlist; spin_proj=true, proj_s=1)

Normalisation: the package's KPM convention (see get_ldos_from_mun): the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units.

source
TensorBinding.get_ldos_spatial — Method
get_ldos_spatial(H::TBHamiltonian, Ncheb::Int, ω_phys_vals;
                 num_x=H.N, num_y=nothing, num_avg=1, mode=:mpo,
                 x_start=1, x_end=H.N, x_groups=nothing,
                 grid=false, xwin=nothing, ywin=nothing, box_half=0,
                 reduce=:point, sublattice=:auto,
                 kernel=:jackson, lambda=4.0, maxdim=100, cutoff=1e-8,
                 verbose=false,
                 ordering=:physical, conumber_orientation=:standard,
                 conumber_centered=true, conumber_origin=0,
                 conumber_alignment=:atomic,
                 nambu_proj=false, proj_nambu=nothing, spin_proj=false,
                 proj_s=nothing, layer_proj=false, proj_layer=nothing,
                 sublat_proj=false, proj_sl=nothing)
    -> Matrix{Float64}

Spatially-resolved LDOS, real-space analogue of get_bands.

Sampling procedures (reduce) — full detail in spatial_sampling_plan.

  • :point (default) — read the LDOS at num_x[×num_y] sample cells; with box_half > 0 each pixel is the mean over a (2·box_half+1)² box. Cheap, but a grid coarser than a feature's width aliases it (thin in-gap edge / domain-wall channels can fall between pixels and be missed).
  • :block — partition the system into num_x × num_y blocks (powers of two) and report the integral over each block, computed by tracing out the within-block position bits (a partial contraction, cost independent of block size). Gap-free: every cell belongs to one block, so a thin feature on a gapped background cannot be missed. Use it for large-scale maps of edge networks. Output columns are row-major over coarse pixels (col = ixp + iyp·num_x + 1); block centres come from the plan. :mpo mode only.

Return shape (sublattice geometry-awareness)

For a multi-atom unit cell (H.sublattice_s set) the layout depends on the sampling scale, decided by spatial_sampling_plan from the local stride (see sublattice below):

  • resolved (atomic scale — every unit cell probed, or proj_sl=k): (Nω × ng×n_sub), columns interleaved in atom order matching the *_positions functions — [A₀, B₀, A₁, B₁, …] (2-sublattice), [A₀, B₀, C₀, …] (3-sublattice). proj_sl=k fills only sublattice k.
  • averaged (large scale — the grid skips unit cells): (Nω × ng), the sublattice is traced out into one value per unit cell (mean over the n_sub atoms).

With no sublattice DOF the shape is always (Nω × ng). ng is the number of sample groups of the plan: num_x for the default 1D sweep, num_x × num_y for grid=true or reduce=:block, length(x_groups) for explicit groups.

sublattice (resolve vs average)

  • :auto (default) — resolve when sampling at full unit-cell resolution (stride == 1, e.g. zooming a small window and probing every cell); average whenever the grid is coarser or box_half > 0.
  • :resolve — always emit per-atom columns. :average — always trace the sublattice to one value per cell. proj_sl=k always resolves that one atom.

Sampling parameters (passed to spatial_sampling_plan)

  • num_x/num_y : sample counts (per axis for grid=true; num_x is the total for the default 1D linear sweep). num_x defaults to H.N = full resolution; num_y=nothing (default) uses the same count as num_x (capped at the window).
  • num_avg : sub-samples per coarse block for local averaging (1D, default 1).
  • x_start, x_end : 1-indexed linear position range (1D layout; defaults 1, H.N).
  • grid : true lays centers on a 2D num_x × num_y unit-cell grid. Default false.
  • xwin, ywin : 0-indexed unit-cell (lo, hi) windows for grid=true (e.g. zoom into a patch of a large system). Default nothing = the full system.
  • x_groups : explicit Vector{Vector{Int}} override (treated as atomic). Default nothing.
  • box_half : 2D neighbourhood half-width (averages, forces sublattice averaging). Default 0.
  • reduce : :point (default; sample/box) or :block (block-integrate; see above).
  • sublattice : :auto (default), :resolve or :average (see above).

grid, xwin, ywin, box_half > 0 and reduce=:block need a 2D H.geometry.

Modes

  • :mpo (default) — single Chebyshev pass; evaluates all positions simultaneously. Cost ∝ Ncheb × (MPO×MPO), independent of num_x or n_sub.
  • :mps — independent MPS recursion per (position, sector) combination.

Chebyshev keywords

  • kernel, lambda : KPM kernel (:jackson default, :lorentz with lambda (default 4.0), :fejer, :dirichlet).
  • maxdim, cutoff : truncation of each recursion step (defaults 100, 1e-8).
  • verbose : print progress (every 15 steps in :mpo mode, every 15 positions in :mps mode). Default false.

Auxiliary DOF projections (same interface as get_bands): nambu_proj/proj_nambu, spin_proj/proj_s, layer_proj/proj_layer, sublat_proj/proj_sl. The flags default to false and the selectors to nothing (sum all sectors); an integer selector picks one 1-based sector. A DOF present on H is always projected: its flag is switched on automatically, with an info line (sublat_proj is kept only for backward compatibility).

Site ordering (ordering, conumber_*)

  • ordering=:physical (default) samples positions in physical order.
  • ordering=:conumber (Fibonacci position spaces only) orders the columns by conumber: the groups become [[x] for x in site_permutation(H; ordering=:conumber, …)], with conumber_orientation (:standard default, or :reversed), conumber_centered (default true; it only relabels the conumbers around zero, so the column order does not depend on it), conumber_origin (default 0, shifts the site index before conumbering) and conumber_alignment passed on as orientation, centered, origin and alignment. It requires full-resolution 1D point sampling (num_x, num_y, num_avg, x_start, x_end, x_groups, grid, xwin, ywin, box_half, reduce at their defaults) and no auxiliary DOF.

conumber_alignment=:atomic (default) places the AA sites in one central block; :raw exposes the unshifted modular residues. A recursive atomic zoom should slice the interval returned by fibonacci_rg_partition rather than re-conumbering its sites with a reduced L.

Examples

# Standard 1D chain — shape (Nω × 8)
ldos = get_ldos_spatial(H, 200, ωlist; num_x=8)

# Honeycomb, large-scale map — sublattice averaged, shape (Nω × 64)
ldos_uc  = get_ldos_spatial(H_hc, 200, ωlist; num_x=64)

# Honeycomb, atomic zoom into a 50×50 patch — sublattice resolved (Nω × 50*50*2)
ldos_zoom = get_ldos_spatial(H_hc, 200, ωlist; grid=true,
                             xwin=(1000, 1049), ywin=(1000, 1049))

# Large 2^14×2^14 system: 128×128 block-integrated map — catches thin in-gap
# edge channels that point sampling would alias away. Shape (Nω × 128*128).
ldos_blk = get_ldos_spatial(H_big, 200, ωlist; reduce=:block, num_x=128, num_y=128)

# Kagome: sublattice A only — only A columns filled, B/C columns zero
ldos_A   = get_ldos_spatial(H_kg, 200, ωlist; proj_sl=1, num_x=H_kg.N)

Normalisation: the package's KPM convention (see get_ldos_from_mun): the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units.

source
TensorBinding._dos_stochastic — Method
_dos_stochastic(H, H̃, Ncheb, ω_phys_vals, aux; N_sample, N_bound, seed, normalize,
                dos_weighting, kernel, lambda, eta, m_order, maxdim, cutoff,
                continuum_only=false, caller="get_dos_stochastic",
                to_device=_on_host, device_type=ComplexF64, after_run=nothing,
                progress=nothing) -> Vector{Float64}

The sampling and normalisation of get_dos_stochastic (documented there), also the body of get_dos_stochastic_gpu, from the rescaled Hamiltonian H̃ (on the device) and the aux projection aux (autoenable=false). Each probe state is built on the CPU, moved by to_device(·, device_type) (see _on_host) and run through _run_kpm_mps!; after_run() follows each run and progress(kind, i, n, χ, info) reports it, with kind one of :projected (first sector of sample i only), :full, :continuum (info = (x_e, x_h)) and :bound (info = x).

continuum_only=true (the GPU option; exciton Hamiltonians, checked by the caller) draws the N_sample probes as ordered electron-hole pairs x_e ≠ x_h, weighted by D − N_phys; together with aux projections it is an error, reported as caller's.

source
TensorBinding.get_dos_stochastic — Method
get_dos_stochastic(H::TBHamiltonian, Ncheb::Int, ω_phys_vals;
                   N_sample=50, N_bound=0, seed=42, normalize=false,
                   dos_weighting=:trace, kernel=:jackson, lambda=4.0, eta=0.0,
                   m_order=4, maxdim=100, cutoff=1e-8, verbose=false,
                   nambu_proj=false, proj_nambu=nothing, spin_proj=false,
                   proj_s=nothing, layer_proj=false, proj_layer=nothing,
                   sublat_proj=false, proj_sl=nothing)
    -> Vector{Float64}

Stochastic full DOS via random trace estimation (MPS Chebyshev, 3 MPS per sample).

Sampling: N_sample random basis states (default 50), drawn from a MersenneTwister(seed); seed=nothing draws from the global RNG. maxdim and cutoff truncate each MPS recursion step; verbose prints the bond dimension every 15 samples.

Normalization

  • dos_weighting=:trace (default): returns the trace DOS. With normalize=false this is the total spectral weight per unit rescaled energy ω̃ = (ω − H.center)/H.scale: Tr[δ(ω̃ − H̃)]/π with the convolution kernels (the package's KPM convention, see get_ldos_from_mun) and Tr[δ(ω̃ − H̃)] with kernel=:hodc; multiply by π/H.scale (:hodc: 1/H.scale) for physical units. With normalize=true it is divided by the traced Hilbert-space dimension.
  • dos_weighting=:sample: returns the unweighted sample signal. For exciton stratified runs this is avg_full + avg_bound (when N_bound > 0), with no phase-space factor multiplying the continuum. This is intended for visualising the bound peak; normalize is ignored in this mode.

Auxiliary DOF projections

Unlike get_ldos_spatial, projections are not auto-enabled here. The default is full Hilbert-space sampling over all D states — always correct and cheapest. Projections must be requested explicitly:

  • layer_proj=true, proj_layer=k — DOS on layer k only.
  • sublat_proj=true, proj_sl=k — DOS on sublattice k only.
  • Combining multiple *_proj=true flags is supported.

When any flag is set the function samples from position-basis states with fixed aux sectors (N_phys effective states), which is n_sectors× slower than the default. Only use projections when you actually need a sector-resolved DOS.

Exciton stratification (no aux projections)

For exciton Hamiltonians (the 2L-site register of exciton_hamiltonian), stratified sampling dedicates N_bound samples to the bound sector |x,x⟩ and N_sample to the full Hilbert space, combining with proper weights: DOS = N_phys × avg_bound + (D − N_phys) × avg_scatter. N_bound = 0 (default) = uniform sampling over all D states. Set dos_weighting=:sample to inspect the sampled spectral signal before these sector-size weights are applied.

Reconstruction kernel

kernel=:hodc uses the Higher-Order Delta Chebyshev contour reconstruction (eta, m_order control it; eta=0 → 1/(Ncheb+1)), whose weights already carry the full KPM normalisation. Other values are convolution kernels (:jackson default, :lorentz with lambda, :fejer, :dirichlet).

Examples

# Per-state DOS, size-independent
dos = get_dos_stochastic(H, 100, ωlist; N_sample=50, normalize=true)

# Sublattice-resolved per-state DOS (kagome)
dos_A = get_dos_stochastic(H_kg, 100, ωlist; sublat_proj=true, proj_sl=1,
                            N_sample=50, normalize=true)

# BdG: particle + hole combined per-state DOS
dos   = get_dos_stochastic(H_bdg, 100, ωlist; nambu_proj=true,
                            N_sample=50, normalize=true)
source
TensorBinding.get_dos_trace — Method
get_dos_trace(H, Ncheb, ω_phys_vals; normalize=false, kernel=:jackson,
              lambda=4.0, eta=0.0, m_order=4,
              maxdim=100, cutoff=1e-8, verbose=false) -> Vector{Float64}

Deterministic total DOS from the exact tensor-network trace of each online Chebyshev MPO. Only three MPOs are retained. At every order the diagonal MPO is converted to an MPS and contracted with the product MPS |1,1,...>, giving Tr[T_n(H_tilde)] without summing LDOS curves or integrating a spectrum.

For projected position spaces, T_0 is physical_projector(H) and the trace is therefore over physical states only. normalize=true divides by Tr(T_0); otherwise the spectral weight corresponds to the total traced state count.

Normalisation: the package's KPM convention (see get_ldos_from_mun): with the convolution kernels the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units. kernel=:hodc is normalised to 1 (multiply by 1/H.scale).

source
TensorBinding.exciton_radius2 — Method
exciton_radius2(rho, d_list) -> Matrix{Float64}

Energy-resolved exciton radius

xi^2(R, E) = sum_d d^2 * P(d | R, E),   P(d | R, E) = rho(d,R,E) / sum_d' rho(d',R,E)

from a rho array as returned by get_exciton_ldos_separation (size(rho) == (Nomega, length(d_list), n_R)). Returns an (Nomega, n_R) matrix. Entries where any rho[:, :, R] along d is NaN (e.g. R+d outside the chain under boundary=:open), or where the normalisation sum_d rho(d,R,E) is zero, are returned as NaN.

source
TensorBinding.get_exciton_ldos — Method
get_exciton_ldos(H::TBHamiltonian, X::Int, omega_phys::Real; Ncheb=200,
                 kernel=:jackson, lambda=4.0, eta=0.0, m_order=4, maxdim=40,
                 cutoff=1e-8, verbose=false) -> Float64
get_exciton_ldos(H::TBHamiltonian, X::Int, omega_phys_vals; <same keywords>)
    -> Vector{Float64}

Bound-pair exciton LDOS at the single position X (1-indexed in 1:H.N): a one-column call of get_exciton_ldos_spatial with X_list=[X]. Note that the Chebyshev order is the keyword Ncheb here, and that maxdim defaults to 40 (get_exciton_ldos_spatial: 100). The normalisation is that of get_exciton_ldos_spatial (the package's KPM convention, 1/π per state).

source
TensorBinding.get_exciton_ldos_separation — Method
get_exciton_ldos_separation(H, Ncheb, omega_phys_vals; d_list, R_list=1:H.N,
                            boundary=:open, kernel=:jackson, lambda=4.0, eta=0.0,
                            m_order=4, maxdim=100, cutoff=1e-8, verbose=false,
                            printinfo=false) -> Array{Float64,3}

Relative-separation-resolved exciton LDOS

rho(d, R, E) = <R+d, R| delta(E - H) |R+d, R>

generalising get_exciton_ldos_spatial (the d = 0 slice) to electron-hole probes with electron at R+d and hole at R (both 1-indexed in 1:H.N).

For each (d, R) pair the probe |R+d, R> is a single product state (mpsexciton(R+d, R, H.sites)) — no superposition / carry construction is needed, unlike the momentum-space probes mpsexcitonQ/mpsexcitonQTrace. An online MPS Chebyshev recursion accumulates all energies in one pass, exactly as in get_exciton_ldos_spatial.

boundary=:open (default): pairs with R+d outside 1:H.N are left as NaN. boundary=:periodic: R+d is wrapped modulo H.N.

Returns an (Nomega, length(d_list), length(R_list)) array. Cost is length(d_list) * length(R_list) Chebyshev recursions, so keep these (and Ncheb) small for a first pass.

source
TensorBinding.get_exciton_ldos_spatial — Method
get_exciton_ldos_spatial(H::TBHamiltonian, Ncheb::Int, omega_phys_vals;
                         X_list=nothing, X_groups=nothing, x_groups=nothing,
                         num_x=H.N, num_avg=1, x_start=1, x_end=H.N,
                         kernel=:jackson, lambda=4.0, eta=0.0, m_order=4,
                         maxdim=100, cutoff=1e-8, verbose=false,
                         printinfo=false, return_maxlinkdim=false)
    -> Matrix{Float64}, or (; ldos, maxlinkdims) with return_maxlinkdim=true

CPU spatial exciton LDOS. For each bound exciton position X (electron = hole = X, 1-indexed in 1:H.N) this runs an online MPS Chebyshev recursion from |X,X> and accumulates all requested energies in one pass. No Chebyshev cache is stored on H.

Rows are energies, columns are positions/groups. X_list selects positions directly. X_groups (or alias x_groups) averages several bound-pair probes into one output column. If no explicit positions are provided, num_x coarse groups are generated over x_start:x_end, with num_avg subpositions per group.

kernel=:hodc uses the HODC reconstruction (eta, m_order; eta=0 means 1/(Ncheb+1)); otherwise the standard KPM kernels are available (:jackson, :lorentz with lambda, :fejer, :dirichlet). maxdim and cutoff truncate each MPS recursion step; verbose or printinfo prints progress every 5 columns.

return_maxlinkdim=true returns (; ldos = result, maxlinkdims) instead of just result, where maxlinkdims::Vector{Int} is the reached MPS bond dimension per output column (the χ the Chebyshev recursion hit under the given maxdim/cutoff); up to v0.1.1 it was the tuple (result, linkdims), which destructures the same way. Mirrors the GPU entry point; useful for cutoff/tolerance studies where χ is the observable.

Normalisation: the package's KPM convention (see get_ldos_from_mun): with the convolution kernels the result is the spectral density per unit rescaled energy (ω − H.center)/H.scale times 1/π, so each state integrates to 1/π; multiply by π/H.scale for physical units. kernel=:hodc is normalised to 1 (multiply by 1/H.scale).

source

Krylov Green's Function

TensorBinding._minres_shifted — Method
_minres_shifted(A, b, x0, a0, a1; tol=1e-10, maxiter=2000) -> (x, info)

Solve (a0 + a1·A) x = b for a Hermitian linear map A (a function v -> A v) and complex a0, a1 ≠ 0 by MINRES: the Lanczos three-term recurrence of A from the residual of x0, with complex Givens rotations on the shifted tridiagonal T − σ, σ = −a0/a1. In exact arithmetic the iterates are those of GMRES without restarts, kept in three vectors.

Stops when the residual estimate |a1|·|t| is at most tol (absolute, as KrylovKit's tol), on a Lanczos breakdown, or after maxiter products with A. info = (; converged, numops, residual), with numops the products with A (the residual of x0 included) and residual the final estimate.

Works on any vector type with norm, dot, copy and linear combinations (ITensors, Vectors). A non-Hermitian A gives a wrong x without an error.

source
TensorBinding._vec_mps_from_mpo — Method
_vec_mps_from_mpo(G_mpo::MPO, sites2; cutoff=1e-12, maxdim=typemax(Int)) -> MPS

Convert an L-site MPO into the 2L-site interleaved vectorized MPS that get_green_krylov uses for the right-hand side |I⟩⟩ and for the optional initial guess x0_mpo.

Each MPO tensor at site k is split by SVD into two MPS tensors at positions (2k-1, 2k): the bra (primed) physical index maps to the odd row site and the ket (unprimed) index maps to the even column site, the encoding that custom_mpo reads back into an MPO.

source
TensorBinding.eval_haydock_cf — Method
eval_haydock_cf(a, b, z) -> ComplexF64

Evaluate the Haydock continued fraction ⟨seed|(z−H)⁻¹|seed⟩ via backward recursion. b[1] must be norm0 = ||seed||F (as returned by `haydockcf`).

G(z) = b[1]² / (z − a[1] − b[2]²/(z − a[2] − b[3]²/…))

Calling with truncated arrays a[1:N], b[1:N] gives the N-th CF convergent, whose sequence over N is suitable for Wynn ε-acceleration.

source
TensorBinding.get_green_krylov — Method
get_green_krylov(H_mpo::MPO, sites, ω_phys; η=1e-2, nsweeps=12, maxdim=100,
                 cutoff=nothing, x0_mpo=nothing, start=:random, rng=Xoshiro(1),
                 solver=:gmres, ishermitian=false, tol=1e-10, maxiter=600,
                 krylovdim=30, return_info=false, residual_warn=0.1,
                 verbose=false) -> MPO

Low-level: compute the retarded Green's function G(ω) = (ω + iη − H)⁻¹ for a raw MPO H_mpo defined on sites, via the vectorized linear system

[I ⊗ (ω + iη − H)ᵀ] |G⟩⟩ = |I⟩⟩

(G (ω + iη − H) = I, with the operator on the column sites of |G⟩⟩).

See the TBHamiltonian overload for the full keyword-argument reference.

source
TensorBinding.get_green_krylov — Method
get_green_krylov(H::TBHamiltonian, ω_phys; η=1e-2, nsweeps=12, maxdim=100,
                 cutoff=nothing, x0_mpo=nothing, start=:random, rng=Xoshiro(1),
                 solver=:gmres, ishermitian=false, tol=1e-10, maxiter=600,
                 krylovdim=30, return_info=false, residual_warn=0.1,
                 verbose=false) -> MPO

Compute the retarded Green's function

G(ω) = (ω + iη − H)⁻¹

as an MPO by solving the vectorized linear system

[I ⊗ (ω + iη − H)ᵀ] |G⟩⟩ = |I⟩⟩

(G (ω + iη − H) = I, with the operator on the column sites of |G⟩⟩)

using ITensorMPS.linsolve (DMRG-like Krylov solver). The Hamiltonian is used unscaled — no KPM Chebyshev expansion required.

Keyword arguments

  • η : Lorentzian broadening. Default 1e-2.
  • nsweeps : Number of DMRG sweeps for the linear solver. Default 12.
  • maxdim : Maximum bond dimension of the solution MPS. Default 100.
  • cutoff : SVD truncation cutoff of the sweeps, relative to ‖|G⟩⟩‖², which grows as the dimension D of the site space (the number of sites). Default nothing: 1e-8 up to 2^10 sites and 1e-8·2^10/D beyond (never below 1e-14), so that it weighs the same next to one row of G at every size. A fixed 1e-8 (the default up to v0.2.1, still available by passing it) truncates away what sets a row apart from the others on a large system: the end rows of a clean open chain came back as bulk rows from 2^20 sites. The cutoff sets the accuracy of G row by row. With the default, on open chains of 2^10–2^30 sites with one impurity, the chain ends, the middle bond and the impurity site were right to 4e-6 or better and the rows with the largest error were off by a few 1e-3 of their norm (‖G(z − H) − 1‖F up to 4e-2). Beyond 2^30 sites the floor 1e-14 binds and rows lose accuracy again: at 2^34–2^36 the same elements were right to 1e-4, or to 0.3–2 % at a band edge, with the warning; from about 2^38 sites a single row is below double precision next to ‖|G⟩⟩‖², and the ends of a chain come back as bulk rows, with the warning. For local quantities on such systems use the correction vectors (`getldos_cv`), which solve for one row.
  • x0_mpo : Optional MPO initial guess for G(ω). When provided it is vectorized via _vec_mps_from_mpo and passed as x0 to linsolve, replacing the start chosen by start. Typical use: pass a low-accuracy KPM Green's function to warm-start the Krylov iteration. Default nothing. It is used as given, without the basis expansion of the two starts below: from a low-rank guess (a multiple of the identity) the sweeps stall as they do from :identity.
  • start : The start of the sweeps when x0_mpo is not given. :random (default since v0.2.2): |I⟩⟩ + 0.1·(a random MPS of bond dimension 8 and norm 1, drawn from rng: a tenth of one row of G at every size), with its bonds enlarged by an 8-vector global Krylov expansion (ITensorMPS.expand). :identity: |I⟩⟩ with a 2-vector expansion, the start up to v0.2.1, which stalls on a short-ranged G (an open chain's end corrections, ω outside the band) and returns a G wrong by 1e-3–0.2. The sweeps keep the rank their start spans.
  • rng : Random number generator of the :random start. Default Random.Xoshiro(1), created anew at each call, so the result does not depend on the global RNG state.
  • solver : Local solver of the sweeps. :gmres (default): KrylovKit's GMRES, restarted every krylovdim products. :minres: MINRES, for Hermitian H only (an ArgumentError otherwise, from ‖H − H†‖/‖H‖ > 1e-6 in the Frobenius norm, which a non-Hermitian term on a single site passes beyond ~2^40 sites; the residual still shows a wrong G). Each local problem (z − H_eff)x = b is a complex shift of a Hermitian matrix, which MINRES solves by a three-term recurrence without restarts: the same G in fewer products, most at small η, where restarted GMRES slows down. MINRES uses tol, and maxiter · krylovdim as its product budget per local solve (the GMRES one); ishermitian does not apply.
  • ishermitian : GMRES only. Set true only when the shifted operator is Hermitian (requires purely imaginary η = 0, not physical for GF). Default false.
  • tol : Krylov solver convergence tolerance (absolute, on the local residual). Default 1e-10.
  • maxiter : Maximum Krylov iterations per site (GMRES restarts). Default 600.
  • krylovdim : Krylov subspace dimension. Default 30.
  • return_info : Return (; G, residual, residual_abs, residual_floor, maxlinkdim) instead of the MPO G: residual_abs = ‖G(z − H) − 1‖F, and residual = `residualabs/√D, the residual of the solve relative to ‖|I⟩⟩‖ = √D. Defaultfalse`.
  • residual_warn: Warn when the residual ‖G(z − H) − 1‖F exceeds this value: G is then not converged (cutoff, maxdim or nsweeps too coarse). This residual bounds that of every row, ‖Gr(z − H) − er‖, and on open chains with an impurity it was 1–8 times the relative error of the worst row of G: the default 0.1 flags rows that are off by a few % or more (the bulk rows returned for the ends of a long chain give 0.9), where the default settings leave up to 4e-2. The relative residual cannot do that: it is the root mean square over the D rows, 8e-4 for those wrong end rows at 2^20 sites. The residual comes from inner products whose terms cancel: it is an upper bound that includes the rounding floor of that evaluation (`residualfloor, a few 1e-7 relative, i.e. times √D for the absolute one), so a converged solve reads as its floor, not 0; beyond ~2^32 sites, where that floor nears the threshold, the residual is evaluated exactly instead. The check costs about one sweep or less, and is skipped with a message when its contraction would hold more than 2^27 numbers (the residuals are thenNaN).Infskips its computation unlessreturn_info=true. Default0.1`.
  • verbose : Print progress messages (with MINRES, also the number of local solves and products) and the residual. Default false.

Usage

G = get_green_krylov(H, ω; η=0.05, nsweeps=20, maxdim=200)
dos  = -imag(tr(G)) / π                              # total DoS
ldos = real(inner(psi_i, apply(G, psi_i)))           # LDoS at site i
gij  = inner(psi_i, apply(G, psi_j))                 # off-diagonal element

# Warm-start from a cheap KPM estimate (get_Green_retarded_from_Tn works in the
# rescaled window: ω and η are rescaled, and the result is divided by the scale)
TensorBinding.KPM_Tn(H, 15; maxdim=50)
G_kpm = (1 / H.scale) * TensorBinding.get_Green_retarded_from_Tn(H._tn_cache, 15,
            (ω - H.center) / H.scale; η=η / H.scale, maxdim=50)
G_ws  = get_green_krylov(H, ω; x0_mpo=G_kpm, nsweeps=6, maxdim=200)

# Small η with a Hermitian H: MINRES as the local solver
G_mr  = get_green_krylov(H, ω; η=1e-3, nsweeps=20, maxdim=200, solver=:minres)
source
TensorBinding.haydock_cf — Method
haydock_cf(H_mpo::MPO, seed::MPO, N_steps::Int; maxdim=200, cutoff=1e-8,
           verbose=false)
    -> (a, b, basis, norm0)

Haydock (Lanczos) recursion with Hmpo acting on MPO vectors from the left. Starting from seed, builds an orthogonal Krylov basis under Hmpo using the Frobenius (Hilbert-Schmidt) inner product (A, B) = Tr[A† B].

Three-term recurrence (Φ₀ = seed / β₀, β₀ = ||seed||_F):

Φₙ₊₁ = H·Φₙ − aₙ·Φₙ − bₙ·Φₙ₋₁    (b₁ = 0)

Returns:

  • a : diagonal coefficients a[1..N]
  • b : b[1] = norm0 = ||seed||_F; b[2..N] = off-diagonal βₙ
  • basis: normalized Krylov MPOs {Φ₀, …, Φₙ₋₁}
  • norm0: sqrt(inner(seed, seed))

The scalar projected GF ⟨seed|(z−H)⁻¹|seed⟩ is recovered via eval_haydock_cf(a, b, z). The full resolvent MPO (z−H)⁻¹|seed⟩ is recovered via haydock_resolve_mpo(a, b, basis, z).

H_mpo must be Hermitian (then H· is Hermitian for Tr[A† B] and every aₙ is real); the seed may be any MPO on the same sites, real or complex.

source
TensorBinding.haydock_resolve_mpo — Method
haydock_resolve_mpo(a, b, basis, z; maxdim=200, cutoff=1e-8) -> MPO

Reconstruct (z−H)⁻¹|seed⟩ as an MPO by solving the N×N Lanczos tridiagonal system and forming a linear combination of the Krylov basis MPOs:

(z·I − T) c = b[1]·e₁,   Π₀(z) = Σₙ c[n]·basis[n]

where T has diagonal a and off-diagonal b[2:], and b[1] = norm0.

source

Correction Vectors

The resolvent of one probe state, (ω + iη − H)⁻¹|b⟩, by a DMRG-like linear solve: site and exciton LDOS at a resolution set by η instead of a number of moments, and the energy and weight of an isolated level. When to use which route:

  • One site, one probe, a few frequencies, small η: correction vectors. They cost far less than the full Green's function and resolve isolated peaks and gaps that KPM needs thousands of moments for. Check converged (the residual).
  • Many frequencies, a continuum, or a spectrum over a whole window: KPM, whose one recursion serves every ω and η.
  • The whole G(ω) as an MPO: get_green_krylov, cheap when G has a low rank (clean and impurity lattices, ω outside the band).

The correction-vector LDOS is per unit physical energy (one state integrates to 1); with the default KPM kernel, get_ldos_online(…) · π/H.scale is in the same units (1/H.scale with kernel = :hodc, which is normalised to 1).

TensorBinding.get_correction_vector — Method
get_correction_vector(H, b::MPS, ω; eta=1e-2, x0=nothing, eta_path=(),
                      solver=:gmres, maxdim=400, cutoff=1e-12, nsweeps=12,
                      gtol=1e-6, rtol=0.02, rounds=3, seed_krylov=40,
                      seed_maxdim=64, tol=1e-10, krylovdim=30, maxiter=30)
    -> (; G, x, residual, residual_floor, converged, maxlinkdim, sweeps, rounds)

The correction vector x = (ω + iη − H)⁻¹|b⟩ of the probe |b⟩ and G = ⟨b|x⟩ = ⟨b|(ω + iη − H)⁻¹|b⟩, the resolvent projected on the probe, with η = eta. H is a TBHamiltonian or an MPO on the sites of b; the energies are physical (no KPM rescaling). The local density of the probe is −imag(G)/π, per unit physical energy for a normalised b.

For one probe a correction vector costs far less than the full Green's function (get_green_krylov), and it resolves what KPM needs many moments for: an isolated peak at small η, a gap in a band. Its bond dimension stays small where x is dominated by a bound state, and grows where ω lies in a continuum: there a KPM run that serves every ω is usually cheaper.

Algorithm. ITensorMPS.linsolve sweeps on (ω + iη − H)x = b, one at a time, until |ΔG| ≤ gtol·|G| (at least 2, at most nsweeps), from

  • x0 when given (a warm start, e.g. the x of a neighbouring ω);
  • otherwise the Krylov seed b + Σₖ Hᵏb/‖Hᵏb‖, k = 1…seed_krylov, compressed to seed_maxdim. From the probe alone, a product state, the two-site sweeps stall on two-particle (interleaved) registers and return a wrong x that looks converged.

Then the relative residual ‖(ω + iη − H)x − b‖/‖b‖. Above rtol, up to rounds residual expansions x ← x + 0.3‖x‖/‖r‖·r with 3 sweeps each, keeping the best x. converged = residual ≤ rtol: when false, G is not to be trusted (raise maxdim, or warm-start).

The residual comes from inner products whose terms cancel to about 1e-7·(|ω| + ‖H‖)·‖x‖/‖b‖, a rounding floor that grows as 1/η (and with a constant energy offset in H). residual is an upper bound that includes this floor (residual_floor); where the floor would leave the comparison with rtol open (η ≲ 1e-5 on a level, or an offset of 10³ at η = 1e-4) the residual is evaluated exactly instead, from the direct sum of its terms, as long as that sum fits in memory (a bond dimension of x up to about 100–300 for the usual Hamiltonians; beyond, a converged x reads as its floor and converged = false). The truncation sets a second floor, about √cutoff·‖x‖/‖b‖: at small η, rtol is reachable only with cutoff ≲ (rtol·η)². Where the contraction of the check would hold more than 2^27 numbers it is skipped with a message: residual = NaN, converged = false.

eta_path: broadenings solved first, in order, each warm-starting the next and the last one eta (continuation in η at fixed ω). At small η a cold start can fail where a path from a larger η converges, provided its first step converges.

Keywords

  • solver: local solver of the sweeps, :gmres (KrylovKit) or :minres (Hermitian H only, see get_green_krylov).
  • maxdim, cutoff: truncation of x. The default cutoff 1e-12 is tighter than elsewhere: the bound-state part of x grows as 1/η and the rest is small next to it.
  • tol, krylovdim, maxiter: of the local solver (GMRES restarts maxiter; MINRES takes maxiter·krylovdim products). maxiter is 30 here, 900 products per local solve, where get_green_krylov has 600: a local solve that stops short is taken up by the next sweep, and the residual shows what is left.

Returns x and G, the residual and its rounding floor, converged, the bond dimension of x, and the numbers of sweeps and expansion rounds.

b = TensorBinding.probe_state(H, 17)                # site 17
r = get_correction_vector(H, b, 0.3; eta=1e-3)
r.converged || @warn "not converged" r.residual
ρ = -imag(r.G) / π
source
TensorBinding.get_exciton_ldos_cv — Method
get_exciton_ldos_cv(H::TBHamiltonian, X::Int, ω_vals; eta=1e-2,
                    <get_correction_vector keywords>)
    -> (; ldos, G, residual, converged, maxlinkdims)
get_exciton_ldos_cv(H::TBHamiltonian, X::Int, ω::Real; …)
    -> (; ldos, G, residual, converged, maxlinkdim)

The exciton LDOS at the contact probe |X, X⟩ (electron and hole on position X, 1-indexed in 1:H.N; mpsexciton, the probe of get_exciton_ldos) from correction vectors, in the units and with the scan of get_ldos_cv: per unit physical energy, ldos = −Im G/π; with its default kernel, get_exciton_ldos(…) · π/H.scale is in the same units. A single frequency ω::Real returns scalars.

The bound-exciton peaks of a contact probe are where correction vectors pay most: x stays at a small bond dimension down to small η, where KPM-MPS needs moments beyond its truncation floor. In the two-particle continuum x spreads and its bond dimension grows; check converged.

source
TensorBinding.get_ldos_cv — Method
get_ldos_cv(H::TBHamiltonian, X::Int, ω_vals; eta=1e-2,
            <projection keywords>, <get_correction_vector keywords>)
    -> (; ldos, G, residual, converged, maxlinkdims)
get_ldos_cv(H::TBHamiltonian, X::Int, ω::Real; …)
    -> (; ldos, G, residual, converged, maxlinkdim)

The local density of states at position X (1-indexed in 1:H.N) from correction vectors: ldos[i] = −Im⟨X|(ω_i + iη − H)⁻¹|X⟩/π, a Lorentzian of width eta around each level, per unit physical energy (one state integrates to 1). The KPM functions return the density per unit rescaled energy times 1/π (Solvers page, Conventions): with their default kernel, get_ldos_online(…) · π/H.scale is in the units of ldos here (with kernel = :hodc, which is normalised to 1, the factor is 1/H.scale).

The frequencies are solved in the given order, each correction vector warm-starting the next (only the first is seeded), so a fine grid is cheaper per point than a coarse one. Each point keeps its residual; a warning counts the points above rtol. The result holds one entry per frequency (maxlinkdims: the bond dimension of each correction vector); a single frequency ω::Real returns scalars.

On an exciton Hamiltonian (two-particle register) the probe is the contact state |X, X⟩, as in get_exciton_ldos_cv. Auxiliary degrees of freedom are summed or selected with the keywords of get_ldos_online (spin_proj, proj_s, nambu_proj, proj_nambu, layer_proj, proj_layer, sublat_proj, proj_sl), one scan per sector. Every other keyword goes to get_correction_vector.

source
TensorBinding.refine_bound_state — Method
refine_bound_state(H, b::MPS, ω0; eta_steps=(0.05, 0.01, 1e-3, 1e-4), x0=nothing,
                   <get_correction_vector keywords>)
    -> (; energy, weight, x, residual, energy_step, converged, history)

The energy E and the probe weight w = |⟨ψ|b⟩|²/⟨b|b⟩ of an isolated eigenstate ψ near ω0, by Rayleigh-quotient iteration on the correction vector: for each η of eta_steps, x = (ω + iη − H)⁻¹|b⟩ (warm-started), then ω ← ⟨x|H|x⟩/⟨x|x⟩ and w = |⟨b|x⟩|²/(⟨x|x⟩⟨b|b⟩). As η → 0 at ω = E, x is dominated by ψ, so the quotients converge to E and w: the content of an isolated peak, which a spectrum at finite η only broadens. The other levels enter at order η²/Δ (Δ the distance to the next level the probe sees), so the last η sets the accuracy: with the default 1e-4 and Δ of order one, E to ~1e-8.

Start ω0 within the peak's width at the first η (a coarse scan with get_ldos_cv at η ≈ 0.1–0.2 finds it). history holds (; eta, omega, energy, weight, residual) per step, and energy_step is the last move of the energy, |E − ω| of the last step.

converged is true when the last correction vector is converged (its residual) and the last two steps agree that there is a level:

  • the weight is stationary. On a level w does not depend on η; in a continuum x spreads over the states within η and w is proportional to η. The change of w over the last step must be within a tenth of the change a continuum would show, |1 − w_last/w_before| ≤ 0.1·|1 − η_last/η_before|;
  • the energy has stopped moving: energy_step is at most the η of the step before the last. (In a continuum the step is about η_last whatever ω, so this alone shows nothing; it catches a quotient crawling between the levels of a small system.)

So eta_steps needs two different broadenings at its end: a single step, or two equal ones, is never reported as converged. A level that is only resolved at the last η (its weight below about η_before times the background of the other states) is reported as not converged. Two levels closer than the last η are not told apart, and nothing shows it: the history looks like that of one level, energy is their weighted mean and weight the sum of their weights. Lower the last η below the splitting you need to resolve.

The broadenings are those of eta_steps (eta is not a keyword here); every other keyword goes to get_correction_vector.

source

DMRG

TensorBinding._ensure_scale! — Method
_ensure_scale!(H::TBHamiltonian; dmrg_nsweeps=5, dmrg_maxdim=[10, 20, 40],
               dmrg_linkdim=4)

If H.scale == 0 (sentinel meaning "not yet determined"), run _estimate_spectral_bounds and store the results in H.scale and H.center. No-op if H.scale > 0 (analytic estimate already set at construction or a previous KPM call already ran DMRG).

source
TensorBinding._estimate_spectral_bounds — Method
_estimate_spectral_bounds(H_mpo::MPO, sites; dmrg_nsweeps=5,
                          dmrg_maxdim=[10, 20, 40], dmrg_linkdim=4)
    -> (scale, center)

Run two short DMRG sweeps (minimising H and −H) to find the spectral edges Emin and Emax, then return: center = (Emax + Emin) / 2 scale = (Emax − Emin) / 2 × 1.1 (10 % buffer)

source
TensorBinding.build_K — Method
build_K(H_mpo::MPO, sites, ω, η; maxdim_K=200, cutoff_K=min(1e-8, 1e-4η⁴, 0.1r²/D²)) -> MPO

Build the resolvent-squared MPO

K(ω,η) = (H − ω I)² + η² I

The ground state energy of K satisfies E_K ≥ η², with E_K → η² when ω coincides with an eigenvalue of H. The ground state concentrates on the eigenstate of H nearest to ω.

maxdim_K and cutoff_K control truncation of the intermediate MPO product; larger maxdim_K gives a more accurate K at the cost of DMRG wall time.

cutoff_K is relative (to the squared Frobenius norm of each sum and product). The default is the smallest of 1e-8, the fixed value of v0.2.0, and two bounds that keep the two smallest parts of K:

  • 1e-4 η⁴ (η ≠ 0) keeps η² I, which the truncation can drop from cutoff_K ≈ η⁴ on (a 5-qubit chain at η = 1e-2 kept almost none of it with 1e-8: ‖ΔK‖ = 9.7e-5 ≈ η²). It assumes eigenvalues of H − ω of order one: for a wider spectrum pass a smaller cutoff_K.
  • 0.1 r²/D², D the dimension of the site space (2^L for qubits) and r = min(1, ‖H‖²/‖H − ω‖²) (Frobenius norms), keeps the terms that live on a few sites, such as the missing bond at the end of an open chain. The norm of K grows with D and, through ‖H − ω‖, with ω, and the product apply(H − ω, H − ω) drops such a term once cutoff_K exceeds about 0.5 r²/D² (uniform chain): with 1e-8, ⟨0|K|0⟩ came out as 2.01 instead of 1.01 from L = 13 on at ω = 0.05, and from L = 12 at ω = 1.7t, K wrong by t² at both ends.

The default is therefore 1e-8, as in v0.2.0, as long as D ≤ 3162 r (L ≤ 11 near the band centre, η ≥ 0.1 or η = 0). On an open chain it keeps K within 5e-7 for |ω| ≤ 5t at L = 14–26 and within 2e-7 at ω = 0.05 up to L = 30, provided H_mpo itself is exact: an MPO truncated with a relative cutoff of its own can already lack such terms. Terms that are weak next to the rest of H are not protected: with an on-site potential of a few t part of K is lost again (a 14-qubit chain with V cos(2πbn): 0.17 at V = 2t), and cutoff_K = 1e-2/D² (V ≲ 3t) or 1e-3/D² (V ≲ 5t) is needed there. An explicit cutoff_K is used as given; it warns once when it is not below η⁴ or when it is above 0.3 r²/D².

source
TensorBinding.dmrg_gs — Method
dmrg_gs(H_mpo::MPO, sites; linkdim_init=10, nsweeps=10,
        maxdim=[10, 20, 50, 100, 200], cutoff=1e-8,
        noise=[1e-6, 1e-7, 1e-8, 0.0], kwargs...) -> (E, ψ)

Find the ground state and energy of H_mpo using DMRG.

Keyword arguments

  • linkdim_init : bond dimension of the random initial MPS. Default 10.
  • nsweeps : total number of DMRG sweeps. Default 10.
  • maxdim : max bond dimension per sweep (scalar or vector). Default [10, 20, 50, 100, 200].
  • cutoff : SVD truncation cutoff. Default 1e-8.
  • noise : perturbative noise per sweep (scalar or vector; aids convergence). Default [1e-6, 1e-7, 1e-8, 0.0].
  • kwargs... : passed on to ITensorMPS.dmrg (e.g. outputlevel=0).

Returns (E, ψ).

source
TensorBinding.dmrg_spectral — Method
dmrg_spectral(H_mpo::MPO, sites, ω, η; ψ0=nothing, maxdim_K=200,
              cutoff_K=min(1e-8, 1e-4η⁴, 0.1r²/D²), linkdim_init=10, nsweeps=10,
              maxdim=[10, 20, 50, 100, 200],
              cutoff=1e-8, noise=[1e-6, 1e-7, 1e-8, 0.0], kwargs...) -> (E_K, ψ)

Find the ground state of K(ω,η) = (H−ωI)² + η²I using DMRG.

The ground state |ψ(ω)⟩ concentrates on the eigenstate of H closest to ω. Use local_weight(ψ, i, L, sites) to read off the LDoS proxy |⟨i|ψ(ω)⟩|².

Keyword arguments

  • ψ0 : warm-start MPS (random if nothing, the default)
  • maxdim_K, cutoff_K : truncation for building K (see build_K). Defaults 200 and min(1e-8, 1e-4η⁴, 0.1r²/D²), D the dimension of the site space and r = min(1, ‖H‖²/‖H − ω‖²) (1e-8 up to v0.2.0, which drops most of the η² term at η = 1e-2 and the end bonds of an open chain from L = 13).
  • linkdim_init : bond dimension of the random initial MPS (if ψ0=nothing). Default 10.
  • nsweeps, maxdim, cutoff, noise : DMRG sweep parameters, with the same defaults as dmrg_gs.
  • kwargs... : passed on to ITensorMPS.dmrg (e.g. outputlevel=0).

Returns (E_K, ψ) where E_K ≈ η² at spectral peaks.

source
TensorBinding.local_weight — Method
local_weight(ψ, i, L, sites) -> Float64

Return |⟨i|ψ⟩|² where |i⟩ is the position-basis state for 0-based integer i (big-endian quantics encoding over L qubit sites).

When ψ = ψ(ω) is the DMRG ground state of K(ω,η), this gives the LDoS proxy at site i and energy ω:

ρ(ω, i) ≈ |⟨i|ψ(ω)⟩|²

which peaks at eigenvalues of H that have support on site i.

For a BdG or spin-extended system pass the full ext_sites and set L = length(ext_sites).

source

Time Evolution

TensorBinding.apply_mpo_to_mps — Method
apply_mpo_to_mps(U_mpo, psi; cutoff=1e-12, maxdim=500, normalize=true) -> MPS

Apply a propagator MPO U_mpo to the MPS psi with optional truncation and normalisation. Used to advance a state by one time step when U_mpo was prebuilt by build_tdvp_propagator_mpo.

source
TensorBinding.basis_amplitude — Method
basis_amplitude(psi, n, L, sites) -> ComplexF64

Return the amplitude ⟨n|ψ⟩ where |n⟩ is the n-th computational basis state (0-indexed big-endian quantics encoding over L qubit sites).

source
TensorBinding.bond_current_x — Method
bond_current_x(ρ, j, tx, L, sites) -> ComplexF64

Compute the x-direction bond current

Jⱼˣ = i tₓ (ρⱼ,ⱼ₊₁ − ρⱼ₊₁,ⱼ)

for a single bond at 0-indexed site j in density-matrix MPO ρ. tx is the hopping amplitude.

source
TensorBinding.bond_current_x_trajectory — Method
bond_current_x_trajectory(states, j, tx, L, sites; dt=1.0) -> Vector{ComplexF64}

Compute the x-direction bond current Jⱼˣ(t) along a trajectory of density-matrix MPOs.

tx may be a scalar or a callable t -> hopping amplitude for a time-dependent drive. States are assumed spaced by dt: t_n = (n-1)*dt.

source
TensorBinding.build_tdvp_propagator_mpo — Method
build_tdvp_propagator_mpo(H, dt, L, sites; maxdim=50, cutoff=1e-8,
                          reverse_step=true, outputlevel=0, nsite=2,
                          cross_tol=1e-8, initial_positions=[],
                          use_diagonal_pivots=false, expand_basis=true,
                          cache_columns=true, interpolation_type=ComplexF64)
    -> MPO

Build an MPO approximation of the short-time propagator U(dt) = e^{-iH dt} by sampling matrix elements ⟨i|U(dt)|j⟩ via TDVP and compressing with TCI.

H must already be multiplied by -im for Schrödinger evolution. TDVP runs once per column j that TCI samples: U|j⟩ is kept, and every other element of that column is an overlap with it (cache_columns). The diagonal is dominant for small dt; TCI starts from (1, 1) and QuanticsTCI moves its random initial pivots to large elements, so it lands on the diagonal without seeding.

Each sample evolves a basis state |j⟩, an MPS of bond dimension 1. TDVP cannot leave the tangent space of that state, so on its own it drops every hop that flips three or more qubits (the carry chains 0111 → 1000 of the quantics encoding, such as the middle bond of a chain). By default |j⟩ first gets the Krylov basis of H|j⟩, H²|j⟩ (ITensorMPS.expand(...; alg="global_krylov")). The samples then match the dense exp(-iH dt) to TDVP accuracy (chain_1d, dt = 0.05: Frobenius error 7e-5 at L = 3 and 1.3e-4 at L = 6, limited by cutoff; 0.07 and 0.27 without the expansion). The expansion makes each TDVP run about 4x more expensive (L = 8-10: 15-16 ms against 3.5-5 ms).

Warning

From about L = 5, the QTCI fit in hopping2MPO can miss those isolated carry-chain elements even though they are sampled correctly. In 1D-chain tests it missed them (max error ≈ dt) for most random seeds at L = 6 and for every seed at L = 8. It does the same on a plain hopping matrix. For a chain, seeding initial_positions with the elements near the middle boundary, [(N÷2+a, N÷2+b) for a in -3:4 for b in -3:4 if abs(a-b) <= 4], fixed L = 6. From L = 8, the final truncate!(cutoff=1e-8) in hopping2MPO also drops the second-order elements (error ≈ dt²/2), because that cutoff is relative to ‖U‖² = N. Check the result against a dense exp(-iH dt) at small L.

Keyword arguments

  • maxdim, cutoff : TDVP truncation parameters. Defaults 50, 1e-8.
  • reverse_step : Evolve the bond tensor backwards between two-site updates, as the TDVP projector splitting requires. Default true (the ITensorMPS default). false counts terms of H twice, so sampled elements are off at O(dt) (some hops come out 1.5x too large); it warns.
  • outputlevel, nsite : passed to tdvp. Defaults 0, 2.
  • cross_tol : TCI interpolation tolerance. Default 1e-8.
  • initial_positions : TCI pivots (i, j) (1-indexed) passed to hopping2MPO. Default [] (none).
  • use_diagonal_pivots : Seed TCI with all N diagonal positions (i, i) when initial_positions is empty. Default false: seeding makes TCI sample every column, so it costs N TDVP runs (L = 8: 256 against 182-238 unseeded; L = 10: 1024 against 334), and it does not make TCI find the off-diagonal structure more reliably.
  • expand_basis : Expand each basis state with its Krylov vectors before TDVP (see above; needs H::MPO). Default true.
  • cache_columns : Keep each evolved column U|j⟩ (one MPS of a few kB per sampled j), so TDVP runs once per column instead of once per sampled element (L = 8: about 200 runs against 1500-2300). The samples, and so the MPO, are the same either way; false saves the memory. Default true.
  • interpolation_type : Element type for TCI sampling. Default ComplexF64.

To reproduce the samples and seeding used before these defaults changed, pass reverse_step=false, expand_basis=false, use_diagonal_pivots=true.

A TBHamiltonian overload applies -im internally: build_tdvp_propagator_mpo(H::TBHamiltonian, dt; ...).

source
TensorBinding.central_x_bond — Method
central_x_bond(L; Nx=nothing) -> Int

Return the 0-indexed site j of the central x-direction bond (j → j+1).

  • 1D (Nx=nothing): central bond at j = 2^L ÷ 2 − 1.
  • 2D row-major (Nx = 2^Lx): bond at the centre column of the centre row, j = (Ny÷2)*Nx + Nx÷2 − 1 where Ny = 2^L ÷ Nx.
source
TensorBinding.check_tdvp_vs_U_mpo — Method
check_tdvp_vs_U_mpo(H, U_mpo, dt, L, sites;
                    test_states=[0, 1, 3, 7, 13, 29, 57, 2^L - 1],
                    tdvp_maxdim=200, tdvp_cutoff=1e-10, tdvp_normalize=true,
                    tdvp_reverse_step=true, tdvp_outputlevel=0, tdvp_nsite=2,
                    apply_maxdim=500, apply_cutoff=1e-12,
                    print_sample_amplitudes=true, sample_amplitudes=[0, 1, 2, 3])
    -> (max_overlap_error, max_phase_error)
check_tdvp_vs_U_mpo(H::TBHamiltonian, U_mpo::MPO, dt; kwargs...)

Validate that U_mpo agrees with direct TDVP on a set of computational basis states. Prints per-state overlap errors and phase-aligned distances, then returns the maxima.

Keyword arguments

  • test_states : 0-indexed basis states |n⟩ to evolve both ways.
  • tdvp_* : maxdim, cutoff, normalize, reverse_step, outputlevel, nsite of the reference tdvp_evolve step (tdvp_normalize also normalises the U_mpo result).
  • apply_maxdim, apply_cutoff : truncation of apply_mpo_to_mps.
  • print_sample_amplitudes : also print ⟨m|ψ⟩ of both results for each m in sample_amplitudes.

The reference is one TDVP step from the bare basis state, so it has the errors described in build_tdvp_propagator_mpo: it drops the hops that flip three or more qubits, and with tdvp_reverse_step=false (the default up to v0.2.0) it also counts terms of H twice. An error of order dt therefore does not mean U_mpo is wrong (chain1d, L = 4, dt = 0.05, `tdvpreversestep=false: a phase error of 0.056 for aUmpowithin 8e-5 ofexp(-iH dt)). At small L, compare with a denseexp(-iH dt)` instead.

The TBHamiltonian method applies -im internally and takes L, sites from H.

source
TensorBinding.compute_basis_overlaps — Method
compute_basis_overlaps(states, L, sites)
    -> NamedTuple(overlaps, abs_overlaps, probabilities, norms)

For each MPS in states, compute overlaps with all 2^L computational basis states.

Returns a named tuple with fields:

  • overlaps : (nsteps+1) × 2^L matrix of ComplexF64 amplitudes ⟨j|ψ(t)⟩
  • abs_overlaps : element-wise absolute values
  • probabilities : |⟨j|ψ(t)⟩|²
  • norms : ⟨ψ(t)|ψ(t)⟩ at each step
source
TensorBinding.dm_expect — Method
dm_expect(O, ρ) -> Float64

Compute Tr(O ρ) for a Hermitian operator MPO O and density-matrix MPO ρ, using inner(O, ρ) = Tr(O† ρ) = Tr(O ρ).

source
TensorBinding.evolve_rk4_dm_nh — Method
evolve_rk4_dm_nh(Hoft, ρ0::MPO, nsteps::Int, dt::Float64; maxdim=200,
                 cutoff=1e-10, truncate_intermediates=true, verbose=false)
    -> Vector{MPO}

RK4 evolution of a density-matrix MPO under the non-Hermitian von Neumann equation

dρ/dt = -i(H(t) ρ − ρ H(t)†)

Hoft is a callable t::Float64 -> MPO. For H = H₀ - iΓ the anti-Hermitian part causes Tr(ρ) to decay whenever Γ > 0, modelling lossy open systems.

Returns [ρ(0), ρ(dt), ..., ρ(nsteps*dt)] as a Vector{MPO}. See evolve_rk4_dm_timedep for keyword-argument descriptions.

source
TensorBinding.evolve_rk4_dm_timedep — Method
evolve_rk4_dm_timedep(Hoft, ρ0::MPO, nsteps::Int, dt::Float64; maxdim=200,
                      cutoff=1e-10, truncate_intermediates=true, verbose=false)
    -> Vector{MPO}

Evolve a density-matrix MPO ρ0 under dρ/dt = -i[H(t), ρ] for nsteps steps of size dt using RK4.

Hoft is a callable t::Float64 -> MPO returning the physical Hamiltonian at time t. Returns the full trajectory [ρ(0), ρ(dt), ..., ρ(nsteps*dt)] as a Vector{MPO}.

Keyword arguments

  • maxdim, cutoff : Truncation for intermediate MPO sums and products. Defaults 200, 1e-10.
  • truncate_intermediates : Truncate after each RK4 sub-step to control bond growth. Default true.
  • verbose : Print step/bond-dim progress. Default false.
source
TensorBinding.evolve_with_propagator — Method
evolve_with_propagator(U_mpo, psi0, nsteps; normalize_each_step=true,
                       cutoff=1e-8, maxdim=10_000) -> Vector{MPS}

Apply the fixed MPO propagator U_mpo repeatedly for nsteps steps, returning the full trajectory [psi(0), psi(1*dt), ..., psi(nsteps*dt)].

Useful when the same short-time propagator is reused at every step (time-independent H). For efficiency the MPO is built once via build_tdvp_propagator_mpo; this function then applies it nsteps times.

source
TensorBinding.evolve_with_tdvp — Method
evolve_with_tdvp(H, psi0, nsteps, dt; normalize_each_step=true, maxdim=200,
                 cutoff=1e-10, reverse_step=true, outputlevel=0, nsite=2)
    -> Vector{MPS}

Run a TDVP loop for nsteps steps of size dt under a fixed Hamiltonian H, returning [psi(0), psi(dt), ..., psi(nsteps*dt)].

H must carry the -im prefactor for Schrödinger evolution. reverse_step is as in tdvp_evolve: true by default (it was false up to v0.2.0, which is wrong at O(dt) per step and now warns).

A TBHamiltonian overload applies -im internally: evolve_with_tdvp(H::TBHamiltonian, psi0, nsteps, dt; ...).

source
TensorBinding.evolve_with_tdvp_timedep — Method
evolve_with_tdvp_timedep(Hoft, psi0, nsteps, dt; normalize_each_step=true,
                         maxdim=200, cutoff=1e-10, reverse_step=true,
                         outputlevel=0, nsite=2, krylovdim=20, tol=1e-10)
    -> Vector{MPS}

TDVP loop for a time-dependent Hamiltonian H(t).

Hoft is a callable t::Float64 -> MPO. On each interval [t, t+dt] the Hamiltonian is frozen at the midpoint t + dt/2 (midpoint rule). Hoft must return the physical Hamiltonian; the -im prefactor is applied internally. krylovdim and tol go to the TDVP exponentiation step (updater_kwargs); the other keywords are as in evolve_with_tdvp (reverse_step=true by default; it was false up to v0.2.0).

Returns [psi(0), psi(dt), ..., psi(nsteps*dt)].

source
TensorBinding.observables_trajectory — Method
observables_trajectory(ops, states) -> Dict

Measure a named collection of Hermitian operator MPOs along a density-matrix trajectory.

ops is a NamedTuple or Dict mapping labels to MPOs, e.g. (J=J_mpo, N=N_mpo). Returns a Dict mapping each label to a Vector{Float64} of expectation values.

source
TensorBinding.phase_aligned_distance — Method
phase_aligned_distance(psi_a, psi_b) -> Float64

Phase-insensitive distance between two (unnormalised) MPS states:

d = min_{φ} ‖â − e^{iφ} b̂‖ = √(2 − 2|⟨â|b̂⟩|)

where â = psi_a/‖psi_a‖. Returns Inf when either state has zero norm. Useful for comparing TDVP and MPO propagator trajectories independent of any global phase accumulated during time evolution.

source
TensorBinding.purity — Method
purity(ρ) -> Float64

Return the purity Tr(ρ²) = inner(ρ, ρ). Equals 1 for a pure state and decreases as the system becomes mixed.

source
TensorBinding.rk4_step_dm_nh — Method
rk4_step_dm_nh(Hoft, ρ::MPO, t::Float64, dt::Float64; maxdim=200, cutoff=1e-10,
               truncate_intermediates=true) -> MPO

Single RK4 step for the non-Hermitian von Neumann equation

dρ/dt = -i(H(t) ρ − ρ H(t)†)

Hoft is a callable t -> MPO; pass (_ -> H.mpo) for a static NH Hamiltonian.

source
TensorBinding.rk4_step_dm_timedep — Method
rk4_step_dm_timedep(Hoft, ρ::MPO, t::Float64, dt::Float64; maxdim=200,
                    cutoff=1e-10, truncate_intermediates=true) -> MPO

Single RK4 step for dρ/dt = -i[H(t), ρ] with a time-dependent Hamiltonian MPO. H is evaluated at t, t+dt/2, and t+dt per the classical RK4 tableau.

source
TensorBinding.tdvp_evolve — Method
tdvp_evolve(H, psi, dt; maxdim=200, cutoff=1e-10, normalize=true,
            reverse_step=true, outputlevel=0, nsite=2) -> MPS

Apply one TDVP step to psi under Hamiltonian H for time dt.

H must already carry the -im prefactor for Schrödinger evolution. When normalize=true the output is normalised (tdvp normalises the state at the end of each half-sweep).

reverse_step evolves the bond tensor backwards between site updates, as the TDVP projector splitting requires (the ITensorMPS default). false counts terms of H twice, so the step is wrong at O(dt); it warns. The default was false up to v0.2.0 (see the CHANGELOG); pass reverse_step=false to reproduce those results.

A TBHamiltonian overload applies -im internally: tdvp_evolve(H::TBHamiltonian, psi, dt; ...).

source
TensorBinding.timedep_observable_trajectory — Method
timedep_observable_trajectory(Oft, states, dt) -> Vector{Float64}

Measure a time-dependent Hermitian operator O(t) along a density-matrix trajectory.

Oft is a callable t -> MPO. State n is assigned time t_n = (n-1)*dt. Covers e.g. ⟨H(t)⟩ = Tr(H(t) ρ(t)) under a driven Hamiltonian.

source