-
Notifications
You must be signed in to change notification settings - Fork 128
[ITensorMPS] Added option for MPO-MPS zipup #1536
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
Changes from 8 commits
5a257c8
ec126ba
7040462
74f452a
07f7534
a332ac9
e2979a1
54387b9
08c6cd6
f1f6cc2
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 |
|---|---|---|
|
|
@@ -662,11 +662,16 @@ Choose the method with the `method` keyword, for example | |
| - `mindim::Int=1`: the minimal bond dimension of the resulting MPS. | ||
| - `normalize::Bool=false`: whether or not to normalize the resulting MPS. | ||
| - `method::String="densitymatrix"`: the algorithm to use for the contraction. | ||
| Currently the options are "densitymatrix", where the network formed by the | ||
| MPO and MPS is squared and contracted down to a density matrix which is | ||
| diagonalized iteratively at each site, and "naive", where the MPO and MPS | ||
| tensor are contracted exactly at each site and then a truncation of the | ||
| resulting MPS is performed. | ||
| - "densitymatrix": The network formed by the MPO and MPS is squared and contracted down to | ||
| a density matrix which is diagonalized iteratively at each site. | ||
| - "naive": The MPO and MPS tensor are contracted exactly at each site and then a truncation | ||
| of the resulting MPS is performed. | ||
| - "zipup": The MPO and MPS tensors are contracted then truncated at each site without enforcing | ||
| the appropriate orthogonal gauge. Once this sweep is complete a call to `truncate!` occurs. | ||
| Because the initial truncation is not locally optimal it is recommended to use a loose | ||
| `cutoff` and `maxdim` and then pass the desired truncation parameters to the locally optimal | ||
| `truncate!` sweep via the additional keyword argument `truncate_kwargs`. | ||
| Suggested use is `contract(A, ψ; method="zipup", cutoff=cutoff / 10, maxdim=2 * maxdim, truncate_kwargs=(; cutoff, maxdim))`. | ||
|
|
||
| See also [`apply`](@ref). | ||
| """ | ||
|
|
@@ -822,10 +827,11 @@ end | |
| function ITensors.contract( | ||
| ::Algorithm"zipup", | ||
| A::MPO, | ||
| B::MPO; | ||
| B::AbstractMPS; | ||
| cutoff=1e-14, | ||
| maxdim=maxlinkdim(A) * maxlinkdim(B), | ||
| mindim=1, | ||
| truncate_kwargs=(; cutoff, maxdim, mindim), | ||
| kwargs..., | ||
| ) | ||
| if hassameinds(siteinds, A, B) | ||
|
|
@@ -837,13 +843,13 @@ function ITensors.contract( | |
| N != length(B) && | ||
| throw(DimensionMismatch("lengths of MPOs A ($N) and B ($(length(B))) do not match")) | ||
| # Special case for a single site | ||
| N == 1 && return MPO([A[1] * B[1]]) | ||
| N == 1 && return typeof(B)([A[1] * B[1]]) | ||
| A = orthogonalize(A, 1) | ||
| B = orthogonalize(B, 1) | ||
| A = sim(linkinds, A) | ||
| sA = siteinds(uniqueinds, A, B) | ||
| sB = siteinds(uniqueinds, B, A) | ||
| C = MPO(N) | ||
| C = typeof(B)(N) | ||
| lCᵢ = Index[] | ||
| R = ITensor(true) | ||
| for i in 1:(N - 2) | ||
|
|
@@ -874,7 +880,7 @@ function ITensors.contract( | |
| mindim, | ||
| kwargs..., | ||
| ) | ||
| truncate!(C; kwargs...) | ||
corbett5 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| truncate!(C; truncate_kwargs...) | ||
| return C | ||
| end | ||
|
|
||
|
|
@@ -945,14 +951,20 @@ C = apply(A, B; alg="naive", truncate=false) | |
| in general you should set a `cutoff` value. | ||
| - `maxdim::Int=maxlinkdim(A) * maxlinkdim(B))`: the maximal bond dimension of the results MPS. | ||
| - `mindim::Int=1`: the minimal bond dimension of the resulting MPS. | ||
| - `alg="zipup"`: Either `"zipup"` or `"naive"`. `"zipup"` contracts pairs of | ||
| site tensors and truncates with SVDs in a sweep across the sites, while `"naive"` | ||
| first contracts pairs of tensor exactly and then truncates at the end if `truncate=true`. | ||
| - `truncate=true`: Enable or disable truncation. If `truncate=false`, ignore | ||
| other truncation parameters like `cutoff` and `maxdim`. This is most relevant | ||
| for the `"naive"` version, if you just want to contract the tensors pairwise | ||
| exactly. This can be useful if you are contracting MPOs that have diverging | ||
| norms, such as MPOs originating from sums of local operators. | ||
| - `alg="zipup"`: the algorithm to use for the contraction. Supported algorithms are | ||
| - "naive": The MPO tensors are contracted exactly at each site and then a truncation | ||
| of the resulting MPO is performed. | ||
| - "zipup": The MPO and MPS tensors are contracted then truncated at each site without enforcing | ||
| the appropriate orthogonal gauge. Once this sweep is complete a call to `truncate!` occurs. | ||
| Because the initial truncation is not locally optimal it is recommended to use a loose | ||
| `cutoff` and `maxdim` and then pass the desired truncation parameters to the locally optimal | ||
| `truncate!` sweep via the additional keyword argument `truncate_kwargs`. | ||
| Suggested use is `contract(A, ψ; method="zipup", cutoff=cutoff / 10, maxdim=2 * maxdim, truncate_kwargs=(; cutoff, maxdim))`. | ||
|
||
|
|
||
| See also [`apply`](@ref) for details about the arguments available. | ||
| """ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.