Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrehmer committed Jul 11, 2024
1 parent 3de5685 commit 8e9ca87
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 63 deletions.
75 changes: 75 additions & 0 deletions test/ctmrg/fixediter.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Test
using Random
using TensorKit
using PEPSKit
using PEPSKit:
FixedSVD,
ctmrg_iter,
gauge_fix,
fix_relative_phases,
fix_global_phases,
check_elementwise_convergence

# initialize parameters
χbond = 2
χenv = 16
svd_algs = [SVDAdjoint(; fwd_alg=TensorKit.SVD()), SVDAdjoint(; fwd_alg=IterSVD())]
unitcells = [(1, 1), (3, 4)]

# test for element-wise convergence after application of FixedIter step
@testset "$unitcell unit cell with $(typeof(svd_alg.fwd_alg))" for (unitcell, svd_alg) in
Iterators.product(
unitcells, svd_algs
)
ctm_alg = CTMRG(; tol=1e-12, verbosity=1, ctmrgscheme=:AllSides, svd_alg)

# initialize states
Random.seed!(91283219347)
psi = InfinitePEPS(2, χbond; unitcell)
env_conv1 = leading_boundary(CTMRGEnv(psi; Venv=ComplexSpace(χenv)), psi, ctm_alg)

# do extra iteration to get SVD
env_conv2, info = ctmrg_iter(psi, env_conv1, ctm_alg)
env_fix, signs = gauge_fix(env_conv1, env_conv2)
@test check_elementwise_convergence(env_conv1, env_fix)

# fix gauge of SVD
U_fix, V_fix = fix_relative_phases(info.U, info.V, signs)
svd_alg_fix = SVDAdjoint(; fwd_alg=FixedSVD(U_fix, info.S, V_fix))
ctm_alg_fix = CTMRG(; svd_alg=svd_alg_fix, trscheme=notrunc(), ctmrgscheme=:AllSides)

# do iteration with FixedSVD
env_fixedsvd, = ctmrg_iter(psi, env_conv1, ctm_alg_fix)
env_fixedsvd = fix_global_phases(env_conv1, env_fixedsvd)
@test check_elementwise_convergence(env_conv1, env_fixedsvd)
end

##
# ctm_alg = CTMRG(;
# tol=1e-12,
# miniter=4,
# maxiter=100,
# verbosity=1,
# ctmrgscheme=:AllSides,
# svd_alg=SVDAdjoint(; fwd_alg=IterSVD()),
# )

# # initialize states
# Random.seed!(91283219347)
# psi = InfinitePEPS(2, χbond)
# env_conv1 = leading_boundary(CTMRGEnv(psi; Venv=ComplexSpace(χenv)), psi, ctm_alg);

# # do extra iteration to get SVD
# env_conv2, info = ctmrg_iter(psi, env_conv1, ctm_alg);
# env_fix, signs = gauge_fix(env_conv1, env_conv2);
# @test check_elementwise_convergence(env_conv1, env_fix)

# # fix gauge of SVD
# U_fix, V_fix = fix_relative_phases(info.U, info.V, signs);
# svd_alg_fix = SVDAdjoint(; fwd_alg=FixedSVD(U_fix, info.S, V_fix));
# ctm_alg_fix = CTMRG(; svd_alg=svd_alg_fix, trscheme=notrunc(), ctmrgscheme=:AllSides);

# # do iteration with FixedSVD
# env_fixedsvd, = ctmrg_iter(psi, env_conv1, ctm_alg_fix);
# env_fixedsvd = fix_global_phases(env_conv1, env_fixedsvd);
# @test check_elementwise_convergence(env_conv1, env_fixedsvd)
60 changes: 0 additions & 60 deletions test/ctmrg/fixedsvd.jl

This file was deleted.

10 changes: 8 additions & 2 deletions test/ctmrg/gradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ models = [square_lattice_heisenberg(), square_lattice_pwave()]
names = ["Heisenberg", "p-wave superconductor"]
Random.seed!(42039482030)
tol = 1e-8
boundary_alg = CTMRG(; tol=tol, miniter=4, maxiter=100, verbosity=0)
boundary_alg = CTMRG(; tol=tol, miniter=4, maxiter=100, verbosity=0, ctmrgscheme=:AllSides)
gradmodes = [
nothing, GeomSum(; tol), ManualIter(; tol), KrylovKit.GMRES(; tol=tol, maxiter=10)
nothing,
GeomSum(; tol, iterscheme=:FixedIter),
GeomSum(; tol, iterscheme=:DiffGauge),
ManualIter(; tol, iterscheme=:FixedIter),
ManualIter(; tol, iterscheme=:DiffGauge),
LinSolve(; alg=KrylovKit.GMRES(; tol=tol, maxiter=10), iterscheme=:FixedIter),
LinSolve(; alg=KrylovKit.GMRES(; tol=tol, maxiter=10), iterscheme=:DiffGauge),
]
steps = -0.01:0.005:0.01

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end
include("ctmrg/svd_wrapper.jl")
end
@time @safetestset "SVD wrapper" begin
include("ctmrg/fixedsvd.jl")
include("ctmrg/fixediter.jl")
end
@time @safetestset "SVD wrapper" begin
include("ctmrg/unitcell.jl")
Expand Down

0 comments on commit 8e9ca87

Please sign in to comment.