-
Notifications
You must be signed in to change notification settings - Fork 28
[WIP] Environment initialization for CTMRG #264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 12 commits
cb6b2a3
2b32182
c1216f4
2a6f121
78cef7c
c20aab3
11d8535
10ea2ef
991ecc7
707728d
4996e1b
c5855c0
7e4dd21
f4a9afb
12f4b0f
e12b527
5a7605b
854aa77
a767c94
2502615
885faaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| abstract type InitializationStyle end | ||
| struct ProductStateInitialization <: InitializationStyle end | ||
| struct RandomInitialization{F} <: InitializationStyle | ||
| f::F | ||
| RandomInitialization(f::F = randn) where {F} = new{F}(f) | ||
| end | ||
| struct ApplicationInitialization <: InitializationStyle end | ||
|
|
||
| function initialize_environment( | ||
|
Yue-Zhengyuan marked this conversation as resolved.
Outdated
|
||
| elt::Type{<:Number}, | ||
| n::InfiniteSquareNetwork, | ||
| alg::RandomInitialization, | ||
| virtual_spaces... = oneunit(spacetype(n)), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about calling it
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was indeed trying to be consistent with |
||
| ) | ||
| return CTMRGEnv(alg.f, elt, n, virtual_spaces...) | ||
| end | ||
|
|
||
| function initialize_environment( | ||
| elt::Type{<:Number}, | ||
| n::InfiniteSquareNetwork, | ||
| ::ProductStateInitialization, | ||
|
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) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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, | ||
| ) | ||
|
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(scalartype(n), n, args...; kwargs...) | ||
| end | ||
| function initialize_environment(A::Union{InfinitePEPS, InfinitePartitionFunction}, args...; kwargs...) | ||
| return initialize_environment(scalartype(A), A, args...; kwargs...) | ||
| end | ||
| function initialize_environment(elt::Type{<:Number}, A::Union{InfinitePEPS, InfinitePartitionFunction}, args...; kwargs...) | ||
| return initialize_environment(elt, InfiniteSquareNetwork(A), args...; kwargs...) | ||
| end | ||
| 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 |
Uh oh!
There was an error while loading. Please reload this page.