Skip to content
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LoggingExtras = "~1.0"
OptimKit = "0.4.0"
Zygote = "0.7.7"
julia = "1.11"
TensorKit = "0.14"
TensorKit = "0.15"

[extras]
QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ using TNRKit, TensorKit

T = classical_ising_symmetric(ising_βc) # partition function of classical Ising model at the critical point
scheme = BTRG(T) # Bond-weighted TRG (excellent choice)
data = run!(scheme, truncdim(16), maxiter(25)) # max bond-dimension of 16, for 25 iterations
data = run!(scheme, truncrank(16), maxiter(25)) # max bond-dimension of 16, for 25 iterations
```

`data` now contains 26 norms of the tensor, 1 for every time the tensor was normalized. (By default there is a normalization step before the first coarse-graining step wich can be turned off by changing the kwarg `run!(...; finalize_beginning=false)`)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using TNRKit, TensorKit

T = classical_ising_symmetric(ising_βc) # partition function of classical Ising model at the critical point
scheme = BTRG(T) # Bond-weighted TRG (excellent choice)
data = run!(scheme, truncdim(16), maxiter(25)) # max bond-dimension of 16, for 25 iterations
data = run!(scheme, truncrank(16), maxiter(25)) # max bond-dimension of 16, for 25 iterations
```
`data` now contains 26 norms of the tensor, 1 for every time the tensor was normalized. (By default there is a normalization step before the first coarse-graining step wich can be turned off by changing the kwarg `run!(...; finalize_beginning=false)`)

Expand Down
4 changes: 2 additions & 2 deletions examples/example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ trg_f(steps::Int, data) = abs(log(data[end]) * 2.0^(-steps))
stopping_criterion = convcrit(1.0e-16, trg_f) & maxiter(20)

# choose a TensorKit truncation scheme
trunc = truncdim(16) & truncbelow(1.0e-40)
trunc = truncrank(16) & truncbelow(1.0e-40)

# initialize the TRG scheme
scheme = TRG(classical_ising(1.0))

# run the TRG scheme (and normalize and store the norm in the beginning (finalize_beginning=true))
data = run!(scheme, trunc, stopping_criterion; finalize_beginning = true)
# or: data = run!(scheme, truncdim(16)), this will default to maxiter(100)
# or: data = run!(scheme, truncrank(16)), this will default to maxiter(100)

# initialize the BTRG scheme
scheme = BTRG(classical_ising(1.0), -0.5)
Expand Down
6 changes: 3 additions & 3 deletions src/models/ising.jl
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ function classical_ising_3D(β; J = 1.0)
K = β * J

# Boltzmann weights
t = ComplexF64[exp(K) exp(-K); exp(-K) exp(K)]
r = eigen(t)
q = r.vectors * sqrt(LinearAlgebra.Diagonal(r.values)) * r.vectors
t = Float64[exp(K) exp(-K); exp(-K) exp(K)]
D, V = eig_full(t)
q = D * sqrt(V) * D

# local partition function tensor
O = zeros(2, 2, 2, 2, 2, 2)
Expand Down
6 changes: 3 additions & 3 deletions src/schemes/atrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function step!(scheme::ATRG, trunc::TensorKit.TruncationScheme)
end

function _step!(scheme::ATRG, trunc::TensorKit.TruncationScheme)
A, S, B, _ = tsvd(scheme.T, ((1, 3), (2, 4)); trunc = trunc)
A, S, B = svd_trunc(permute(scheme.T, ((1, 3), (2, 4))); trunc)
C, D = deepcopy.([A, B])

@tensor begin
Expand All @@ -53,7 +53,7 @@ function _step!(scheme::ATRG, trunc::TensorKit.TruncationScheme)

@tensor M[-1 -2; -3 -4] := B[-3; 1 -4] * C[-1 1; -2]

X, S, Y, _ = tsvd(M, ((1, 3), (2, 4)); trunc = trunc)
X, S, Y = svd_trunc(permute(M, ((1, 3), (2, 4))); trunc)
sqrtS = sqrt(S)

@tensor begin
Expand All @@ -64,7 +64,7 @@ function _step!(scheme::ATRG, trunc::TensorKit.TruncationScheme)
@tensor Q[-1 -2; -3 -4] := A[3 -3; 2] * D[1; -2 4] * X[4 2; -4] *
Y[-1 1; 3]

H, S, G, _ = tsvd(Q; trunc = trunc)
H, S, G = svd_trunc(Q; trunc)
sqrtS = sqrt(S)

@tensor begin
Expand Down
16 changes: 8 additions & 8 deletions src/schemes/atrg3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ mutable struct ATRG_3D{E, S, TT <: AbstractTensorMap{E, S, 2, 4}} <: TNRScheme{E
end

function _step!(scheme::ATRG_3D, trunc::TensorKit.TruncationScheme)
U, S, V, _ = tsvd(scheme.T, ((2, 5, 6), (3, 4, 1)); trunc = trunc)
U, S, V = svd_trunc(permute(scheme.T, ((2, 5, 6), (3, 4, 1))); trunc)
A = permute(U, ((4, 1), (2, 3)))
D = permute(V, ((4, 1), (2, 3)))
C = permute(U * S, ((4, 1), (2, 3)))
B = permute(S * V, ((4, 1), (2, 3)))

@tensor M[-1 -2; -3 -4 -5 -6] := B[1 -2; -3 -4] * C[-1 1; -5 -6]

U, S, V, _ = tsvd(M, ((2, 5, 6), (3, 4, 1)); trunc = trunc)
U, S, V = svd_trunc(permute(M, ((2, 5, 6), (3, 4, 1))); trunc)
sqrtS = sqrt(S)

X = permute(U * sqrtS, ((4, 1), (2, 3)))
Expand All @@ -51,19 +51,19 @@ function _step!(scheme::ATRG_3D, trunc::TensorKit.TruncationScheme)
@tensor YD[-1 -2; -3 -4 -5 -6] := Y[1 -2; -3 -5] * D[-1 1; -4 -6]

#The QR decompositions and construction of the four isometries
_, R1 = leftorth(YD, ((1, 2, 3, 4), (5, 6)))
R2, _ = rightorth(AX, ((5, 6), (1, 2, 3, 4)))
_, R3 = leftorth(YD, ((1, 2, 5, 6), (3, 4)))
R4, _ = rightorth(AX, ((3, 4), (1, 2, 5, 6)))
_, R1 = left_orth(permute(YD, ((1, 2, 3, 4), (5, 6))))
R2, _ = right_orth(permute(AX, ((5, 6), (1, 2, 3, 4))))
_, R3 = left_orth(permute(YD, ((1, 2, 5, 6), (3, 4))))
R4, _ = right_orth(permute(AX, ((3, 4), (1, 2, 5, 6))))

@tensor temp1[-1; -2] := R1[-1; 1 2] * R2[1 2; -2]
U1, S1, V1, _ = tsvd(temp1; trunc = trunc)
U1, S1, V1 = svd_trunc(temp1; trunc = trunc)
inv_s1 = pseudopow(S1, -0.5)
@tensor Proj_1[-1 -2; -3] := R2[-1 -2; 1] * adjoint(V1)[1; 2] * inv_s1[2; -3]
@tensor Proj_2[-1; -2 -3] := inv_s1[-1; 1] * adjoint(U1)[1; 2] * R1[2; -2 -3]

@tensor temp2[-1; -2] := R3[-1; 1 2] * R4[1 2; -2]
U2, S2, V2, _ = tsvd(temp2; trunc = trunc)
U2, S2, V2 = svd_trunc(temp2; trunc = trunc)
inv_s2 = pseudopow(S2, -0.5)
@tensor Proj_3[-1 -2; -3] := R4[-1 -2; 1] * adjoint(V2)[1; 2] * inv_s2[2; -3]
@tensor Proj_4[-1; -2 -3] := inv_s2[-1; 1] * adjoint(U2)[1; 2] * R3[2; -2 -3]
Expand Down
4 changes: 2 additions & 2 deletions src/schemes/btrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function pseudopow(t::DiagonalTensorMap, a::Real; tol = eps(scalartype(t))^(3 /
end

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

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

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

S_a = pseudopow(S, (1 - scheme.k) / 2)
S_b = pseudopow(S, scheme.k)
Expand Down
4 changes: 2 additions & 2 deletions src/schemes/ctm/ctm_hotrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mutable struct ctm_HOTRG{E, S, TT <: AbstractTensorMap{E, S, 2, 2}, TC <: Abstra
@info "Finding the environment using rCTM..."
run!(
scheme_init,
truncdim(χenv),
truncrank(χenv),
ctm_tol & ctm_iter;
verbosity = 0,
)
Expand Down Expand Up @@ -60,7 +60,7 @@ end

function find_UVt(scheme::ctm_HOTRG, trunc)
mat = corner_matrix(scheme)
U, S, Vt = tsvd(mat; trunc = trunc & truncbelow(1.0e-20))
U, S, Vt = svd_trunc(mat; trunc = trunc & truncbelow(1.0e-20))
return mat, U, S, Vt
end

Expand Down
8 changes: 4 additions & 4 deletions src/schemes/ctm/ctm_trg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mutable struct ctm_TRG{E, S, TT <: AbstractTensorMap{E, S, 2, 2}, TC <: Abstract
@info "Finding the environment using rCTM..."
TNRKit.run!(
scheme_init,
truncdim(χenv),
truncrank(χenv),
trivial_convcrit(ctm_tol) & maxiter(ctm_iter);
verbosity = 0,
)
Expand All @@ -36,12 +36,12 @@ end

function find_UVt(scheme::ctm_TRG, trunc)
mat = corner_matrix(scheme)
U, S, Vt = tsvd(mat; trunc = trunc & truncbelow(1.0e-20))
U, S, Vt = svd_trunc(mat; trunc = trunc & truncbelow(1.0e-20))
return mat, U, S, Vt
end

function Levin_decomposition(T, trunc)
U, S, Vt = tsvd(T, ((1, 3), (2, 4)); trunc = trunc)
U, S, Vt = svd_trunc(permute(T, ((1, 3), (2, 4))); trunc = trunc)

S1 = U * sqrt(S)
S2 = sqrt(S) * Vt
Expand All @@ -64,7 +64,7 @@ function insert_PtoS(scheme, trunc; enlarge = true)
if enlarge
P1, P2 = find_P1P2(
env_left_top, env_right_bottom, (3,), (1,),
truncdim(trunc.dim * 2)
truncrank(trunc.dim * 2)
)
else
P1, P2 = find_P1P2(env_left_top, env_right_bottom, (3,), (1,), trunc)
Expand Down
2 changes: 1 addition & 1 deletion src/schemes/ctm/onesite_ctm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ end
function corner_spectrum(ctm::CTM)
rho = ρA(ctm)
rho /= abs(tr(rho))
_, S, _ = tsvd(rho)
_, S, _ = svd_full(rho)
return S.data
end

Expand Down
2 changes: 1 addition & 1 deletion src/schemes/ctm/rctm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end

function find_UVt(scheme, trunc)
mat = rt_build_corner_matrix(scheme)
U, S, Vt = tsvd(mat; trunc = trunc & truncbelow(1.0e-20))
U, S, Vt = svd_trunc(mat; trunc = trunc & truncbelow(1.0e-20))
return mat, U, S, Vt
end

Expand Down
2 changes: 1 addition & 1 deletion src/schemes/ctm/sublattice_ctm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ end
function corner_spectrum(ctm::Sublattice_CTM)
rho = ρA(ctm)
rho /= abs(tr(rho))
_, S, _ = tsvd(rho)
_, S, _ = svd_full(rho)
return S.data
end

Expand Down
8 changes: 4 additions & 4 deletions src/schemes/ctm/utility.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ end
# QR decomposition
function R1R2(A1, A2, p1, p2; check_space = true)
p, q1 = ind_pair(A1, p1)
_, RA1 = leftorth(A1, (q1, p1))
_, RA1 = left_orth(permute(A1, (q1, p1)))
p, q2 = ind_pair(A2, p2)
RA2, _ = rightorth(A2, (p2, q2))
RA2, _ = right_orth(permute(A2, (p2, q2)))
if check_space
if domain(RA1) != codomain(RA2)
@error "space mismatch"
Expand All @@ -33,7 +33,7 @@ end

function oblique_projector(R1, R2, trunc; cutoff = 1.0e-16)
mat = R1 * R2
U, S, Vt = tsvd(mat; trunc = trunc & truncbelow(cutoff))
U, S, Vt = svd_trunc(mat; trunc = trunc & truncbelow(cutoff))

P1 = R2 * adjoint(Vt) / sqrt(S)
P2 = adjoint(U) * R1
Expand All @@ -50,7 +50,7 @@ function tr_tensor(T; inv = false)
end
end

function rctm_step!(scheme; trunc = truncdim(dim(space(scheme.C2, 1))))
function rctm_step!(scheme; trunc = truncrank(dim(space(scheme.C2, 1))))
mat, U, S, Vt = find_UVt(scheme, trunc)
scheme.C2 = adjoint(U) * mat * adjoint(Vt)
@tensor opt = true scheme.E1[-1 -2; -3] := scheme.E1[1 5; 3] * scheme.T[2 -2; 5 4] *
Expand Down
8 changes: 4 additions & 4 deletions src/schemes/hotrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ function _get_hotrg_xproj(
@plansor MM[-1 -2; -3 -4] :=
A2[-1 5; 1 2] * A1[-2 3; 5 4] *
conj(A2[-3 6; 1 2]) * conj(A1[-4 3; 6 4])
U, s, _, ε = tsvd!(MM; trunc)
U, s, _, ε = eigh_trunc(MM; trunc = trunc)
# get right unitary
@plansor MM[-1 -2; -3 -4] :=
conj(A2[2 5; 1 -1]) * conj(A1[4 3; 5 -2]) *
A2[2 6; 1 -3] * A1[4 3; 6 -4]
_, s′, U′, ε′ = tsvd!(MM; trunc)
_, s′, U′, ε′ = eigh_trunc(MM; trunc = trunc)
if ε > ε′
U, s, ε = adjoint(U′), s′, ε′
end
Expand All @@ -134,12 +134,12 @@ function _get_hotrg_yproj(
@plansor MM[-1 -2; -3 -4] :=
A1[1 -1; 2 5] * A2[5 -2; 4 3] *
conj(A1[1 -3; 2 6]) * conj(A2[6 -4; 4 3])
U, s, _, ε = tsvd!(MM; trunc)
U, s, _, ε = eigh_trunc(MM; trunc = trunc)
# get top unitary
@plansor MM[-1 -2; -3 -4] :=
conj(A1[1 2; -1 5]) * conj(A2[5 4; -2 3]) *
A1[1 2; -3 6] * A2[6 4; -4 3]
_, s′, U′, ε′ = tsvd!(MM; trunc)
_, s′, U′, ε′ = eigh_trunc(MM; trunc = trunc)
if ε > ε′
U, s, ε = adjoint(U′), s′, ε′
end
Expand Down
4 changes: 2 additions & 2 deletions src/schemes/hotrg3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ function _get_hotrg3d_xproj(
A2[z z2; Y2 X2 y2 x2] * conj(A2′[z′ z2; Y2 X2 y2 x2′])
@tensoropt MM[x1 x2; x1′ x2′] := MM[x2 z z′ x2′] *
A1[z1 z; Y1 X1 y1 x1] * conj(A1′[z1 z′; Y1 X1 y1 x1′])
U, s, _, ε = tsvd!(MM; trunc)
U, s, _, ε = eigh_trunc(MM; trunc = trunc)
# right unitary
A2′ = twistdual(A2, [2, 3, 5, 6])
A1′ = twistdual(A1, [1, 3, 5, 6])
@tensoropt MM[x2 z z′ x2′] :=
conj(A2[z z2; Y2 x2 y2 X2]) * A2′[z′ z2; Y2 x2′ y2 X2]
@tensoropt MM[x1 x2; x1′ x2′] := MM[x2 z z′ x2′] *
conj(A1[z1 z; Y1 x1 y1 X1]) * A1′[z1 z′; Y1 x1′ y1 X1]
_, s′, U′, ε′ = tsvd!(MM; trunc)
_, s′, U′, ε′ = eigh_trunc(MM; trunc = trunc)
if ε > ε′
U, s, ε = adjoint(U′), s′, ε′
end
Expand Down
2 changes: 1 addition & 1 deletion src/schemes/looptnr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ end
# Function to construct MPS Ψ_B from MPS Ψ_A. Using a large cut-off dimension in SVD but a small cut-off dimension in loop to increase the precision of initialization.
function Ψ_B(ΨA::Vector{<:AbstractTensorMap{E, S, 1, 3}}, trunc::TensorKit.TruncationScheme, truncentanglement::TensorKit.TruncationScheme) where {E, S}
NA = length(ΨA)
ΨB = [s for A in ΨA for s in SVD12(A, truncdim(trunc.dim * 2))]
ΨB = [s for A in ΨA for s in SVD12(A, truncrank(trunc.dim * 2))]

ΨB_function(steps, data) = abs(data[end])
criterion = maxiter(10) & convcrit(1.0e-12, ΨB_function)
Expand Down
4 changes: 2 additions & 2 deletions src/schemes/symmetric_looptnr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ end

########## Initialization of loop optimizations ##########
function decompose_T(T, trunc)
u, s, _ = tsvd(T, (1, 2), (3, 4); trunc)
u, s, _ = svd_trunc(permute(T, ((1, 2), (3, 4))); trunc = trunc)
return u * sqrt(s)
end

function ef_oneloop(T, trunc::TensorKit.TruncationScheme)
ΨA = Ψ_center(T)
ΨB = [s for A in ΨA for s in SVD12(A, truncdim(trunc.dim * 2))]
ΨB = [s for A in ΨA for s in SVD12(A, truncrank(trunc.dim * 2))]

ΨB_function(steps, data) = abs(data[end])
criterion = maxiter(100) & convcrit(1.0e-12, ΨB_function)
Expand Down
2 changes: 1 addition & 1 deletion src/utility/cdl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function cdl_tensor(χ::Int; χcdl = 2)
C[10; 9] * U[1 2 3; -1] * U[4 5 6; -2] *
conj(U[7 8 9; -3]) * conj(U[10 11 12; -4])
# random rotation
U, _, Vt = tsvd(randn(ℂ^(2 * χcdl + χ) ← ℂ^(2 * χcdl + χ)))
U, _, Vt = svd_trunc(randn(ℂ^(2 * χcdl + χ) ← ℂ^(2 * χcdl + χ)))
@tensoropt Anew[-1 -2; -3 -4] := Anew[1 2; 3 4] * U[1; -1] * conj(U[4; -4]) *
Vt[2; -2] * conj(Vt[3; -3])
return Anew
Expand Down
10 changes: 5 additions & 5 deletions src/utility/cft.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function cft_data(scheme::TNRScheme; v = 1, unitcell = 1, is_real = true)
ininds = Tuple(collect((unitcell + 1):(2unitcell)))

T = permute(T, (outinds, ininds))
D, _ = eig(T)
D, _ = eig_full(T)

data = zeros(ComplexF64, dim(space(D, 1)))

Expand Down Expand Up @@ -49,7 +49,7 @@ function cft_data(scheme::BTRG; v = 1, unitcell = 1, is_real = true)
ininds = Tuple(collect((unitcell + 1):(2unitcell)))

T = permute(T, (outinds, ininds))
D, _ = eig(T)
D, _ = eig_full(T)

data = zeros(ComplexF64, dim(space(D, 1)))

Expand Down Expand Up @@ -99,7 +99,7 @@ function MPO_opt(
TA::TensorMap, TB::TensorMap, trunc::TensorKit.TruncationScheme,
truncentanglement::TensorKit.TruncationScheme
)
pretrunc = truncdim(2 * trunc.dim)
pretrunc = truncrank(2 * trunc.dim)
dl, ur = SVD12(TA, pretrunc)
dr, ul = SVD12(transpose(TB, ((2, 4), (1, 3))), pretrunc)

Expand Down Expand Up @@ -256,7 +256,7 @@ Get the central charge given the current state of a `TNRScheme` and the previous
"""
function central_charge(scheme::TNRScheme, n::Number)
@tensor M[-1; -2] := (scheme.T / n)[1 -1; -2 1]
_, S, _ = tsvd(M)
_, S, _ = svd_full(M)
return log(S.data[1]) * 6 / (π)
end

Expand All @@ -265,6 +265,6 @@ function central_charge(scheme::BTRG, n::Number)
(scheme.T)[1 -1; 3 2] * scheme.S1[3; -2] *
scheme.S2[2; 1]
) / n
_, S, _ = tsvd(M)
_, S, _ = svd_full(M)
return log(S.data[1]) * 6 / (π)
end
2 changes: 1 addition & 1 deletion src/utility/finalize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function finalize_cft!(scheme::SLoopTNR)
Tflip = flip(scheme.T, (1, 2, 3, 4))
@tensoropt mat[-1 -2; -3 -4] := scheme.T[1 3; -1 2] * Tflip[1 4; -2 2] *
Tflip[5 3; -3 6] * scheme.T[5 4; -4 6]
val, vec = eig(mat)
val, _ = eig_full(mat)
val = sort(real(val).data; rev = true)
data = -log.(abs.(val ./ val[1])) / 2 / π
return data
Expand Down
Loading
Loading