From cba94247b2ec859811901ed8b58f9d7d9ddf09cc Mon Sep 17 00:00:00 2001 From: lkdvos Date: Tue, 3 Oct 2023 18:18:31 +0200 Subject: [PATCH] some refactoring --- src/algorithms/groundstate/vumps.jl | 50 +++++++++++++++-------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/algorithms/groundstate/vumps.jl b/src/algorithms/groundstate/vumps.jl index b477ba5e..84606259 100644 --- a/src/algorithms/groundstate/vumps.jl +++ b/src/algorithms/groundstate/vumps.jl @@ -29,43 +29,45 @@ end " function find_groundstate(Ψ::InfiniteMPS, H, alg::VUMPS, envs=environments(Ψ, H)) - galerkin::Float64 = 1 + alg.tol_galerkin - iter = 1 + ε::Float64 = 1 + alg.tol_galerkin temp_ACs = similar.(Ψ.AC) - while true - eigalg = Arnoldi(; tol=galerkin / (4 * sqrt(iter))) + for iter in 1:(alg.maxiter) + Δt = @elapsed begin + eigalg = Arnoldi(; tol=ε / (4 * sqrt(iter))) - @static if Defaults.parallelize_sites - @sync begin - for loc in 1:length(Ψ) - Threads.@spawn begin - _vumps_localupdate!(temp_ACs[loc], loc, Ψ, H, envs, eigalg) + @static if Defaults.parallelize_sites + @sync begin + for loc in 1:length(Ψ) + Threads.@spawn begin + _vumps_localupdate!(temp_ACs[loc], loc, Ψ, H, envs, eigalg) + end end end + else + for loc in 1:length(Ψ) + _vumps_localupdate!(temp_ACs[loc], loc, Ψ, H, envs, eigalg) + end end - else - for loc in 1:length(Ψ) - _vumps_localupdate!(temp_ACs[loc], loc, Ψ, H, envs, eigalg) - end - end - - Ψ = InfiniteMPS(temp_ACs, Ψ.CR[end]; tol=alg.tol_gauge, maxiter=alg.orthmaxiter) - recalculate!(envs, Ψ) - Ψ, envs = alg.finalize(iter, Ψ, H, envs)::Tuple{typeof(Ψ),typeof(envs)} + Ψ = InfiniteMPS(temp_ACs, Ψ.CR[end]; tol=alg.tol_gauge, maxiter=alg.orthmaxiter) + recalculate!(envs, Ψ) - galerkin = calc_galerkin(Ψ, envs) - alg.verbose && @info "vumps @iteration $(iter) galerkin = $(galerkin)" + Ψ, envs = alg.finalize(iter, Ψ, H, envs)::Tuple{typeof(Ψ),typeof(envs)} - if galerkin <= alg.tol_galerkin || iter >= alg.maxiter - iter >= alg.maxiter && @warn "vumps didn't converge $(galerkin)" - return Ψ, envs, galerkin + ε = calc_galerkin(Ψ, envs) end - iter += 1 + alg.verbose && + @info "VUMPS iteration:" iter ε λ = sum(expectation_value(Ψ, H, envs)) Δt + + ε <= alg.tol_galerkin && break + iter == alg.maxiter && + @warn "VUMPS maximum iterations" iter ε λ = sum(expectation_value(Ψ, H, envs)) Δt end + + return Ψ, envs, ε end function _vumps_localupdate!(AC′, loc, Ψ, H, envs, eigalg, factalg=QRpos())