Skip to content

Commit

Permalink
Adjust scripts to new leading_boundary return values
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrehmer committed Dec 19, 2024
1 parent d0d42f6 commit e38dbce
Show file tree
Hide file tree
Showing 15 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ opt_alg = PEPSOptimize(;

# ground state search
state = InfinitePEPS(2, D)
ctm = leading_boundary(CTMRGEnv(state, ComplexSpace(chi)), state, ctm_alg)
ctm, = leading_boundary(CTMRGEnv(state, ComplexSpace(chi)), state, ctm_alg)
result = fixedpoint(state, H, opt_alg, ctm)

@show result.E # -0.6625...
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ opt_alg = PEPSOptimize(;

# ground state search
state = InfinitePEPS(2, D)
ctm = leading_boundary(CTMRGEnv(state, ComplexSpace(chi)), state, ctm_alg)
ctm, = leading_boundary(CTMRGEnv(state, ComplexSpace(chi)), state, ctm_alg)
result = fixedpoint(state, H, opt_alg, ctm)

@show result.E # -0.6625...
Expand Down
4 changes: 2 additions & 2 deletions examples/boundary_mps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ mps, envs, ϵ = leading_boundary(mps, T, VUMPS())
N = abs(prod(expectation_value(mps, T)))

# This can be compared to the result obtained using the CTMRG algorithm
ctm = leading_boundary(
ctm, = leading_boundary(
peps, SimultaneousCTMRG(; verbosity=1), CTMRGEnv(peps, ComplexSpace(20))
)
= abs(norm(peps, ctm))
Expand All @@ -55,7 +55,7 @@ mps2 = PEPSKit.initializeMPS(T2, fill(ComplexSpace(20), 2, 2))
mps2, envs2, ϵ = leading_boundary(mps2, T2, VUMPS())
N2 = abs(prod(expectation_value(mps2, T2)))

ctm2 = leading_boundary(
ctm2, = leading_boundary(
peps2, SimultaneousCTMRG(; verbosity=1), CTMRGEnv(peps2, ComplexSpace(20))
)
N2´ = abs(norm(peps2, ctm2))
Expand Down
2 changes: 1 addition & 1 deletion examples/heisenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ opt_alg = PEPSOptimize(;
# E/N = −0.6694421, which is a QMC estimate from https://arxiv.org/abs/1101.3281.
# Of course there is a noticable bias for small χbond and χenv.
ψ₀ = InfinitePEPS(2, χbond)
env₀ = leading_boundary(CTMRGEnv(ψ₀, ℂ^χenv), ψ₀, ctm_alg)
env₀, = leading_boundary(CTMRGEnv(ψ₀, ℂ^χenv), ψ₀, ctm_alg)
result = fixedpoint(ψ₀, H, opt_alg, env₀)
@show result.E
2 changes: 1 addition & 1 deletion examples/hubbard_su.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Espace = Vect[fℤ₂](0 => χenv0 / 2, 1 => χenv0 / 2)
envs = CTMRGEnv(randn, Float64, peps, Espace)
for χ in [χenv0, χenv]
ctm_alg = SequentialCTMRG(; maxiter=300, tol=1e-7)
envs = leading_boundary(envs, peps, ctm_alg)
envs, = leading_boundary(envs, peps, ctm_alg)
end

# Benchmark values of the ground state energy from
Expand Down
4 changes: 2 additions & 2 deletions src/algorithms/peps_opt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ function _rrule(
state,
alg::CTMRGAlgorithm,
)
envs = leading_boundary(envinit, state, alg)
envs, info = leading_boundary(envinit, state, alg)

function leading_boundary_diffgauge_pullback((Δenvs′, Δinfo))
Δenvs = unthunk(Δenvs′)
Expand All @@ -434,7 +434,7 @@ function _rrule(
return NoTangent(), ZeroTangent(), ∂F∂envs, NoTangent()
end

return envs, leading_boundary_diffgauge_pullback
return (envs, info), leading_boundary_diffgauge_pullback
end

# Here f is differentiated from an pre-computed SVD with fixed U, S and V
Expand Down
4 changes: 2 additions & 2 deletions test/boundarymps/vumps.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const vumps_alg = VUMPS(; alg_eigsolve=MPSKit.Defaults.alg_eigsolve(; ishermitia
mps, envs, ϵ = leading_boundary(mps, T, vumps_alg)
N = abs(sum(expectation_value(mps, T)))

ctm = leading_boundary(
ctm, = leading_boundary(
CTMRGEnv(psi, ComplexSpace(20)), psi, SimultaneousCTMRG(; verbosity=1)
)
= abs(norm(psi, ctm))
Expand All @@ -33,7 +33,7 @@ end
mps, envs, ϵ = leading_boundary(mps, T, vumps_alg)
N = abs(prod(expectation_value(mps, T)))

ctm = leading_boundary(
ctm, = leading_boundary(
CTMRGEnv(psi, ComplexSpace(20)), psi, SimultaneousCTMRG(; verbosity=1)
)
= abs(norm(psi, ctm))
Expand Down
4 changes: 2 additions & 2 deletions test/ctmrg/fixed_iterscheme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ atol = 1e-5
# initialize states
Random.seed!(2394823842)
psi = InfinitePEPS(2, χbond; unitcell)
env_conv1 = leading_boundary(CTMRGEnv(psi, ComplexSpace(χenv)), psi, ctm_alg)
env_conv1, = leading_boundary(CTMRGEnv(psi, ComplexSpace(χenv)), psi, ctm_alg)

# do extra iteration to get SVD
env_conv2, info = ctmrg_iteration(psi, env_conv1, ctm_alg)
Expand Down Expand Up @@ -61,7 +61,7 @@ end
Random.seed!(91283219347)
psi = InfinitePEPS(2, χbond)
env_init = CTMRGEnv(psi, ComplexSpace(χenv))
env_conv1 = leading_boundary(env_init, psi, ctm_alg_iter)
env_conv1, = leading_boundary(env_init, psi, ctm_alg_iter)

# do extra iteration to get SVD
env_conv2_iter, info_iter = ctmrg_iteration(psi, env_conv1, ctm_alg_iter)
Expand Down
6 changes: 3 additions & 3 deletions test/ctmrg/flavors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ projector_algs = [HalfInfiniteProjector, FullInfiniteProjector]
# compute environments
Random.seed!(32350283290358)
psi = InfinitePEPS(2, χbond; unitcell)
env_sequential = leading_boundary(
env_sequential, = leading_boundary(
CTMRGEnv(psi, ComplexSpace(χenv)), psi, ctm_alg_sequential
)
env_simultaneous = leading_boundary(
env_simultaneous, = leading_boundary(
CTMRGEnv(psi, ComplexSpace(χenv)), psi, ctm_alg_simultaneous
)

Expand Down Expand Up @@ -68,7 +68,7 @@ end
χs = [16 17 18; 15 20 21; 14 19 22]
psi = InfinitePEPS(Ds, Ds, Ds)
env = CTMRGEnv(psi, rand(10:20, 3, 3), rand(10:20, 3, 3))
env2 = leading_boundary(env, psi, ctm_alg)
env2, = leading_boundary(env, psi, ctm_alg)

# check that the space is fixed
@test all(space.(env.corners) .== space.(env2.corners))
Expand Down
4 changes: 2 additions & 2 deletions test/ctmrg/gaugefix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function _pre_converge_env(
Random.seed!(seed) # Seed RNG to make random environment consistent
psi = InfinitePEPS(rand, T, physical_space, peps_space; unitcell)
env₀ = CTMRGEnv(psi, ctm_space)
env_conv = leading_boundary(env₀, psi, SequentialCTMRG())
env_conv, = leading_boundary(env₀, psi, SequentialCTMRG())
return env_conv, psi
end

Expand All @@ -44,7 +44,7 @@ end
alg = ctmrg_alg(; projector_alg)
env_pre, psi = preconv[(S, T, unitcell)]
env_pre
env = leading_boundary(env_pre, psi, alg)
env, = leading_boundary(env_pre, psi, alg)
env′, = ctmrg_iteration(psi, env, alg)
env_fixed, = gauge_fix(env, env′)
@test calc_elementwise_convergence(env, env_fixed) 0 atol = atol
Expand Down
2 changes: 1 addition & 1 deletion test/ctmrg/gradients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ steps = -0.01:0.005:0.01
Random.seed!(42039482030)
dir = InfinitePEPS(Pspace, Vspace, Vspace)
psi = InfinitePEPS(Pspace, Vspace, Vspace)
env = leading_boundary(CTMRGEnv(psi, Espace), psi, ctmrg_alg)
env, = leading_boundary(CTMRGEnv(psi, Espace), psi, ctmrg_alg)
# TODO: redo this test using Manopt
# alphas, fs, dfs1, dfs2 = OptimKit.optimtest(
# (psi, env),
Expand Down
4 changes: 2 additions & 2 deletions test/heisenberg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ end
unitcell = (1, 2)
H_1x2 = heisenberg_XYZ(InfiniteSquare(unitcell...))
psi_init_1x2 = InfinitePEPS(2, Dbond; unitcell)
env_init_1x2 = leading_boundary(
env_init_1x2, = leading_boundary(
CTMRGEnv(psi_init_1x2, ComplexSpace(χenv)), psi_init_1x2, ctm_alg
)

Expand Down Expand Up @@ -81,7 +81,7 @@ end
# absorb weight into site tensors and CTMRG
peps = InfinitePEPS(peps)
envs₀ = CTMRGEnv(rand, Float64, peps, Espace)
envs = leading_boundary(envs₀, peps, SimultaneousCTMRG())
envs, = leading_boundary(envs₀, peps, SimultaneousCTMRG())

# measure physical quantities
e_site = costfun(peps, envs, ham) / (N1 * N2)
Expand Down
2 changes: 1 addition & 1 deletion test/j1j2_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Random.seed!(91283219347)
H = j1_j2(InfiniteSquare(); J2=0.25)
psi_init = product_peps(2, χbond; noise_amp=1e-1)
psi_init = symmetrize!(psi_init, RotateReflect())
env_init = leading_boundary(CTMRGEnv(psi_init, ComplexSpace(χenv)), psi_init, ctm_alg);
env_init, = leading_boundary(CTMRGEnv(psi_init, ComplexSpace(χenv)), psi_init, ctm_alg);

# find fixedpoint
result = fixedpoint(psi_init, H, opt_alg, env_init; symmetrization=RotateReflect())
Expand Down
2 changes: 1 addition & 1 deletion test/pwave.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Vspace = Vect[FermionParity](0 => χbond ÷ 2, 1 => χbond ÷ 2)
Envspace = Vect[FermionParity](0 => χenv ÷ 2, 1 => χenv ÷ 2)
Random.seed!(91283219347)
psi_init = InfinitePEPS(Pspace, Vspace, Vspace; unitcell)
env_init = leading_boundary(CTMRGEnv(psi_init, Envspace), psi_init, ctm_alg);
env_init, = leading_boundary(CTMRGEnv(psi_init, Envspace), psi_init, ctm_alg);

# find fixedpoint
result = fixedpoint(psi_init, H, opt_alg, env_init)
Expand Down
2 changes: 1 addition & 1 deletion test/tf_ising.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ opt_alg = PEPSOptimize(;
H = transverse_field_ising(InfiniteSquare(); g)
Random.seed!(91283219347)
psi_init = InfinitePEPS(2, χbond)
env_init = leading_boundary(CTMRGEnv(psi_init, ComplexSpace(χenv)), psi_init, ctm_alg)
env_init, = leading_boundary(CTMRGEnv(psi_init, ComplexSpace(χenv)), psi_init, ctm_alg)

# find fixedpoint
result = fixedpoint(psi_init, H, opt_alg, env_init)
Expand Down

0 comments on commit e38dbce

Please sign in to comment.