From e08ba96cba8309f9a75b9505fc375a93542759df Mon Sep 17 00:00:00 2001 From: Benedikt Kloss Date: Sat, 20 Jan 2024 16:58:07 -0500 Subject: [PATCH] Rename to sweep_plan. --- src/treetensornetworks/solvers/dmrg.jl | 8 ++++---- src/treetensornetworks/solvers/tdvp.jl | 12 ++++++------ src/treetensornetworks/solvers/update_step.jl | 9 ++++----- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/treetensornetworks/solvers/dmrg.jl b/src/treetensornetworks/solvers/dmrg.jl index b5525277..653c00c8 100644 --- a/src/treetensornetworks/solvers/dmrg.jl +++ b/src/treetensornetworks/solvers/dmrg.jl @@ -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( @@ -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 diff --git a/src/treetensornetworks/solvers/tdvp.jl b/src/treetensornetworks/solvers/tdvp.jl index 88ae3a27..98f21849 100644 --- a/src/treetensornetworks/solvers/tdvp.jl +++ b/src/treetensornetworks/solvers/tdvp.jl @@ -30,7 +30,7 @@ function sub_time_steps(order) end end -function tdvp_sweep( +function tdvp_sweep_plan( order::Int, nsites::Int, time_step::Number, @@ -38,7 +38,7 @@ function tdvp_sweep( 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( @@ -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( @@ -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 @@ -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! diff --git a/src/treetensornetworks/solvers/update_step.jl b/src/treetensornetworks/solvers/update_step.jl index cd48983c..90452c43 100644 --- a/src/treetensornetworks/solvers/update_step.jl +++ b/src/treetensornetworks/solvers/update_step.jl @@ -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 @@ -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,