Skip to content

Commit

Permalink
update deprecated TensorKit syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorVanthilt committed Jan 12, 2025
1 parent fb2b128 commit 72c81e2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/schemes/btrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function pseudopow(t::AbstractTensorMap, a::Real; tol=eps(scalartype(t))^(3 / 4)
end

function step!(scheme::BTRG, trunc::TensorKit.TruncationScheme)
U, S, V, ε = tsvd(scheme.T, (1, 2), (3, 4); trunc=trunc)
U, S, V, ε = tsvd(scheme.T, ((1, 2), (3, 4)); trunc=trunc)

S_a = pseudopow(S, (1 - scheme.k) / 2)
S_b = pseudopow(S, scheme.k)
Expand All @@ -37,11 +37,11 @@ function step!(scheme::BTRG, trunc::TensorKit.TruncationScheme)
S1′[-1; -2] := S_b[-1; -2]
end

U, S, V, ε = tsvd(scheme.T, (1, 4), (2, 3); trunc=trunc)
U, S, V, ε = tsvd(scheme.T, ((1, 4), (2, 3)); trunc=trunc)

# permute to correct the spaces
U = permute(U, (1,), (2, 3))
V = permute(V, (1, 2), (3,))
U = permute(U, ((1,), (2, 3)))
V = permute(V, ((1, 2), (3,)))

S_a = pseudopow(S, (1 - scheme.k) / 2)
S_b = pseudopow(S, scheme.k)
Expand Down
6 changes: 3 additions & 3 deletions src/schemes/hotrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ function step!(scheme::HOTRG, trunc::TensorKit.TruncationScheme)
@tensor M[-1 -2 -3; -4 -5 -6] := scheme.T[-1 1; -5 -6] * scheme.T[-2 -3; -4 1]

# Get unitaries
U, _, _, εₗ = tsvd(M, (1, 2), (3, 4, 5, 6); trunc=trunc)
_, _, UR, εᵣ = tsvd(M, (1, 2, 3, 6), (4, 5); trunc=trunc)
U, _, _, εₗ = tsvd(M, ((1, 2), (3, 4, 5, 6)); trunc=trunc)
_, _, UR, εᵣ = tsvd(M, ((1, 2, 3, 6), (4, 5)); trunc=trunc)

if εₗ > εᵣ
U = permute(adjoint(UR), (2, 1), (3,))
U = permute(adjoint(UR), ((2, 1), (3,)))
end

# adjoint(U) on the left, U on the right
Expand Down
8 changes: 4 additions & 4 deletions src/schemes/trg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ mutable struct TRG <: TRGScheme
end

function step!(scheme::TRG, trunc::TensorKit.TruncationScheme)
U, S, V, _ = tsvd(scheme.T, (1, 2), (3, 4); trunc=trunc)
U, S, V, _ = tsvd(scheme.T, ((1, 2), (3, 4)); trunc=trunc)

@plansor begin
A[-1 -2; -3] := U[-1 -2; 1] * sqrt(S)[1; -3]
B[-1; -2 -3] := sqrt(S)[-1; 1] * V[1; -2 -3]
end

U, S, V, _ = tsvd(scheme.T, (1, 4), (2, 3); trunc=trunc)
U, S, V, _ = tsvd(scheme.T, ((1, 4), (2, 3)); trunc=trunc)

# Flip legs to their original domain (to mitigate space mismatch at the end)
U = permute(U, (1,), (2, 3))
V = permute(V, (1, 2), (3,))
U = permute(U, ((1,), (2, 3)))
V = permute(V, ((1, 2), (3,)))

@plansor begin
C[-1; -2 -3] := U[-1; -2 1] * sqrt(S)[1; -3]
Expand Down
44 changes: 44 additions & 0 deletions test-gilt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using TensorKit, TRGKit

T = randn(ComplexF64, ℂ^2 ^2 ^2 ^2)
T = classical_ising_symmetric(0.1)
T = gross_neveu_start(0, 1, 0)

scheme = GILT(T; ε=5e-8);

TRGKit.step!(scheme, truncbelow(5e-8));

scheme.T1
scheme.T3

for _ in 1:100
TRGKit.step!(scheme, truncbelow(scheme.ε))
end

@tensor E[-1 -2 -3 -4 -5 -6 -7 -8; -9 -10] := scheme.T1[-2 1; -10 -1] *
scheme.T2[-9 3; -7 -8] *
scheme.T3[2 -5; -6 3] *
scheme.T4[-3 -4; 2 1];
S², U = eigh(adjoint(E) * E)

space(S²)
space(U)

@plansor t[-1] := U[1 1; -1]

epsid = scheme.ε^2 * id(domain(S²))

@tensor t′[-1] := t[1] * (S² * inv(epsid + S²))[1; -1]

@plansor R′[-1; -2] := adjoint(U)[1; -1 -2] * t′[1]

U, S, V, _ = tsvd(R′; trunc=truncbelow(scheme.ε))
sqrtS = sqrt(S)

@tensor scheme.T1[-1 -2; -3 -4] := scheme.T1[-1 -2; 1 -4] * U[1; 2] * sqrtS[2; -3]
@tensor scheme.T2[-1 -2; -3 -4] := sqrtS[-1; 1] * V[1; 2] * scheme.T2[2 -2; -3 -4]

scheme.T1
scheme.T2
scheme.T3
scheme.T4

0 comments on commit 72c81e2

Please sign in to comment.