From 8a0b34e3aba7f85fae849b9252f29122f9c54183 Mon Sep 17 00:00:00 2001 From: Joey Date: Sun, 20 Oct 2024 17:52:00 +0100 Subject: [PATCH] Reverse edges in the reverse sweep of TDVP --- src/solvers/alternating_update/region_update.jl | 1 + src/solvers/insert/insert.jl | 3 +-- src/solvers/sweep_plans/sweep_plans.jl | 13 ++++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/solvers/alternating_update/region_update.jl b/src/solvers/alternating_update/region_update.jl index 6ad096b4..c741c82a 100644 --- a/src/solvers/alternating_update/region_update.jl +++ b/src/solvers/alternating_update/region_update.jl @@ -55,6 +55,7 @@ function region_update( # drho = noise * noiseterm(PH, phi, ortho) # TODO: actually implement this for trees... # so noiseterm is a solver #end + #if isa(region, AbstractEdge) && state, spec = inserter(state, phi, region; inserter_kwargs..., internal_kwargs) all_kwargs = (; which_region_update, diff --git a/src/solvers/insert/insert.jl b/src/solvers/insert/insert.jl index 42b32023..01fb35bd 100644 --- a/src/solvers/insert/insert.jl +++ b/src/solvers/insert/insert.jl @@ -33,8 +33,7 @@ end function default_inserter( state::AbstractTTN, phi::ITensor, - region::NamedEdge, - ortho; + region::NamedEdge; cutoff=nothing, maxdim=nothing, mindim=nothing, diff --git a/src/solvers/sweep_plans/sweep_plans.jl b/src/solvers/sweep_plans/sweep_plans.jl index 69221995..384cf8dc 100644 --- a/src/solvers/sweep_plans/sweep_plans.jl +++ b/src/solvers/sweep_plans/sweep_plans.jl @@ -13,10 +13,11 @@ end support(r) = r -function reverse_region(edges, which_edge; nsites=1, region_kwargs=(;)) +function reverse_region(edges, which_edge; reverse_edge=false, nsites=1, region_kwargs=(;)) current_edge = edges[which_edge] if nsites == 1 - return [(current_edge, region_kwargs)] + !reverse_edge && return [(current_edge, region_kwargs)] + reverse_edge && return [(reverse(current_edge), region_kwargs)] elseif nsites == 2 if last(edges) == current_edge return () @@ -62,6 +63,7 @@ function forward_sweep( dir::Base.ForwardOrdering, graph::AbstractGraph; root_vertex=GraphsExtensions.default_root_vertex(graph), + reverse_edges=false, region_kwargs, reverse_kwargs=region_kwargs, reverse_step=false, @@ -71,12 +73,13 @@ function forward_sweep( regions = collect( flatten(map(i -> forward_region(edges, i; region_kwargs, kwargs...), eachindex(edges))) ) - if reverse_step reverse_regions = collect( flatten( map( - i -> reverse_region(edges, i; region_kwargs=reverse_kwargs, kwargs...), + i -> reverse_region( + edges, i; reverse_edge=reverse_edges, region_kwargs=reverse_kwargs, kwargs... + ), eachindex(edges), ), ), @@ -90,7 +93,7 @@ end #ToDo: is there a better name for this? unidirectional_sweep? traversal? function forward_sweep(dir::Base.ReverseOrdering, args...; kwargs...) - return reverse(forward_sweep(Base.Forward, args...; kwargs...)) + return reverse(forward_sweep(Base.Forward, args...; reverse_edges=true, kwargs...)) end function default_sweep_plans(