Skip to content

Commit 65c24b3

Browse files
authored
Gauge improvements (#101)
1 parent f2ef42b commit 65c24b3

File tree

4 files changed

+47
-15
lines changed

4 files changed

+47
-15
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ITensorInfiniteMPS"
22
uuid = "1dc1fb26-a137-4954-ae60-1bd4106e95ad"
33
authors = ["Matthew Fishman <[email protected]> and contributors"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[deps]
77
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

examples/vumps/vumps_hubbard_extended.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ subspace_expansion_kwargs = (cutoff=cutoff, maxdim=maxdim)
5656

5757
println("\nRun VUMPS on initial product state, unit cell size $N")
5858
ψ = vumps_subspace_expansion(H, ψ; outer_iters, subspace_expansion_kwargs, vumps_kwargs)
59+
ψ = orthogonalize.AL, :; tol=1e-14) # ensure translation invariance
5960

6061
# Check translational invariance
6162
println("\nCheck translational invariance of optimized infinite MPS")

src/infinitecanonicalmps.jl

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,21 +249,37 @@ function InfMPS(s::CelledVector, f::Function)
249249
return ψ = InfiniteCanonicalMPS(ψL, ψC, ψR)
250250
end
251251

252-
function finite_mps::InfiniteCanonicalMPS, range::AbstractRange)
252+
function finite_mps(
253+
ψ::InfiniteCanonicalMPS,
254+
range::AbstractRange;
255+
ortho_lims::AbstractUnitRange=last(range):last(range),
256+
)
253257
@assert isone(step(range))
258+
@assert first(ortho_lims) == last(ortho_lims) # TODO: variable ortho_lims
259+
@assert first(ortho_lims) range
260+
254261
N = length(range)
255-
ψ_finite = ψ.AL[range]
256-
ψ_finite[N] *= ψ.C[last(range)]
262+
ψ_finite = Vector{ITensor}(undef, N)
263+
for i in first(range):first(ortho_lims)
264+
ψ_finite[i] = ψ.AL[i]
265+
end
266+
ψ_finite[first(ortho_lims)] *= ψ.C[first(ortho_lims)]
267+
268+
for i in (last(ortho_lims) + 1):last(range)
269+
ψ_finite[i] = ψ.AR[i]
270+
end
271+
257272
l0 = linkind.AL, first(range) - 1 => first(range))
258-
l̃0 = sim(l0)
259273
lN = linkind.AR, last(range) => last(range) + 1)
274+
l̃0 = sim(l0)
260275
l̃N = sim(lN)
261276
δl0 = δ(dag(l̃0), l0)
262277
δlN = δ(dag(l̃N), lN)
263278
ψ_finite[1] *= δl0
264279
ψ_finite[N] *= dag(δlN)
265-
ψ_finite = MPS([dag(δl0); [ψ_finiteᵢ for ψ_finiteᵢ in ψ_finite]; δlN])
266-
set_ortho_lims!(ψ_finite, (N + 1):(N + 1))
280+
ψ_finite = MPS(
281+
[dag(δl0); ψ_finite; δlN]; ortho_lims=(first(ortho_lims) + 1):(last(ortho_lims) + 1)
282+
)
267283
return ψ_finite
268284
end
269285
function ITensorMPS.expect::InfiniteCanonicalMPS, o::String, n::Int)

src/orthogonalize.jl

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1+
using KrylovKit: schursolve, Arnoldi
12
# TODO: call as `orthogonalize(ψ, -∞)`
23
# TODO: could use commontags(ψ) as a default for left_tags
34
function right_orthogonalize(
4-
ψ::InfiniteMPS; left_tags=ts"Left", right_tags=ts"Right", tol::Real=1e-12
5+
ψ::InfiniteMPS;
6+
left_tags=ts"Left",
7+
right_tags=ts"Right",
8+
tol::Real=1e-12,
9+
eager=true,
10+
ishermitian_kwargs=(; rtol=tol * 100),
511
)
612
# A transfer matrix made from the 1st unit cell of the infinite MPS
713
T = TransferMatrix(ψ)
@@ -12,9 +18,20 @@ function right_orthogonalize(
1218
# Start by getting the right eivenvector/eigenvalue of T
1319
# TODO: make a function `right_environments(::InfiniteMPS)` that computes
1420
# all of the right environments using `eigsolve` and shifting unit cells
15-
λ⃗₁ᴿᴺ, v⃗₁ᴿᴺ, eigsolve_info = eigsolve(T, v₁ᴿᴺ, 1, :LM; tol=tol)
21+
22+
# original eigsolve function, switch to schur which enforces real
23+
#λ⃗₁ᴿᴺ, v⃗₁ᴿᴺ, eigsolve_info = eigsolve(T, v₁ᴿᴺ, 1, :LM; tol, eager)
24+
TT, v⃗₁ᴿᴺ, λ⃗₁ᴿᴺ, info = schursolve(T, v₁ᴿᴺ, 1, :LM, Arnoldi(; tol, eager))
1625
λ₁ᴿᴺ, v₁ᴿᴺ = λ⃗₁ᴿᴺ[1], v⃗₁ᴿᴺ[1]
1726

27+
if info.converged == 0
28+
@warn "orthogonalize not converged after $(info.numiter) iterations"
29+
end
30+
31+
if size(TT, 2) > 1 && TT[2, 1] != 0
32+
@warn("Non-unique largest eigenvector of transfer matrix found")
33+
end
34+
1835
if imag(λ₁ᴿᴺ) / norm(λ₁ᴿᴺ) > 1e-15
1936
@show λ₁ᴿᴺ
2037
error(
@@ -24,11 +41,9 @@ function right_orthogonalize(
2441

2542
# Fix the phase of the diagonal to make Hermitian
2643
v₁ᴿᴺ .*= conj(sign(v₁ᴿᴺ[1, 1]))
27-
if !ishermitian(v₁ᴿᴺ; rtol=tol)
28-
@show λ₁ᴿᴺ
29-
@show v₁ᴿᴺ
44+
if !ishermitian(v₁ᴿᴺ; ishermitian_kwargs...)
3045
@show norm(v₁ᴿᴺ - swapinds(dag(v₁ᴿᴺ), reverse(Pair(inds(v₁ᴿᴺ)...))))
31-
error("v₁ᴿᴺ not hermitian")
46+
@warn("v₁ᴿᴺ is not hermitian, passed kwargs: $ishermitian_kwargs")
3247
end
3348
if norm(imag(v₁ᴿᴺ)) / norm(v₁ᴿᴺ) > 1e-13
3449
println(
@@ -105,8 +120,8 @@ end
105120
function mixed_canonical(
106121
ψ::InfiniteMPS; left_tags=ts"Left", right_tags=ts"Right", tol::Real=1e-12
107122
)
108-
_, ψᴿ, _ = right_orthogonalize(ψ; left_tags=ts"", right_tags=ts"Right")
109-
ψᴸ, C, λ = left_orthogonalize(ψᴿ; left_tags=ts"Left", right_tags=ts"Right")
123+
_, ψᴿ, _ = right_orthogonalize(ψ; left_tags=ts"", right_tags)
124+
ψᴸ, C, λ = left_orthogonalize(ψᴿ; left_tags, right_tags)
110125
if λ one(λ)
111126
error("λ should be approximately 1 after orthogonalization, instead it is ")
112127
end

0 commit comments

Comments
 (0)