Skip to content

Commit 19fae27

Browse files
BlockTensorMap (#199)
This is an admittedly too large PR that involves changing the MPO tensors and associated environments to start using `BlockTensorKit`. This allows a large amount of code logic to be offloaded and separated out, which leads to overall better readability, and should improve maintenance and development of this package in the future. --- * Update for TensorKit changes * Add FiniteMPOHamiltonian * Add linearalgebra * Rewrite Operators * Add virtualspace functions QP * Add `axes` multiline * Add PeriodicVector and PeriodicMatrix constructors * update tests * Start refactor environments * update SVDCut * Update excitations * Update TimeEvolution MPO * Update ED * update derivatives and transfers * Add utility functions * Update convenience functions * fix very important typo * compat with TensorKitManifolds * remove @shows * change opp to operator, like it is in `MultipleEnvironments` * add copy methods for `FiniteMPOHamiltonian` and `InfiniteMPOHamiltonian` * add creation of `FiniteMPOHamiltonian` and `InfiniteMPOHamiltonian` directly from a local operator * change MPOHamiltonian copies to deepcopies * implement scalar multiplication for `FiniteMPOHamiltonian` and `InfiniteMPOHamiltonian` * split MPOHamiltonian creation from local operator into Finite and Infinite case * fix typo in fidelity susceptibility testset * change WI() to WI * check for (and don't add) zero-valued A-blocks in `AbstractMPOHamiltonian` addition * formatting * remove creation of `FiniteMPOHamiltonian` from local operator * update BlockTensorKit compat * Add WindowMPS environments * Add convenience methods quasiparticles * Fix small typo * Add length to quasiparticle state tests * Relax MPO setindex * fix some wrong references to fields * Small style change in linalg * Update some mpo linalg * change tensortype inference in `*(::InfiniteMPOHamiltonian, ::InfiniteMPOHamiltonian)` * convenience methods * Fix some operator tests * update DenseMPO * Fix type signature * add `open_boundary_conditions` and extend all boundary condition methods to `InfiniteMPOHamiltonian`s * Add more physicalspace methods * readd `propagator` methods and change function signatures to new types * Add conj * implementing fix from `*(::Inf.Ham.,::Inf.Ham)` in the finite case * some more test/operators fixes * add `randomize!(::AbstractBlockTensorMap)` * Add *(::InfiniteMPO, ::InfiniteMPS) * use methods instead of removed MPO properties * add creation of `InfiniteMPO` from `AbstractTensorMaps` * fix creation of `DenseMPO` * fix periodic boundary conditions test * physicalspace never returns SumSpace * Fix `*(::InfiniteMPO, ::InfiniteMPS)` * More operator test fixes * Some more linalg cleanup * some more operators test cleanup * change dynamical DMRG test case * Fix DynamicalDMRG * add `show()` for `AbstractMPO`s * Add / for multiplied operator * small fix * Add dropzeros in H*H * add `BlockTensorKit.show_braille(::AbstractHMPO)` * important copy fix * little bit cleanup * More generic linalg * Clean up MPO structs * Fix infiniteMPOEnvironments * Fix expval for mpo * fix overlylong excitations test * fidelity_susceptibility fix * Changes to accomodate new `MPOHamiltonian` type * Extend `BlockTensorKit.show_braille()` to SparseMPOs * drop zeros after imposing PBC * change `make_time_mpo` to be compatible with `FiniteMPOHamiltonian`s * implement `remove_orphans` for `FiniteMPO`s * add conversion to `DenseMPO` from `MPOHamiltonian`s * remove redundant check in `remove_orphans!(::FiniteMPO)` * fix multiplication of `FiniteMPOHamiltonian`s * move boundary condition application step * use `droptol!()` * use `droptol!()` * rename `BlockTensorKit.braille(::SparseMPO)` to `braille(::SparseMPO)` for convenience * add assert for MPOs that aren't the same size everywhere * use finite Hamiltonian for finite mps test * add L parameter to approximate tests * fix converting Hamiltonian to 'square' one * change only() to TensorMap() * compensate for env fieldname changes * compensate for env namechange * change approximate test * remove return statement for aesthetics and consistency * use dot notation for dropzeros in periodic_boundary_conditions * change boundary condition application in pbc * delete old environment stuct and code * rename permpoinfenv to infinitempoenv * add `FiniteMPO` to finite environments arguments * change `permpoinfenv` to `InfiniteMPOEnvironments` in docs * oneline `dropzeros` step in `periodic_boundary_conditions` * implement new test for `periodic_boundary_conditions` and comment out the old one * formatting change * Version changes * robust `storagetype` handling * implement pr 180 '3 site tests' into blocktensor2 branch * format * cleanup and fix `force_planar` * Fix arguments being reversed * Fix periodic boundary * formatter * Fix deprecation warning in test * Improve implementation of multiplying MPOs * Fix for InfiniteMPOHamiltonian * Remove `RecursiveVec` * Update outdated names * improve MPOHamiltonian constructors * Add `add_physical_charge` * fixes MPO constructor * Fix mpohamiltonian constructor * Fix `make_time_mpo` extensions step * TaylorCluster optimizations * Update gitignore * change test tol * update oplus syntax * Bump julia version in tests * Rename environments/files and cleanup unused code * remove more unused code * remove more unused code * small fix in examples * Add Aqua and fix some tests * more unused code deletion * more unused code deletion * small formatting change * revert Aqua-related change * Restrict Aqua tests for now * more unused code removal * more unused code removal * improve test stability * minor doc updates * Temporary fix for docs --------- Co-authored-by: Victor <[email protected]>
1 parent cd81eef commit 19fae27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+3185
-5578
lines changed

.github/workflows/Tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
version:
26-
- '1.8' # minimal supported version
26+
- 'lts' # minimal supported version
2727
- '1' # latest released Julia version
2828
group:
2929
- states

Project.toml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name = "MPSKit"
22
uuid = "bb1c41ca-d63c-52ed-829e-0820dda26502"
3-
authors = ["Maarten Van Damme", "Jutho Haegeman", "Lukas Devos", "Gertian Roose", "Markus Hauru", "Daan Maertens"]
4-
version = "0.11.6"
3+
authors = "Lukas Devos, Maarten Van Damme and contributors"
4+
version = "0.12.0"
55

66
[deps]
77
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
8+
BlockTensorKit = "5f87ffc2-9cf1-4a46-8172-465d160bd8cd"
89
FLoops = "cc61a311-1640-44b5-9fba-1b764f453329"
910
FastClosures = "9aa1b823-49e4-5ca5-8b0f-3971ec8bab6a"
1011
FoldsThreads = "9c68100b-dfe1-47cf-94c8-95104e173443"
@@ -14,37 +15,48 @@ LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36"
1415
OptimKit = "77e91f04-9b3b-57a6-a776-40b61faaebe0"
1516
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
1617
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
18+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1719
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
1820
TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec"
1921
TensorKitManifolds = "11fa318c-39cb-4a83-b1ed-cdc7ba1e3684"
20-
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
2122
Transducers = "28d57a85-8fef-5791-bfe6-a80928e7c999"
23+
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
2224
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"
2325

2426
[compat]
2527
Accessors = "0.1"
28+
Aqua = "0.8.9"
29+
BlockTensorKit = "0.1.1"
2630
FLoops = "0.1, 0.2"
2731
FastClosures = "0.3"
2832
FoldsThreads = "0.1"
2933
KrylovKit = "0.8.3"
3034
LinearAlgebra = "1.6"
31-
LoggingExtras = "1"
35+
LoggingExtras = "~1.0"
3236
OptimKit = "0.3.1"
37+
Pkg = "1"
38+
Plots = "1.40"
3339
Preferences = "1"
3440
Printf = "1"
41+
Random = "1"
3542
RecipesBase = "1.1"
36-
TensorKit = "0.12"
37-
TensorKitManifolds = "0.5, 0.6, 0.7"
38-
TensorOperations = "4"
43+
TensorKit = "0.13"
44+
TensorKitManifolds = "0.7"
45+
TensorOperations = "5"
46+
Test = "1"
47+
TestExtras = "0.3"
3948
Transducers = "0.4"
49+
TupleTools = "1.6.0"
4050
VectorInterface = "0.2, 0.3, 0.4, 0.5"
41-
julia = "1.8"
51+
julia = "1.10"
4252

4353
[extras]
54+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
4455
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
4556
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
57+
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
4658
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
4759
TestExtras = "5ed8adda-3752-4e41-b88a-e8b09835ee3a"
4860

4961
[targets]
50-
test = ["Pkg", "Test", "TestExtras", "Plots"]
62+
test = ["Aqua", "Pkg", "Test", "TestExtras", "Plots"]

docs/Project.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
33
KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77"
44
MPSKit = "bb1c41ca-d63c-52ed-829e-0820dda26502"
5-
MPSKitModels = "ca635005-6f8c-4cd1-b51d-8491250ef2ab"
65
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
76
Polynomials = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
87
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"

docs/src/index.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ operators and models.
3737
using TensorOperations
3838
using TensorKit
3939
using MPSKit
40-
using MPSKitModels
4140
using LinearAlgebra: norm
4241
```
4342

@@ -48,7 +47,6 @@ using LinearAlgebra
4847
using TensorOperations
4948
using TensorKit
5049
using MPSKit
51-
using MPSKitModels
5250
```
5351

5452
Finite MPS are characterised by a set of tensors, one for each site, which each have 3 legs.
@@ -106,10 +104,16 @@ Using the pre-defined models in `MPSKitModels`, we can construct the groundstate
106104
transverse field Ising model:
107105

108106
```@example finitemps
109-
H = transverse_field_ising(; J=1.0, g=0.5)
107+
J = 1.0
108+
g = 0.5
109+
lattice = fill(ComplexSpace(2), 10)
110+
X = TensorMap(ComplexF64[0 1; 1 0], ComplexSpace(2), ComplexSpace(2))
111+
Z = TensorMap(ComplexF64[1 0; 0 -1], space(X))
112+
H = FiniteMPOHamiltonian(lattice, (i, i+1) => -J * X ⊗ X for i in 1:length(lattice)-1) +
113+
FiniteMPOHamiltonian(lattice, (i,) => - g * Z for i in 1:length(lattice))
110114
find_groundstate!(mps, H, DMRG(; maxiter=10))
111115
E0 = expectation_value(mps, H)
112-
println("<mps|H|mps> = $(sum(real(E0)) / length(mps))")
116+
println("<mps|H|mps> = $real(E0)")
113117
```
114118

115119
### Infinite Matrix Product States
@@ -119,7 +123,6 @@ using LinearAlgebra
119123
using TensorOperations
120124
using TensorKit
121125
using MPSKit
122-
using MPSKitModels
123126
```
124127

125128
Similarly, an infinite MPS can be constructed by specifying the tensors for the unit cell,
@@ -173,11 +176,16 @@ println("<mps|𝕀₁|mps> = $N2")
173176
observable computed from the MPS would either blow up to infinity or vanish to zero.
174177

175178
Finally, the MPS can be optimized in order to determine groundstates of given Hamiltonians.
176-
Using the pre-defined models in `MPSKitModels`, we can construct the groundstate for the
177-
transverse field Ising model:
179+
There are plenty of pre-defined models in `MPSKitModels`, but we can also manually construct
180+
the groundstate for the transverse field Ising model:
178181

179182
```@example infinitemps
180-
H = transverse_field_ising(; J=1.0, g=0.5)
183+
J = 1.0
184+
g = 0.5
185+
lattice = PeriodicVector([ComplexSpace(2)])
186+
X = TensorMap(ComplexF64[0 1; 1 0], ComplexSpace(2), ComplexSpace(2))
187+
Z = TensorMap(ComplexF64[1 0; 0 -1], space(X))
188+
H = InfiniteMPOHamiltonian(lattice, (1, 2) => -J * X ⊗ X, (1,) => - g * Z)
181189
mps, = find_groundstate(mps, H, VUMPS(; maxiter=10))
182190
E0 = expectation_value(mps, H)
183191
println("<mps|H|mps> = $(sum(real(E0)) / length(mps))")
@@ -212,4 +220,4 @@ request or an issue on the [GitHub repository](https://github.com/QuantumKitHub/
212220
- Gertian Roose, Laurens Vanderstraeten, Jutho Haegeman, and Nick Bultinck. Anomalous domain wall condensation in a modified ising chain. Phys. Rev. B, 99: 195132, May 2019. 10.1103/​PhysRevB.99.195132.
213221
https:/​/​doi.org/​10.1103/​PhysRevB.99.195132
214222
- Roose, G., Bultinck, N., Vanderstraeten, L. et al. Lattice regularisation and entanglement structure of the Gross-Neveu model. J. High Energ. Phys. 2021, 207 (2021). https://doi.org/10.1007/JHEP07(2021)207
215-
- Roose, G., Haegeman, J., Van Acoleyen, K. et al. The chiral Gross-Neveu model on the lattice via a Landau-forbidden phase transition. J. High Energ. Phys. 2022, 19 (2022). https://doi.org/10.1007/JHEP06(2022)019
223+
- Roose, G., Haegeman, J., Van Acoleyen, K. et al. The chiral Gross-Neveu model on the lattice via a Landau-forbidden phase transition. J. High Energ. Phys. 2022, 19 (2022). https://doi.org/10.1007/JHEP06(2022)019

docs/src/lib/lib.md

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,19 @@ MPSMultiline
1010

1111
## Operators
1212
```@docs
13-
FiniteMPO
14-
SparseMPO
15-
DenseMPO
13+
AbstractMPO
14+
MPO
1615
MPOHamiltonian
1716
```
1817

1918
## Environments
2019
```@docs
21-
MPSKit.AbstractInfEnv
22-
MPSKit.PerMPOInfEnv
23-
MPSKit.MPOHamInfEnv
24-
MPSKit.FinEnv
25-
MPSKit.IDMRGEnvs
26-
```
27-
28-
## Generic actions
29-
```@docs
30-
∂C
31-
∂∂C
32-
∂AC
33-
∂∂AC
34-
∂AC2
35-
∂∂AC2
36-
37-
c_proj
38-
ac_proj
39-
ac2_proj
40-
41-
transfer_left
42-
transfer_right
20+
MPSKit.AbstractMPSEnvironments
21+
MPSKit.AbstractInfiniteEnvironments
22+
MPSKit.InfiniteMPOEnvironments
23+
MPSKit.InfiniteMPOHamiltonianEnvironments
24+
MPSKit.FiniteEnvironments
25+
MPSKit.IDMRGEnvironments
4326
```
4427

4528
## Algorithms

docs/src/man/algorithms.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
```@meta
2-
DocTestSetup = quote
3-
using MPSKit, MPSKitModels, TensorKit
4-
end
2+
DocTestSetup = :( using MPSKit, TensorKit)
53
```
64

75
# [Algorithms](@id um_algorithms)
@@ -168,7 +166,9 @@ in the transverse field Ising model, we calculate the first excited state as sho
168166
provided code snippet, amd check the accuracy against theoretical values. Some deviations
169167
are expected, both due to finite-bond-dimension and finite-size effects.
170168

171-
```jldoctest; output = false
169+
<!-- TODO: reenable doctest -->
170+
171+
```julia
172172
# Model parameters
173173
g = 10.0
174174
L = 16
@@ -194,7 +194,9 @@ in the unit cell in a plane-wave superposition, requiring momentum specification
194194
[Haldane gap](https://iopscience.iop.org/article/10.1088/0953-8984/1/19/001) computation in
195195
the Heisenberg model illustrates this approach.
196196

197-
```jldoctest; output = false
197+
<!-- TODO: reenable doctest -->
198+
199+
```julia
198200
# Setting up the model and momentum
199201
momentum = π
200202
H = heisenberg_XXX()
@@ -219,7 +221,9 @@ trivial total charge. However, quasiparticles with different charges can be obta
219221
the sector keyword. For instance, in the transverse field Ising model, we consider an
220222
excitation built up of flipping a single spin, aligning with `Z2Irrep(1)`.
221223

222-
```jldoctest; output = false
224+
<!-- TODO: reenable doctest -->
225+
226+
```julia
223227
g = 10.0
224228
L = 16
225229
H = transverse_field_ising(Z2Irrep; g)
@@ -260,7 +264,9 @@ often referred to as the 'Chepiga ansatz', named after one of the authors of thi
260264

261265
This is supported via the following syntax:
262266

263-
```jldoctest
267+
<!-- TODO: reenable doctest -->
268+
269+
```julia
264270
g = 1.0
265271
L = 16
266272
H = transverse_field_ising(; g)
@@ -278,7 +284,9 @@ true
278284
In order to improve the accuracy, a two-site version also exists, which varies two
279285
neighbouring sites:
280286

281-
```jldoctest
287+
<!-- TODO: reenable doctest -->
288+
289+
```julia
282290
g = 1.0
283291
L = 16
284292
H = transverse_field_ising(; g)

docs/src/man/operators.md

Lines changed: 15 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ O_xzx_sum * FiniteMPS(3, ℂ^2, ℂ^4)
7171
make sure that the virtual spaces do not increase past the maximal virtual space that
7272
is dictated by the requirement of being full-rank tensors.
7373

74-
## MPOHamiltonian
74+
## FiniteMPOHamiltonian
7575

7676
We can also represent quantum Hamiltonians in the same form. This is done by converting a
7777
sum of local operators into a single MPO operator. The resulting operator has a very
7878
specific structure, and is often referred to as a *Jordan block MPO*.
7979

80-
This object can be constructed as an MPO by using the [`MPOHamiltonian`](@ref) constructor,
80+
This object can be constructed as an MPO by using the [`FiniteMPOHamiltonian`](@ref) constructor,
8181
which takes two crucial pieces of information:
8282

8383
1. An array of `VectorSpace` objects, which determines the local Hilbert spaces of the
@@ -103,16 +103,16 @@ h = 0.5
103103
chain = fill(ℂ^2, 3) # a finite chain of 4 sites, each with a 2-dimensional Hilbert space
104104
single_site_operators = [1 => -h * S_z, 2 => -h * S_z, 3 => -h * S_z]
105105
two_site_operators = [(1, 2) => -J * S_x ⊗ S_x, (2, 3) => -J * S_x ⊗ S_x]
106-
H_ising = MPOHamiltonian(chain, single_site_operators..., two_site_operators...);
106+
H_ising = FiniteMPOHamiltonian(chain, single_site_operators..., two_site_operators...);
107107
```
108108

109109
Various alternative constructions are possible, such as using a `Dict` with key-value pairs
110110
that specify the operators, or using generator expressions to simplify the construction.
111111

112112
```@example operators
113-
H_ising′ = -J * MPOHamiltonian(chain,
113+
H_ising′ = -J * FiniteMPOHamiltonian(chain,
114114
(i, i + 1) => S_x ⊗ S_x for i in 1:(length(chain) - 1)) -
115-
h * MPOHamiltonian(chain, i => S_z for i in 1:length(chain))
115+
h * FiniteMPOHamiltonian(chain, i => S_z for i in 1:length(chain))
116116
isapprox(H_ising, H_ising′; atol=1e-6)
117117
```
118118

@@ -147,9 +147,9 @@ for I in eachindex(IndexCartesian(), square)
147147
end
148148
end
149149
150-
H_ising_2d = MPOHamiltonian(square, local_operators) +
151-
MPOHamiltonian(square, horizontal_operators) +
152-
MPOHamiltonian(square, vertical_operators);
150+
H_ising_2d = FiniteMPOHamiltonian(square, local_operators) +
151+
FiniteMPOHamiltonian(square, horizontal_operators) +
152+
FiniteMPOHamiltonian(square, vertical_operators);
153153
```
154154

155155
There are various utility functions available for constructing more advanced lattices, for
@@ -224,20 +224,22 @@ Vᵣ = [0, 0, 1]
224224
expand(Vₗ * prod(Ws) * Vᵣ)
225225
```
226226

227-
The `MPOHamiltonian` constructor can also be used to construct the operator from this most
227+
The `FiniteMPOHamiltonian` constructor can also be used to construct the operator from this most
228228
general form, by supplying a 3-dimensional array $W$ to the constructor. Here, the first
229229
dimension specifies the site in the unit cell, the second dimension specifies the row of the
230230
matrix, and the third dimension specifies the column of the matrix.
231231

232-
```@example operators
232+
<!-- TODO: reenable doctest -->
233+
234+
```julia
233235
data = Array{Any,3}(missing, 1, 3, 3) # missing is interpreted as zero
234-
data[1, 1, 1] = id(Matrix{ComplexF64}, ℂ^2)
236+
data[1, 1, 1] = id(ComplexF64, ℂ^2)
235237
data[1, 3, 3] = 1 # regular numbers are interpreted as identity operators
236238
data[1, 1, 2] = -J * S_x
237239
data[1, 2, 3] = S_x
238240
data[1, 1, 3] = -h * S_z
239241
data_range = repeat(data, 4, 1, 1) # make 4 sites long
240-
H_ising″ = MPOHamiltonian(data_range)
242+
H_ising″ = FiniteMPOHamiltonian(data_range)
241243
```
242244

243245
MPSKit will then automatically attach the correct boundary vectors to the Hamiltonian whenever this is required.
@@ -255,42 +257,11 @@ MPSKit will then automatically attach the correct boundary vectors to the Hamilt
255257
!!! warning
256258
This part is still a work in progress
257259

258-
Because of the discussion above, the `MPOHamiltonian` object is in fact just a `FiniteMPO`,
260+
Because of the discussion above, the `FiniteMPOHamiltonian` object is in fact just an `AbstractMPO`,
259261
with some additional structure. This means that similar operations and properties are
260262
available, such as the virtual spaces, or the individual tensors. However, the block
261263
structure of the operator means that now the virtual spaces are not just a single space, but
262264
a collection (direct sum) of spaces, one for each row/column.
263265

264266
<!-- TODO: add examples virtualspace once blocktensors are in place -->
265267

266-
## DenseMPO
267-
268-
This operator is used for statistical physics problems. It is simply a periodic array of mpo tensors.
269-
270-
Can be created using
271-
```julia
272-
DenseMPO(t::AbstractArray{T,1}) where T<:MPOTensor
273-
```
274-
275-
## SparseMPO
276-
277-
`SparseMPO` is similar to a `DenseMPO`, in that it again represents an mpo tensor, periodically repeated. However this type keeps track of all internal zero blocks, allowing for a more efficient representation of certain operators (such as time evolution operators and quantum hamiltonians). You can convert a sparse mpo to a densempo, but the converse does not hold.
278-
279-
280-
Indexing a `SparseMPO` returns a `SparseMPOSlice` object, which has 3 fields
281-
282-
```@docs
283-
MPSKit.SparseMPOSlice
284-
```
285-
286-
When indexing a `SparseMPOSlice` at index `[j, k]` (or equivalently `SparseMPO[i][j, k]`), the code looks up the corresponding field in `Os[j, k]`. Either that element is a tensormap, in which case it gets returned. If it equals `zero(E)`, then we return a tensormap
287-
```julia
288-
domspaces[j] * pspace pspace * imspaces[k]
289-
```
290-
with norm zero. If the element is a nonzero number, then implicitly we have the identity operator there (multiplied by that element).
291-
292-
The idea here is that you don't have to worry about the underlying structure, you can just index into a sparsempo as if it is a vector of matrices. Behind the scenes we then optimize certain contractions by using the sparsity structure.
293-
294-
SparseMPO are always assumed to be periodic in the first index (position).
295-
In this way, we can both represent periodic infinite mpos and place dependent finite mpos.
296-

0 commit comments

Comments
 (0)