-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor interfaces built around alternating update #121
Changes from all commits
ac76123
b23ab06
c2c5455
ed0df91
db524f7
d258ccc
6ff116a
0ac2f2d
c02662c
1a8ff33
80620b8
4c33d65
114ef3e
b817587
723fae9
1e40a79
5587391
0620943
7865f81
e08ba96
30455a4
86dd746
59f45c1
8bc62fb
ac1a923
2748927
1fe92b3
9e8e635
23cc545
3d5ade8
64ef223
812de92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 |
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 | ||
b-kloss marked this conversation as resolved.
Show resolved
Hide resolved
|
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, | ||
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the plan to combine these into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm ok, I just have found it hard to keep track of the logic of why certain keyword arguments are bundled in certain ways, how they will be used, etc. For example, from the perspective of this function, the only argument I can see that is being used here from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As discussed, these will eventually be bundled together in an upcoming PR. |
||
) | ||
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 |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think
region_update_kwargs
sounds better to me.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though the same discussion on
exponentiate_updater
applies here, I think we should discuss how these are being passed and maybe merge them withupdater_kwargs
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this will be obsolete soon, I am in favor of sticking with
region_kwargs
.