-
Notifications
You must be signed in to change notification settings - Fork 48
Fixing changebonds, some inconsistency remaining #415
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
base: main
Are you sure you want to change the base?
Changes from all commits
989c1d6
e1f8e39
afdc245
9a29b8c
44d514c
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 |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ An algorithm that expands the given mps as described in | |
| [Zauner-Stauber et al. Phys. Rev. B 97 (2018)](@cite zauner-stauber2018), by selecting the | ||
| dominant contributions of a two-site updated MPS tensor, orthogonal to the original ψ. | ||
|
|
||
| changedbonds! is only defined for FiniteMPS, and modify its environment. | ||
|
|
||
| ## Fields | ||
|
|
||
| $(TYPEDFIELDS) | ||
|
|
@@ -17,6 +19,18 @@ $(TYPEDFIELDS) | |
| trscheme::TruncationStrategy | ||
| end | ||
|
|
||
| ##= This is only useful for OptimalExpand | ||
|
lkdvos marked this conversation as resolved.
|
||
| ### Simple wrapper to convert between diffrent type of InifniteMPS. | ||
| function changebonds( | ||
| ψ::InfiniteMPS, operator::InfiniteMPO, alg::OptimalExpand, envs = environments(ψ, operator) | ||
| ) | ||
| ψ′, envs′ = changebonds( | ||
| convert(MultilineMPS, ψ), convert(MultilineMPO, operator), alg, Multiline([envs]) | ||
| ) | ||
| return convert(InfiniteMPS, ψ′), only(parent(envs′)) | ||
| end | ||
| # =# | ||
|
|
||
| function changebonds( | ||
| ψ::InfiniteMPS, H::InfiniteMPOHamiltonian, alg::OptimalExpand, | ||
| envs = environments(ψ, H) | ||
|
|
@@ -39,7 +53,7 @@ function changebonds( | |
| end | ||
|
|
||
| newψ = _expand(ψ, AL′, AR′) | ||
| recalculate!(envs, newψ, H) | ||
| envs = environments(newψ, H) | ||
|
Member
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. I'm not entirely following this change. Is it not possible to overwrite the old environments?
Member
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. Ah, I think I see now what you intended: is it that the non-bang (!) functions shouldn't modify their inputs? |
||
| return newψ, envs | ||
| end | ||
|
|
||
|
|
@@ -64,13 +78,14 @@ function changebonds(ψ::MultilineMPS, H, alg::OptimalExpand, envs = environment | |
| end | ||
|
|
||
| newψ = _expand(ψ, AL′, AR′) | ||
| recalculate!(envs, newψ, H) | ||
| envs = environments(newψ, H) # recalculate!(envs, newψ, H) | ||
|
Member
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. Same comment here |
||
| return newψ, envs | ||
| end | ||
|
|
||
| function changebonds(ψ::AbstractFiniteMPS, H, alg::OptimalExpand, envs = environments(ψ, H)) | ||
| return changebonds!(copy(ψ), H, alg, envs) | ||
| end | ||
|
|
||
| function changebonds!(ψ::AbstractFiniteMPS, H, alg::OptimalExpand, envs = environments(ψ, H)) | ||
| #inspired by the infinite mps algorithm, alternative is to use https://arxiv.org/pdf/1501.05504.pdf | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -9,6 +9,9 @@ parallel, and therefore the expansion will never go beyond the local two-site su | |||||
| The truncation strategy dictates the number of expanded states, by generating uniformly | ||||||
| distributed weights for each state in the two-site space and truncating that. | ||||||
|
|
||||||
| The environments are not used here. | ||||||
| changebonds! modify both the provided state and environments. | ||||||
|
Member
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.
Suggested change
|
||||||
|
|
||||||
| ## Fields | ||||||
|
|
||||||
| $(TYPEDFIELDS) | ||||||
|
|
@@ -50,6 +53,19 @@ end | |||||
| changebonds(ψ::AbstractMPS, alg::RandExpand) = changebonds!(copy(ψ), alg) | ||||||
| changebonds(ψ::MultilineMPS, alg::RandExpand) = changebonds!(copy(ψ), alg) | ||||||
|
|
||||||
| function changebonds(ψ, H, alg::RandExpand, envs) | ||||||
| newψ = changebonds(ψ, alg) | ||||||
| return newψ, environments(newψ, H) | ||||||
| end | ||||||
|
|
||||||
|
|
||||||
| function changebonds!(ψ, H, alg::RandExpand, envs) | ||||||
| ψ = changebonds!(ψ, alg) | ||||||
| recalculate!(envs, ψ, H) | ||||||
| return ψ, envs | ||||||
| end | ||||||
|
|
||||||
|
|
||||||
| function changebonds!(ψ::AbstractFiniteMPS, alg::RandExpand) | ||||||
| for i in 1:(length(ψ) - 1) | ||||||
| AC2 = randomize!(_transpose_front(ψ.AC[i]) * _transpose_tail(ψ.AR[i + 1])) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,8 @@ $(TYPEDEF) | |||||||
|
|
||||||||
| An algorithm that uses a two-site update step to change the bond dimension of a state. | ||||||||
|
|
||||||||
| changedbonds! is not defined. | ||||||||
|
Member
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.
Suggested change
|
||||||||
|
|
||||||||
| ## Fields | ||||||||
|
|
||||||||
| $(TYPEDFIELDS) | ||||||||
|
|
@@ -44,9 +46,8 @@ function changebonds_1( | |||||||
| collapsed = InfiniteMPS( | ||||||||
| [nstate.AL[1]], nstate.C[1]; alg.alg_gauge.tol, alg.alg_gauge.maxiter | ||||||||
| ) | ||||||||
| recalculate!(envs, collapsed, H, collapsed) | ||||||||
|
|
||||||||
| return collapsed, envs | ||||||||
| return collapsed, environments(collapsed, H) | ||||||||
| end | ||||||||
|
|
||||||||
| function changebonds_n(state::InfiniteMPS, H, alg::VUMPSSvdCut, envs = environments(state, H)) | ||||||||
|
|
@@ -75,7 +76,7 @@ function changebonds_n(state::InfiniteMPS, H, alg::VUMPSSvdCut, envs = environme | |||||||
| copied[loc] = AL1 | ||||||||
| copied[loc + 1] = AL2 | ||||||||
| state = InfiniteMPS(copied; alg.alg_gauge.tol, alg.alg_gauge.maxiter) | ||||||||
| recalculate!(envs, state, H, state) | ||||||||
| envs = environments(state, H) | ||||||||
| end | ||||||||
| return state, envs | ||||||||
| 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.