Skip to content

Commit

Permalink
Fix rrule for sdiag_pow and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Yue-Zhengyuan committed Dec 9, 2024
1 parent 68b94b0 commit ee6b16e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 146 deletions.
4 changes: 2 additions & 2 deletions src/algorithms/ctmrg/ctmrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ end
Perform CTMRG left move on the `col`-th column
"""
function ctmrg_leftmove(col::Int, state, envs::CTMRGEnv, alg::SequentialCTMRG)
"""
#=
----> left move
C1 ← T1 ← r-1
↓ ‖
T4 = M == r
↓ ‖
C4 → T3 → r+1
c-1 c
"""
=#
projectors, info = ctmrg_projectors(col, state, envs, alg)
envs = ctmrg_renormalize(col, projectors, state, envs, alg)
return envs, info
Expand Down
1 change: 0 additions & 1 deletion src/operators/localoperator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,3 @@ function Base.rot180(H::LocalOperator)
)
return LocalOperator(lattice2, terms2...)
end

7 changes: 4 additions & 3 deletions src/utility/util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ function ChainRulesCore.rrule(
::typeof(sdiag_pow), S::AbstractTensorMap, pow::Real; tol::Real=eps(eltype(S))^(3 / 4)
)
tol *= norm(S, Inf)
spow = sdiag_pow(S, pow - 1; tol)
spow = sdiag_pow(S, pow; tol)
spow2 = sdiag_pow(S, pow - 1; tol)
function sdiag_pow_pullback(c̄)
return (ChainRulesCore.NoTangent(), pow * _elementwise_mult(c̄, spow))
return (ChainRulesCore.NoTangent(), pow * _elementwise_mult(c̄, spow2))
end
return invsq, sdiag_pow_pullback
return spow, sdiag_pow_pullback
end

# Check whether diagonals contain degenerate values up to absolute or relative tolerance
Expand Down
78 changes: 0 additions & 78 deletions test/heisenberg_suad.jl

This file was deleted.

13 changes: 4 additions & 9 deletions test/heisenberg_sufu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ using Random
using PEPSKit
using TensorKit
import Statistics: mean
include("utility/measure_heis.jl")
import .MeasureHeis: measure_heis

# benchmark data is from Phys. Rev. B 94, 035133 (2016)

Expand Down Expand Up @@ -39,7 +37,7 @@ ham = LocalOperator(ham.lattice, Tuple(ind => real(op) for (ind, op) in ham.term
# simple update
dts = [1e-2, 1e-3, 4e-4, 1e-4]
tols = [1e-6, 1e-8, 1e-8, 1e-8]
maxiter = 10000
maxiter = 5000
for (n, (dt, tol)) in enumerate(zip(dts, tols))
trscheme = truncerr(1e-10) & truncdim(Dcut)
alg = SimpleUpdate(dt, tol, maxiter, trscheme)
Expand All @@ -54,9 +52,6 @@ trscheme = truncerr(1e-9) & truncdim(χenv)
ctm_alg = CTMRG(; tol=1e-10, verbosity=2, trscheme=trscheme, ctmrgscheme=:sequential)
envs = leading_boundary(envs, peps, ctm_alg)
# measure physical quantities
meas = measure_heis(peps, ham, envs)
display(meas)
@info @sprintf("Energy = %.8f\n", meas["e_site"])
@info @sprintf("Staggered magnetization = %.8f\n", mean(meas["mag_norm"]))
@test isapprox(meas["e_site"], -0.6675; atol=1e-3)
@test isapprox(mean(meas["mag_norm"]), 0.3767; atol=1e-3)
e_site = costfun(peps, envs, ham)
@info @sprintf("Energy = %.8f\n", e_site)
@test isapprox(e_site, -0.6675; atol=1e-3)
3 changes: 0 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ end
@time @safetestset "Heisenberg model (simple and full update)" begin
include("heisenberg_sufu.jl")
end
@time @safetestset "Hubbard model (simple update)" begin
include("hubbard_su.jl")
end
@time @safetestset "J1-J2 model" begin
include("j1j2_model.jl")
end
Expand Down
50 changes: 0 additions & 50 deletions test/utility/measure_heis.jl

This file was deleted.

0 comments on commit ee6b16e

Please sign in to comment.