Skip to content

Commit

Permalink
update examples in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
lkdvos committed Jul 27, 2023
1 parent c1ec984 commit 46eadbc
Show file tree
Hide file tree
Showing 19 changed files with 3,040 additions and 4 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
docs/build
docs/src/examples
Manifest.toml
.vscode
14 changes: 14 additions & 0 deletions docs/src/examples/classic2d/1.hard-hexagon/hexagon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
169 changes: 169 additions & 0 deletions docs/src/examples/classic2d/1.hard-hexagon/index.md

Large diffs are not rendered by default.

155 changes: 155 additions & 0 deletions docs/src/examples/classic2d/1.hard-hexagon/main.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
{
"cells": [
{
"cell_type": "markdown",
"source": [
"# The Hard Hexagon model\n",
"\n",
"![logo](hexagon.svg)\n",
"\n",
"Tensor networks are a natural way to do statistical mechanics on a lattice.\n",
"As an example of this we will extract the central charge of the hard hexagon model.\n",
"This model is known to have central charge 0.8, and has very peculiar non-local (anyonic) symmetries.\n",
"Because TensorKit supports anyonic symmetries, so does MPSKit.\n",
"To follow the tutorial you need the following packages."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"using MPSKit, MPSKitModels, TensorKit, Plots, Polynomials\n",
"import TensorOperations; TensorOperations.disable_cache(); # hide"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"The [hard hexagon model](https://en.wikipedia.org/wiki/Hard_hexagon_model) is a 2-dimensional lattice model of a gas, where particles are allowed to be on the vertices of a triangular lattice, but no two particles may be adjacent.\n",
"This can be encoded in a transfer matrix with a local MPO tensor using anyonic symmetries, and the resulting MPO has been implemented in MPSKitModels.\n",
"\n",
"In order to use these anyonic symmetries, we need to generalise the notion of the bond dimension and define how it interacts with the symmetry. Thus, we implement away of converting integers to symmetric spaces of the given dimension, which provides a crude guess for how the final MPS would distribute its Schmidt spectrum."
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"mpo = hard_hexagon()\n",
"P = space(mpo.opp[1], 2)\n",
"function virtual_space(D::Integer)\n",
" _D = round(Int, D / sum(dim, values(FibonacciAnyon)))\n",
" return Vect[FibonacciAnyon](sector => _D for sector in (:I, :τ))\n",
"end\n",
"\n",
"@assert isapprox(dim(virtual_space(100)), 100; atol=3)"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"## The leading boundary\n",
"\n",
"One way to study statistical mechanics in infinite systems with tensor networks is by approximating the dominant eigenvector of the transfer matrix by an MPS.\n",
"This dominant eigenvector contains a lot of hidden information.\n",
"For example, the free energy can be extracted by computing the expectation value of the mpo.\n",
"Additionally, we can compute the entanglement entropy as well as the correlation length of the state:"
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"D = 10\n",
"V = virtual_space(D)\n",
"ψ₀ = InfiniteMPS([P], [V])\n",
"ψ, envs, = leading_boundary(ψ₀, mpo, VUMPS(; verbose=false))\n",
"F = real(first(expectation_value(ψ, mpo)))\n",
"S = real(first(entropy(ψ)))\n",
"ξ = correlation_length(ψ)\n",
"println(\"F = $F\\tS = $S\\tξ = $ξ\")"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"## The scaling hypothesis\n",
"\n",
"The dominant eigenvector is of course only an approximation. The finite bond dimension enforces a finite correlation length, which effectively introduces a length scale in the system. This can be exploited to formulate a [scaling hypothesis](https://arxiv.org/pdf/0812.2903.pdf), which in turn allows to extract the central charge.\n",
"\n",
"First we need to know the entropy and correlation length at a bunch of different bond dimensions. Our approach will be to re-use the previous approximated dominant eigenvector, and then expanding its bond dimension and re-running VUMPS.\n",
"According to the scaling hypothesis we should have $S \\propto \\frac{c}{6} log(ξ)$. Therefore we should find $c$ using"
],
"metadata": {}
},
{
"outputs": [],
"cell_type": "code",
"source": [
"function scaling_simulations(ψ₀, mpo, Ds; verbose=false, tol=1e-6)\n",
" entropies = similar(Ds, Float64)\n",
" correlations = similar(Ds, Float64)\n",
" alg = VUMPS(; verbose=verbose, tol_galerkin=tol)\n",
"\n",
" ψ, envs, = leading_boundary(ψ₀, mpo, alg)\n",
" entropies[1] = real(entropy(ψ)[1])\n",
" correlations[1] = correlation_length(ψ)\n",
"\n",
" for (i, d) in enumerate(diff(Ds))\n",
" ψ, envs = changebonds(ψ, mpo, OptimalExpand(; trscheme=truncdim(d)), envs)\n",
" ψ, envs, = leading_boundary(ψ, mpo, alg, envs)\n",
" entropies[i+1] = real(entropy(ψ)[1])\n",
" correlations[i+1] = correlation_length(ψ)\n",
" end\n",
" return entropies, correlations\n",
"end\n",
"\n",
"\n",
"bond_dimensions = 10:5:25\n",
"ψ₀ = InfiniteMPS([P], [virtual_space(bond_dimensions[1])])\n",
"Ss, ξs = scaling_simulations(ψ₀, mpo, bond_dimensions)\n",
"\n",
"f = fit(log.(ξs), 6 * Ss, 1)\n",
"c = f.coeffs[2]\n",
"p = plot(; xlabel=\"logarithmic correlation length\", ylabel=\"entanglement entropy\")\n",
"p = plot(log.(ξs), Ss; seriestype=:scatter, label=nothing)\n",
"plot!(p, ξ -> f(ξ) / 6; label=\"fit\")"
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"source": [
"---\n",
"\n",
"*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*"
],
"metadata": {}
}
],
"nbformat_minor": 3,
"metadata": {
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.9.2"
},
"kernelspec": {
"name": "julia-1.9",
"display_name": "Julia 1.9.2",
"language": "julia"
}
},
"nbformat": 4
}
15 changes: 15 additions & 0 deletions docs/src/examples/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Examples

## Quantum (1+1)d

```@contents
Pages = map(file -> joinpath("quantum1d", file, "index.md"), readdir("quantum1d"))
Depth = 1
```

## Classical (2+0)d

```@contents
Pages = map(file -> joinpath("classic2d", file, "index.md"), readdir("classic2d"))
Depth = 1
```
457 changes: 457 additions & 0 deletions docs/src/examples/quantum1d/1.ising-cft/index.md

Large diffs are not rendered by default.

Loading

0 comments on commit 46eadbc

Please sign in to comment.