-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt eigsolve and dmrg to new interfaces, fix dmrg tests (and remove…
… a broken one for now).
- Loading branch information
Showing
4 changed files
with
90 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,39 @@ | ||
|
||
function eigsolve_solver(; | ||
solver_which_eigenvalue=:SR, #TODO: settle on pattern to pass solver kwargs | ||
function eigsolve_updater( | ||
init; | ||
psi_ref!, | ||
PH_ref!, | ||
outputlevel, | ||
which_sweep, | ||
region_updates, | ||
which_region_update, | ||
region_kwargs, | ||
updater_kwargs, | ||
) | ||
Check warning on line 12 in src/solvers/eigsolve.jl GitHub Actions / format
|
||
|
||
Check warning on line 13 in src/solvers/eigsolve.jl GitHub Actions / format
|
||
default_updater_kwargs=(; | ||
solver_which_eigenvalue=:SR, | ||
ishermitian=true, | ||
solver_tol=1e-14, | ||
solver_krylovdim=3, | ||
solver_maxiter=1, | ||
solver_verbosity=0, | ||
) | ||
function solver( | ||
init; | ||
psi_ref!, | ||
PH_ref!, | ||
normalize, | ||
region, | ||
sweep_regions, | ||
sweep_step, | ||
sweep_kwargs..., | ||
# slurp solver_kwargs? #TODO: homogenize how the solver kwargs are passed | ||
tol=1e-14, | ||
krylovdim=3, | ||
maxiter=1, | ||
outputlevel=0, | ||
eager=false, | ||
) | ||
howmany = 1 | ||
which = solver_which_eigenvalue | ||
vals, vecs, info = eigsolve( | ||
PH_ref![], | ||
updater_kwargs=merge(default_updater_kwargs,updater_kwargs) #last collection has precedence | ||
Check warning on line 23 in src/solvers/eigsolve.jl GitHub Actions / format
|
||
howmany=1 | ||
which=updater_kwargs[:solver_which_eigenvalue] | ||
vals, vecs, info = KrylovKit.eigsolve(PH_ref![], | ||
init, | ||
howmany, | ||
which; | ||
ishermitian, | ||
tol=solver_tol, | ||
krylovdim=solver_krylovdim, | ||
maxiter=solver_maxiter, | ||
verbosity=solver_verbosity, | ||
ishermitian=updater_kwargs[:ishermitian], | ||
tol=updater_kwargs[:tol], | ||
krylovdim=updater_kwargs[:krylovdim], | ||
maxiter=updater_kwargs[:maxiter], | ||
verbosity=updater_kwargs[:outputlevel], | ||
eager=updater_kwargs[:eager], | ||
) | ||
phi = vecs[1] | ||
return phi, (; solver_info=info, energies=vals) | ||
end | ||
return solver | ||
return vecs[1], (; info, energies=vals) | ||
end | ||
|
||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,59 @@ | ||
""" | ||
Overload of `ITensors.dmrg`. | ||
""" | ||
|
||
|
||
function dmrg_sweep( | ||
nsite::Int, | ||
graph::AbstractGraph; | ||
root_vertex=default_root_vertex(graph), | ||
) | ||
return tdvp_sweep(2,nsite,Inf,graph;root_vertex,reverse_step=false) | ||
end | ||
|
||
|
||
function default_sweep_regions(nsite, graph::AbstractGraph; kwargs...) ###move this to a different file, algorithmic level idea | ||
return vcat( | ||
[ | ||
half_sweep( | ||
direction(half), | ||
graph, | ||
make_region; | ||
nsite, | ||
region_args=(; substep=half), | ||
kwargs..., | ||
) for half in 1:2 | ||
]..., | ||
) | ||
end | ||
|
||
function dmrg( | ||
updater, | ||
H, | ||
init::AbstractTTN; | ||
solver_which_eigenvalue=:SR, | ||
ishermitian=true, | ||
solver_tol=1e-14, | ||
solver_krylovdim=3, | ||
solver_maxiter=1, | ||
solver_verbosity=0, | ||
nsweeps, #it makes sense to require this to be defined | ||
nsite=2, | ||
(sweep_observer!)=observer(), | ||
root_vertex=default_root_vertex(init), | ||
updater_kwargs=NamedTuple(;), | ||
kwargs..., | ||
) | ||
return alternating_update( | ||
eigsolve_solver(; | ||
solver_which_eigenvalue, | ||
ishermitian, | ||
solver_tol, | ||
solver_krylovdim, | ||
solver_maxiter, | ||
solver_verbosity, | ||
), | ||
H, | ||
init; | ||
reverse_step=false, | ||
kwargs..., | ||
) | ||
region_updates = dmrg_sweep(nsite,init; root_vertex) | ||
|
||
psi = alternating_update( | ||
updater, H, init; nsweeps, sweep_observer!, region_updates, updater_kwargs, kwargs... | ||
) | ||
return psi | ||
end | ||
|
||
|
||
function dmrg(H, init::AbstractTTN; updater=eigsolve_updater, kwargs...) | ||
return dmrg(updater, H, init; kwargs...) | ||
end | ||
|
||
""" | ||
Overload of `KrylovKit.eigsolve`. | ||
""" | ||
eigsolve(H, init::AbstractTTN; kwargs...) = dmrg(H, init; kwargs...) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters