|
| 1 | +using TensorKit |
| 2 | +using MPSKit |
| 3 | +using MPSKit.BlockTensorKit: nonzero_keys |
| 4 | +using MPSKit.BlockTensorKit |
| 5 | +using MPSKitModels |
| 6 | +using TOML |
| 7 | + |
| 8 | +include(joinpath(@__DIR__, "..", "MPSKitBenchmarks.jl")) |
| 9 | +using .MPSKitBenchmarks |
| 10 | +# MPSKitBenchmarks.load!("derivatives") |
| 11 | +using .MPSKitBenchmarks.DerivativesBenchmarks: AC2Spec |
| 12 | +using .MPSKitBenchmarks.BenchUtils: tomlify |
| 13 | + |
| 14 | +# Utility functions |
| 15 | +# ---------------- |
| 16 | +# setup "product state" -> ⨂^N |↑↓ - ↓↑⟩ |
| 17 | +function initial_state(H) |
| 18 | + @assert iseven(length(H)) |
| 19 | + @assert allequal(physicalspace(H)) |
| 20 | + |
| 21 | + pspace = physicalspace(H, 1) |
| 22 | + A = rand(oneunit(pspace) ⊗ pspace^2 ← oneunit(pspace)) |
| 23 | + As = MPSKit.decompose_localmps(A) |
| 24 | + return FiniteMPS(repeat(As, length(H) ÷ 2)) |
| 25 | +end |
| 26 | + |
| 27 | +function generate_spaces(H, alg; D_min = 2, D_steps = 5) |
| 28 | + # compute maximal spaces |
| 29 | + psi_init = initial_state(H) |
| 30 | + psi, = find_groundstate(psi_init, H, alg) |
| 31 | + |
| 32 | + D_max = maximum(dim, left_virtualspace(psi)) |
| 33 | + Ds = round.(Int, logrange(D_min, D_max, D_steps)) |
| 34 | + |
| 35 | + return map(Ds) do D |
| 36 | + mps = changebonds(psi, SvdCut(; trscheme = truncrank(D))) |
| 37 | + return AC2Spec(mps, H) |
| 38 | + end |
| 39 | +end |
| 40 | + |
| 41 | +# Parameters |
| 42 | +# ---------- |
| 43 | +T = Float64 |
| 44 | +spin = 1 |
| 45 | + |
| 46 | +D_max = 10_000 |
| 47 | + |
| 48 | +D_steps = 10 |
| 49 | +D_min = 3 |
| 50 | + |
| 51 | + |
| 52 | +# FiniteChain |
| 53 | +# ----------- |
| 54 | +L = 100 |
| 55 | +lattice = FiniteChain(L) |
| 56 | + |
| 57 | +symmetry = SU2Irrep |
| 58 | +alg = DMRG2(; |
| 59 | + maxiter = 10, tol = 1.0e-12, |
| 60 | + alg_eigsolve = (; tol = 1.0e-5, dynamic_tols = false, maxiter = 3), |
| 61 | + trscheme = truncrank(D_max) |
| 62 | +) |
| 63 | + |
| 64 | +H = heisenberg_XXX(T, symmetry, lattice; spin); |
| 65 | +specs_su2 = generate_spaces(H, alg; D_min, D_steps) |
| 66 | + |
| 67 | +specs_triv = filter!(convert.(AC2Spec{ComplexSpace}, specs_su2)) do spec |
| 68 | + dim(spec.mps_virtualspaces[1]) < 1000 |
| 69 | +end |
| 70 | + |
| 71 | +specs_u1 = filter!(convert.(AC2Spec{U1Space}, specs_su2)) do spec |
| 72 | + dim(spec.mps_virtualspaces[1]) < 5000 |
| 73 | +end |
| 74 | + |
| 75 | +specs = vcat(specs_triv, specs_u1, specs_su2) |
| 76 | + |
| 77 | +output_file = joinpath(@__DIR__, "heisenberg_NN_specs.toml") |
| 78 | +open(output_file, "w") do io |
| 79 | + TOML.print(io, Dict("specs" => tomlify.(specs))) |
| 80 | +end |
| 81 | +@info("Spaces written to $output_file") |
0 commit comments