-
Notifications
You must be signed in to change notification settings - Fork 27
Adapt simple update to DiagonalTensorMap #124
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
902945e
Adapt simple update to DiagonalTensorMap
Yue-Zhengyuan 7c3c56d
Merge remote-tracking branch 'upstream/master' into su-diagtm
Yue-Zhengyuan 4ca0d10
Resolve test errors
Yue-Zhengyuan e124afa
Use `SVD` in simple update
Yue-Zhengyuan 874f048
Merge branch 'master' into su-diagtm
Yue-Zhengyuan 3d3f72b
Update src/states/infiniteweightpeps.jl
Yue-Zhengyuan 57fb93d
Merge branch 'master' into su-diagtm
lkdvos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| @static if Sys.isapple() | ||
| using AppleAccelerate | ||
| end | ||
| using Test | ||
| using Printf | ||
| using Random | ||
| import Statistics: mean | ||
| using TensorKit | ||
| using PEPSKit | ||
|
|
||
| module MeasureHeis | ||
|
|
||
| export measure_heis | ||
|
|
||
| using TensorKit | ||
| import MPSKitModels: S_x, S_y, S_z, S_exchange | ||
| using PEPSKit | ||
|
|
||
| """ | ||
| Measure magnetization on each site | ||
| """ | ||
| function cal_mags(peps::InfinitePEPS, envs::CTMRGEnv) | ||
| N1, N2 = size(peps) | ||
| lattice = collect(space(t, 1) for t in peps.A) | ||
| # detect symmetry on physical axis | ||
| symm = sectortype(space(peps.A[1, 1])) | ||
| if symm == Trivial | ||
| Sas = real.([S_x(symm), im * S_y(symm), S_z(symm)]) | ||
| elseif symm == U1Irrep | ||
| # only Sz preserves <Sz> | ||
| Sas = real.([S_z(symm)]) | ||
| else | ||
| throw(ArgumentError("Unrecognized symmetry on physical axis")) | ||
| end | ||
| return [ | ||
| collect( | ||
| expectation_value( | ||
| peps, LocalOperator(lattice, (CartesianIndex(r, c),) => Sa), envs | ||
| ) for (r, c) in Iterators.product(1:N1, 1:N2) | ||
| ) for Sa in Sas | ||
| ] | ||
| end | ||
|
|
||
| """ | ||
| Measure physical quantities for Heisenberg model | ||
| """ | ||
| function measure_heis(peps::InfinitePEPS, H::LocalOperator, envs::CTMRGEnv) | ||
| results = Dict{String,Any}() | ||
| N1, N2 = size(peps) | ||
| results["e_site"] = costfun(peps, envs, H) / (N1 * N2) | ||
| results["mag"] = cal_mags(peps, envs) | ||
| results["mag_norm"] = collect( | ||
| norm([mags[r, c] for mags in results["mag"]]) for | ||
| (r, c) in Iterators.product(1:N1, 1:N2) | ||
| ) | ||
| return results | ||
| end | ||
|
|
||
| end | ||
|
|
||
| import .MeasureHeis: measure_heis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| include("heis_tools.jl") | ||
|
|
||
| # benchmark data is from Phys. Rev. B 94, 035133 (2016) | ||
| Dbond, χenv, symm = 4, 16, U1Irrep | ||
| trscheme_peps = truncerr(1e-10) & truncdim(Dbond) | ||
| trscheme_envs = truncerr(1e-10) & truncdim(χenv) | ||
| N1, N2 = 2, 2 | ||
| # Heisenberg model Hamiltonian | ||
| # (already only includes nearest neighbor terms) | ||
| ham = heisenberg_XYZ(ComplexF64, symm, InfiniteSquare(N1, N2); Jx=1.0, Jy=1.0, Jz=1.0) | ||
| # convert to real tensors | ||
| ham = LocalOperator(ham.lattice, Tuple(ind => real(op) for (ind, op) in ham.terms)...) | ||
|
|
||
| # random initialization of 2x2 iPEPS with weights and CTMRGEnv (using real numbers) | ||
| if symm == Trivial | ||
| Pspace = ℂ^2 | ||
| Vspace = ℂ^Dbond | ||
| Espace = ℂ^χenv | ||
| elseif symm == U1Irrep | ||
| Pspace = ℂ[U1Irrep](1//2 => 1, -1//2 => 1) | ||
| Vspace = ℂ[U1Irrep](0 => Dbond ÷ 2, 1//2 => Dbond ÷ 4, -1//2 => Dbond ÷ 4) | ||
| Espace = ℂ[U1Irrep](0 => χenv ÷ 2, 1//2 => χenv ÷ 4, -1//2 => χenv ÷ 4) | ||
| else | ||
| error("Not implemented") | ||
| end | ||
| Random.seed!(0) | ||
| peps = InfiniteWeightPEPS(rand, Float64, Pspace, Vspace; unitcell=(N1, N2)) | ||
| # normalize vertex tensors | ||
| for ind in CartesianIndices(peps.vertices) | ||
| peps.vertices[ind] /= norm(peps.vertices[ind], Inf) | ||
| end | ||
|
|
||
| # simple update | ||
| dts = [1e-2, 1e-3, 4e-4] | ||
| tols = [1e-6, 1e-8, 1e-8] | ||
| maxiter = 10000 | ||
| for (dt, tol) in zip(dts, tols) | ||
| alg = SimpleUpdate(dt, tol, maxiter, trscheme_peps) | ||
| result = simpleupdate(peps, ham, alg; bipartite=true) | ||
| global peps = result[1] | ||
| end | ||
| # measure physical quantities with CTMRG | ||
| peps_ = InfinitePEPS(peps) | ||
| envs = CTMRGEnv(rand, Float64, peps_, Espace) | ||
| ctm_alg = SequentialCTMRG(; tol=1e-10, verbosity=2, trscheme=trscheme_envs) | ||
| envs = leading_boundary(envs, peps_, ctm_alg) | ||
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.