Skip to content

Commit

Permalink
Reverse edges in the reverse sweep of TDVP
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeyT1994 committed Oct 20, 2024
1 parent 32ebca7 commit 8a0b34e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/solvers/alternating_update/region_update.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/solvers/insert/insert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ end
function default_inserter(
state::AbstractTTN,
phi::ITensor,
region::NamedEdge,
ortho;
region::NamedEdge;
cutoff=nothing,
maxdim=nothing,
mindim=nothing,
Expand Down
13 changes: 8 additions & 5 deletions src/solvers/sweep_plans/sweep_plans.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down Expand Up @@ -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,
Expand All @@ -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),
),
),
Expand All @@ -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(
Expand Down

0 comments on commit 8a0b34e

Please sign in to comment.