Skip to content

Commit e50c3eb

Browse files
authored
Update info in leading_boundary output for CTMRG (#365)
1 parent 343e80d commit e50c3eb

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/algorithms/ctmrg/ctmrg.jl

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,11 @@ supplied via the keyword arguments or directly as an [`CTMRGAlgorithm`](@ref) st
8888
8989
## Return values
9090
91-
The `leading_boundary` routine returns the final environment as well as an information `NamedTuple`
92-
that generally contains a `contraction_metrics` `NamedTuple` storing different contents depending
93-
on the chosen `alg`. Depending on the contraction method, the information tuple may also contain
94-
the final tensor decomposition (used in the projectors) including its truncation indices.
91+
* `env` : The final environment.
92+
* `info` : A `NamedTuple` containing information about the `leading_boundary` convergence, which has the following fields:
93+
- `info.converged::Bool` : Convergence flag indicating whether the contraction converged within `maxiter` and `tol`.
94+
- `info.convergence_error::Real` : The final convergence error at the end of the contraction procedure.
95+
- `info.contraction_metrics::NamedTuple` : A `NamedTuple` containing metrics which characterize the contraction. The precise contents depend on `alg`.
9596
"""
9697
function leading_boundary(env₀::CTMRGEnv, network::InfiniteSquareNetwork; kwargs...)
9798
alg = select_algorithm(leading_boundary, env₀; kwargs...)
@@ -109,13 +110,15 @@ function leading_boundary(
109110
end
110111
η = one(real(scalartype(network)))
111112
ctmrg_loginit!(log, η, network, env₀)
112-
local info
113+
local info_iter
114+
converged = false
113115
for iter in 1:(alg.maxiter)
114-
env, info = ctmrg_iteration(network, env, alg)
116+
env, info_iter = ctmrg_iteration(network, env, alg)
115117
η, CS, TS = calc_convergence(env, CS, TS)
116118

117119
if η alg.tol && iter alg.miniter
118120
ctmrg_logfinish!(log, iter, η, network, env)
121+
converged = true
119122
break
120123
end
121124
if iter == alg.maxiter
@@ -124,6 +127,11 @@ function leading_boundary(
124127
ctmrg_logiter!(log, iter, η, network, env)
125128
end
126129
end
130+
info = (;
131+
converged,
132+
convergence_error = η,
133+
contraction_metrics = info_iter.contraction_metrics,
134+
)
127135
return env, info
128136
end
129137
end

0 commit comments

Comments
 (0)