diff --git a/src/MPS.jl b/src/MPS.jl index 0b9d52fc..439d426a 100644 --- a/src/MPS.jl +++ b/src/MPS.jl @@ -543,13 +543,23 @@ function mixed_canonize!(tn::AbstractMPO, orthog_center) end """ - evolve!(ψ::AbstractAnsatz, mpo::AbstractMPO; threshold=nothing, maxdim=nothing, normalize=true) + evolve!(ψ::AbstractAnsatz, mpo::AbstractMPO; threshold=nothing, maxdim=nothing, normalize=true, reset_index=true) Evolve the [`AbstractAnsatz`](@ref) `ψ` with the [`AbstractMPO`](@ref) `mpo` along the output indices of `ψ`. -If `threshold` or `maxdim` are not `nothing`, the tensors are truncated after each sweep at the proper value. +If `threshold` or `maxdim` are not `nothing`, the tensors are truncated after each sweep at the proper value, and the +bond is normalized if `normalize=true`. If `reset_index=true`, the indices of the `ψ` are reset to the original ones. """ -function evolve!(ψ::AbstractAnsatz, mpo::AbstractMPO; threshold=nothing, maxdim=nothing, normalize=true) +function evolve!(ψ::AbstractAnsatz, mpo::AbstractMPO; threshold=nothing, maxdim=nothing, normalize=true, reset_index=true) + original_sites = copy(Quantum(ψ).sites) evolve!(form(ψ), ψ, mpo; threshold, maxdim, normalize) + + if reset_index + resetindex!(Quantum(ψ); init=ninds(TensorNetwork(ψ))+1) + + replacements = [(Quantum(ψ).sites[key] => original_sites[key]) for key in keys(original_sites)] + replace!(Quantum(ψ), replacements) + end + return ψ end