-
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.
Initial refactor of
alternating_update
(#121)
- Loading branch information
Showing
21 changed files
with
621 additions
and
691 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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
function contract_updater( | ||
init; | ||
state!, | ||
projected_operator!, | ||
outputlevel, | ||
which_sweep, | ||
sweep_plan, | ||
which_region_update, | ||
region_kwargs, | ||
updater_kwargs, | ||
) | ||
v = ITensor(true) | ||
projected_operator = projected_operator![] | ||
for j in sites(projected_operator) | ||
v *= projected_operator.psi0[j] | ||
end | ||
vp = contract(projected_operator, v) | ||
return vp, (;) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function dmrg_x_updater( | ||
init; | ||
state!, | ||
projected_operator!, | ||
outputlevel, | ||
which_sweep, | ||
sweep_plan, | ||
which_region_update, | ||
region_kwargs, | ||
updater_kwargs, | ||
) | ||
# this updater does not seem to accept any kwargs? | ||
default_updater_kwargs = (;) | ||
updater_kwargs = merge(default_updater_kwargs, updater_kwargs) | ||
H = contract(projected_operator![], ITensor(true)) | ||
D, U = eigen(H; ishermitian=true) | ||
u = uniqueind(U, H) | ||
max_overlap, max_ind = findmax(abs, array(dag(init) * U)) | ||
U_max = U * dag(onehot(u => max_ind)) | ||
# TODO: improve this to return the energy estimate too | ||
return U_max, (;) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function eigsolve_updater( | ||
init; | ||
state!, | ||
projected_operator!, | ||
outputlevel, | ||
which_sweep, | ||
sweep_plan, | ||
which_region_update, | ||
region_kwargs, | ||
updater_kwargs, | ||
) | ||
default_updater_kwargs = (; | ||
which_eigval=:SR, | ||
ishermitian=true, | ||
tol=1e-14, | ||
krylovdim=3, | ||
maxiter=1, | ||
verbosity=0, | ||
eager=false, | ||
) | ||
updater_kwargs = merge(default_updater_kwargs, updater_kwargs) #last collection has precedence | ||
howmany = 1 | ||
(; which_eigval) = updater_kwargs | ||
updater_kwargs = Base.structdiff(updater_kwargs, (; which_eigval=nothing)) | ||
vals, vecs, info = eigsolve( | ||
projected_operator![], init, howmany, which_eigval; updater_kwargs... | ||
) | ||
return vecs[1], (; info, eigvals=vals) | ||
end | ||
|
||
function _pop_which_eigenvalue(; which_eigenvalue, kwargs...) | ||
return which_eigenvalue, NamedTuple(kwargs) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function exponentiate_updater( | ||
init; | ||
state!, | ||
projected_operator!, | ||
outputlevel, | ||
which_sweep, | ||
sweep_plan, | ||
which_region_update, | ||
region_kwargs, | ||
updater_kwargs, | ||
) | ||
default_updater_kwargs = (; | ||
krylovdim=30, | ||
maxiter=100, | ||
verbosity=0, | ||
tol=1E-12, | ||
ishermitian=true, | ||
issymmetric=true, | ||
eager=true, | ||
) | ||
|
||
updater_kwargs = merge(default_updater_kwargs, updater_kwargs) #last collection has precedence | ||
result, exp_info = exponentiate( | ||
projected_operator![], region_kwargs.time_step, init; updater_kwargs... | ||
) | ||
return result, (; info=exp_info) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
function linsolve_updater( | ||
init; | ||
state!, | ||
projected_operator!, | ||
outputlevel, | ||
which_sweep, | ||
sweep_plan, | ||
which_region_update, | ||
region_kwargs, | ||
updater_kwargs, | ||
) | ||
default_updater_kwargs = (; | ||
ishermitian=false, tol=1E-14, krylovdim=30, maxiter=100, verbosity=0, a₀, a₁ | ||
) | ||
updater_kwargs = merge(default_updater_kwargs, updater_kwargs) | ||
P = projected_operator![] | ||
(; a₀, a₁) = updater_kwargs | ||
updater_kwargs = Base.structdiff(updater_kwargs, (; a₀=nothing, a₁=nothing)) | ||
b = dag(only(proj_mps(P))) | ||
x, info = KrylovKit.linsolve(P, b, init, a₀, a₁; updater_kwargs...) | ||
return x, (;) | ||
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
Oops, something went wrong.