Skip to content

Commit

Permalink
Rename to sweep_plan.
Browse files Browse the repository at this point in the history
  • Loading branch information
b-kloss committed Jan 20, 2024
1 parent 7865f81 commit e08ba96
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/treetensornetworks/solvers/dmrg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Overload of `ITensors.dmrg`.
"""

function dmrg_sweep(
function dmrg_sweep_plan(
nsites::Int, graph::AbstractGraph; root_vertex=default_root_vertex(graph)
)
order = 2
time_step = Inf
return tdvp_sweep(order, nsites, time_step, graph; root_vertex, reverse_step=false)
return tdvp_sweep_plan(order, nsites, time_step, graph; root_vertex, reverse_step=false)
end

function dmrg(
Expand All @@ -21,10 +21,10 @@ function dmrg(
updater_kwargs=(;),
kwargs...,
)
region_updates = dmrg_sweep(nsites, init; root_vertex)
sweep_plan = dmrg_sweep_plan(nsites, init; root_vertex)

psi = alternating_update(
updater, H, init; nsweeps, sweep_observer!, region_updates, updater_kwargs, kwargs...
updater, H, init; nsweeps, sweep_observer!, sweep_plan, updater_kwargs, kwargs...
)
return psi
end
Expand Down
12 changes: 6 additions & 6 deletions src/treetensornetworks/solvers/tdvp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ function sub_time_steps(order)
end
end

function tdvp_sweep(
function tdvp_sweep_plan(
order::Int,
nsites::Int,
time_step::Number,
graph::AbstractGraph;
root_vertex=default_root_vertex(graph),
reverse_step=true,
)
sweep = []
sweep_plan = []
for (substep, fac) in enumerate(sub_time_steps(order))
sub_time_step = time_step * fac
half = half_sweep(
Expand All @@ -51,9 +51,9 @@ function tdvp_sweep(
reverse_args=(; substep, time_step=-sub_time_step),
reverse_step,
)
append!(sweep, half)
append!(sweep_plan, half)
end
return sweep
return sweep_plan
end

function tdvp(
Expand All @@ -72,7 +72,7 @@ function tdvp(
kwargs...,
)
nsweeps = _compute_nsweeps(nsteps, t, time_step, order)
region_updates = tdvp_sweep(order, nsites, time_step, init_state; root_vertex, reverse_step)
sweep_plan = tdvp_sweep_plan(order, nsites, time_step, init_state; root_vertex, reverse_step)

function sweep_time_printer(; outputlevel, which_sweep, kwargs...)
if outputlevel >= 1
Expand All @@ -88,7 +88,7 @@ function tdvp(
insert_function!(sweep_observer!, "sweep_time_printer" => sweep_time_printer)

state = alternating_update(
updater, operator, init_state; nsweeps, sweep_observer!, region_updates, updater_kwargs, kwargs...
updater, operator, init_state; nsweeps, sweep_observer!, sweep_plan, updater_kwargs, kwargs...
)

# remove sweep_time_printer from sweep_observer!
Expand Down
9 changes: 4 additions & 5 deletions src/treetensornetworks/solvers/update_step.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function sweep_update(
(region_observer!)=observer(), # ToDo: change name to region_observer! ?
which_sweep::Int,
sweep_params::NamedTuple,
region_updates,# =default_sweep_regions(nsite, state; reverse_step), #move default up to algorithmic level
sweep_plan,
updater_kwargs,
)
insert_function!(region_observer!, "region_update_printer" => region_update_printer) #ToDo fix this
Expand All @@ -61,10 +61,9 @@ function sweep_update(
)
end

for which_region_update in eachindex(region_updates)
# merge sweep params in step_kwargs
(region, region_kwargs)=region_updates[which_region_update]
region_kwargs=merge(region_kwargs, sweep_params) #in this case sweep params has precedence over step_kwargs --- correct behaviour?
for which_region_update in eachindex(sweep_plan)
(region, region_kwargs)=sweep_plan[which_region_update]
region_kwargs=merge(region_kwargs, sweep_params) # sweep params has precedence over step_kwargs
state, projected_operator = region_update(
solver,
projected_operator,
Expand Down

0 comments on commit e08ba96

Please sign in to comment.