Skip to content

Commit 7fb8f83

Browse files
Add model docstrings (#83)
* add `classical_ising` docstring * update docstring * fix docstring formatting * update `free_energy` kwarg name and add extra ising docstrings * update docstrings * add Potts model docstrings * remove redundant sentence * add ref to potts critical temperature * add sixvertex docstring * add clock model dosctring * add gross_neveu_start docstring * update sixvertex docstring * format bib file * update citation names * fix failing tests * add references in models on homepage * fix spelling mistake in `classical_potts_symmetric` * add documentation comment bot * make the bot use proper punctuation
1 parent e489dc0 commit 7fb8f83

17 files changed

Lines changed: 264 additions & 100 deletions

File tree

.github/workflows/PR_comment.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Docs preview comment
2+
on:
3+
pull_request:
4+
types: [labeled]
5+
6+
permissions:
7+
pull-requests: write
8+
jobs:
9+
pr_comment:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Create PR comment
13+
if: github.event_name == 'pull_request' && github.event.label.name == 'documentation'
14+
uses: thollander/actions-comment-pull-request@v3
15+
with:
16+
message: 'After the build completes, the updated documentation will be available [here](https://victorvanthilt.github.io/TNRKit.jl/previews/PR${{ github.event.number }}/).'
17+
comment-tag: 'preview-doc'

docs/src/assets/tnrkit.bib

Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,88 @@
1+
@article{adachiAnisotropicTensorRenormalization2020,
2+
title = {Anisotropic Tensor Renormalization Group},
3+
author = {Adachi, Daiki and Okubo, Tsuyoshi and Todo, Synge},
4+
year = {2020},
5+
month = aug,
6+
journal = {Physical Review B},
7+
volume = {102},
8+
number = {5},
9+
publisher = {American Physical Society},
10+
doi = {10.1103/PhysRevB.102.054432}
11+
}
12+
13+
@article{adachiBondweightedTensorRenormalization2022,
14+
title = {Bond-Weighted Tensor Renormalization Group},
15+
author = {Adachi, Daiki and Okubo, Tsuyoshi and Todo, Synge},
16+
year = {2022},
17+
month = feb,
18+
journal = {Physical Review B},
19+
volume = {105},
20+
number = {6},
21+
publisher = {American Physical Society},
22+
doi = {10.1103/PhysRevB.105.L060402},
23+
keywords = {TNR Algorithm}
24+
}
125

2-
@article{adachi_bond-weighted_2022,
3-
title = {Bond-weighted tensor renormalization group},
4-
volume = {105},
5-
url = {https://link.aps.org/doi/10.1103/PhysRevB.105.L060402},
6-
doi = {10.1103/PhysRevB.105.L060402},
7-
abstract = {We propose an improved tensor renormalization-group (TRG) algorithm, the bond-weighted TRG (BTRG). In BTRG, we generalize the conventional TRG by introducing bond weights on the edges of the tensor network. We show that BTRG outperforms the conventional TRG and the higher-order tensor renormalization group with the same bond dimension, whereas its computation time is almost the same as that of TRG. Furthermore, BTRG can have nontrivial fixed-point tensors at an optimal hyperparameter. We demonstrate that the singular value spectrum obtained by BTRG is invariant under the renormalization procedure in the case of the two-dimensional Ising model at the critical point. This property indicates that BTRG performs the tensor contraction with high accuracy whereas keeping the scale-invariant structure of tensors.},
8-
number = {6},
9-
urldate = {2024-11-18},
10-
journal = {Physical Review B},
11-
author = {Adachi, Daiki and Okubo, Tsuyoshi and Todo, Synge},
12-
month = feb,
13-
year = {2022},
14-
note = {Publisher: American Physical Society},
15-
keywords = {TNR Algorithm},
16-
pages = {L060402},
17-
file = {APS Snapshot:/home/vvthilt/Zotero/storage/IXUQZVH3/PhysRevB.105.html:text/html;Full Text PDF:/home/vvthilt/Zotero/storage/BA59K9FQ/Adachi et al. - 2022 - Bond-weighted tensor renormalization group.pdf:application/pdf},
26+
@article{akiyamaTensorRenormalizationGroup2024a,
27+
title = {Tensor Renormalization Group for Fermions},
28+
author = {Akiyama, Shinichiro and Meurice, Yannick and Sakai, Ryo},
29+
year = {2024},
30+
month = may,
31+
journal = {Journal of Physics: Condensed Matter},
32+
volume = {36},
33+
number = {34},
34+
publisher = {IOP Publishing},
35+
issn = {0953-8984},
36+
doi = {10.1088/1361-648X/ad4760},
37+
langid = {english}
1838
}
1939

20-
@article{yang_loop_2017,
21-
title = {Loop {Optimization} for {Tensor} {Network} {Renormalization}},
22-
volume = {118},
23-
url = {https://link.aps.org/doi/10.1103/PhysRevLett.118.110504},
24-
doi = {10.1103/PhysRevLett.118.110504},
25-
abstract = {We introduce a tensor renormalization group scheme for coarse graining a two-dimensional tensor network that can be successfully applied to both classical and quantum systems on and off criticality. The key innovation in our scheme is to deform a 2D tensor network into small loops and then optimize the tensors on each loop. In this way, we remove short-range entanglement at each iteration step and significantly improve the accuracy and stability of the renormalization flow. We demonstrate our algorithm in the classical Ising model and a frustrated 2D quantum model.},
26-
number = {11},
27-
urldate = {2024-12-03},
28-
journal = {Physical Review Letters},
29-
author = {Yang, Shuo and Gu, Zheng-Cheng and Wen, Xiao-Gang},
30-
month = mar,
31-
year = {2017},
32-
note = {Publisher: American Physical Society},
33-
keywords = {TNR Algorithm},
34-
pages = {110504},
35-
file = {APS Snapshot:/home/vvthilt/Zotero/storage/DG7Q5V7F/PhysRevLett.118.html:text/html;Full Text PDF:/home/vvthilt/Zotero/storage/7L5XPMGF/Yang et al. - 2017 - Loop Optimization for Tensor Network Renormalization.pdf:application/pdf;Loop TNR supplementary material:/home/vvthilt/Zotero/storage/IL5NTDBS/Yang et al. - 2017 - Loop Optimization for Tensor Network Renormalization.pdf:application/pdf},
40+
@article{levinTensorRenormalizationGroup2007,
41+
title = {Tensor {{Renormalization Group Approach}} to {{Two-Dimensional Classical Lattice Models}}},
42+
author = {Levin, Michael and Nave, Cody P.},
43+
year = {2007},
44+
month = sep,
45+
journal = {Physical Review Letters},
46+
volume = {99},
47+
number = {12},
48+
publisher = {American Physical Society},
49+
doi = {10.1103/PhysRevLett.99.120601},
50+
keywords = {TNR Algorithm}
3651
}
3752

38-
@article{levin_tensor_2007,
39-
title = {Tensor {Renormalization} {Group} {Approach} to {Two}-{Dimensional} {Classical} {Lattice} {Models}},
40-
volume = {99},
41-
url = {https://link.aps.org/doi/10.1103/PhysRevLett.99.120601},
42-
doi = {10.1103/PhysRevLett.99.120601},
43-
abstract = {We describe a simple real space renormalization group technique for two-dimensional classical lattice models. The approach is similar in spirit to block spin methods, but at the same time it is fundamentally based on the theory of quantum entanglement. In this sense, the technique can be thought of as a classical analogue of the density matrix renormalization group method. We demonstrate the method—which we call the tensor renormalization group method—by computing the magnetization of the triangular lattice Ising model.},
44-
number = {12},
45-
urldate = {2025-02-10},
46-
journal = {Physical Review Letters},
47-
author = {Levin, Michael and Nave, Cody P.},
48-
month = sep,
49-
year = {2007},
50-
note = {Publisher: American Physical Society},
51-
keywords = {TNR Algorithm},
52-
pages = {120601},
53-
file = {APS Snapshot:/home/vvthilt/Zotero/storage/IZLKUB5B/PhysRevLett.99.html:text/html;Full Text PDF:/home/vvthilt/Zotero/storage/AYJHLV3C/Levin and Nave - 2007 - Tensor Renormalization Group Approach to Two-Dimensional Classical Lattice Models.pdf:application/pdf},
53+
@article{moritaGlobalOptimizationTensor2021,
54+
title = {Global Optimization of Tensor Renormalization Group Using the Corner Transfer Matrix},
55+
author = {Morita, Satoshi and Kawashima, Naoki},
56+
year = {2021},
57+
month = jan,
58+
journal = {Physical Review B},
59+
volume = {103},
60+
number = {4},
61+
publisher = {American Physical Society},
62+
doi = {10.1103/PhysRevB.103.045131}
5463
}
5564

56-
@article{adachi_anisotropic_2020,
57-
title = {Anisotropic tensor renormalization group},
58-
volume = {102},
59-
url = {https://link.aps.org/doi/10.1103/PhysRevB.102.054432},
60-
doi = {10.1103/PhysRevB.102.054432},
61-
abstract = {We propose a different tensor renormalization group algorithm, anisotropic tensor renormalization group (ATRG), for lattice models in arbitrary dimensions. The proposed method shares the same versatility with the higher-order tensor renormalization group (HOTRG) algorithm, i.e., it preserves the lattice topology after the renormalization. In comparison with HOTRG, both the computation cost and the memory footprint of our method are drastically reduced, especially in higher dimensions, by renormalizing tensors in an anisotropic way after the singular value decomposition. We demonstrate the ability of ATRG for the square lattice and the simple cubic lattice Ising models. Although the accuracy of the present method degrades when compared with HOTRG of the same bond dimension, the accuracy with fixed computation time is improved greatly due to the drastic reduction of the computation cost.},
62-
number = {5},
63-
urldate = {2025-03-04},
64-
journal = {Physical Review B},
65-
author = {Adachi, Daiki and Okubo, Tsuyoshi and Todo, Synge},
66-
month = aug,
67-
year = {2020},
68-
note = {Publisher: American Physical Society},
69-
pages = {054432},
70-
file = {APS Snapshot:/home/vvthilt/Zotero/storage/E6A7899K/PhysRevB.102.html:text/html;Full Text PDF:/home/vvthilt/Zotero/storage/H4K8SDX8/Adachi et al. - 2020 - Anisotropic tensor renormalization group.pdf:application/pdf},
65+
@article{xieCoarsegrainingRenormalizationHigherorder2012,
66+
title = {Coarse-Graining Renormalization by Higher-Order Singular Value Decomposition},
67+
author = {Xie, Z. Y. and Chen, J. and Qin, M. P. and Zhu, J. W. and Yang, L. P. and Xiang, T.},
68+
year = {2012},
69+
month = jul,
70+
journal = {Physical Review B},
71+
volume = {86},
72+
number = {4},
73+
publisher = {American Physical Society},
74+
doi = {10.1103/PhysRevB.86.045139}
7175
}
7276

73-
@article{xie_coarse-graining_2012,
74-
title = {Coarse-graining renormalization by higher-order singular value decomposition},
75-
volume = {86},
76-
url = {https://link.aps.org/doi/10.1103/PhysRevB.86.045139},
77-
doi = {10.1103/PhysRevB.86.045139},
78-
abstract = {We propose a novel coarse-graining tensor renormalization group method based on the higher-order singular value decomposition. This method provides an accurate but low computational cost technique for studying both classical and quantum lattice models in two or three dimensions. We have demonstrated this method using the Ising model on the square and cubic lattices. By keeping up to 16 bond basis states, we obtain by far the most accurate numerical renormalization group results for the three-dimensional Ising model. We have also applied the method to study the ground state as well as finite temperature properties for the two-dimensional quantum transverse Ising model and obtain the results which are consistent with published data.},
79-
number = {4},
80-
urldate = {2025-05-24},
81-
journal = {Physical Review B},
82-
author = {Xie, Z. Y. and Chen, J. and Qin, M. P. and Zhu, J. W. and Yang, L. P. and Xiang, T.},
83-
month = jul,
84-
year = {2012},
85-
note = {Publisher: American Physical Society},
86-
pages = {045139},
87-
file = {APS Snapshot:/home/vvthilt/Zotero/storage/G2NF7VSD/PhysRevB.86.html:text/html;Preprint PDF:/home/vvthilt/Zotero/storage/V3CIZHIS/Xie et al. - 2012 - Coarse-graining renormalization by higher-order singular value decomposition.pdf:application/pdf},
77+
@article{yangLoopOptimizationTensor2017,
78+
title = {Loop {{Optimization}} for {{Tensor Network Renormalization}}},
79+
author = {Yang, Shuo and Gu, Zheng-Cheng and Wen, Xiao-Gang},
80+
year = {2017},
81+
month = mar,
82+
journal = {Physical Review Letters},
83+
volume = {118},
84+
number = {11},
85+
publisher = {American Physical Society},
86+
doi = {10.1103/PhysRevLett.118.110504},
87+
keywords = {TNR Algorithm}
8888
}

docs/src/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ to choose the verbosity level, simply use `run!(...; verbosity=n)`. The default
7171

7272
## Included Models
7373
TNRKit includes several common models out of the box.
74-
- Ising model: `classical_ising(β; h=0)` and `classical_ising_symmetric(β)`, which has a Z2 grading on each leg.
75-
- Potts model: `classical_potts(q, β)` and `classical_potts_symetric(q, β)`, which has a Zq grading on each leg.
76-
- Six Vertex model: `sixvertex(scalartype, spacetype; a=1.0, b=1.0, c=1.0)`
77-
- Clock model: `classical_clock`
74+
- Ising model: [`classical_ising`](@ref) and [`classical_ising_symmetric`](@ref), which has a Z2 grading on each leg.
75+
- Potts model: [`classical_potts`](@ref) and [`classical_potts_symmetric`](@ref), which has a Zq grading on each leg.
76+
- Six Vertex model: [`sixvertex`](@ref)
77+
- Clock model: [`classical_clock`](@ref)
7878
If you want to implement your own model you must respect the leg-convention assumed by all TNRKit schemes.
7979

8080
## Leg-convention

src/models/clock.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
$(SIGNATURES)
3+
4+
Constructs the partition function tensor for the classical clock model with `q` states
5+
and a given inverse temperature `β`.
6+
"""
17
function classical_clock(q::Int64, β::Float64)
28
V =^q
39
A_clock = TensorMap(zeros, V V V V)

src/models/gross-neveu.jl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ function gross_neveu_8_leg_tensor(μ::Number, m::Number, g::Number)
4646
return TensorMap(T, V V V V V V V V)
4747
end
4848

49+
50+
"""
51+
$(SIGNATURES)
52+
53+
Constructs the partition function tensor for the Gross-Neveu model with given parameters `μ`, `m`, and `g`.
54+
55+
### References
56+
* [Akiyama et. al. J. Phys.: Condens. Matter 36 (2024) 343002](@cite akiyamaTensorRenormalizationGroup2024a)
57+
"""
4958
function gross_neveu_start::Number, m::Number, g::Number)
5059
T_unfused = gross_neveu_8_leg_tensor(μ, m, g)
5160
V = Vect[FermionParity](0 => 1, 1 => 1)
@@ -55,6 +64,5 @@ function gross_neveu_start(μ::Number, m::Number, g::Number)
5564
@tensor T_fused[-1 -2; -3 -4] := T_unfused[1 2 3 4; 5 6 7 8] * U[-1; 1 2] * U[-2; 3 4] *
5665
Udg[5 6; -3] * Udg[7 8; -4]
5766

58-
# restore the TNRKit.jl convention
5967
return T_fused
6068
end

src/models/ising.jl

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@ const ising_cft_exact = [
44
3, 3, 3,
55
25 / 8, 25 / 8, 25 / 8, 25 / 8, 25 / 8, 25 / 8,
66
]
7+
const ising_βc_3D = 1.0 / 4.51152469
8+
9+
"""
10+
$(SIGNATURES)
11+
12+
Constructs the partition function tensor for a 2D square lattice
13+
for the classical Ising model with a given inverse temperature `β` and external magnetic field `h`.
14+
15+
### Examples
16+
```julia
17+
classical_ising() # Default inverse temperature is `ising_βc`
18+
classical_ising(0.5; h = 1.0) # Custom inverse temperature and magnetic field.
19+
```
20+
!!! info
21+
When calculating the free energy with `free_energy()`, set the `initial_size` keyword argument to `2.0`.
22+
The initial lattice holds 2 spins.
23+
24+
See also: [`classical_ising_symmetric`](@ref), [`classical_ising_symmetric_3D`](@ref), [`classical_ising_3D`](@ref).
25+
"""
726
function classical_ising::Number; h = 0)
827
function σ(i::Int64)
928
return 2i - 3
@@ -23,6 +42,22 @@ function classical_ising(β::Number; h = 0)
2342
end
2443
classical_ising() = classical_ising(ising_βc)
2544

45+
"""
46+
$(SIGNATURES)
47+
48+
Constructs the partition function tensor for a symmetric 2D square lattice
49+
for the classical Ising model with a given inverse temperature `β`.
50+
51+
This tensor has explicit ℤ₂ symmetry on each of it spaces.
52+
53+
### Examples
54+
```julia
55+
classical_ising_symmetric() # Default inverse temperature is `ising_βc`
56+
classical_ising_symmetric(0.5) # Custom inverse temperature.
57+
```
58+
59+
See also: [`classical_ising`](@ref), [`classical_ising_symmetric_3D`](@ref), [`classical_ising_3D`](@ref).
60+
"""
2661
function classical_ising_symmetric(β)
2762
x = cosh(β)
2863
y = sinh(β)
@@ -38,6 +73,22 @@ classical_ising_symmetric() = classical_ising_symmetric(ising_βc)
3873

3974
const f_onsager::BigFloat = -2.10965114460820745966777928351108478082549327543540531781696107967700291143188081390114126499095041781
4075

76+
"""
77+
$(SIGNATURES)
78+
79+
Constructs the partition function tensor for a symmetric 3D cubic lattice
80+
for the classical Ising model with a given inverse temperature `β`.
81+
82+
This tensor has explicit ℤ₂ symmetry on each of its spaces.
83+
84+
### Examples
85+
```julia
86+
classical_ising_symmetric_3D() # Default inverse temperature is `ising_βc_3D`
87+
classical_ising_symmetric_3D(0.5) # Custom inverse temperature.
88+
```
89+
90+
See also: [`classical_ising_3D`](@ref), [`classical_ising`](@ref), [`classical_ising_symmetric`](@ref).
91+
"""
4192
function classical_ising_symmetric_3D(β)
4293
x = cosh(β)
4394
y = sinh(β)
@@ -55,7 +106,22 @@ function classical_ising_symmetric_3D(β)
55106

56107
return permute(T, ((1, 4), (5, 6, 2, 3)))
57108
end
109+
classical_ising_symmetric_3D() = classical_ising_symmetric_3D(ising_βc_3D)
110+
111+
"""
112+
$(SIGNATURES)
58113
114+
Constructs the partition function tensor for a 3D cubic lattice
115+
for the classical Ising model with a given inverse temperature `β` and coupling constant `J` (by default J = `1.0`).
116+
117+
### Examples
118+
```julia
119+
classical_ising_3D() # Default inverse temperature is `ising_βc_3D`, coupling constant is `J = 1.0`.
120+
classical_ising_3D(0.5; J = 1.0) # Custom inverse temperature and coupling constant.
121+
```
122+
123+
See also: [`classical_ising_symmetric_3D`](@ref), [`classical_ising`](@ref), [`classical_ising_symmetric`](@ref).
124+
"""
59125
function classical_ising_3D(β; J = 1.0)
60126
K = β * J
61127

@@ -75,7 +141,4 @@ function classical_ising_3D(β; J = 1.0)
75141

76142
return TensorMap(o, TMS)
77143
end
78-
const ising_βc_3D = 1.0 / 4.51152469
79-
80-
classical_ising_symmetric_3D() = classical_ising_symmetric_3D(ising_βc_3D)
81144
classical_ising_3D() = classical_ising_3D(ising_βc_3D)

src/models/potts.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
"""
2+
$(SIGNATURES)
3+
4+
returns the inverse critical temperature for the classical q-state Potts model on a 2D square lattice.
5+
6+
See also: [`classical_potts`](@ref), [`classical_potts_symmetric`](@ref).
7+
"""
18
potts_βc(q) = log(1.0 + sqrt(q))
29

10+
"""
11+
$(SIGNATURES)
12+
13+
Constructs the partition function tensor for the classical Potts model with `q` states
14+
and a given inverse temperature `β`.
15+
16+
### Examples
17+
```julia
18+
classical_potts(3) # Default inverse temperature is `potts_βc(3)`
19+
classical_potts(3, 0.5) # Custom inverse temperature.
20+
```
21+
22+
See also: [`classical_potts_symmetric`](@ref), [`potts_βc`](@ref).
23+
"""
324
function classical_potts(q::Int, β::Float64)
425
V =^q
526
A_potts = TensorMap(zeros, V V V V)
@@ -34,6 +55,22 @@ function weyl_heisenberg_matrices(Q::Int, elt = ComplexF64)
3455
return U, V, W / sqrt(Q)
3556
end
3657

58+
"""
59+
$(SIGNATURES)
60+
61+
Constructs the partition function tensor for a symmetric Potts model with `q` states
62+
and a given inverse temperature `β`.
63+
64+
This tensor has explicit ℤq symmetry on each of its spaces.
65+
66+
### Examples
67+
```julia
68+
classical_potts_symmetric(3) # Default inverse temperature is `potts_βc(3)`
69+
classical_potts_symmetric(3, 0.5) # Custom inverse temperature.
70+
```
71+
72+
See also: [`classical_potts`](@ref), [`potts_βc`](@ref).
73+
"""
3774
function classical_potts_symmetric(q::Int64, β::Float64)
3875
V =^q
3976
A_potts = TensorMap(zeros, Float64, V V V V)

0 commit comments

Comments
 (0)