diff --git a/Project.toml b/Project.toml index 78683ad9..0bc673fc 100644 --- a/Project.toml +++ b/Project.toml @@ -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" diff --git a/README.md b/README.md index fea76806..4bc835f8 100644 --- a/README.md +++ b/README.md @@ -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)`) diff --git a/docs/src/index.md b/docs/src/index.md index 7d9e0b0d..28e2a002 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -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)`) diff --git a/examples/example.jl b/examples/example.jl index 15f65358..7790d711 100644 --- a/examples/example.jl +++ b/examples/example.jl @@ -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) diff --git a/src/models/ising.jl b/src/models/ising.jl index 58905db2..a563d414 100644 --- a/src/models/ising.jl +++ b/src/models/ising.jl @@ -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) diff --git a/src/schemes/atrg.jl b/src/schemes/atrg.jl index 7098e0a0..e79171b7 100644 --- a/src/schemes/atrg.jl +++ b/src/schemes/atrg.jl @@ -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 @@ -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 @@ -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 diff --git a/src/schemes/atrg3d.jl b/src/schemes/atrg3d.jl index 51f37f81..28c43db5 100644 --- a/src/schemes/atrg3d.jl +++ b/src/schemes/atrg3d.jl @@ -33,7 +33,7 @@ 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))) @@ -41,7 +41,7 @@ function _step!(scheme::ATRG_3D, trunc::TensorKit.TruncationScheme) @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))) @@ -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] diff --git a/src/schemes/btrg.jl b/src/schemes/btrg.jl index 8c48ce95..cf527d30 100644 --- a/src/schemes/btrg.jl +++ b/src/schemes/btrg.jl @@ -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) @@ -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) diff --git a/src/schemes/ctm/ctm_hotrg.jl b/src/schemes/ctm/ctm_hotrg.jl index 2bfd352d..714f225e 100644 --- a/src/schemes/ctm/ctm_hotrg.jl +++ b/src/schemes/ctm/ctm_hotrg.jl @@ -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, ) @@ -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 diff --git a/src/schemes/ctm/ctm_trg.jl b/src/schemes/ctm/ctm_trg.jl index 63cd141d..f86517d9 100644 --- a/src/schemes/ctm/ctm_trg.jl +++ b/src/schemes/ctm/ctm_trg.jl @@ -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, ) @@ -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 @@ -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) diff --git a/src/schemes/ctm/onesite_ctm.jl b/src/schemes/ctm/onesite_ctm.jl index 5b8df1ed..068169d4 100644 --- a/src/schemes/ctm/onesite_ctm.jl +++ b/src/schemes/ctm/onesite_ctm.jl @@ -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 diff --git a/src/schemes/ctm/rctm.jl b/src/schemes/ctm/rctm.jl index f878fb40..716686c7 100644 --- a/src/schemes/ctm/rctm.jl +++ b/src/schemes/ctm/rctm.jl @@ -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 diff --git a/src/schemes/ctm/sublattice_ctm.jl b/src/schemes/ctm/sublattice_ctm.jl index 00b7ed18..1cf8c00e 100644 --- a/src/schemes/ctm/sublattice_ctm.jl +++ b/src/schemes/ctm/sublattice_ctm.jl @@ -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 diff --git a/src/schemes/ctm/utility.jl b/src/schemes/ctm/utility.jl index 439427b2..fc7544d5 100644 --- a/src/schemes/ctm/utility.jl +++ b/src/schemes/ctm/utility.jl @@ -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" @@ -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 @@ -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] * diff --git a/src/schemes/hotrg.jl b/src/schemes/hotrg.jl index 2799646c..a6611b3e 100644 --- a/src/schemes/hotrg.jl +++ b/src/schemes/hotrg.jl @@ -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 @@ -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 diff --git a/src/schemes/hotrg3d.jl b/src/schemes/hotrg3d.jl index e8d3fbf7..2b6586ee 100644 --- a/src/schemes/hotrg3d.jl +++ b/src/schemes/hotrg3d.jl @@ -56,7 +56,7 @@ 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]) @@ -64,7 +64,7 @@ function _get_hotrg3d_xproj( 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 diff --git a/src/schemes/looptnr.jl b/src/schemes/looptnr.jl index a47758a8..fbd313c2 100644 --- a/src/schemes/looptnr.jl +++ b/src/schemes/looptnr.jl @@ -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) diff --git a/src/schemes/symmetric_looptnr.jl b/src/schemes/symmetric_looptnr.jl index 026b5f7f..39d44bee 100644 --- a/src/schemes/symmetric_looptnr.jl +++ b/src/schemes/symmetric_looptnr.jl @@ -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) diff --git a/src/utility/cdl.jl b/src/utility/cdl.jl index 35cf8d88..af0c4b6b 100644 --- a/src/utility/cdl.jl +++ b/src/utility/cdl.jl @@ -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 diff --git a/src/utility/cft.jl b/src/utility/cft.jl index 258fd6e6..002c101d 100644 --- a/src/utility/cft.jl +++ b/src/utility/cft.jl @@ -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))) @@ -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))) @@ -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) @@ -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 @@ -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 diff --git a/src/utility/finalize.jl b/src/utility/finalize.jl index a5796337..0a330d3f 100644 --- a/src/utility/finalize.jl +++ b/src/utility/finalize.jl @@ -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 diff --git a/src/utility/projectors.jl b/src/utility/projectors.jl index f47301a1..cd840dbb 100644 --- a/src/utility/projectors.jl +++ b/src/utility/projectors.jl @@ -17,7 +17,7 @@ function QR_L( ), (in_ind + out_ind,), ) LT = transpose(L * transpose(T, permT), permLT) - _, Rt = leftorth(LT) + _, Rt = left_orth(LT) return Rt / norm(Rt, Inf) end @@ -39,7 +39,7 @@ function QR_R( ), ) TR = transpose(transpose(T, permT) * R, permTR) - Lt, _ = rightorth(TR) + Lt, _ = right_orth(TR) return Lt / norm(Lt, Inf) end @@ -110,7 +110,7 @@ function P_decomp( R::TensorMap{E, S, 1, 1}, L::TensorMap{E, S, 1, 1}, trunc::TensorKit.TruncationScheme ) where {E, S} - U, s, V, _ = tsvd(L * R; trunc = trunc, alg = TensorKit.SVD()) + U, s, V, _ = svd_trunc(L * R; trunc = trunc, alg = TensorKit.SVD()) re_sq = pseudopow(s, -0.5) PR = R * V' * re_sq PL = re_sq * U' * L @@ -177,13 +177,13 @@ end function SVD12(T::AbstractTensorMap{E, S, 1, 3}, trunc::TensorKit.TruncationScheme) where {E, S} T_trans = transpose(T, ((2, 1), (3, 4)); copy = true) - U, s, V, e = tsvd(T_trans; trunc = trunc, alg = TensorKit.SVD()) + U, s, V = svd_trunc(T_trans; trunc = trunc, alg = TensorKit.SVD()) @plansor S1[-1; -2 -3] := U[-2 -1; 1] * sqrt(s)[1; -3] @plansor S2[-1; -2 -3] := sqrt(s)[-1; 1] * V[1; -2 -3] return S1, S2 end function SVD12(T::AbstractTensorMap{E, S, 2, 2}, trunc::TensorKit.TruncationScheme) where {E, S} - U, s, V, e = tsvd(T; trunc = trunc) + U, s, V = svd_trunc(T; trunc = trunc) return U * sqrt(s), sqrt(s) * V end diff --git a/test/fermions.jl b/test/fermions.jl index 02a0519c..8d9f89df 100644 --- a/test/fermions.jl +++ b/test/fermions.jl @@ -4,35 +4,35 @@ T = gross_neveu_start(0, 0, 0) # === TRG === @testset "TRG - Gross-Neveu Model" begin scheme = TRG(T) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) @test free_energy(data, 1.0) ≈ f_bench rtol = 1.0e-3 end # === BTRG === @testset "BTRG - Gross-Neveu Model" begin scheme = BTRG(T) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) @test free_energy(data, 1.0) ≈ f_bench rtol = 1.0e-4 end # === HOTRG === @testset "HOTRG - Gross-Neveu Model" begin scheme = HOTRG(T) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) @test free_energy(data, 1.0; scalefactor = 4.0) ≈ f_bench rtol = 1.0e-3 end # === ATRG === @testset "ATRG - Gross-Neveu Model" begin scheme = ATRG(T) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) @test free_energy(data, 1.0; scalefactor = 4.0) ≈ f_bench rtol = 1.0e-2 end # === LoopTNR === @testset "LoopTNR - Gross-Neveu Model" begin scheme = LoopTNR(T) - data = run!(scheme, truncdim(8), maxiter(10)) + data = run!(scheme, truncrank(8), maxiter(10)) @test free_energy(data, 1.0) ≈ f_bench rtol = 1.0e-3 end @@ -49,12 +49,12 @@ end β = 1.0 # Calculate the free energy using c4vCTM - data_c4vCTM = run!(c4vCTM(T_flipped_C4v), truncdim(8), maxiter(10)) + data_c4vCTM = run!(c4vCTM(T_flipped_C4v), truncrank(8), maxiter(10)) free_energy_c4vCTM = -data_c4vCTM / β schemes = [TRG, BTRG, HOTRG, ATRG, LoopTNR] for scheme in schemes - data = run!(scheme(T_flipped_C4v), truncdim(8), maxiter(10)) + data = run!(scheme(T_flipped_C4v), truncrank(8), maxiter(10)) scalefactor = scheme ∈ [HOTRG, ATRG] ? 4.0 : 2.0 @test free_energy_c4vCTM ≈ free_energy(data, β; scalefactor) rtol = 1.0e-10 end diff --git a/test/finalize.jl b/test/finalize.jl index f04e3780..fd20560e 100644 --- a/test/finalize.jl +++ b/test/finalize.jl @@ -9,7 +9,7 @@ T = classical_ising_symmetric() # TRG @testset "TRG - Ising Model" begin scheme = TRG(T; finalize = (finalize_two_by_two!)) - data = run!(scheme, truncdim(24), maxiter(25)) + data = run!(scheme, truncrank(24), maxiter(25)) lnz = 0 for (i, d) in enumerate(data) @@ -25,7 +25,7 @@ end # BTRG @testset "BTRG - Ising Model" begin scheme = BTRG(T, -0.5; finalize = (finalize_two_by_two!)) - data = run!(scheme, truncdim(24), maxiter(25)) + data = run!(scheme, truncrank(24), maxiter(25)) lnz = 0 for (i, d) in enumerate(data) @@ -41,7 +41,7 @@ end # HOTRG @testset "HOTRG - Ising Model" begin scheme = HOTRG(T; finalize = (finalize_two_by_two!)) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) lnz = 0 for (i, d) in enumerate(data) @@ -57,7 +57,7 @@ end # ATRG @testset "ATRG - Ising Model" begin scheme = ATRG(T; finalize = (finalize_two_by_two!)) - data = run!(scheme, truncdim(24), maxiter(25)) + data = run!(scheme, truncrank(24), maxiter(25)) lnz = 0 for (i, d) in enumerate(data) diff --git a/test/models.jl b/test/models.jl index ae986fc5..bcc3f167 100644 --- a/test/models.jl +++ b/test/models.jl @@ -39,7 +39,7 @@ answers = [ @testset "2D Models" begin for (model, temp, answer) in zip(models_2D, temperatures, answers) scheme = TRG(model) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) @test free_energy(data, temp) ≈ answer rtol = 1.0e-3 end end diff --git a/test/schemes.jl b/test/schemes.jl index d99b0b58..a8f2966d 100644 --- a/test/schemes.jl +++ b/test/schemes.jl @@ -18,13 +18,13 @@ end @testset "TRG - Ising Model" begin @info "TRG ising free energy" scheme = TRG(T) - data = run!(scheme, truncdim(24), maxiter(25)) + data = run!(scheme, truncrank(24), maxiter(25)) @test free_energy(data, ising_βc) ≈ f_onsager rtol = 2.0e-6 @info "TRG ising CFT data" scheme = TRG(T) - run!(scheme, truncdim(24), maxiter(10)) + run!(scheme, truncrank(24), maxiter(10)) cft = cft_data(scheme)[2:end] @@ -36,13 +36,13 @@ end @testset "BTRG - Ising Model" begin @info "BTRG ising free energy" scheme = BTRG(T) - data = run!(scheme, truncdim(24), maxiter(25)) + data = run!(scheme, truncrank(24), maxiter(25)) @test free_energy(data, ising_βc) ≈ f_onsager rtol = 6.0e-8 @info "BTRG ising CFT data" scheme = BTRG(T) - run!(scheme, truncdim(24), maxiter(10)) + run!(scheme, truncrank(24), maxiter(10)) cft = cft_data(scheme)[2:end] @@ -54,13 +54,13 @@ end @testset "HOTRG - Ising Model" begin @info "HOTRG ising free energy" scheme = HOTRG(T) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) @test free_energy(data, ising_βc; scalefactor = 4.0) ≈ f_onsager rtol = 6.0e-7 @info "HOTRG ising CFT data" scheme = HOTRG(T) - run!(scheme, truncdim(16), maxiter(4)) + run!(scheme, truncrank(16), maxiter(4)) cft = cft_data(scheme)[2:end] @@ -72,13 +72,13 @@ end @testset "ATRG - Ising Model" begin @info "ATRG ising free energy" scheme = ATRG(T) - data = run!(scheme, truncdim(24), maxiter(25)) + data = run!(scheme, truncrank(24), maxiter(25)) @test free_energy(data, ising_βc; scalefactor = 4.0) ≈ f_onsager rtol = 3.0e-6 @info "ATRG ising CFT data" scheme = ATRG(T) - run!(scheme, truncdim(24), maxiter(3)) + run!(scheme, truncrank(24), maxiter(3)) cft = cft_data(scheme)[2:end] @@ -95,7 +95,7 @@ end loop_criterion = maxiter(5) data = run!( - scheme, truncdim(8), truncbelow(1.0e-12), maxiter(25), entanglement_criterion, + scheme, truncrank(8), truncbelow(1.0e-12), maxiter(25), entanglement_criterion, loop_criterion ) @@ -103,7 +103,7 @@ end @info "LoopTNR ising CFT data" scheme = LoopTNR(T) - run!(scheme, truncdim(12), maxiter(10)) + run!(scheme, truncrank(12), maxiter(10)) for shape in [[1, 4, 1], [sqrt(2), 2 * sqrt(2), 0]] cft = cft_data!(scheme, shape) @@ -114,7 +114,7 @@ end end for shape in [[1, 8, 1], [4 / sqrt(10), 2 * sqrt(10), 2 / sqrt(10)]] - cft = cft_data!(scheme, shape, truncdim(12), truncbelow(1.0e-10)) + cft = cft_data!(scheme, shape, truncrank(12), truncbelow(1.0e-10)) d1, d2 = real(cft[Z2Irrep(1)][1]), real(cft[Z2Irrep(0)][2]) @info "Obtained lowest scaling dimensions:\n$(d1), $(d2)." @test d1 ≈ ising_cft_exact[1] rtol = 1.0e-3 @@ -124,12 +124,12 @@ end @testset "LoopTNR - Initialization with 2 x 2 unit cell" begin loop_criterion = maxiter(5) - trunc = truncdim(8) + trunc = truncrank(8) truncentanglement = truncbelow(1.0e-12) entanglement_criterion = maxiter(100) scheme = LoopTNR(fill(T, (2, 2)); loop_criterion, trunc, truncentanglement) data = run!( - scheme, truncdim(8), truncbelow(1.0e-12), maxiter(25), entanglement_criterion, + scheme, truncrank(8), truncbelow(1.0e-12), maxiter(25), entanglement_criterion, loop_criterion ) @test free_energy(data, ising_βc; initial_size = 2) ≈ f_onsager rtol = 1.0e-6 @@ -141,7 +141,7 @@ end T_inv = classical_ising_inv() scheme = SLoopTNR(T_inv) - data = run!(scheme, truncdim(4), maxiter(25)) + data = run!(scheme, truncrank(4), maxiter(25)) @test free_energy(data, ising_βc) ≈ f_onsager rtol = 1.0e-5 end @@ -150,7 +150,7 @@ end @testset "ctm_TRG - Ising Model" begin @info "ctm_TRG ising free energy" scheme = ctm_TRG(T, 8) - lz = run!(scheme, truncdim(8), maxiter(25)) + lz = run!(scheme, truncrank(8), maxiter(25)) fs = lz * -1 / ising_βc @test fs ≈ f_onsager rtol = 7.0e-6 @@ -160,7 +160,7 @@ end @testset "ctm_HOTRG - Ising Model" begin @info "ctm_HOTRG ising free energy" scheme = ctm_HOTRG(T, 8) - lz = run!(scheme, truncdim(8), maxiter(25)) + lz = run!(scheme, truncrank(8), maxiter(25)) fs = lz * -1 / ising_βc @test fs ≈ f_onsager rtol = 2.0e-5 @@ -170,7 +170,7 @@ end @testset "c4vCTM - Ising Model" begin @info "c4vCTM ising free energy" scheme = c4vCTM(T) - lz = run!(scheme, truncdim(24), trivial_convcrit(1.0e-9); verbosity = 1) + lz = run!(scheme, truncrank(24), trivial_convcrit(1.0e-9); verbosity = 1) fs = lz * -1 / ising_βc @@ -181,7 +181,7 @@ end @testset "rCTM - Ising Model" begin @info "rCTM ising free energy" scheme = rCTM(T) - lz = run!(scheme, truncdim(24), trivial_convcrit(1.0e-9); verbosity = 1) + lz = run!(scheme, truncrank(24), trivial_convcrit(1.0e-9); verbosity = 1) fs = lz * -1 / ising_βc @@ -192,7 +192,7 @@ end @testset "ATRG_3D - Ising Model" begin @info "ATRG_3D ising free energy" scheme = ATRG_3D(T_3D) - data = run!(scheme, truncdim(12), maxiter(25)) + data = run!(scheme, truncrank(12), maxiter(25)) fs = free_energy(data, ising_βc_3D; scalefactor = 8.0) @info "Calculated f = $(fs)." @test fs ≈ f_benchmark3D rtol = 5.0e-3 @@ -202,7 +202,7 @@ end @testset "HOTRG_3D - Ising Model" begin @info "HOTRG_3D ising free energy" scheme = HOTRG_3D(T_3D) - data = run!(scheme, truncdim(8), maxiter(25)) + data = run!(scheme, truncrank(8), maxiter(25)) fs = free_energy(data, ising_βc_3D; scalefactor = 8.0) @info "Calculated f = $(fs)." @test fs ≈ f_benchmark3D rtol = 1.0e-3 @@ -216,7 +216,7 @@ end scheme = ImpurityHOTRG(T, T_imp1, T_imp1, T) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) @test free_energy(getindex.(data, 1), ising_βc; scalefactor = 4.0) ≈ f_onsager rtol = 6.0e-7 end @@ -231,7 +231,7 @@ end scheme = ImpurityHOTRG(T, T_imp_order1_1, T_imp_order1_1, T_imp_order2) - data = run!(scheme, truncdim(8), maxiter(25)) + data = run!(scheme, truncrank(8), maxiter(25)) m2_highT = data[end][4] / data[end][1] @test m2_highT ≈ 0.0 atol = 1.0e-14 @@ -245,7 +245,7 @@ end scheme = ImpurityHOTRG(T, T_imp_order1_1, T_imp_order1_1, T_imp_order2) - data = run!(scheme, truncdim(8), maxiter(25)) + data = run!(scheme, truncrank(8), maxiter(25)) m2_lowT = data[end][4] / data[end][1] @test m2_lowT ≈ 1 rtol = 1.0e-2 @@ -258,7 +258,7 @@ end scheme = ImpurityTRG(T, T_imp, T, T, T) - data = run!(scheme, truncdim(24), maxiter(25)) + data = run!(scheme, truncrank(24), maxiter(25)) @test free_energy(getindex.(data, 1), ising_βc) ≈ f_onsager rtol = 2.0e-6 end @@ -272,7 +272,7 @@ end scheme = ImpurityTRG(T, T_imp, T, T, T) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) m_expection = data[end][2] / data[end][1] @test m_expection ≈ 0.0 atol = 1.0e-4 @@ -285,7 +285,7 @@ end scheme = ImpurityTRG(T, T_imp, T, T, T) - data = run!(scheme, truncdim(16), maxiter(25)) + data = run!(scheme, truncrank(16), maxiter(25)) m_expection = data[end][2] / data[end][1] @test m_expection ≈ 1.0 rtol = 1.0e-4 diff --git a/test/spaces.jl b/test/spaces.jl index efdc9e18..acc4b5ca 100644 --- a/test/spaces.jl +++ b/test/spaces.jl @@ -18,7 +18,7 @@ for S in schemes for T in models @eval begin println("--- $($(T[1])) ---") - @test isa(run!($S($(T[2])), truncdim(7), maxiter(25)), Any) + @test isa(run!($S($(T[2])), truncrank(7), maxiter(25)), Any) end end end