Currently, the run! interface runs the TNR scheme to the end of the RG process, with only a limited information of the intermediate RG steps only accessible at the end from the returned value of Finalizer. This also negatively affects the tests (especially in test/schemes/schemes.jl): sometimes TNR are repeatedly run for different number of steps to examine different properties (free energy or CFT data). For example:
|
@testset "TRG - Ising Model" begin |
|
@info "TRG ising free energy" |
|
scheme = TRG(T) |
|
data = run!(scheme, truncrank(24), maxiter(25)) |
|
|
|
@test free_energy(data, ising_βc) ≈ f_onsager rtol = 2.0e-6 |
|
|
|
@info "TRG ising CFT data" |
|
scheme = TRG(T) |
|
run!(scheme, truncrank(24), maxiter(10)) |
|
|
|
cft = sort(CFTData(scheme; shape = [1, 1, 0]).scaling_dimensions[2:end]; by = abs) .|> real |
A nicer interface in my opinion is to make the TNR schemes iterable (similar to the TimeEvolver in PEPSKit or IterativeSolver in MPSKit). Each iteration returns the tensors at the current step, and the normalization factor (for free energy calculation, etc). The TRG test above then may be written as
@info "BTRG ising free energy"
scheme = TRG(T)
data = scalartype(T)[]
# may make `scheme` callable; or use other approaches
rg_runner = scheme(truncrank(24), maxiter(25))
for (n, (T, nrm)) in enumerate(rg_runner)
push!(data, nrm)
(n != 10) && continue
# examine CFT data at step 10
cft = sort(CFTData(scheme; shape = [1, 1, 0]).scaling_dimensions[2:end]; by = abs) .|> real
# CFT tests
end
@test free_energy(data, ising_βc) ≈ f_onsager rtol = 6.0e-8
Then, no need to run TRG twice.
Currently, the
run!interface runs the TNR scheme to the end of the RG process, with only a limited information of the intermediate RG steps only accessible at the end from the returned value ofFinalizer. This also negatively affects the tests (especially in test/schemes/schemes.jl): sometimes TNR are repeatedly run for different number of steps to examine different properties (free energy or CFT data). For example:TNRKit.jl/test/schemes/schemes.jl
Lines 20 to 31 in 24f658e
A nicer interface in my opinion is to make the TNR schemes iterable (similar to the
TimeEvolverin PEPSKit orIterativeSolverin MPSKit). Each iteration returns the tensors at the current step, and the normalization factor (for free energy calculation, etc). The TRG test above then may be written asThen, no need to run TRG twice.