Skip to content

Commit

Permalink
Remove unnecessary Quantum functions, add docstring for truncate_sweep!
Browse files Browse the repository at this point in the history
  • Loading branch information
jofrevalles committed Nov 29, 2024
1 parent d8688e8 commit 98018c3
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/MPS.jl
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,10 @@ function evolve!(
evolve!(form(ψ), ψ, mpo; threshold, maxdim, normalize)

if reset_index
resetindex!(Quantum(ψ); init=ninds(TensorNetwork(ψ)) + 1)
resetindex!(ψ; init=ninds(TensorNetwork(ψ)) + 1)

replacements = [(Quantum(ψ).sites[key] => original_sites[key]) for key in keys(original_sites)]
replace!(Quantum(ψ), replacements)
replacements = [inds(ψ; at=site) => original_sites[site] for site in keys(original_sites)]
replace!(ψ, replacements)
end

return ψ
Expand Down Expand Up @@ -620,9 +620,17 @@ function evolve!(::Canonical, ψ::AbstractAnsatz, mpo::AbstractMPO; threshold, m
return ψ
end

"""
truncate_sweep!
Do a right-to-left QR sweep on the [`AbstractMPO`](@ref) `ψ` and then left-to-right SVD sweep and truncate the tensors
according to the `threshold` or `maxdim` values. The bond is normalized if `normalize=true`.
"""
function truncate_sweep! end

function truncate_sweep!(::NonCanonical, ψ::AbstractMPO; threshold, maxdim, normalize)
for i in nsites(ψ):-1:2
canonize_site!(ψ, Site(i); direction=:left, method=:svd)
canonize_site!(ψ, Site(i); direction=:left, method=:qr)
end

# left-to-right SVD sweep, get left-canonical tensors and singular values and truncate
Expand All @@ -646,7 +654,7 @@ end

function truncate_sweep!(::Canonical, ψ::AbstractMPO; threshold, maxdim, normalize)
for i in nsites(ψ):-1:2
canonize_site!(ψ, Site(i); direction=:left, method=:svd)
canonize_site!(ψ, Site(i); direction=:left, method=:qr)
end

# left-to-right SVD sweep, get left-canonical tensors and singular values and truncate
Expand Down

0 comments on commit 98018c3

Please sign in to comment.