Skip to content

Commit e0cb5bf

Browse files
authored
Updated README. (#8)
1 parent b575567 commit e0cb5bf

File tree

4 files changed

+102
-3
lines changed

4 files changed

+102
-3
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,19 @@ opCacheVec = [
114114

115115
return MPO_new(os, sites; basisOpCacheVec=opCacheVec)
116116
```
117+
118+
## Examples: Electronic Structure Hamiltonian
119+
120+
After looking at the previous example one might assume that the relative speed of ITensorMPOConstruction over Renormalizer might be due to the fact that for the Fermi-Hubbard Hamiltonian ITensorMPOConstruction is able to construct a much more compact MPO. In the case of the electronic structure Hamiltonian all algorithms produce MPOs of similar bond dimensions.
121+
122+
![](./docs/plot-generators/es.png)
123+
124+
However ITensorMPOConstruction is still an order of magnitude faster than Renormalizer. The code for this example can be found in [examples/electronic-structure.jl](https://github.com/ITensor/ITensorMPOConstruction.jl/blob/main/examples/electronic-structure.jl). The run time to generate these MPOs are shown below (again on a 2021 MacBook Pro with the M1 Max CPU and 32GB of memory).
125+
126+
| $N$ | ITensors | Renormalizer | ITensorMPOConstruction |
127+
|-----|----------|--------------|------------------------|
128+
| 10 | 3.0s | 2.1s | 0.37s |
129+
| 20 | 498s | 61s | 7.1s |
130+
| 30 | N/A | 458s | 46s |
131+
| 40 | N/A | 2250s | 183 |
132+
| 50 | N/A | N/A | 510s |

docs/plot-generators/es.png

36.5 KB
Loading

docs/plot-generators/plots.ipynb

Lines changed: 36 additions & 0 deletions
Large diffs are not rendered by default.

docs/plot-generators/renormalizer-plots.py

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import numpy as np
22
from timeit import default_timer as timer
33
from renormalizer import Model, Op, BasisSimpleElectron, Mpo
4+
import random
45

56

6-
def fermiHubbardKS(N, t, U):
7+
def fermi_hubbard_ks(N, t, U):
78
toSite = lambda k, s: 2 * k + s
89

910
terms = []
@@ -22,12 +23,58 @@ def fermiHubbardKS(N, t, U):
2223
model = Model([BasisSimpleElectron(i) for i in range(2 * N)], terms)
2324
return Mpo(model)
2425

26+
27+
def electronic_structure(N):
28+
toSite = lambda k, s: 2 * k + s
29+
coeff = lambda : random.random()
30+
31+
terms = []
32+
for a in range(N):
33+
for b in range(a, N):
34+
factor = coeff()
35+
for spin in (0, 1):
36+
sites = [toSite(a, spin), toSite(b, spin)]
37+
terms.append(Op(r"a^\dagger a", sites, factor))
38+
39+
if a != b:
40+
sites = [toSite(b, spin), toSite(a, spin)]
41+
terms.append(Op(r"a^\dagger a", sites, np.conj(factor)))
42+
43+
for j in range(N):
44+
for s_j in (0, 1):
45+
46+
for k in range(N):
47+
s_k = s_j
48+
if (s_k, k) <= (s_j, j):
49+
continue
50+
51+
for l in range(N):
52+
for s_l in (0, 1):
53+
if (s_l, l) <= (s_j, j):
54+
continue
55+
56+
for m in range(N):
57+
s_m = s_l
58+
if (s_m, m) <= (s_k, k):
59+
continue
60+
61+
value = coeff()
62+
sites = [toSite(j, s_j), toSite(l, s_l), toSite(m, s_m), toSite(k, s_k)]
63+
terms.append(Op(r"a^\dagger a^\dagger a a", sites, factor))
64+
65+
sites = list(reversed(sites))
66+
terms.append(Op(r"a^\dagger a^\dagger a a", sites, np.conj(factor)))
67+
68+
model = Model([BasisSimpleElectron(i) for i in range(2 * N)], terms)
69+
return Mpo(model)
70+
71+
2572
numSites = []
2673
bondDims = []
2774
times = []
28-
for N in [10, 20, 30, 40, 50]:
75+
for N in [40]:
2976
start = timer()
30-
mpo = fermiHubbardKS(N, 1, 4)
77+
mpo = electronic_structure(N)
3178
stop = timer()
3279

3380
numSites.append(N)

0 commit comments

Comments
 (0)