Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
cb6b2a3
Add `initialize_environment`
leburgel Sep 26, 2025
2b32182
Merge branch 'master' into lb/initialize_env
leburgel Sep 26, 2025
c1216f4
Add test
leburgel Sep 26, 2025
2a6f121
Not converging isn't really passing though
leburgel Sep 26, 2025
78cef7c
Pass virtual space specification through to `CTMRGEnv` constructor
leburgel Sep 26, 2025
c20aab3
Slurp, make an actual product state, and increase coverage
leburgel Sep 28, 2025
11d8535
Better optional alg specification
leburgel Sep 28, 2025
10ea2ef
Merge branch 'master' into lb/initialize_env
lkdvos Sep 30, 2025
991ecc7
Apply suggestions from code review
leburgel Oct 1, 2025
707728d
Merge branch 'master' into lb/initialize_env
leburgel Oct 6, 2025
4996e1b
Add initialization function to `ProductStateInitialization` struct
leburgel Oct 6, 2025
c5855c0
Merge branch 'master' into lb/initialize_env
leburgel Oct 22, 2025
7e4dd21
Merge remote-tracking branch 'upstream/master' into lb/initialize_env
Yue-Zhengyuan Jan 11, 2026
f4a9afb
Change `trscheme` to `trunc`
Yue-Zhengyuan Jan 11, 2026
12f4b0f
Merge branch 'master' into lb/initialize_env
leburgel Jan 29, 2026
e12b527
Merge branch 'master' into lb/initialize_env
Yue-Zhengyuan Apr 7, 2026
5a7605b
Stash update
leburgel Apr 10, 2026
854aa77
Merge branch 'master' into lb/initialize_env
leburgel Apr 10, 2026
a767c94
Merge remote-tracking branch 'upstream/master' into lb/initialize_env
Yue-Zhengyuan Apr 11, 2026
2502615
Update env init in finite-T SU tests
Yue-Zhengyuan Apr 11, 2026
885faaf
Update test/ctmrg/initialization.jl
leburgel Apr 15, 2026
ad77085
Merge branch 'main' into lb/initialize_env
leburgel Jun 5, 2026
d56074a
Some fixes, and add environment initialization for PEPS using identit…
leburgel Jun 5, 2026
fa0d980
No longer use `@insert`
leburgel Jun 5, 2026
203266a
Remove `bipartite_id`, add dedicated initialization from identity, ad…
leburgel Jun 15, 2026
ae9abe0
Merge branch 'main' into lb/initialize_env
leburgel Jun 15, 2026
4c844f9
Reduce boilerplate a bit, add test for starting from specific product…
leburgel Jun 16, 2026
e05f662
Small cleanup for `BPEnv`
leburgel Jun 16, 2026
9123bb3
Merge remote-tracking branch 'origin/main' into lb/initialize_env
leburgel Jun 16, 2026
af90a13
TensorMap data should be a matrix
leburgel Jun 17, 2026
9dfd6b3
Forgot import
leburgel Jun 17, 2026
d0ec8d9
Actually use seed
leburgel Jun 17, 2026
9a72484
Only seed at the start
leburgel Jun 19, 2026
f5f25ae
Merge remote-tracking branch 'origin/main' into lb/initialize_env
leburgel Jun 19, 2026
f51ed73
Update src/environments/product_state_environments.jl
leburgel Jun 23, 2026
b8a36dd
Define `TensorKit.storagetype` for `ProductStateEnv`
leburgel Jun 23, 2026
bed9c2f
Add actual `CTMRGEnv(::CTMRGEnv)` constructor
leburgel Jun 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/PEPSKit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module PEPSKit

using LinearAlgebra, Statistics, Base.Threads, Base.Iterators, Printf
using Compat
using Accessors: @set, @reset
using Accessors: @set, @reset, @insert
using VectorInterface
import VectorInterface as VI

Expand Down Expand Up @@ -64,6 +64,7 @@ include("algorithms/ctmrg/projectors.jl")
include("algorithms/ctmrg/simultaneous.jl")
include("algorithms/ctmrg/sequential.jl")
include("algorithms/ctmrg/gaugefix.jl")
include("algorithms/ctmrg/initialization.jl")

include("algorithms/truncation/truncationschemes.jl")
include("algorithms/truncation/fullenv_truncation.jl")
Expand All @@ -87,6 +88,8 @@ using .Defaults: set_scheduler!
export set_scheduler!
export SVDAdjoint, FullSVDReverseRule, IterSVD
export CTMRGEnv, SequentialCTMRG, SimultaneousCTMRG
export initialize_environment,
RandomInitialization, ProductStateInitialization, ApplicationInitialization
export FixedSpaceTruncation, SiteDependentTruncation
export HalfInfiniteProjector, FullInfiniteProjector
export LocalOperator, physicalspace
Expand Down
2 changes: 2 additions & 0 deletions src/algorithms/ctmrg/ctmrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ containing the following fields:

* `truncation_error` : Last (maximal) SVD truncation error of the CTMRG projectors.
* `condition_number` : Last (maximal) condition number of the enlarged CTMRG environment.
* `convergence_error` : Convergence error of the CTMRG algorithm at termination.

In case the `alg` is a `SimultaneousCTMRG`, the last SVD will also be returned:

Expand Down Expand Up @@ -120,6 +121,7 @@ function leading_boundary(
for iter in 1:(alg.maxiter)
env, info = ctmrg_iteration(network, env, alg) # Grow and renormalize in all 4 directions
η, CS, TS = calc_convergence(env, CS, TS)
info = @insert info.convergence_error = η

if η ≤ alg.tol && iter ≥ alg.miniter
ctmrg_logfinish!(log, iter, η, network, env)
Expand Down
56 changes: 56 additions & 0 deletions src/algorithms/ctmrg/initialization.jl
Comment thread
leburgel marked this conversation as resolved.
Comment thread
lkdvos marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
abstract type InitializationStyle end
struct ProductStateInitialization <: InitializationStyle end
struct RandomInitialization <: InitializationStyle end
Comment thread
leburgel marked this conversation as resolved.
Outdated
struct ApplicationInitialization <: InitializationStyle end

function initialize_environment(
Comment thread
Yue-Zhengyuan marked this conversation as resolved.
Outdated
elt::Type{<:Number},
n::InfiniteSquareNetwork,
::RandomInitialization,
virtual_spaces... = oneunit(spacetype(n)),
Comment thread
leburgel marked this conversation as resolved.
)
return CTMRGEnv(randn, elt, n, virtual_spaces...)
end

function initialize_environment(
elt::Type{<:Number},
n::InfiniteSquareNetwork,
::ProductStateInitialization,
Comment thread
Yue-Zhengyuan marked this conversation as resolved.
Outdated
virtual_spaces... = oneunit(spacetype(n)),
)
i = one(sectortype(n))
env = CTMRGEnv(ones, elt, n, virtual_spaces...)
for (dir, r, c) in Iterators.product(axes(env)...)
@assert i in blocksectors(env.corners[dir, r, c])
for (c, b) in blocks(env.corners[dir, r, c])
b .= 0
c == i && (b[1, 1] = 1)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely need a test with fermionic iPEPS on this, in case parity-odd elements become -1 due to twists.

end
end
return env
end

function initialize_environment(
elt::Type{<:Number},
n::InfiniteSquareNetwork,
::ApplicationInitialization,
trscheme::TruncationScheme;
boundary_alg = (;
alg = :sequential, tol = 1.0e-5, maxiter = 10, verbosity = -1,
)
Comment thread
leburgel marked this conversation as resolved.
Outdated
)
boundary_alg = (; boundary_alg..., trscheme) # merge trscheme with optional alg definition
env = initialize_environment(elt, n, ProductStateInitialization())
env, = leading_boundary(env, n; boundary_alg...)
return env
end

function initialize_environment(n::InfiniteSquareNetwork, args...; kwargs...)
return initialize_environment(ComplexF64, n, args...; kwargs...)
Comment thread
leburgel marked this conversation as resolved.
Outdated
end
function initialize_environment(A::Union{InfinitePEPS, InfinitePartitionFunction}, args...; kwargs...)
return initialize_environment(ComplexF64, A, args...; kwargs...)
Comment thread
leburgel marked this conversation as resolved.
Outdated
end
function initialize_environment(elt::Type{<:Number}, A::Union{InfinitePEPS, InfinitePartitionFunction}, args...; kwargs...)
return initialize_environment(elt, InfiniteSquareNetwork(A), args...; kwargs...)
end
1 change: 1 addition & 0 deletions src/networks/infinitesquarenetwork.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ end

## Spaces

TensorKit.spacetype(::Type{T}) where {T <: InfiniteSquareNetwork} = spacetype(eltype(T))
virtualspace(n::InfiniteSquareNetwork, r::Int, c::Int, dir) = virtualspace(n[r, c], dir)

## Vector interface
Expand Down
51 changes: 51 additions & 0 deletions test/ctmrg/initialization.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Test
using TensorKit
using PEPSKit
using Random

using MPSKitModels: classical_ising

sd = 12345

# toggle symmetry, but same issue for both
symmetries = [Z2Irrep, Trivial]

χ = 20
tol = 1.0e-4
maxiter = 1000
verbosity = 2
trscheme = FixedSpaceTruncation()
boundary_alg = (;
alg = :simultaneous,
tol,
verbosity,
trscheme,
maxiter,
)

@testset "CTMRG environment initialization for critical ising with $S symmetry (#255)" for S in symmetries
# initialize
T = classical_ising(S)
O = T[1]
n = InfinitePartitionFunction([O O; O O])
Venv = S == Z2Irrep ? Z2Space(0 => χ / 2, 1 => χ / 2) : ℂ^χ
P = space(O, 2)

# random, doesn't converge
Random.seed!(sd)
env0_rand = initialize_environment(n, RandomInitialization(), Venv)
env_rand, info = leading_boundary(env0_rand, n; boundary_alg...)
@test_broken info.convergence_error ≤ tol

# embedded product state, converges
Random.seed!(sd)
env0_prod = initialize_environment(n, ProductStateInitialization(), Venv)
env_prod, info = leading_boundary(env0_prod, n; boundary_alg...)
@test info.convergence_error ≤ tol

# grown product state, converges
Random.seed!(sd)
env0_appl = initialize_environment(InfiniteSquareNetwork(n), ApplicationInitialization(), truncdim(χ))
env_appl, info = leading_boundary(env0_appl, n; boundary_alg...)
@test info.convergence_error ≤ tol
end
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ end
@time @safetestset "correlation length" begin
include("ctmrg/correlation_length.jl")
end
@time @safetestset "initialization" begin
include("ctmrg/initialization.jl")
end
end
if GROUP == "ALL" || GROUP == "GRADIENTS"
@time @safetestset "CTMRG gradients" begin
Expand Down
Loading