diff --git a/.gitignore b/.gitignore index 8e2b6fec5..6d9656c0c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,9 @@ Manifest.toml .DS_Store **/dev/ benchmark/results + +# DocumenterVitepress / Node build artifacts +**/node_modules/ +**/.vitepress/cache/ +**/.vitepress/dist/ +package-lock.json diff --git a/Project.toml b/Project.toml index 12ef6ed42..d985065a9 100644 --- a/Project.toml +++ b/Project.toml @@ -4,7 +4,7 @@ version = "0.13.13" authors = "Lukas Devos, Maarten Van Damme and contributors" [workspace] -projects = ["test", "docs"] +projects = ["test", "docs", "examples"] [deps] Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697" diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 000000000..0587d7400 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,4 @@ +build/ +node_modules/ +package-lock.json +Manifest.toml \ No newline at end of file diff --git a/docs/Project.toml b/docs/Project.toml index 896f3aeec..dc5e8d2bc 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -4,6 +4,7 @@ name = "MPSKitDocs" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244" DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656" +DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365" KrylovKit = "0b1a1467-8014-51b9-945f-bf0ae24f4b77" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" MPSKit = "bb1c41ca-d63c-52ed-829e-0820dda26502" @@ -18,5 +19,6 @@ TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" MPSKit = {path = ".."} [compat] -Documenter = "1.0" +Documenter = "1.11" DocumenterInterLinks = "1" +DocumenterVitepress = "0.3" diff --git a/docs/make.jl b/docs/make.jl index feba2a849..5922e4ee3 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -8,6 +8,7 @@ end using MPSKit using Documenter +using DocumenterVitepress using DocumenterCitations using DocumenterInterLinks @@ -37,23 +38,12 @@ links = InterLinks( # include MPSKit in all doctests DocMeta.setdocmeta!(MPSKit, :DocTestSetup, :(using MPSKit, TensorKit); recursive = true) -mathengine = MathJax3( - Dict( - :loader => Dict("load" => ["[tex]/physics"]), - :tex => Dict( - "inlineMath" => [["\$", "\$"], ["\\(", "\\)"]], - "tags" => "ams", - "packages" => ["base", "ams", "autoload", "physics"] - ) - ) -) makedocs(; sitename = "MPSKit.jl", - format = Documenter.HTML(; - prettyurls = true, - mathengine, - assets = ["assets/custom.css"], - size_threshold = 1024000, + format = DocumenterVitepress.MarkdownVitepress(; + repo = "github.com/QuantumKitHub/MPSKit.jl", + devbranch = "main", + devurl = "dev", ), pages = [ "Home" => "index.md", @@ -76,4 +66,10 @@ makedocs(; plugins = [bib, links] ) -deploydocs(; repo = "github.com/QuantumKitHub/MPSKit.jl.git", push_preview = true) +DocumenterVitepress.deploydocs(; + repo = "github.com/QuantumKitHub/MPSKit.jl.git", + target = joinpath(@__DIR__, "build"), + branch = "gh-pages", + devbranch = "main", + push_preview = true, +) diff --git a/docs/package.json b/docs/package.json new file mode 100644 index 000000000..046391917 --- /dev/null +++ b/docs/package.json @@ -0,0 +1,20 @@ +{ + "devDependencies": { + "@types/node": "^25.3.5", + "@types/markdown-it-footnote": "^3.0.4" + }, + "scripts": { + "docs:dev": "vitepress dev build/.documenter", + "docs:build": "vitepress build build/.documenter", + "docs:preview": "vitepress preview build/.documenter" + }, + "dependencies": { + "@nolebase/vitepress-plugin-enhanced-readabilities": "^2.18.2", + "@mdit/plugin-mathjax": "^0.26.1", + "@mdit/plugin-tex": "^0.24.1", + "markdown-it-footnote": "^4.0.0", + "markdown-it": "^14.1.0", + "vitepress": "^1.6.4", + "vitepress-plugin-tabs": "^0.8.0" + } +} diff --git a/docs/src/.vitepress/theme/custom.css b/docs/src/.vitepress/theme/custom.css new file mode 100644 index 000000000..bcc238a95 --- /dev/null +++ b/docs/src/.vitepress/theme/custom.css @@ -0,0 +1,21 @@ +/* ===== MPSKit branding ===== */ +/* Accent color matching the (green) MPSKit logo in light mode. + Dark mode already uses the green palette defined by the DVP template. */ +:root { + --vp-c-brand: var(--julia-green); + --vp-c-brand-1: #389826; + --vp-c-brand-2: #2f8420; + --vp-c-brand-3: #277018; + --vp-c-brand-light: #389826; +} + +/* ===== Color-invertible diagrams ===== + The manual embeds line-drawing diagrams (black on transparent) via + `@raw html` . Legible on a light background + as-is; invert them in dark mode so they read as light-on-dark. */ +.color-invertible { + transition: filter 0.2s ease; +} +.dark .color-invertible { + filter: invert(1) hue-rotate(180deg); +} diff --git a/docs/src/.vitepress/theme/index.ts b/docs/src/.vitepress/theme/index.ts new file mode 100644 index 000000000..b300a6900 --- /dev/null +++ b/docs/src/.vitepress/theme/index.ts @@ -0,0 +1,44 @@ +// .vitepress/theme/index.ts +import { h } from 'vue' +import DefaultTheme from 'vitepress/theme' +import type { Theme as ThemeConfig } from 'vitepress' +import 'virtual:mathjax-styles.css'; + +import { + NolebaseEnhancedReadabilitiesMenu, + NolebaseEnhancedReadabilitiesScreenMenu, +} from '@nolebase/vitepress-plugin-enhanced-readabilities/client' + +import VersionPicker from "@/VersionPicker.vue" +import AuthorBadge from '@/AuthorBadge.vue' +import Authors from '@/Authors.vue' +import SidebarDrawerToggle from '@/SidebarDrawerToggle.vue' + +import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client' + +import '@nolebase/vitepress-plugin-enhanced-readabilities/client/style.css' +import './style.css' // template default, auto-supplied to the build by DVP +import './docstrings.css' // template default, auto-supplied to the build by DVP +import './custom.css' // MPSKit customizations (this repo) + +export const Theme: ThemeConfig = { + extends: DefaultTheme, + Layout() { + return h(DefaultTheme.Layout, null, { + 'nav-bar-content-after': () => [ + h(NolebaseEnhancedReadabilitiesMenu), // Enhanced Readabilities menu + ], + // A enhanced readabilities menu for narrower screens (usually smaller than iPad Mini) + 'nav-screen-content-after': () => h(NolebaseEnhancedReadabilitiesScreenMenu), + // Sidebar drawer toggle button (to the left of search bar) + 'nav-bar-content-before': () => h(SidebarDrawerToggle), + }) + }, + enhanceApp({ app, router, siteData }) { + enhanceAppWithTabs(app); + app.component('VersionPicker', VersionPicker); + app.component('AuthorBadge', AuthorBadge) + app.component('Authors', Authors) + } +} +export default Theme \ No newline at end of file diff --git a/docs/src/assets/custom.css b/docs/src/assets/custom.css deleted file mode 100644 index ef9f18328..000000000 --- a/docs/src/assets/custom.css +++ /dev/null @@ -1,42 +0,0 @@ -/* set fixed non-trivial inversion and hue rotation */ -:root { - --inversionFraction: 100%; - --hueRotation: -180deg; -} - -/* color-invert images */ -.color-invertible { - filter: invert(var(--inversionFraction)) hue-rotate(var(--hueRotation)) !important; - -ms-filter: invert(var(--inversionFraction)) !important; - -webkit-filter: invert(var(--inversionFraction)) hue-rotate(var(--hueRotation)) !important; -} -/* including the logo */ -.docs-logo { - filter: invert(var(--inversionFraction)) hue-rotate(var(--hueRotation)) !important; - -ms-filter: invert(var(--inversionFraction)) !important; - -webkit-filter: invert(var(--inversionFraction)) hue-rotate(var(--hueRotation)) !important; -} - - -/* but disable for the two light themes */ -.theme--documenter-light .color-invertible { - filter: invert(0%) hue-rotate(0deg) !important; - -ms-filter: invert(var(0%)) !important; - -webkit-filter: invert(var(0%)) hue-rotate(0deg) !important; -} -.theme--catppuccin-latte .color-invertible { - filter: invert(0%) hue-rotate(0deg) !important; - -ms-filter: invert(var(0%)) !important; - -webkit-filter: invert(var(0%)) hue-rotate(0deg) !important; -} -/* for the logo as well */ -.theme--documenter-light .docs-logo { - filter: invert(0%) hue-rotate(0deg) !important; - -ms-filter: invert(var(0%)) !important; - -webkit-filter: invert(var(0%)) hue-rotate(0deg) !important; -} -.theme--catppuccin-latte .docs-logo { - filter: invert(0%) hue-rotate(0deg) !important; - -ms-filter: invert(var(0%)) !important; - -webkit-filter: invert(var(0%)) hue-rotate(0deg) !important; -} diff --git a/docs/src/assets/favicon.ico b/docs/src/assets/favicon.ico new file mode 100644 index 000000000..8588b61a8 Binary files /dev/null and b/docs/src/assets/favicon.ico differ diff --git a/docs/src/examples/classic2d/1.hard-hexagon/figure-1.png b/docs/src/examples/classic2d/1.hard-hexagon/figure-1.png new file mode 100644 index 000000000..62ee1bbbb Binary files /dev/null and b/docs/src/examples/classic2d/1.hard-hexagon/figure-1.png differ diff --git a/docs/src/examples/classic2d/1.hard-hexagon/index.md b/docs/src/examples/classic2d/1.hard-hexagon/index.md index c9575c2e4..96d27fd21 100644 --- a/docs/src/examples/classic2d/1.hard-hexagon/index.md +++ b/docs/src/examples/classic2d/1.hard-hexagon/index.md @@ -6,7 +6,7 @@ EditURL = "../../../../../examples/classic2d/1.hard-hexagon/main.jl" [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](https://nbviewer.jupyter.org/github/QuantumKitHub/MPSKit.jl/blob/gh-pages/dev/examples/classic2d/1.hard-hexagon/main.ipynb) [![](https://img.shields.io/badge/download-project-orange)](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/QuantumKitHub/MPSKit.jl/examples/tree/gh-pages/dev/examples/classic2d/1.hard-hexagon) -# [The Hard Hexagon model](@id demo_hardhexagon) +# The Hard Hexagon model ![logo](hexagon.svg) @@ -58,7 +58,7 @@ println("F = $F\tS = $S\tξ = $ξ") ```` ```` -F = 0.8839037051703852 S = 1.280782962156832 ξ = 13.849682579815157 +F = 0.8839037051703849 S = 1.280782962202701 ξ = 13.849682582739709 ```` @@ -100,7 +100,7 @@ c = f.coeffs[2] ```` ```` -0.802523415438401 +0.8025237309498792 ```` ````julia @@ -109,9 +109,7 @@ p = plot(log.(ξs), Ss; seriestype = :scatter, label = nothing) plot!(p, ξ -> f(ξ) / 6; label = "fit") ```` -```@raw html - -``` +![](figure-1.png) --- diff --git a/docs/src/examples/classic2d/1.hard-hexagon/main.ipynb b/docs/src/examples/classic2d/1.hard-hexagon/main.ipynb index 4eebe0d8d..0a98e0195 100644 --- a/docs/src/examples/classic2d/1.hard-hexagon/main.ipynb +++ b/docs/src/examples/classic2d/1.hard-hexagon/main.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "metadata": {}, "source": [ "# The Hard Hexagon model\n", "\n", @@ -12,31 +13,32 @@ "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", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "using MPSKit, MPSKitModels, TensorKit, Plots, Polynomials" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "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", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "mpo = hard_hexagon()\n", "P = physicalspace(mpo, 1)\n", @@ -46,12 +48,11 @@ "end\n", "\n", "@assert isapprox(dim(virtual_space(100)), 100; atol = 3)" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## The leading boundary\n", "\n", @@ -59,12 +60,13 @@ "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", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "D = 10\n", "V = virtual_space(D)\n", @@ -77,12 +79,11 @@ "S = real(first(entropy(ψ)))\n", "ξ = correlation_length(ψ)\n", "println(\"F = $F\\tS = $S\\tξ = $ξ\")" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## The scaling hypothesis\n", "\n", @@ -90,12 +91,13 @@ "\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", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "function scaling_simulations(\n", " ψ₀, mpo, Ds; verbosity = 0, tol = 1.0e-6,\n", @@ -127,33 +129,31 @@ "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", + "metadata": {}, "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" - ], - "metadata": {} + ] } ], - "nbformat_minor": 3, "metadata": { + "kernelspec": { + "display_name": "Julia 1.12.6", + "language": "julia", + "name": "julia-1.12" + }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.12.4" - }, - "kernelspec": { - "name": "julia-1.12", - "display_name": "Julia 1.12.4", - "language": "julia" + "version": "1.12.6" } }, - "nbformat": 4 + "nbformat": 4, + "nbformat_minor": 3 } \ No newline at end of file diff --git a/docs/src/examples/quantum1d/1.ising-cft/figure-1.png b/docs/src/examples/quantum1d/1.ising-cft/figure-1.png new file mode 100644 index 000000000..ec004e5a0 Binary files /dev/null and b/docs/src/examples/quantum1d/1.ising-cft/figure-1.png differ diff --git a/docs/src/examples/quantum1d/1.ising-cft/figure-2.png b/docs/src/examples/quantum1d/1.ising-cft/figure-2.png new file mode 100644 index 000000000..53fb8d8f2 Binary files /dev/null and b/docs/src/examples/quantum1d/1.ising-cft/figure-2.png differ diff --git a/docs/src/examples/quantum1d/1.ising-cft/figure-3.png b/docs/src/examples/quantum1d/1.ising-cft/figure-3.png new file mode 100644 index 000000000..8f76b9208 Binary files /dev/null and b/docs/src/examples/quantum1d/1.ising-cft/figure-3.png differ diff --git a/docs/src/examples/quantum1d/1.ising-cft/index.md b/docs/src/examples/quantum1d/1.ising-cft/index.md index 2005cddcc..f634da5ff 100644 --- a/docs/src/examples/quantum1d/1.ising-cft/index.md +++ b/docs/src/examples/quantum1d/1.ising-cft/index.md @@ -61,9 +61,7 @@ plot( ) ```` -```@raw html - -``` +![](figure-1.png) !!! note "Krylov dimension" Note that we have specified a large Krylov dimension as degenerate eigenvalues are @@ -76,7 +74,7 @@ through the use of the translation operator. This operator can be defined in MPO either diagramatically as ```@raw html -translation operator +translation operator ``` or in the code as: @@ -128,24 +126,24 @@ append!(momenta, fix_degeneracies(states[17:18])) ```` 18-element Vector{Float64}: - -3.369480642089346e-17 - 3.9966961823263104e-17 - -2.4201642794270328e-17 + 1.0963150642957372e-17 + -2.4157081442786943e-17 + 9.150251499481629e-18 + -0.523598775598299 0.5235987755982987 - -0.5235987755982985 - 1.0471975511965979 - -1.047197551196598 - -0.5235987755982991 - 0.5235987755982989 - -1.0471975511965974 - 1.0471975511965979 - -1.4167067287245392e-18 - -1.570796326794897 - 1.5707963267948968 -1.0471975511965979 - 1.0471975511965979 - 1.5707963267948966 + 1.0471975511965976 + 0.5235987755982989 + -0.5235987755982993 + 1.047197551196598 + -1.0471975511965976 + 1.4597368636872088e-17 -1.5707963267948966 + 1.5707963267948963 + 1.0471975511965976 + -1.0471975511965976 + -1.570796326794897 + 1.5707963267948963 ```` We can compute the scaling dimensions $\Delta_n$ of the operators in the CFT from the @@ -168,9 +166,7 @@ hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color = "gray", linestyle = :dash) p ```` -```@raw html - -``` +![](figure-2.png) ## Finite bond dimension @@ -185,34 +181,48 @@ D = 64 ```` ```` -[ Info: DMRG init: obj = -1.947519345847e+01 err = 7.5797e-02 -[ Info: DMRG 1: obj = -2.549098874118e+01 err = 9.1376055611e-03 time = 3.54 sec -[ Info: DMRG 2: obj = -2.549098968631e+01 err = 1.1687746206e-06 time = 0.99 sec -[ Info: DMRG 3: obj = -2.549098968636e+01 err = 1.5592263716e-07 time = 1.21 sec -[ Info: DMRG 4: obj = -2.549098968636e+01 err = 1.3434579843e-08 time = 0.62 sec -[ Info: DMRG 5: obj = -2.549098968636e+01 err = 5.9955426595e-09 time = 0.69 sec -[ Info: DMRG 6: obj = -2.549098968636e+01 err = 4.4303868458e-09 time = 0.62 sec -[ Info: DMRG 7: obj = -2.549098968636e+01 err = 3.2709219988e-09 time = 0.62 sec -[ Info: DMRG 8: obj = -2.549098968636e+01 err = 2.3764855423e-09 time = 0.63 sec -[ Info: DMRG 9: obj = -2.549098968636e+01 err = 1.7190997617e-09 time = 0.55 sec -[ Info: DMRG 10: obj = -2.549098968636e+01 err = 1.2467309044e-09 time = 0.55 sec -[ Info: DMRG 11: obj = -2.549098968636e+01 err = 9.1015412118e-10 time = 0.59 sec -[ Info: DMRG 12: obj = -2.549098968636e+01 err = 7.7947998405e-10 time = 0.61 sec -[ Info: DMRG 13: obj = -2.549098968636e+01 err = 6.8300434048e-10 time = 0.61 sec -[ Info: DMRG 14: obj = -2.549098968636e+01 err = 5.9682764775e-10 time = 0.67 sec -[ Info: DMRG 15: obj = -2.549098968636e+01 err = 5.2006815587e-10 time = 0.75 sec -[ Info: DMRG 16: obj = -2.549098968636e+01 err = 4.5212003413e-10 time = 1.13 sec -[ Info: DMRG 17: obj = -2.549098968636e+01 err = 3.9234738860e-10 time = 0.67 sec -[ Info: DMRG 18: obj = -2.549098968636e+01 err = 3.4004240572e-10 time = 0.56 sec -[ Info: DMRG 19: obj = -2.549098968636e+01 err = 2.9445818985e-10 time = 0.59 sec -[ Info: DMRG 20: obj = -2.549098968636e+01 err = 2.5485045197e-10 time = 0.62 sec -[ Info: DMRG 21: obj = -2.549098968636e+01 err = 2.2050912081e-10 time = 0.59 sec -[ Info: DMRG 22: obj = -2.549098968636e+01 err = 1.9077747364e-10 time = 0.60 sec -[ Info: DMRG 23: obj = -2.549098968636e+01 err = 1.6506123889e-10 time = 0.59 sec -[ Info: DMRG 24: obj = -2.549098968636e+01 err = 1.4283083882e-10 time = 0.59 sec -[ Info: DMRG 25: obj = -2.549098968636e+01 err = 1.2361940779e-10 time = 0.65 sec -[ Info: DMRG 26: obj = -2.549098968636e+01 err = 1.0701848483e-10 time = 0.59 sec -[ Info: DMRG conv 27: obj = -2.549098968636e+01 err = 9.2672581484e-11 time = 21.17 sec +[ Info: DMRG init: obj = -1.946908612087e+01 err = 7.7434e-02 +[ Info: DMRG 1: obj = -2.549098951719e+01 err = 8.0439536934e-03 time = 2.57 sec +[ Info: DMRG 2: obj = -2.549098968635e+01 err = 1.0703227324e-06 time = 0.80 sec +[ Info: DMRG 3: obj = -2.549098968636e+01 err = 1.4373447563e-07 time = 0.98 sec +[ Info: DMRG 4: obj = -2.549098968636e+01 err = 1.4665972881e-08 time = 0.42 sec +[ Info: DMRG 5: obj = -2.549098968636e+01 err = 6.8081026722e-09 time = 0.44 sec +[ Info: DMRG 6: obj = -2.549098968636e+01 err = 3.7573810815e-09 time = 0.43 sec +[ Info: DMRG 7: obj = -2.549098968636e+01 err = 2.5698292651e-09 time = 0.43 sec +[ Info: DMRG 8: obj = -2.549098968636e+01 err = 2.0113551709e-09 time = 0.43 sec +[ Info: DMRG 9: obj = -2.549098968636e+01 err = 1.6427286008e-09 time = 0.89 sec +[ Info: DMRG 10: obj = -2.549098968636e+01 err = 1.3479784013e-09 time = 0.55 sec +[ Info: DMRG 11: obj = -2.549098968636e+01 err = 1.2769471445e-09 time = 0.44 sec +[ Info: DMRG 12: obj = -2.549098968636e+01 err = 1.4168057275e-09 time = 0.48 sec +[ Info: DMRG 13: obj = -2.549098968636e+01 err = 1.5595217750e-09 time = 0.42 sec +[ Info: DMRG 14: obj = -2.549098968636e+01 err = 1.6950091915e-09 time = 0.41 sec +[ Info: DMRG 15: obj = -2.549098968636e+01 err = 1.8105744613e-09 time = 0.40 sec +[ Info: DMRG 16: obj = -2.549098968636e+01 err = 1.8924908787e-09 time = 0.96 sec +[ Info: DMRG 17: obj = -2.549098968636e+01 err = 1.9288336151e-09 time = 0.49 sec +[ Info: DMRG 18: obj = -2.549098968636e+01 err = 1.9133807885e-09 time = 0.31 sec +[ Info: DMRG 19: obj = -2.549098968636e+01 err = 1.8713994972e-09 time = 0.38 sec +[ Info: DMRG 20: obj = -2.549098968636e+01 err = 1.7813737815e-09 time = 0.41 sec +[ Info: DMRG 21: obj = -2.549098968636e+01 err = 1.6542099689e-09 time = 0.40 sec +[ Info: DMRG 22: obj = -2.549098968636e+01 err = 1.5039369007e-09 time = 0.40 sec +[ Info: DMRG 23: obj = -2.549098968636e+01 err = 1.3441838671e-09 time = 0.90 sec +[ Info: DMRG 24: obj = -2.549098968636e+01 err = 1.1858446625e-09 time = 0.28 sec +[ Info: DMRG 25: obj = -2.549098968636e+01 err = 1.0362811206e-09 time = 0.34 sec +[ Info: DMRG 26: obj = -2.549098968636e+01 err = 8.9963099646e-10 time = 0.35 sec +[ Info: DMRG 27: obj = -2.549098968636e+01 err = 7.7760121034e-10 time = 0.41 sec +[ Info: DMRG 28: obj = -2.549098968636e+01 err = 6.7030150822e-10 time = 0.40 sec +[ Info: DMRG 29: obj = -2.549098968636e+01 err = 5.7691780289e-10 time = 0.41 sec +[ Info: DMRG 30: obj = -2.549098968636e+01 err = 4.9618146296e-10 time = 0.91 sec +[ Info: DMRG 31: obj = -2.549098968636e+01 err = 4.2666435281e-10 time = 0.36 sec +[ Info: DMRG 32: obj = -2.549098968636e+01 err = 3.6694816435e-10 time = 0.40 sec +[ Info: DMRG 33: obj = -2.549098968636e+01 err = 3.1571200436e-10 time = 0.36 sec +[ Info: DMRG 34: obj = -2.549098968636e+01 err = 2.7176974363e-10 time = 0.38 sec +[ Info: DMRG 35: obj = -2.549098968636e+01 err = 2.3407977700e-10 time = 0.40 sec +[ Info: DMRG 36: obj = -2.549098968636e+01 err = 2.0173966270e-10 time = 0.40 sec +[ Info: DMRG 37: obj = -2.549098968636e+01 err = 1.7397391951e-10 time = 0.40 sec +[ Info: DMRG 38: obj = -2.549098968636e+01 err = 1.5011934910e-10 time = 0.87 sec +[ Info: DMRG 39: obj = -2.549098968636e+01 err = 1.2961022917e-10 time = 0.35 sec +[ Info: DMRG 40: obj = -2.549098968636e+01 err = 1.1196457020e-10 time = 0.38 sec +[ Info: DMRG conv 41: obj = -2.549098968636e+01 err = 9.6771723038e-11 time = 22.14 sec ```` @@ -250,9 +260,7 @@ hline!(p_mps, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color = "gray", linestyle = :dash p_mps ```` -```@raw html - -``` +![](figure-3.png) --- diff --git a/docs/src/examples/quantum1d/1.ising-cft/main.ipynb b/docs/src/examples/quantum1d/1.ising-cft/main.ipynb index a9142c06d..54e1b0ed7 100644 --- a/docs/src/examples/quantum1d/1.ising-cft/main.ipynb +++ b/docs/src/examples/quantum1d/1.ising-cft/main.ipynb @@ -2,45 +2,46 @@ "cells": [ { "cell_type": "markdown", + "metadata": {}, "source": [ "# The Ising CFT spectrum\n", "\n", "This tutorial is meant to show the finite size CFT spectrum for the quantum Ising model. We\n", "do this by first employing an exact diagonalization technique, and then extending the\n", "analysis to larger system sizes through the use of MPS techniques." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "using MPSKit, MPSKitModels, TensorKit, Plots, KrylovKit\n", "using LinearAlgebra: eigvals, diagm, Hermitian" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "The Hamiltonian is defined on a finite lattice with periodic boundary conditions,\n", "which can be implemented as follows:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "L = 12\n", "H = periodic_boundary_conditions(transverse_field_ising(), L)" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Exact diagonalisation\n", "\n", @@ -49,34 +50,34 @@ "site which implements the action of the entire Hamiltonian. Thus, optimizing the middle\n", "tensor is equivalent to optimixing a state in the entire Hilbert space, as all other tensors\n", "are just unitary matrices that mix the basis." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "energies, states = exact_diagonalization(H; num = 18, alg = Lanczos(; krylovdim = 200));\n", "plot(\n", " real.(energies);\n", " seriestype = :scatter, legend = false, ylabel = \"energy\", xlabel = \"#eigenvalue\"\n", ")" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "> **Krylov dimension**\n", ">\n", "> Note that we have specified a large Krylov dimension as degenerate eigenvalues are\n", "> notoriously difficult for iterative methods." - ], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Extracting momentum\n", "\n", @@ -85,28 +86,28 @@ "either diagramatically as\n", "\n", "\n", - "\"translation\n", + "\"translation\n", "\n", "\n", "or in the code as:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "function O_shift(L)\n", " I = id(ComplexF64, ℂ^2)\n", " @tensor O[W S; N E] := I[W; N] * I[S; E]\n", " return periodic_boundary_conditions(InfiniteMPO([O]), L)\n", "end" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "We can then calculate the momentum of the ground state as the expectation value of this\n", "operator. However, there is a subtlety because of the degeneracies in the energy\n", @@ -115,12 +116,13 @@ "to fix this, we diagonalize the translation operator within each energy subspace.\n", "The resulting energy levels have one-to-one correspondence to the operators in CFT, where\n", "the momentum is related to their conformal spin as $P_n = \\frac{2\\pi}{L}S_n$." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "function fix_degeneracies(basis)\n", " L = length(basis[1])\n", @@ -144,23 +146,23 @@ "append!(momenta, fix_degeneracies(states[12:12]))\n", "append!(momenta, fix_degeneracies(states[13:16]))\n", "append!(momenta, fix_degeneracies(states[17:18]))" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "We can compute the scaling dimensions $\\Delta_n$ of the operators in the CFT from the\n", "energy gap of the corresponding excitations as $E_n - E_0 = \\frac{2\\pi v}{L} \\Delta_n$,\n", "where $v = 2$. If we plot these scaling dimensions against the conformal spin $S_n$ from\n", "above, we retrieve the familiar spectrum of the Ising CFT." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "v = 2.0\n", "Δ = real.(energies[1:18] .- energies[1]) ./ (2π * v / L)\n", @@ -174,44 +176,44 @@ "vline!(p, -3:3; color = \"gray\", linestyle = :dash)\n", "hline!(p, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color = \"gray\", linestyle = :dash)\n", "p" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Finite bond dimension\n", "\n", "If we limit the maximum bond dimension of the MPS, we get an approximate solution, but we\n", "can reach higher system sizes." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "L_mps = 20\n", "H_mps = periodic_boundary_conditions(transverse_field_ising(), L_mps)\n", "D = 64\n", "ψ, envs, δ = find_groundstate(FiniteMPS(L_mps, ℂ^2, ℂ^D), H_mps, DMRG());" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "Excitations on top of the ground state can be found through the use of the quasiparticle\n", "ansatz. This returns quasiparticle states, which can be converted to regular `FiniteMPS`\n", "objects." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "E_ex, qps = excitations(H_mps, QuasiparticleAnsatz(), ψ, envs; num = 18)\n", "states_mps = vcat(ψ, map(qp -> convert(FiniteMPS, qp), qps))\n", @@ -240,33 +242,31 @@ "vline!(p_mps, -3:3; color = \"gray\", linestyle = :dash)\n", "hline!(p_mps, [0, 1 / 8, 1, 9 / 8, 2, 17 / 8]; color = \"gray\", linestyle = :dash)\n", "p_mps" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" - ], - "metadata": {} + ] } ], - "nbformat_minor": 3, "metadata": { + "kernelspec": { + "display_name": "Julia 1.12.6", + "language": "julia", + "name": "julia-1.12" + }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.12.4" - }, - "kernelspec": { - "name": "julia-1.12", - "display_name": "Julia 1.12.4", - "language": "julia" + "version": "1.12.6" } }, - "nbformat": 4 + "nbformat": 4, + "nbformat_minor": 3 } \ No newline at end of file diff --git a/docs/src/examples/quantum1d/2.haldane/figure-1.png b/docs/src/examples/quantum1d/2.haldane/figure-1.png new file mode 100644 index 000000000..e170413cc Binary files /dev/null and b/docs/src/examples/quantum1d/2.haldane/figure-1.png differ diff --git a/docs/src/examples/quantum1d/2.haldane/figure-2.png b/docs/src/examples/quantum1d/2.haldane/figure-2.png new file mode 100644 index 000000000..786b45fd2 Binary files /dev/null and b/docs/src/examples/quantum1d/2.haldane/figure-2.png differ diff --git a/docs/src/examples/quantum1d/2.haldane/figure-3.png b/docs/src/examples/quantum1d/2.haldane/figure-3.png new file mode 100644 index 000000000..3caef8e80 Binary files /dev/null and b/docs/src/examples/quantum1d/2.haldane/figure-3.png differ diff --git a/docs/src/examples/quantum1d/2.haldane/index.md b/docs/src/examples/quantum1d/2.haldane/index.md index 5cf05ecdc..71bcad85e 100644 --- a/docs/src/examples/quantum1d/2.haldane/index.md +++ b/docs/src/examples/quantum1d/2.haldane/index.md @@ -6,7 +6,7 @@ EditURL = "../../../../../examples/quantum1d/2.haldane/main.jl" [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](https://nbviewer.jupyter.org/github/QuantumKitHub/MPSKit.jl/blob/gh-pages/dev/examples/quantum1d/2.haldane/main.ipynb) [![](https://img.shields.io/badge/download-project-orange)](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/QuantumKitHub/MPSKit.jl/examples/tree/gh-pages/dev/examples/quantum1d/2.haldane) -# [The Haldane gap](@id demo_haldane) +# The Haldane gap In this tutorial we will calculate the Haldane gap (the energy gap in the ``S = 1`` Heisenberg model) in two different ways. To follow the tutorial you need the following packages: @@ -61,7 +61,7 @@ En_2, st_2 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector = SU2Irrep(2 ```` ```` -0.798925358948053 +0.7989253589480472 ```` We can go even further and doublecheck the claim that ``S = 1`` is an edge excitation, by plotting the energy density. @@ -79,9 +79,7 @@ plot!(p_density, e₁; label = "S = 1") plot!(p_density, e₂; label = "S = 2") ```` -```@raw html - -``` +![](figure-1.png) Finally, we can obtain a value for the Haldane gap by extrapolating our results for different system sizes. @@ -102,7 +100,7 @@ f = fit(Ls .^ (-2), ΔEs, 1) ```` ```` -0.4517340158584072 +0.4517340158583749 ```` ````julia @@ -111,9 +109,7 @@ plot!(p_size_extrapolation, Ls .^ (-2), ΔEs; seriestype = :scatter, label = "nu plot!(p_size_extrapolation, x -> f(x); label = "fit") ```` -```@raw html - -``` +![](figure-2.png) ## Thermodynamic limit @@ -140,23 +136,23 @@ println("minimum @k = $(kspace[idx]):\t ΔE = $(ΔE)") ```` ```` -[ Info: Found excitations for momentum = 1.8849555921538759 -[ Info: Found excitations for momentum = 1.6755160819145563 -[ Info: Found excitations for momentum = 2.0943951023931953 -[ Info: Found excitations for momentum = 1.4660765716752369 [ Info: Found excitations for momentum = 0.0 [ Info: Found excitations for momentum = 0.20943951023931953 -[ Info: Found excitations for momentum = 1.2566370614359172 -[ Info: Found excitations for momentum = 2.9321531433504737 [ Info: Found excitations for momentum = 0.41887902047863906 -[ Info: Found excitations for momentum = 2.303834612632515 [ Info: Found excitations for momentum = 0.6283185307179586 -[ Info: Found excitations for momentum = 2.5132741228718345 +[ Info: Found excitations for momentum = 1.4660765716752369 +[ Info: Found excitations for momentum = 1.2566370614359172 +[ Info: Found excitations for momentum = 0.8377580409572781 [ Info: Found excitations for momentum = 1.0471975511965976 +[ Info: Found excitations for momentum = 1.6755160819145563 +[ Info: Found excitations for momentum = 1.8849555921538759 +[ Info: Found excitations for momentum = 2.0943951023931953 +[ Info: Found excitations for momentum = 2.303834612632515 +[ Info: Found excitations for momentum = 2.5132741228718345 +[ Info: Found excitations for momentum = 2.9321531433504737 [ Info: Found excitations for momentum = 2.722713633111154 [ Info: Found excitations for momentum = 3.141592653589793 -[ Info: Found excitations for momentum = 0.8377580409572781 -minimum @k = 3.141592653589793: ΔE = 0.410479248594856 +minimum @k = 3.141592653589793: ΔE = 0.41047924848831047 ```` @@ -164,9 +160,7 @@ minimum @k = 3.141592653589793: ΔE = 0.410479248594856 plot(kspace, real.(Es); xaxis = "momentum", yaxis = "ΔE", label = "S = 1") ```` -```@raw html - -``` +![](figure-3.png) --- diff --git a/docs/src/examples/quantum1d/2.haldane/main.ipynb b/docs/src/examples/quantum1d/2.haldane/main.ipynb index 605d4e4cc..2084d50d9 100644 --- a/docs/src/examples/quantum1d/2.haldane/main.ipynb +++ b/docs/src/examples/quantum1d/2.haldane/main.ipynb @@ -2,25 +2,26 @@ "cells": [ { "cell_type": "markdown", + "metadata": {}, "source": [ "# The Haldane gap\n", "\n", "In this tutorial we will calculate the Haldane gap (the energy gap in the $S = 1$ Heisenberg model) in two different ways.\n", "To follow the tutorial you need the following packages:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "using MPSKit, MPSKitModels, TensorKit, Plots, Polynomials" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "The Heisenberg model is defined by the following Hamiltonian:\n", "\n", @@ -29,22 +30,22 @@ "$$\n", "\n", "This Hamiltonian has an SU(2) symmetry, which we can enforce by using SU(2)-symmetric tensors:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "symmetry = SU2Irrep\n", "spin = 1\n", "J = 1" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Finite size extrapolation\n", "\n", @@ -57,12 +58,13 @@ "\n", "In Steven White's original DMRG paper it was remarked that the $S = 1$ excitations correspond to edge states, and that one should define the Haldane gap as the difference in energy between the $S = 2$ and $S = 1$ states.\n", "This can be done as follows." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "L = 11\n", "chain = FiniteChain(L)\n", @@ -76,20 +78,20 @@ "En_1, st_1 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector = SU2Irrep(1))\n", "En_2, st_2 = excitations(H, QuasiparticleAnsatz(), ψ, envs; sector = SU2Irrep(2))\n", "ΔE_finite = real(En_2[1] - En_1[1])" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "We can go even further and doublecheck the claim that $S = 1$ is an edge excitation, by plotting the energy density." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "p_density = plot(; xaxis = \"position\", yaxis = \"energy density\")\n", "excited_1 = convert(FiniteMPS, st_1[1])\n", @@ -101,20 +103,20 @@ "plot!(p_density, e₀; label = \"S = 0\")\n", "plot!(p_density, e₁; label = \"S = 1\")\n", "plot!(p_density, e₂; label = \"S = 2\")" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "Finally, we can obtain a value for the Haldane gap by extrapolating our results for different system sizes." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "Ls = 12:4:30\n", "ΔEs = map(Ls) do L\n", @@ -132,12 +134,11 @@ "p_size_extrapolation = plot(; xaxis = \"L^(-2)\", yaxis = \"ΔE\", xlims = (0, 0.015))\n", "plot!(p_size_extrapolation, Ls .^ (-2), ΔEs; seriestype = :scatter, label = \"numerical\")\n", "plot!(p_size_extrapolation, x -> f(x); label = \"fit\")" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Thermodynamic limit\n", "\n", @@ -148,12 +149,13 @@ "\n", "In contrast with the finite size case, we now should specify a momentum label to the excitations.\n", "This way, it is possible to scan the dispersion relation over the entire momentum space." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "chain = InfiniteChain(1)\n", "H = heisenberg_XXX(symmetry, chain; J, spin)\n", @@ -167,33 +169,31 @@ "ΔE, idx = findmin(real.(Es))\n", "println(\"minimum @k = $(kspace[idx]):\\t ΔE = $(ΔE)\")\n", "plot(kspace, real.(Es); xaxis = \"momentum\", yaxis = \"ΔE\", label = \"S = 1\")" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" - ], - "metadata": {} + ] } ], - "nbformat_minor": 3, "metadata": { + "kernelspec": { + "display_name": "Julia 1.12.6", + "language": "julia", + "name": "julia-1.12" + }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.12.4" - }, - "kernelspec": { - "name": "julia-1.12", - "display_name": "Julia 1.12.4", - "language": "julia" + "version": "1.12.6" } }, - "nbformat": 4 + "nbformat": 4, + "nbformat_minor": 3 } \ No newline at end of file diff --git a/docs/src/examples/quantum1d/3.ising-dqpt/index.md b/docs/src/examples/quantum1d/3.ising-dqpt/index.md index 114dff78f..c21cd3b4c 100644 --- a/docs/src/examples/quantum1d/3.ising-dqpt/index.md +++ b/docs/src/examples/quantum1d/3.ising-dqpt/index.md @@ -6,7 +6,7 @@ EditURL = "../../../../../examples/quantum1d/3.ising-dqpt/main.jl" [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](https://nbviewer.jupyter.org/github/QuantumKitHub/MPSKit.jl/blob/gh-pages/dev/examples/quantum1d/3.ising-dqpt/main.ipynb) [![](https://img.shields.io/badge/download-project-orange)](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/QuantumKitHub/MPSKit.jl/examples/tree/gh-pages/dev/examples/quantum1d/3.ising-dqpt) -# [DQPT in the Ising model](@id demo_dqpt) +# DQPT in the Ising model In this tutorial we will try to reproduce the results from [this paper](https://arxiv.org/pdf/1206.2505.pdf). The needed packages are @@ -39,13 +39,13 @@ H₀ = transverse_field_ising(FiniteChain(L); g = -0.5) ```` ```` -[ Info: DMRG init: obj = +1.000110728540e+01 err = 1.6485e-01 -[ Info: DMRG 1: obj = -2.040021714732e+01 err = 2.0639142207e-02 time = 0.05 sec -[ Info: DMRG 2: obj = -2.040021715172e+01 err = 4.6522148018e-07 time = 0.02 sec -[ Info: DMRG 3: obj = -2.040021780162e+01 err = 3.6601066271e-05 time = 0.07 sec -[ Info: DMRG 4: obj = -2.040021786698e+01 err = 1.6025039584e-06 time = 0.04 sec -[ Info: DMRG 5: obj = -2.040021786703e+01 err = 1.6324890445e-07 time = 0.03 sec -[ Info: DMRG conv 6: obj = -2.040021786703e+01 err = 7.7060474652e-11 time = 0.23 sec +[ Info: DMRG init: obj = +9.979013604153e+00 err = 1.4988e-01 +[ Info: DMRG 1: obj = -2.040021714911e+01 err = 6.6274818897e-04 time = 4.21 sec +[ Info: DMRG 2: obj = -2.040021715179e+01 err = 4.7025708686e-07 time = 0.30 sec +[ Info: DMRG 3: obj = -2.040021786572e+01 err = 3.1050733385e-05 time = 0.09 sec +[ Info: DMRG 4: obj = -2.040021786702e+01 err = 1.7208246127e-06 time = 0.04 sec +[ Info: DMRG 5: obj = -2.040021786703e+01 err = 3.5080300899e-08 time = 0.04 sec +[ Info: DMRG conv 6: obj = -2.040021786703e+01 err = 3.6868374475e-11 time = 4.71 sec ```` @@ -79,7 +79,7 @@ function finite_sim(L; dt = 0.05, finaltime = 5.0) H₁ = transverse_field_ising(FiniteChain(L); g = -2.0) ψₜ = deepcopy(ψ₀) - envs = environments(ψₜ, H₁) + envs = environments(ψₜ, H₁, ψₜ) echos = [echo(ψₜ, ψ₀)] times = collect(0:dt:finaltime) @@ -111,13 +111,14 @@ H₀ = transverse_field_ising(; g = -0.5) ```` ```` -[ Info: VUMPS init: obj = +4.821692686834e-01 err = 3.7170e-01 -[ Info: VUMPS 1: obj = -1.062759988951e+00 err = 2.3248148483e-02 time = 4.48 sec -[ Info: VUMPS 2: obj = -1.063544409807e+00 err = 1.3008047000e-05 time = 0.01 sec -[ Info: VUMPS 3: obj = -1.063544409973e+00 err = 1.7599807614e-07 time = 0.01 sec -[ Info: VUMPS 4: obj = -1.063544409973e+00 err = 9.6477135912e-09 time = 0.01 sec -[ Info: VUMPS 5: obj = -1.063544409973e+00 err = 4.4909944158e-10 time = 0.01 sec -[ Info: VUMPS conv 6: obj = -1.063544409973e+00 err = 4.9916284444e-11 time = 4.52 sec +[ Info: VUMPS init: obj = +4.970192050239e-01 err = 3.8858e-01 +[ Info: VUMPS 1: obj = -1.049521519045e+00 err = 9.6762771022e-02 time = 1.62 sec +[ Info: VUMPS 2: obj = -1.063544398670e+00 err = 1.0462983506e-04 time = 0.02 sec +[ Info: VUMPS 3: obj = -1.063544409966e+00 err = 3.0128180222e-06 time = 0.01 sec +[ Info: VUMPS 4: obj = -1.063544409973e+00 err = 5.4785900416e-08 time = 0.01 sec +[ Info: VUMPS 5: obj = -1.063544409973e+00 err = 3.5329191510e-09 time = 0.01 sec +[ Info: VUMPS 6: obj = -1.063544409973e+00 err = 3.7796484550e-10 time = 0.01 sec +[ Info: VUMPS conv 7: obj = -1.063544409973e+00 err = 2.9001138645e-11 time = 1.69 sec ```` @@ -129,7 +130,7 @@ dot(ψ₀, ψ₀) ```` ```` -0.9999999999999987 + 1.749244813012143e-16im +0.9999999999999996 + 3.8955006105253705e-16im ```` so the Loschmidt echo takes on the pleasant form @@ -165,7 +166,7 @@ function infinite_sim(dt = 0.05, finaltime = 5.0) ψ₀, _ = find_groundstate(ψ₀, H₀, VUMPS()) ψₜ = deepcopy(ψ₀) - envs = environments(ψₜ, H₁) + envs = environments(ψₜ, H₁, ψₜ) echos = [echo(ψₜ, ψ₀)] times = collect(0:dt:finaltime) diff --git a/docs/src/examples/quantum1d/3.ising-dqpt/main.ipynb b/docs/src/examples/quantum1d/3.ising-dqpt/main.ipynb index 195a9171e..c2e843e0b 100644 --- a/docs/src/examples/quantum1d/3.ising-dqpt/main.ipynb +++ b/docs/src/examples/quantum1d/3.ising-dqpt/main.ipynb @@ -2,25 +2,26 @@ "cells": [ { "cell_type": "markdown", + "metadata": {}, "source": [ "# DQPT in the Ising model\n", "\n", "In this tutorial we will try to reproduce the results from\n", "[this paper](https://arxiv.org/pdf/1206.2505.pdf). The needed packages are" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "using MPSKit, MPSKitModels, TensorKit" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "Dynamical quantum phase transitions (DQPT in short) are signatures of equilibrium phase transitions in a dynamical quantity - the Loschmidt echo.\n", "This quantity is given by $L(t) = \\frac{-2}{N} ln(| < \\psi(t) | \\psi(0) > |) $ where $N$ is the system size.\n", @@ -37,71 +38,72 @@ "For those $g$ we expect non-analyticities to occur at $t_n ≈ 2.35 (n + 1/2)$.\n", "\n", "First we construct the Hamiltonian in MPO form, and obtain the pre-quenched ground state:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "L = 20\n", "H₀ = transverse_field_ising(FiniteChain(L); g = -0.5)\n", "ψ₀ = FiniteMPS(L, ℂ^2, ℂ^10)\n", "ψ₀, _ = find_groundstate(ψ₀, H₀, DMRG());" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Finite MPS quenching\n", "\n", "We can define a helper function that measures the loschmith echo" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "echo(ψ₀::FiniteMPS, ψₜ::FiniteMPS) = -2 * log(abs(dot(ψ₀, ψₜ))) / length(ψ₀)\n", "@assert isapprox(echo(ψ₀, ψ₀), 0, atol = 1.0e-10)" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "We will initially use a two-site TDVP scheme to dynamically increase the bond dimension while time evolving, and later on switch to a faster one-site scheme. A single timestep can be done using" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "H₁ = transverse_field_ising(FiniteChain(L); g = -2.0)\n", "ψₜ = deepcopy(ψ₀)\n", "dt = 0.01\n", "ψₜ, envs = timestep(ψₜ, H₁, 0, dt, TDVP2(; trscheme = truncrank(20)));" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "\"envs\" is a kind of cache object that keeps track of all environments in `ψ`. It is often advantageous to re-use the environment, so that MPSKit doesn't need to recalculate everything.\n", "\n", "Putting it all together, we get" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "function finite_sim(L; dt = 0.05, finaltime = 5.0)\n", " ψ₀ = FiniteMPS(L, ℂ^2, ℂ^10)\n", @@ -110,7 +112,7 @@ "\n", " H₁ = transverse_field_ising(FiniteChain(L); g = -2.0)\n", " ψₜ = deepcopy(ψ₀)\n", - " envs = environments(ψₜ, H₁)\n", + " envs = environments(ψₜ, H₁, ψₜ)\n", "\n", " echos = [echo(ψₜ, ψ₀)]\n", " times = collect(0:dt:finaltime)\n", @@ -123,126 +125,126 @@ "\n", " return times, echos\n", "end" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "![](finite_timeev.png)" - ], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Infinite MPS quenching\n", "\n", "Similarly we could start with an initial infinite state and find the pre-quench ground state:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "ψ₀ = InfiniteMPS([ℂ^2], [ℂ^10])\n", "H₀ = transverse_field_ising(; g = -0.5)\n", "ψ₀, _ = find_groundstate(ψ₀, H₀, VUMPS());" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "The dot product of two infinite matrix product states scales as $\\alpha ^N$ where $α$ is the dominant eigenvalue of the transfer matrix.\n", "It is this $α$ that is returned when calling" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "dot(ψ₀, ψ₀)" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "so the Loschmidt echo takes on the pleasant form" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "echo(ψ₀::InfiniteMPS, ψₜ::InfiniteMPS) = -2 * log(abs(dot(ψ₀, ψₜ)))\n", "@assert isapprox(echo(ψ₀, ψ₀), 0, atol = 1.0e-10)" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "We make use of the `changebonds` machinery to grow the bond dimension. This can also be achieved through a two-site scheme.\n", "Multiple algorithms are available, but we will only focus on `OptimalExpand()`.\n", "Growing the bond dimension by $5$ can be done by calling:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "ψₜ = deepcopy(ψ₀)\n", "H₁ = transverse_field_ising(; g = -2.0)\n", "ψₜ, envs = changebonds(ψₜ, H₁, OptimalExpand(; trscheme = truncrank(5)));" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "a single timestep is easy" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "dt = 0.01\n", "ψₜ, envs = timestep(ψₜ, H₁, 0, dt, TDVP(), envs);" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "With performance in mind we should once again try to re-use these \"envs\" cache objects.\n", "The final code is" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "function infinite_sim(dt = 0.05, finaltime = 5.0)\n", " ψ₀ = InfiniteMPS([ℂ^2], [ℂ^10])\n", " ψ₀, _ = find_groundstate(ψ₀, H₀, VUMPS())\n", "\n", " ψₜ = deepcopy(ψ₀)\n", - " envs = environments(ψₜ, H₁)\n", + " envs = environments(ψₜ, H₁, ψₜ)\n", "\n", " echos = [echo(ψₜ, ψ₀)]\n", " times = collect(0:dt:finaltime)\n", @@ -257,40 +259,38 @@ "\n", " return times, echos\n", "end" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "![](infinite_timeev.png)" - ], - "metadata": {} + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" - ], - "metadata": {} + ] } ], - "nbformat_minor": 3, "metadata": { + "kernelspec": { + "display_name": "Julia 1.12.6", + "language": "julia", + "name": "julia-1.12" + }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.12.4" - }, - "kernelspec": { - "name": "julia-1.12", - "display_name": "Julia 1.12.4", - "language": "julia" + "version": "1.12.6" } }, - "nbformat": 4 + "nbformat": 4, + "nbformat_minor": 3 } \ No newline at end of file diff --git a/docs/src/examples/quantum1d/4.xxz-heisenberg/figure-1.png b/docs/src/examples/quantum1d/4.xxz-heisenberg/figure-1.png new file mode 100644 index 000000000..f5e4a5ec2 Binary files /dev/null and b/docs/src/examples/quantum1d/4.xxz-heisenberg/figure-1.png differ diff --git a/docs/src/examples/quantum1d/4.xxz-heisenberg/figure-2.png b/docs/src/examples/quantum1d/4.xxz-heisenberg/figure-2.png new file mode 100644 index 000000000..bd8dee700 Binary files /dev/null and b/docs/src/examples/quantum1d/4.xxz-heisenberg/figure-2.png differ diff --git a/docs/src/examples/quantum1d/4.xxz-heisenberg/index.md b/docs/src/examples/quantum1d/4.xxz-heisenberg/index.md index 1776379be..a2d2159bf 100644 --- a/docs/src/examples/quantum1d/4.xxz-heisenberg/index.md +++ b/docs/src/examples/quantum1d/4.xxz-heisenberg/index.md @@ -285,9 +285,7 @@ To understand why, we can look at the transfer matrix spectrum. transferplot(groundstate, groundstate) ```` -```@raw html - -``` +![](figure-1.png) We can clearly see multiple eigenvalues close to the unit circle. Our state is close to being non-injective, and represents the sum of multiple injective states. @@ -442,9 +440,7 @@ groundstate, envs, delta = find_groundstate( entanglementplot(groundstate) ```` -```@raw html - -``` +![](figure-2.png) We see that some eigenvalues clearly belong to a group, and are almost degenerate. This implies 2 things: diff --git a/docs/src/examples/quantum1d/5.haldane-spt/figure-1.png b/docs/src/examples/quantum1d/5.haldane-spt/figure-1.png new file mode 100644 index 000000000..f3641018e Binary files /dev/null and b/docs/src/examples/quantum1d/5.haldane-spt/figure-1.png differ diff --git a/docs/src/examples/quantum1d/5.haldane-spt/figure-2.png b/docs/src/examples/quantum1d/5.haldane-spt/figure-2.png new file mode 100644 index 000000000..6091af86d Binary files /dev/null and b/docs/src/examples/quantum1d/5.haldane-spt/figure-2.png differ diff --git a/docs/src/examples/quantum1d/5.haldane-spt/figure-3.png b/docs/src/examples/quantum1d/5.haldane-spt/figure-3.png new file mode 100644 index 000000000..8dfdfe224 Binary files /dev/null and b/docs/src/examples/quantum1d/5.haldane-spt/figure-3.png differ diff --git a/docs/src/examples/quantum1d/5.haldane-spt/index.md b/docs/src/examples/quantum1d/5.haldane-spt/index.md index 903e39db1..7fe114d77 100644 --- a/docs/src/examples/quantum1d/5.haldane-spt/index.md +++ b/docs/src/examples/quantum1d/5.haldane-spt/index.md @@ -6,7 +6,7 @@ EditURL = "../../../../../examples/quantum1d/5.haldane-spt/main.jl" [![](https://img.shields.io/badge/show-nbviewer-579ACA.svg)](https://nbviewer.jupyter.org/github/QuantumKitHub/MPSKit.jl/blob/gh-pages/dev/examples/quantum1d/5.haldane-spt/main.ipynb) [![](https://img.shields.io/badge/download-project-orange)](https://minhaskamal.github.io/DownGit/#/home?url=https://github.com/QuantumKitHub/MPSKit.jl/examples/tree/gh-pages/dev/examples/quantum1d/5.haldane-spt) -# [Spin 1 Heisenberg model](@id spin1heisenberg) +# Spin 1 Heisenberg model The quantum Heisenberg model is a model often used in the study of critical points and phase transitions of magnetic systems, in which the spins are treated quantum mechanically. It @@ -102,9 +102,7 @@ sectors = SU2Irrep[0, 1 // 2, 1, 3 // 2] transferplot(ψ; sectors, title = "Transfer matrix spectrum", legend = :outertop) ```` -```@raw html - -``` +![](figure-1.png) Nevertheless, using the symmetry, this can be remedied rather easily, by imposing the ground state to belong to a single class, and comparing the results. We can readily obtain 3 @@ -130,7 +128,7 @@ E_plus = expectation_value(ψ_plus, H) ```` ```` --1.4014193313393002 - 1.1731597242433267e-16im +-1.4014193313393009 - 5.2545708620134027e-17im ```` ````julia @@ -141,7 +139,7 @@ E_minus = expectation_value(ψ_minus, H) ```` ```` --1.4014839739630833 + 2.1061363600641873e-16im +-1.401483973963084 - 2.875923408269285e-17im ```` ````julia @@ -156,9 +154,7 @@ transferp_minus = transferplot( plot(transferp_plus, transferp_minus; layout = (1, 2), size = (800, 400)) ```` -```@raw html - -``` +![](figure-2.png) ````julia entanglementp_plus = entanglementplot(ψ_plus; title = "ψ_plus", legend = :outertop) @@ -166,9 +162,7 @@ entanglementp_minus = entanglementplot(ψ_minus; title = "ψ_minus", legend = :o plot(entanglementp_plus, entanglementp_minus; layout = (1, 2), size = (800, 400)) ```` -```@raw html - -``` +![](figure-3.png) As we can see, the ground state can be found in the non-trivial SPT phase, $\ket{\psi_-}$. We can obtain an intuitive understanding of $\ket{\psi_+}$ by considering the following @@ -194,8 +188,8 @@ println("S_plus = $S_plus") ```` ```` -S_minus + log(2) = 1.5486227235412815 -S_plus = 1.545032353058148 +S_minus + log(2) = 1.5486227235421324 +S_plus = 1.5450323530571919 ```` diff --git a/docs/src/examples/quantum1d/5.haldane-spt/main.ipynb b/docs/src/examples/quantum1d/5.haldane-spt/main.ipynb index 57e53f288..b7906ad8d 100644 --- a/docs/src/examples/quantum1d/5.haldane-spt/main.ipynb +++ b/docs/src/examples/quantum1d/5.haldane-spt/main.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "markdown", + "metadata": {}, "source": [ "# Spin 1 Heisenberg model\n", "\n", @@ -30,12 +31,13 @@ "[Casimir element](https://en.wikipedia.org/wiki/Casimir_element) $\\vec{S}^2$, which commutes\n", "with the elements of $SU(2)$. Consequently, the Hamiltonian also commutes with all elements\n", "of $SU(2)$." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "using TensorKit\n", "using MPSKit\n", @@ -53,12 +55,11 @@ " return InfiniteMPOHamiltonian(SS)\n", "end\n", "H = heisenberg_hamiltonian()" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Symmetry-Protected Topological Order\n", "\n", @@ -89,12 +90,13 @@ "cannot deal with non-injective MPS. The resulting MPS will have multiple values of the\n", "transfer matrix spectrum that have a magnitude close to 1, which is a clear sign of a\n", "non-injective MPS." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "ℋ = SU2Space(1 => 1)\n", "V_wrong = SU2Space(0 => 8, 1 // 2 => 8, 1 => 3, 3 // 2 => 3)\n", @@ -102,12 +104,11 @@ "ψ, environments, δ = find_groundstate(ψ, H, VUMPS(; maxiter = 10))\n", "sectors = SU2Irrep[0, 1 // 2, 1, 3 // 2]\n", "transferplot(ψ; sectors, title = \"Transfer matrix spectrum\", legend = :outertop)" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "Nevertheless, using the symmetry, this can be remedied rather easily, by imposing the\n", "ground state to belong to a single class, and comparing the results. We can readily obtain 3\n", @@ -124,12 +125,13 @@ "Finally, the entanglement spectrum of the wrong SPT phase will show degeneracies of all\n", "singular values, which can again be attributed to an attempt to mimick the spectrum of the\n", "right SPT phase." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "V_plus = SU2Space(0 => 10, 1 => 5, 2 => 3)\n", "ψ_plus = InfiniteMPS(ℋ, V_plus)\n", @@ -151,12 +153,11 @@ "entanglementp_plus = entanglementplot(ψ_plus; title = \"ψ_plus\", legend = :outertop)\n", "entanglementp_minus = entanglementplot(ψ_minus; title = \"ψ_minus\", legend = :outertop)\n", "plot(entanglementp_plus, entanglementp_minus; layout = (1, 2), size = (800, 400))" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "As we can see, the ground state can be found in the non-trivial SPT phase, $\\ket{\\psi_-}$. We\n", "can obtain an intuitive understanding of $\\ket{\\psi_+}$ by considering the following\n", @@ -173,44 +174,43 @@ "intuition by looking at the entanglement entropy of the ground state. As we can see, the\n", "entanglement entropy of the state in the wrong SPT phase is exactly $log(2)$ higher than the\n", "one in the right SPT phase, which is exactly what we would expect from the diagram above." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "S_minus = sum(real, entropy(ψ_minus))\n", "S_plus = sum(real, entropy(ψ_plus))\n", "println(\"S_minus + log(2) = $(S_minus + log(2))\")\n", "println(\"S_plus = $S_plus\")" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" - ], - "metadata": {} + ] } ], - "nbformat_minor": 3, "metadata": { + "kernelspec": { + "display_name": "Julia 1.12.6", + "language": "julia", + "name": "julia-1.12" + }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.12.4" - }, - "kernelspec": { - "name": "julia-1.12", - "display_name": "Julia 1.12.4", - "language": "julia" + "version": "1.12.6" } }, - "nbformat": 4 + "nbformat": 4, + "nbformat_minor": 3 } \ No newline at end of file diff --git a/docs/src/examples/quantum1d/6.hubbard/figure-1.png b/docs/src/examples/quantum1d/6.hubbard/figure-1.png new file mode 100644 index 000000000..87a4f10f8 Binary files /dev/null and b/docs/src/examples/quantum1d/6.hubbard/figure-1.png differ diff --git a/docs/src/examples/quantum1d/6.hubbard/figure-2.png b/docs/src/examples/quantum1d/6.hubbard/figure-2.png new file mode 100644 index 000000000..f28bef941 Binary files /dev/null and b/docs/src/examples/quantum1d/6.hubbard/figure-2.png differ diff --git a/docs/src/examples/quantum1d/6.hubbard/figure-3.png b/docs/src/examples/quantum1d/6.hubbard/figure-3.png new file mode 100644 index 000000000..db0c2adce Binary files /dev/null and b/docs/src/examples/quantum1d/6.hubbard/figure-3.png differ diff --git a/docs/src/examples/quantum1d/6.hubbard/index.md b/docs/src/examples/quantum1d/6.hubbard/index.md index 91c9c424b..38fa9bc75 100644 --- a/docs/src/examples/quantum1d/6.hubbard/index.md +++ b/docs/src/examples/quantum1d/6.hubbard/index.md @@ -10,7 +10,7 @@ EditURL = "../../../../../examples/quantum1d/6.hubbard/main.jl" using Markdown ```` -# [Hubbard chain at half filling](@id hubbard) +# Hubbard chain at half filling The Hubbard model is a model of interacting fermions on a lattice, which is often used as a somewhat realistic model for electrons in a solid. The Hamiltonian consists of two terms that describe competing forces of each electron: @@ -115,54 +115,54 @@ Groundstate energy: ```` ```` -[ Info: VUMPS init: obj = -1.472548758147e+00 err = 5.1344e-01 -[ Info: VUMPS conv 6: obj = -4.376626743591e+00 err = 9.9886660196e-03 time = 4.42 sec -[ Info: VUMPS init: obj = -4.376626743590e+00 err = 2.1408e-02 -[ Info: VUMPS conv 8: obj = -4.378746003112e+00 err = 1.5955449521e-04 time = 0.42 sec -[ Info: VUMPS init: obj = -4.378746003112e+00 err = 8.1588e-03 -[ Info: VUMPS conv 6: obj = -4.379161057076e+00 err = 1.5466178028e-04 time = 0.43 sec -[ Info: VUMPS init: obj = -4.379161057076e+00 err = 6.1185e-03 -[ Info: VUMPS conv 5: obj = -4.379452137265e+00 err = 1.6793132081e-04 time = 0.42 sec -[ Info: VUMPS init: obj = -4.379452137265e+00 err = 5.6949e-03 -[ Info: VUMPS conv 4: obj = -4.379651664636e+00 err = 1.6997715633e-04 time = 0.51 sec -[ Info: VUMPS init: obj = -4.379651664636e+00 err = 4.1040e-03 -[ Info: VUMPS conv 3: obj = -4.379734890151e+00 err = 1.9458349625e-04 time = 0.43 sec -[ Info: VUMPS init: obj = -4.379734890151e+00 err = 3.5568e-03 -[ Info: VUMPS conv 3: obj = -4.379797732181e+00 err = 1.3874790123e-04 time = 0.49 sec -[ Info: VUMPS init: obj = -4.379797732181e+00 err = 2.7580e-03 -[ Info: VUMPS conv 2: obj = -4.379838437704e+00 err = 1.7903427058e-04 time = 0.37 sec -[ Info: VUMPS init: obj = -4.379838437704e+00 err = 2.7247e-03 -[ Info: VUMPS conv 3: obj = -4.379878817727e+00 err = 1.9890160987e-04 time = 0.86 sec -[ Info: VUMPS init: obj = -4.379878817727e+00 err = 2.6892e-03 -[ Info: VUMPS conv 3: obj = -4.379929192662e+00 err = 1.7735649634e-04 time = 1.10 sec -[ Info: VUMPS init: obj = -4.379929192662e+00 err = 2.5531e-03 -[ Info: VUMPS conv 3: obj = -4.379968013458e+00 err = 1.8131482590e-04 time = 2.36 sec -[ Info: VUMPS init: obj = -4.379968013458e+00 err = 1.7666e-03 -[ Info: VUMPS conv 2: obj = -4.379986848440e+00 err = 1.8697865996e-04 time = 1.01 sec -[ Info: VUMPS init: obj = -4.379986848440e+00 err = 1.5825e-03 -[ Info: VUMPS conv 2: obj = -4.380000756174e+00 err = 1.9154925356e-04 time = 1.54 sec -[ Info: VUMPS init: obj = -4.380000756174e+00 err = 1.5051e-03 -[ Info: VUMPS conv 2: obj = -4.380013136300e+00 err = 1.5515231683e-04 time = 1.88 sec -[ Info: VUMPS init: obj = -4.380013136300e+00 err = 1.4208e-03 -[ Info: VUMPS conv 2: obj = -4.380024381179e+00 err = 1.7768123800e-04 time = 2.03 sec -[ Info: VUMPS init: obj = -4.380024381179e+00 err = 1.3308e-03 -[ Info: VUMPS conv 2: obj = -4.380038135198e+00 err = 1.5610887648e-04 time = 2.47 sec -[ Info: VUMPS init: obj = -4.380038135198e+00 err = 1.0025e-03 -[ Info: VUMPS conv 1: obj = -4.380043663927e+00 err = 1.6686329927e-04 time = 1.29 sec -[ Info: VUMPS init: obj = -4.380043663928e+00 err = 9.0871e-04 -[ Info: VUMPS conv 1: obj = -4.380048620164e+00 err = 1.8550404960e-04 time = 1.73 sec -[ Info: VUMPS init: obj = -4.380048620164e+00 err = 8.3016e-04 -[ Info: VUMPS conv 1: obj = -4.380053179097e+00 err = 1.8078418705e-04 time = 1.88 sec -[ Info: VUMPS init: obj = -4.380053179097e+00 err = 6.8103e-04 -[ Info: VUMPS conv 1: obj = -4.380057119334e+00 err = 1.9088736457e-04 time = 3.48 sec -[ Info: VUMPS init: obj = -4.380057119334e+00 err = 6.0308e-04 -[ Info: VUMPS conv 1: obj = -4.380060522532e+00 err = 1.8437058341e-04 time = 3.48 sec -[ Info: VUMPS init: obj = -4.379610294430e+00 err = 4.0923e-03 -[ Info: VUMPS conv 19: obj = -4.379763567395e+00 err = 9.9309403645e-06 time = 11.96 sec -[ Info: CG: initializing with f = -4.379763567040e+00, ‖∇f‖ = 3.1464e-05 -[ Info: CG: converged after 154 iterations and time 1.64 m: f = -4.379763577686e+00, ‖∇f‖ = 9.2421e-07 +[ Info: VUMPS init: obj = -1.450454615857e+00 err = 5.5193e-01 +[ Info: VUMPS conv 7: obj = -4.377048688339e+00 err = 8.8092806195e-03 time = 4.49 sec +[ Info: VUMPS init: obj = -4.377048688339e+00 err = 1.6440e-02 +[ Info: VUMPS conv 6: obj = -4.378747269347e+00 err = 1.3129004135e-04 time = 0.25 sec +[ Info: VUMPS init: obj = -4.378747269347e+00 err = 7.9951e-03 +[ Info: VUMPS conv 6: obj = -4.379161081627e+00 err = 1.5539751336e-04 time = 0.37 sec +[ Info: VUMPS init: obj = -4.379161081627e+00 err = 6.1111e-03 +[ Info: VUMPS conv 5: obj = -4.379452169384e+00 err = 1.6927654674e-04 time = 0.27 sec +[ Info: VUMPS init: obj = -4.379452169384e+00 err = 5.6959e-03 +[ Info: VUMPS conv 4: obj = -4.379651733231e+00 err = 1.8162083040e-04 time = 0.26 sec +[ Info: VUMPS init: obj = -4.379651733231e+00 err = 4.1039e-03 +[ Info: VUMPS conv 4: obj = -4.379735601762e+00 err = 1.3801495045e-04 time = 0.42 sec +[ Info: VUMPS init: obj = -4.379735601762e+00 err = 3.5769e-03 +[ Info: VUMPS conv 3: obj = -4.379797886653e+00 err = 1.3472741143e-04 time = 0.39 sec +[ Info: VUMPS init: obj = -4.379797886653e+00 err = 2.7707e-03 +[ Info: VUMPS conv 2: obj = -4.379838526805e+00 err = 1.7752552389e-04 time = 0.33 sec +[ Info: VUMPS init: obj = -4.379838526805e+00 err = 2.7291e-03 +[ Info: VUMPS conv 3: obj = -4.379878849406e+00 err = 1.9781894590e-04 time = 0.74 sec +[ Info: VUMPS init: obj = -4.379878849406e+00 err = 2.6911e-03 +[ Info: VUMPS conv 3: obj = -4.379929229387e+00 err = 1.7761427615e-04 time = 0.82 sec +[ Info: VUMPS init: obj = -4.379929229387e+00 err = 2.5553e-03 +[ Info: VUMPS conv 3: obj = -4.379968040382e+00 err = 1.8461546636e-04 time = 2.21 sec +[ Info: VUMPS init: obj = -4.379968040382e+00 err = 1.7682e-03 +[ Info: VUMPS conv 2: obj = -4.379986877757e+00 err = 1.9131369028e-04 time = 0.98 sec +[ Info: VUMPS init: obj = -4.379986877757e+00 err = 1.5838e-03 +[ Info: VUMPS conv 2: obj = -4.380001005486e+00 err = 1.9231335759e-04 time = 1.05 sec +[ Info: VUMPS init: obj = -4.380001005486e+00 err = 1.5109e-03 +[ Info: VUMPS conv 2: obj = -4.380013169634e+00 err = 1.5225084116e-04 time = 1.32 sec +[ Info: VUMPS init: obj = -4.380013169634e+00 err = 1.4234e-03 +[ Info: VUMPS conv 2: obj = -4.380024401012e+00 err = 1.7737882775e-04 time = 1.59 sec +[ Info: VUMPS init: obj = -4.380024401012e+00 err = 1.3330e-03 +[ Info: VUMPS conv 2: obj = -4.380038158990e+00 err = 1.5757417636e-04 time = 2.60 sec +[ Info: VUMPS init: obj = -4.380038158990e+00 err = 1.0032e-03 +[ Info: VUMPS conv 1: obj = -4.380043682260e+00 err = 1.6736593859e-04 time = 0.89 sec +[ Info: VUMPS init: obj = -4.380043682260e+00 err = 9.0999e-04 +[ Info: VUMPS conv 1: obj = -4.380048641018e+00 err = 1.8573996574e-04 time = 1.19 sec +[ Info: VUMPS init: obj = -4.380048641018e+00 err = 8.3081e-04 +[ Info: VUMPS conv 1: obj = -4.380053199895e+00 err = 1.8060836975e-04 time = 2.30 sec +[ Info: VUMPS init: obj = -4.380053199895e+00 err = 6.8144e-04 +[ Info: VUMPS conv 1: obj = -4.380057143242e+00 err = 1.8854132138e-04 time = 1.71 sec +[ Info: VUMPS init: obj = -4.380057143242e+00 err = 6.0293e-04 +[ Info: VUMPS conv 1: obj = -4.380060551312e+00 err = 1.8083344266e-04 time = 2.45 sec +[ Info: VUMPS init: obj = -4.379609468445e+00 err = 4.0958e-03 +[ Info: VUMPS conv 19: obj = -4.379763157256e+00 err = 9.9415625365e-06 time = 8.41 sec +[ Info: CG: initializing with f = -4.379763156901e+00, ‖∇f‖ = 3.1520e-05 +[ Info: CG: converged after 158 iterations and time 1.36 m: f = -4.379763361376e+00, ‖∇f‖ = 9.9957e-07 ┌ Info: Groundstate energy: -│ * numerical: -2.1899960610249782 +│ * numerical: -2.1899960609769664 └ * analytic: -2.190038374277775 ```` @@ -196,56 +196,56 @@ Groundstate energy: ```` ```` -[ Info: VUMPS init: obj = -5.588042682004e-02 err = 9.2053e-01 -[ Info: VUMPS conv 1: obj = -4.000000000000e+00 err = 2.1240270466e-15 time = 2.96 sec +[ Info: VUMPS init: obj = +2.092499297284e-01 err = 8.6283e-01 +[ Info: VUMPS conv 1: obj = -4.000000000000e+00 err = 1.4030299342e-15 time = 2.40 sec [ Info: VUMPS init: obj = -4.000000000000e+00 err = 3.3634e-01 -[ Info: VUMPS conv 4: obj = -4.289650419749e+00 err = 1.8514003381e-04 time = 0.05 sec +[ Info: VUMPS conv 4: obj = -4.289650419749e+00 err = 1.8514003381e-04 time = 0.09 sec [ Info: VUMPS init: obj = -4.289650419749e+00 err = 1.1203e-01 -[ Info: VUMPS conv 6: obj = -4.359865567620e+00 err = 1.0046942911e-04 time = 0.14 sec +[ Info: VUMPS conv 6: obj = -4.359865567620e+00 err = 1.0046942911e-04 time = 0.29 sec [ Info: VUMPS init: obj = -4.359865567619e+00 err = 4.3643e-02 -[ Info: VUMPS conv 6: obj = -4.372880928482e+00 err = 1.3025843115e-04 time = 2.31 sec +[ Info: VUMPS conv 6: obj = -4.372880928482e+00 err = 1.3025843115e-04 time = 2.61 sec [ Info: VUMPS init: obj = -4.372880928482e+00 err = 3.2693e-02 -[ Info: VUMPS conv 4: obj = -4.375236954488e+00 err = 1.1814239608e-04 time = 0.17 sec +[ Info: VUMPS conv 4: obj = -4.375236954488e+00 err = 1.1814239608e-04 time = 0.20 sec [ Info: VUMPS init: obj = -4.375236954488e+00 err = 2.9487e-02 -[ Info: VUMPS conv 7: obj = -4.378159084364e+00 err = 1.1896740056e-04 time = 0.51 sec +[ Info: VUMPS conv 7: obj = -4.378159084364e+00 err = 1.1896740056e-04 time = 0.60 sec [ Info: VUMPS init: obj = -4.378159084364e+00 err = 1.9312e-02 -[ Info: VUMPS conv 5: obj = -4.379272966040e+00 err = 1.5785413165e-04 time = 0.34 sec +[ Info: VUMPS conv 5: obj = -4.379272966040e+00 err = 1.5785413165e-04 time = 0.50 sec [ Info: VUMPS init: obj = -4.379272966040e+00 err = 9.9128e-03 -[ Info: VUMPS conv 4: obj = -4.379592229143e+00 err = 1.5550378745e-04 time = 0.21 sec +[ Info: VUMPS conv 4: obj = -4.379592229143e+00 err = 1.5550378745e-04 time = 0.51 sec [ Info: VUMPS init: obj = -4.379592229143e+00 err = 6.4841e-03 -[ Info: VUMPS conv 4: obj = -4.379819377264e+00 err = 1.7492038571e-04 time = 0.27 sec +[ Info: VUMPS conv 4: obj = -4.379819377264e+00 err = 1.7492038571e-04 time = 0.56 sec [ Info: VUMPS init: obj = -4.379819377264e+00 err = 3.8754e-03 -┌ Warning: VUMPS cancel 10: obj = -4.379964033305e+00 err = 2.1228930049e-04 time = 1.29 sec -└ @ MPSKit /home/ldevos/LocalProjects/MPSKit.jl/src/algorithms/groundstate/vumps.jl:76 +┌ Warning: VUMPS cancel 10: obj = -4.379964033305e+00 err = 2.1228930049e-04 time = 1.76 sec +└ @ MPSKit ~/Projects/MPSKit.jl/docs/src/algorithms/groundstate/vumps.jl:83 [ Info: VUMPS init: obj = -4.379964033305e+00 err = 2.8978e-03 -[ Info: VUMPS conv 3: obj = -4.380010384710e+00 err = 1.4775284542e-04 time = 0.52 sec +[ Info: VUMPS conv 3: obj = -4.380010384710e+00 err = 1.4775284542e-04 time = 0.88 sec [ Info: VUMPS init: obj = -4.380010384710e+00 err = 2.0609e-03 -[ Info: VUMPS conv 3: obj = -4.380041751503e+00 err = 1.6327798118e-04 time = 0.86 sec +[ Info: VUMPS conv 3: obj = -4.380041751503e+00 err = 1.6327798118e-04 time = 1.81 sec [ Info: VUMPS init: obj = -4.380041751502e+00 err = 1.2364e-03 -[ Info: VUMPS conv 2: obj = -4.380055778759e+00 err = 1.8366845284e-04 time = 0.53 sec +[ Info: VUMPS conv 2: obj = -4.380055778759e+00 err = 1.8366845284e-04 time = 0.83 sec [ Info: VUMPS init: obj = -4.380055778759e+00 err = 8.5857e-04 -[ Info: VUMPS conv 2: obj = -4.380064749427e+00 err = 1.3905442267e-04 time = 0.96 sec +[ Info: VUMPS conv 2: obj = -4.380064749427e+00 err = 1.3905442267e-04 time = 1.14 sec [ Info: VUMPS init: obj = -4.380064749427e+00 err = 5.2502e-04 -[ Info: VUMPS conv 1: obj = -4.380067974777e+00 err = 1.5646700070e-04 time = 0.51 sec +[ Info: VUMPS conv 1: obj = -4.380067974777e+00 err = 1.5646700070e-04 time = 0.79 sec [ Info: VUMPS init: obj = -4.380067974777e+00 err = 3.3275e-04 [ Info: VUMPS conv 1: obj = -4.380070351418e+00 err = 1.3123916502e-04 time = 1.05 sec [ Info: VUMPS init: obj = -4.380070351418e+00 err = 2.0348e-04 -[ Info: VUMPS conv 1: obj = -4.380072125256e+00 err = 1.1119707628e-04 time = 1.50 sec +[ Info: VUMPS conv 1: obj = -4.380072125256e+00 err = 1.1119707628e-04 time = 2.15 sec [ Info: VUMPS init: obj = -4.380072125256e+00 err = 1.3635e-04 -[ Info: VUMPS conv 1: obj = -4.380073467830e+00 err = 8.5045032312e-05 time = 2.38 sec +[ Info: VUMPS conv 1: obj = -4.380073467831e+00 err = 8.5045032311e-05 time = 2.22 sec [ Info: VUMPS init: obj = -4.380073467830e+00 err = 9.7226e-05 -[ Info: VUMPS conv 1: obj = -4.380074455763e+00 err = 6.4430026630e-05 time = 3.97 sec +[ Info: VUMPS conv 1: obj = -4.380074455763e+00 err = 6.4430026631e-05 time = 3.60 sec [ Info: VUMPS init: obj = -4.380074455763e+00 err = 7.3787e-05 -[ Info: VUMPS conv 1: obj = -4.380075159887e+00 err = 6.2144398837e-05 time = 6.74 sec +[ Info: VUMPS conv 1: obj = -4.380075159887e+00 err = 6.2144398833e-05 time = 8.05 sec [ Info: VUMPS init: obj = -4.380075159887e+00 err = 5.9899e-05 -[ Info: VUMPS conv 1: obj = -4.380075661721e+00 err = 4.2515939995e-05 time = 11.38 sec +[ Info: VUMPS conv 1: obj = -4.380075661721e+00 err = 4.2515939994e-05 time = 12.11 sec [ Info: VUMPS init: obj = -4.379308795201e+00 err = 7.9930e-03 -┌ Warning: VUMPS cancel 100: obj = -4.379692711472e+00 err = 1.5979764630e-05 time = 17.26 sec -└ @ MPSKit /home/ldevos/LocalProjects/MPSKit.jl/src/algorithms/groundstate/vumps.jl:76 -[ Info: CG: initializing with f = -4.379692711471e+00, ‖∇f‖ = 5.7923e-05 -[ Info: CG: converged after 13 iterations and time 5.38 s: f = -4.379692712392e+00, ‖∇f‖ = 6.2087e-07 +┌ Warning: VUMPS cancel 100: obj = -4.379692711472e+00 err = 1.5979764572e-05 time = 27.91 sec +└ @ MPSKit ~/Projects/MPSKit.jl/docs/src/algorithms/groundstate/vumps.jl:83 +[ Info: CG: initializing with f = -4.379692711472e+00, ‖∇f‖ = 5.7923e-05 +[ Info: CG: converged after 13 iterations and time 7.22 s: f = -4.379692712393e+00, ‖∇f‖ = 6.2087e-07 ┌ Info: Groundstate energy: -│ * numerical: -2.190015347514449 +│ * numerical: -2.1900153475144695 └ * analytic: -2.190038374277775 ```` @@ -264,9 +264,9 @@ These excitations can be constructed as follows: alg = QuasiparticleAnsatz(; tol = 1.0e-3) momenta = range(-π, π; length = 33) psi_AB = psi -envs_AB = environments(psi_AB, H_u1_su2); +envs_AB = environments(psi_AB, H_u1_su2, psi_AB); psi_BA = circshift(psi, 1) -envs_BA = environments(psi_BA, H_u1_su2); +envs_BA = environments(psi_BA, H_u1_su2, psi_BA); spinon_charge = FermionParity(0) ⊠ U1Irrep(0) ⊠ SU2Irrep(1 // 2) E_spinon, ϕ_spinon = excitations( @@ -282,72 +282,72 @@ E_holon, ϕ_holon = excitations( ```` ```` -[ Info: Found excitations for momentum = 2.945243112740431 [ Info: Found excitations for momentum = -3.141592653589793 -[ Info: Found excitations for momentum = 0.0 -[ Info: Found excitations for momentum = 0.19634954084936207 -[ Info: Found excitations for momentum = -0.19634954084936207 -[ Info: Found excitations for momentum = -2.552544031041707 -[ Info: Found excitations for momentum = -2.748893571891069 [ Info: Found excitations for momentum = -2.945243112740431 +[ Info: Found excitations for momentum = -2.748893571891069 +[ Info: Found excitations for momentum = -2.552544031041707 +[ Info: Found excitations for momentum = -2.356194490192345 +[ Info: Found excitations for momentum = -2.1598449493429825 +[ Info: Found excitations for momentum = -1.7671458676442586 +[ Info: Found excitations for momentum = -1.9634954084936207 +[ Info: Found excitations for momentum = -1.5707963267948966 +[ Info: Found excitations for momentum = -1.3744467859455345 +[ Info: Found excitations for momentum = -0.9817477042468103 +[ Info: Found excitations for momentum = -1.1780972450961724 +[ Info: Found excitations for momentum = -0.7853981633974483 +[ Info: Found excitations for momentum = -0.5890486225480862 +[ Info: Found excitations for momentum = -0.19634954084936207 [ Info: Found excitations for momentum = -0.39269908169872414 +[ Info: Found excitations for momentum = 0.0 +[ Info: Found excitations for momentum = 0.19634954084936207 [ Info: Found excitations for momentum = 0.39269908169872414 -[ Info: Found excitations for momentum = 2.552544031041707 -[ Info: Found excitations for momentum = 2.748893571891069 -[ Info: Found excitations for momentum = -0.5890486225480862 [ Info: Found excitations for momentum = 0.5890486225480862 -[ Info: Found excitations for momentum = -0.7853981633974483 [ Info: Found excitations for momentum = 0.7853981633974483 -[ Info: Found excitations for momentum = 2.356194490192345 -[ Info: Found excitations for momentum = -2.356194490192345 -[ Info: Found excitations for momentum = 1.5707963267948966 -[ Info: Found excitations for momentum = -1.5707963267948966 [ Info: Found excitations for momentum = 0.9817477042468103 -[ Info: Found excitations for momentum = 2.1598449493429825 -[ Info: Found excitations for momentum = -0.9817477042468103 -[ Info: Found excitations for momentum = -2.1598449493429825 -[ Info: Found excitations for momentum = -1.1780972450961724 -[ Info: Found excitations for momentum = 1.7671458676442586 -[ Info: Found excitations for momentum = 1.9634954084936207 [ Info: Found excitations for momentum = 1.3744467859455345 -[ Info: Found excitations for momentum = -1.7671458676442586 -[ Info: Found excitations for momentum = -1.3744467859455345 -[ Info: Found excitations for momentum = -1.9634954084936207 -[ Info: Found excitations for momentum = 3.141592653589793 [ Info: Found excitations for momentum = 1.1780972450961724 -[ Info: Found excitations for momentum = -1.7671458676442586 [ Info: Found excitations for momentum = 1.5707963267948966 -[ Info: Found excitations for momentum = 1.3744467859455345 -[ Info: Found excitations for momentum = -1.3744467859455345 [ Info: Found excitations for momentum = 1.7671458676442586 +[ Info: Found excitations for momentum = 2.356194490192345 [ Info: Found excitations for momentum = 1.9634954084936207 -[ Info: Found excitations for momentum = -1.5707963267948966 -[ Info: Found excitations for momentum = -1.9634954084936207 -[ Info: Found excitations for momentum = 1.1780972450961724 [ Info: Found excitations for momentum = 2.1598449493429825 -[ Info: Found excitations for momentum = 0.0 -[ Info: Found excitations for momentum = -2.1598449493429825 -[ Info: Found excitations for momentum = 0.9817477042468103 -[ Info: Found excitations for momentum = -1.1780972450961724 +[ Info: Found excitations for momentum = 2.552544031041707 +[ Info: Found excitations for momentum = 2.748893571891069 +[ Info: Found excitations for momentum = 2.945243112740431 +[ Info: Found excitations for momentum = 3.141592653589793 [ Info: Found excitations for momentum = -3.141592653589793 +[ Info: Found excitations for momentum = -2.748893571891069 +[ Info: Found excitations for momentum = -2.552544031041707 +[ Info: Found excitations for momentum = -2.945243112740431 [ Info: Found excitations for momentum = -2.356194490192345 -[ Info: Found excitations for momentum = 2.552544031041707 -[ Info: Found excitations for momentum = 0.7853981633974483 -[ Info: Found excitations for momentum = 2.356194490192345 +[ Info: Found excitations for momentum = -2.1598449493429825 +[ Info: Found excitations for momentum = -1.9634954084936207 +[ Info: Found excitations for momentum = -1.7671458676442586 +[ Info: Found excitations for momentum = -1.5707963267948966 +[ Info: Found excitations for momentum = -1.3744467859455345 +[ Info: Found excitations for momentum = -1.1780972450961724 [ Info: Found excitations for momentum = -0.9817477042468103 [ Info: Found excitations for momentum = -0.7853981633974483 [ Info: Found excitations for momentum = -0.5890486225480862 -[ Info: Found excitations for momentum = 2.748893571891069 -[ Info: Found excitations for momentum = -2.748893571891069 -[ Info: Found excitations for momentum = 0.5890486225480862 -[ Info: Found excitations for momentum = 0.39269908169872414 -[ Info: Found excitations for momentum = -2.552544031041707 [ Info: Found excitations for momentum = -0.39269908169872414 [ Info: Found excitations for momentum = -0.19634954084936207 -[ Info: Found excitations for momentum = 2.945243112740431 +[ Info: Found excitations for momentum = 0.0 [ Info: Found excitations for momentum = 0.19634954084936207 -[ Info: Found excitations for momentum = -2.945243112740431 +[ Info: Found excitations for momentum = 0.39269908169872414 +[ Info: Found excitations for momentum = 0.5890486225480862 +[ Info: Found excitations for momentum = 0.7853981633974483 +[ Info: Found excitations for momentum = 0.9817477042468103 +[ Info: Found excitations for momentum = 1.1780972450961724 +[ Info: Found excitations for momentum = 1.3744467859455345 +[ Info: Found excitations for momentum = 1.5707963267948966 +[ Info: Found excitations for momentum = 1.7671458676442586 +[ Info: Found excitations for momentum = 1.9634954084936207 +[ Info: Found excitations for momentum = 2.1598449493429825 +[ Info: Found excitations for momentum = 2.356194490192345 +[ Info: Found excitations for momentum = 2.552544031041707 +[ Info: Found excitations for momentum = 2.748893571891069 [ Info: Found excitations for momentum = 3.141592653589793 +[ Info: Found excitations for momentum = 2.945243112740431 ```` @@ -400,9 +400,7 @@ p = let p_excitations = plot(; xaxis = "momentum", yaxis = "energy") end ```` -```@raw html - -``` +![](figure-1.png) The plot shows some discrepancies between the numerical and analytic results. First and foremost, we must realize that in the thermodynamic limit, the momentum of a domain wall is actually not well-defined. @@ -422,9 +420,7 @@ p = let p_excitations = plot(; xaxis = "momentum", yaxis = "energy", xlims = (- end ```` -```@raw html - -``` +![](figure-2.png) The second discrepancy is that while the spinon dispersion is well-reproduced, the holon dispersion is not. This is due to the fact that the excitation ansatz captures the lowest-energy excitation, and not the elementary single-particle excitation. @@ -490,9 +486,7 @@ p = let p_excitations = plot(; end ```` -```@raw html - -``` +![](figure-3.png) --- diff --git a/docs/src/examples/quantum1d/6.hubbard/main.ipynb b/docs/src/examples/quantum1d/6.hubbard/main.ipynb index 1524ffac0..4371e2364 100644 --- a/docs/src/examples/quantum1d/6.hubbard/main.ipynb +++ b/docs/src/examples/quantum1d/6.hubbard/main.ipynb @@ -1,16 +1,17 @@ { "cells": [ { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "using Markdown" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "# Hubbard chain at half filling\n", "\n", @@ -36,12 +37,13 @@ "$$\n", "H = - \\sum_{\\langle i, j \\rangle, \\sigma} c^{\\dagger}_{i,\\sigma} c_{j,\\sigma} + u \\sum_i (1 - 2 n_{i,\\uparrow}) (1 - 2 n_{i,\\downarrow})\n", "$$" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "using TensorKit\n", "using MPSKit\n", @@ -56,12 +58,11 @@ "const t = 1.0\n", "const mu = 0.0\n", "const U = 3.0" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "For this case, the ground state energy has an analytic solution, which can be used to benchmark the numerical results.\n", "It follows from Eq. (6.82) in []().\n", @@ -71,12 +72,13 @@ "$$\n", "\n", "We can easily verify this by comparing the numerical results to the analytic solution." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "function hubbard_energy(u; rtol = 1.0e-12)\n", " integrandum(ω) = besselj0(ω) * besselj1(ω) / (1 + exp(2u * ω)) / ω\n", @@ -125,12 +127,11 @@ " * numerical: $E\n", " * analytic: $(hubbard_energy(U / 4) - U / 4)\n", "\"\"\"" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Symmetries\n", "\n", @@ -142,12 +143,13 @@ "By construction, imposing symmetries restricts the optimization procedure to a single symmetry sector, which is the trivial sector.\n", "In order to work at half-filling, we need to effectively inject one particle per site.\n", "In MPSKit, this is achieved by the `add_physical_charge` function, which shifts the physical spaces of the tensors to the desired charge sector." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "H_u1_su2 = hubbard_model(ComplexF64, U1Irrep, SU2Irrep, InfiniteChain(2); U, t, mu = U / 2);\n", "charges = fill(FermionParity(1) ⊠ U1Irrep(1) ⊠ SU2Irrep(0), 2);\n", @@ -163,12 +165,11 @@ " * numerical: $E\n", " * analytic: $(hubbard_energy(U / 4) - U / 4)\n", "\"\"\"" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "## Excitations\n", "\n", @@ -179,19 +180,20 @@ "The domain walls can be constructed by noticing that there are two equivalent groundstates, which differ by a translation over a single site.\n", "In other words, the groundstates are $\\psi_{AB}` and $\\psi_{BA}$, where $A$ and $B$ are the two sites.\n", "These excitations can be constructed as follows:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "alg = QuasiparticleAnsatz(; tol = 1.0e-3)\n", "momenta = range(-π, π; length = 33)\n", "psi_AB = psi\n", - "envs_AB = environments(psi_AB, H_u1_su2);\n", + "envs_AB = environments(psi_AB, H_u1_su2, psi_AB);\n", "psi_BA = circshift(psi, 1)\n", - "envs_BA = environments(psi_BA, H_u1_su2);\n", + "envs_BA = environments(psi_BA, H_u1_su2, psi_BA);\n", "\n", "spinon_charge = FermionParity(0) ⊠ U1Irrep(0) ⊠ SU2Irrep(1 // 2)\n", "E_spinon, ϕ_spinon = excitations(\n", @@ -204,21 +206,21 @@ " H_u1_su2, alg, momenta, psi_AB, envs_AB, psi_BA, envs_BA;\n", " sector = holon_charge, num = 1\n", ");" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "Again, we can compare the numerical results to the analytic solution.\n", "Here, the formulae for the excitation energies are expressed in terms of dressed momenta:" - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "function spinon_momentum(Λ, u; rtol = 1.0e-12)\n", " integrandum(ω) = besselj0(ω) * sin(ω * Λ) / ω / cosh(ω * u)\n", @@ -263,23 +265,23 @@ "\n", " p_excitations\n", "end" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "The plot shows some discrepancies between the numerical and analytic results.\n", "First and foremost, we must realize that in the thermodynamic limit, the momentum of a domain wall is actually not well-defined.\n", "Concretely, only the difference in momentum between the two groundstates is well-defined, as we can always shift the momentum by multiplying one of the groundstates by a phase.\n", "Here, we can fix this shift by realizing that our choice of shifting the groundstates by a single site, differs from the formula by a factor $\\pi/2$." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "momenta_shifted = rem2pi.(momenta .- π / 2, RoundNearest)\n", "p = let p_excitations = plot(; xaxis = \"momentum\", yaxis = \"energy\", xlims = (-π, π))\n", @@ -291,24 +293,24 @@ "\n", " p_excitations\n", "end" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "The second discrepancy is that while the spinon dispersion is well-reproduced, the holon dispersion is not.\n", "This is due to the fact that the excitation ansatz captures the lowest-energy excitation, and not the elementary single-particle excitation.\n", "To make this explicit, we can consider the scattering states comprising of a holon and two spinons.\n", "If these are truly scattering states, the energy of the scattering state should be the sum of the energies of the individual excitations, and the momentum is the sum of the momenta.\n", "Thus, we can find the lowest-energy scattering states by minimizing the energy over the combination of momenta for the constituent elementary excitations." - ], - "metadata": {} + ] }, { - "outputs": [], "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "holon_dispersion_itp = linear_interpolation(\n", " P_holon_analytic, E_holon_analytic;\n", @@ -365,33 +367,31 @@ "\n", " p_excitations\n", "end" - ], - "metadata": {}, - "execution_count": null + ] }, { "cell_type": "markdown", + "metadata": {}, "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" - ], - "metadata": {} + ] } ], - "nbformat_minor": 3, "metadata": { + "kernelspec": { + "display_name": "Julia 1.12.6", + "language": "julia", + "name": "julia-1.12" + }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.12.4" - }, - "kernelspec": { - "name": "julia-1.12", - "display_name": "Julia 1.12.4", - "language": "julia" + "version": "1.12.6" } }, - "nbformat": 4 + "nbformat": 4, + "nbformat_minor": 3 } \ No newline at end of file diff --git a/docs/src/examples/quantum1d/7.xy-finiteT/figure-1.png b/docs/src/examples/quantum1d/7.xy-finiteT/figure-1.png new file mode 100644 index 000000000..da451a216 Binary files /dev/null and b/docs/src/examples/quantum1d/7.xy-finiteT/figure-1.png differ diff --git a/docs/src/examples/quantum1d/7.xy-finiteT/figure-2.png b/docs/src/examples/quantum1d/7.xy-finiteT/figure-2.png new file mode 100644 index 000000000..94ec71854 Binary files /dev/null and b/docs/src/examples/quantum1d/7.xy-finiteT/figure-2.png differ diff --git a/docs/src/examples/quantum1d/7.xy-finiteT/figure-3.png b/docs/src/examples/quantum1d/7.xy-finiteT/figure-3.png new file mode 100644 index 000000000..9daa46501 Binary files /dev/null and b/docs/src/examples/quantum1d/7.xy-finiteT/figure-3.png differ diff --git a/docs/src/examples/quantum1d/7.xy-finiteT/figure-4.png b/docs/src/examples/quantum1d/7.xy-finiteT/figure-4.png new file mode 100644 index 000000000..e15988a40 Binary files /dev/null and b/docs/src/examples/quantum1d/7.xy-finiteT/figure-4.png differ diff --git a/docs/src/examples/quantum1d/7.xy-finiteT/figure-5.png b/docs/src/examples/quantum1d/7.xy-finiteT/figure-5.png new file mode 100644 index 000000000..733496a0c Binary files /dev/null and b/docs/src/examples/quantum1d/7.xy-finiteT/figure-5.png differ diff --git a/docs/src/examples/quantum1d/7.xy-finiteT/figure-6.png b/docs/src/examples/quantum1d/7.xy-finiteT/figure-6.png new file mode 100644 index 000000000..c2680aed3 Binary files /dev/null and b/docs/src/examples/quantum1d/7.xy-finiteT/figure-6.png differ diff --git a/docs/src/examples/quantum1d/7.xy-finiteT/index.md b/docs/src/examples/quantum1d/7.xy-finiteT/index.md index 983ad0858..264ebade7 100644 --- a/docs/src/examples/quantum1d/7.xy-finiteT/index.md +++ b/docs/src/examples/quantum1d/7.xy-finiteT/index.md @@ -238,9 +238,7 @@ p_taylor = let end ```` -```@raw html - -``` +![](figure-1.png) Some observations: - The first order approximation fails to capture the behavior of the partition function. @@ -293,9 +291,7 @@ p_taylor_diff = let end ```` -```@raw html - -``` +![](figure-2.png) We can now clearly see that, somewhat unsurprisingly, the error increases the larger $\beta$ becomes. Given that we are computing Taylor expansions around $\beta = 0$, this is to be expected. @@ -349,9 +345,7 @@ p_taylor2_diff = let end ```` -```@raw html - -``` +![](figure-3.png) ### MPO multiplication approach (linear) @@ -428,9 +422,7 @@ p_mpo_mul_diff = let end ```` -```@raw html - -``` +![](figure-4.png) This approach clearly improves the accuracy of the results, indicating that we can indeed compute partition functions at larger $\beta$ values. However, the computational cost of this approach (at fixed maximal bond dimension) is now linear in $\beta$, since we need to compute the partition function at each $\beta$ value. @@ -510,9 +502,7 @@ p_mpo_mul_exp_diff = let end ```` -```@raw html - -``` +![](figure-5.png) Clearly, the exponential approach allows us to reach larger $\beta$ values much quicker, but there is again a trade-off. Since the size of the steps are increasing, we need to be more careful with the accuracy of our approximations. @@ -582,9 +572,7 @@ p_mpo_mul_diff = let end ```` -```@raw html - -``` +![](figure-6.png) !!! note We could further improve the accuracy of the TDVP approach by evolving with $(H \otimes \mathbb{1} + \mathbb{1} \otimes H^\dagger)$, rather than $H \otimes \mathbb{1}$ which is the current implementation. diff --git a/docs/src/examples/quantum1d/8.bose-hubbard/figure-1.png b/docs/src/examples/quantum1d/8.bose-hubbard/figure-1.png new file mode 100644 index 000000000..358ff7c7f Binary files /dev/null and b/docs/src/examples/quantum1d/8.bose-hubbard/figure-1.png differ diff --git a/docs/src/examples/quantum1d/8.bose-hubbard/figure-2.png b/docs/src/examples/quantum1d/8.bose-hubbard/figure-2.png new file mode 100644 index 000000000..85b39fd2f Binary files /dev/null and b/docs/src/examples/quantum1d/8.bose-hubbard/figure-2.png differ diff --git a/docs/src/examples/quantum1d/8.bose-hubbard/figure-3.png b/docs/src/examples/quantum1d/8.bose-hubbard/figure-3.png new file mode 100644 index 000000000..85f16f318 Binary files /dev/null and b/docs/src/examples/quantum1d/8.bose-hubbard/figure-3.png differ diff --git a/docs/src/examples/quantum1d/8.bose-hubbard/figure-4.png b/docs/src/examples/quantum1d/8.bose-hubbard/figure-4.png new file mode 100644 index 000000000..5a88f7b67 Binary files /dev/null and b/docs/src/examples/quantum1d/8.bose-hubbard/figure-4.png differ diff --git a/docs/src/examples/quantum1d/8.bose-hubbard/figure-5.png b/docs/src/examples/quantum1d/8.bose-hubbard/figure-5.png new file mode 100644 index 000000000..4048167a9 Binary files /dev/null and b/docs/src/examples/quantum1d/8.bose-hubbard/figure-5.png differ diff --git a/docs/src/examples/quantum1d/8.bose-hubbard/figure-6.png b/docs/src/examples/quantum1d/8.bose-hubbard/figure-6.png new file mode 100644 index 000000000..9eec6c12d Binary files /dev/null and b/docs/src/examples/quantum1d/8.bose-hubbard/figure-6.png differ diff --git a/docs/src/examples/quantum1d/8.bose-hubbard/index.md b/docs/src/examples/quantum1d/8.bose-hubbard/index.md index 7c1ff7ee0..bc1bdcd1a 100644 --- a/docs/src/examples/quantum1d/8.bose-hubbard/index.md +++ b/docs/src/examples/quantum1d/8.bose-hubbard/index.md @@ -197,9 +197,7 @@ plot(map(i -> real.(expectation_value(ground_state, (0, i) => a_op' ⊗ a_op)), hline!([abs2(expectation_value(ground_state, (0,) => a_op))], ls = :dash, c = :black) ```` -```@raw html - -``` +![](figure-1.png) We see that the correlations drop off exponentially, indicating the existence of a gapped Mott insulating phase. Let us now shift our parameters to probe other phases. @@ -211,9 +209,7 @@ plot(map(i -> real.(expectation_value(ground_state, (0, i) => a_op' ⊗ a_op)), hline!([abs2(expectation_value(ground_state, (0,) => a_op))], ls = :dash, c = :black) ```` -```@raw html - -``` +![](figure-2.png) In this case, the correlation function drops off algebraically and eventually saturates as $\lim_{i \to \infty}\langle\hat{a}_i^{\dagger} \hat{a}_j\rangle ≈ \langle \hat{a}_i^{\dagger}\rangle \langle \hat{a}_j \rangle = |\langle a_i \rangle|^2 \neq 0$. @@ -275,9 +271,7 @@ scatter!( ) ```` -```@raw html - -``` +![](figure-3.png) This shows that any finite bond dimension MPS necessarily breaks the symmetry of the system, forming a Bose-Einstein condensate which introduces erraneous long-distance behaviour of @@ -350,9 +344,7 @@ momentum_distribution = vcat(momentum_distribution...)' plot(ks, momentum_distribution, lab = "D = " .* string.(permutedims(Ds)), lw = 1.5, xlabel = "Momentum k", ylabel = L"\langle n_k \rangle", ylim = [0, 50]) ```` -```@raw html - -``` +![](figure-4.png) We see that the density seems to peak around $k=0$, this time seemingly becoming more prominent as $D \to \infty$ which seems to suggest again that there is a condensate. @@ -434,9 +426,7 @@ superfluid_stiffness_profile(0.2, 0.3, 5, 4) # superfluid superfluid_stiffness_profile(0.01, 0.3, 5, 4) # mott insulator ```` -```@raw html - -``` +![](figure-5.png) Now that we know what phases to expect, we can plot the phase diagram by scanning over a range of parameters. In general, one could do better by performing a bisection algorithm for @@ -465,9 +455,7 @@ end heatmap(ts, mus, order_parameters, xlabel = L"t/U", ylabel = L"\mu/U", title = L"\langle \hat{a}_i \rangle") ```` -```@raw html - -``` +![](figure-6.png) Although the bond dimension here is quite low, we already see the deformation of the Mott insulator lobes to give way to the well known BKT transition that happens at commensurate diff --git a/docs/src/index.md b/docs/src/index.md index 48b4c30a1..dd86bb1ba 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -1,13 +1,50 @@ -# MPSKit.jl - -**Efficient and versatile tools for working with matrix product states** +```@raw html +--- +# https://vitepress.dev/reference/default-theme-home-page +layout: home + +hero: + name: MPSKit.jl + text: Matrix product states in Julia + tagline: Efficient and versatile tools for working with matrix product states + image: + src: /logo.svg + alt: MPSKit.jl + actions: + - theme: brand + text: Manual + link: /man/intro + - theme: alt + text: Examples + link: /examples/ + - theme: alt + text: View on GitHub + link: https://github.com/QuantumKitHub/MPSKit.jl + +features: + - icon: 🔗 + title: States + details: Construction and manipulation of finite and infinite Matrix Product States (MPS). + - icon: 📏 + title: Observables + details: Calculation of observables and expectation values. + - icon: 🎯 + title: Optimization + details: Various optimization methods for obtaining MPS fixed points. + - icon: ⚛️ + title: Symmetries + details: Support for a wide variety of symmetries, including Abelian, non-Abelian, fermionic and anyonic symmetries. +--- +``` ## Table of contents -```@contents -Pages = ["man/intro.md","man/conventions.md","man/states.md","man/operators.md","man/algorithms.md","man/parallelism.md", "man/lattices.md"] -Depth = 1 -``` +- [Prerequisites](@ref) +- [States](@ref um_states) +- [Operators](@ref um_operators) +- [Algorithms](@ref um_algorithms) +- [Parallelism in julia](@ref) +- [Lattices](@ref lattices) ## Installation @@ -17,14 +54,6 @@ as: pkg> add MPSKit ``` -## Key Features - -- Construction and manipulation of Matrix Product States (MPS) -- Calculation of observables and expectation values -- Various optimization methods for obtaining MPS fixed points -- Support for both finite and infinite MPS -- Support for wide variety of symmetries, including Abelian, non-Abelian, fermionic and anyonic symmetries - ## Usage To get started with MPSKit, we recommend also including diff --git a/docs/src/man/environments.md b/docs/src/man/environments.md index dbe00ad25..6d431e05e 100644 --- a/docs/src/man/environments.md +++ b/docs/src/man/environments.md @@ -19,7 +19,7 @@ operator = nonsym_ising_ham(); an environment object can be created by calling ```julia -envs = environments(state, operator) +envs = environments(state, operator, state) ``` The partially contracted mpohamiltonian left of site i can then be queried using: @@ -44,7 +44,7 @@ Infinite Environments are very similar : ```julia state = InfiniteMPS(ℂ^2, ℂ^10) operator = transverse_field_ising() -envs = environments(state, operator) +envs = environments(state, operator, state) ``` There are also some notable differences. Infinite environments typically require solving linear problems or eigenvalue problems iteratively with finite precision. To find out what precision we used we can type: diff --git a/docs/src/man/intro.md b/docs/src/man/intro.md index 48204a5b4..ee6c3ddeb 100644 --- a/docs/src/man/intro.md +++ b/docs/src/man/intro.md @@ -66,7 +66,7 @@ For more information, check out the [TensorKit documentation](https://quantumkit The general definition of an MPS tensor is as follows: ```@raw html -convention MPSTensor +convention MPSTensor ``` These tensors are allowed to have an arbitrary number of physical legs, and both `FiniteMPS` @@ -77,14 +77,14 @@ Similarly, the definition of a bond tensor, appearing in between two MPS tensors follows: ```@raw html -convention BondTensor +convention BondTensor ``` Finally, the definition of a MPO tensor, which is used to represent statistical mechanics problems as well as quantum Hamiltonians, is represented as: ```@raw html -convention MPOTensor +convention MPOTensor ``` While this results at first glance in the not very intuitive ordering of spaces as $V_l diff --git a/docs/src/man/operators.md b/docs/src/man/operators.md index 536a97475..05525add2 100644 --- a/docs/src/man/operators.md +++ b/docs/src/man/operators.md @@ -14,7 +14,7 @@ a dense operator (a subtype of `AbstractTensorMap`), which is then decomposed in product of local tensors. ```@raw html -MPO +MPO ``` ```@setup operators diff --git a/docs/src/man/states.md b/docs/src/man/states.md index 80b018d10..168b2117c 100644 --- a/docs/src/man/states.md +++ b/docs/src/man/states.md @@ -11,7 +11,7 @@ using LinearAlgebra: dot A [`FiniteMPS`](@ref) is - at its core - a chain of mps tensors. ```@raw html -finite MPS +finite MPS ``` ### Usage @@ -40,7 +40,7 @@ An MPS representation is not unique: for every virtual bond we can insert $C \cd Then, by redefining the tensors on both sides of the bond to include one factor each, we can change the representation. ```@raw html -MPS gauge freedom +MPS gauge freedom ``` There are two particularly convenient choices for the gauge at a site, the so-called left and right canonical form. diff --git a/examples/Cache.toml b/examples/Cache.toml index b41aab9b5..76b7cebb6 100644 --- a/examples/Cache.toml +++ b/examples/Cache.toml @@ -1,12 +1,12 @@ [classic2d] -"1.hard-hexagon" = "b78b475bee20d0366789a01277b6242089c9a610290df012bd66ad880127553b" +"1.hard-hexagon" = "71d189b9138f98545c4239ed80a922cc4182e934db30af5ba867a0cee57305d0" [quantum1d] -"2.haldane" = "b81cbd6a4b9347be45acb779fa6e91b3c64c127d39e8a299aea64198ca24fba7" -"6.hubbard" = "f5710bddbb5bc7dc95b69978d45d70fe0a3d3d65dfbad66ad985d8977914c710" +"2.haldane" = "c5a0eb70f0930d38053535c659ab39a87121b6ebda040ceadd9deb5f30921315" +"6.hubbard" = "cef140a6224350345735aac889ee7e33724fc0af9ce94f68be47a7e40107c09c" "7.xy-finiteT" = "0f330a157bea739a43a82a937791c680b2fa6e5e479171ee5ef318d1fdae7bcf" "8.bose-hubbard" = "a060ac3e29a9169e9420f7125cdb020c83b26a380508ac85f108bff1562bc70c" -"3.ising-dqpt" = "735882054a689df10ce0123c56fcc131d5d1156b8d12e9237d544e81b086250d" -"5.haldane-spt" = "9fce2c2d34c9e3a3b91dff3c3cba6404db6880fd92e66dcdfbbe7a6f3067495b" +"3.ising-dqpt" = "a2900eed23de7655f600943fae72d1dc35f87f33d11947f707d302ce245399fe" +"5.haldane-spt" = "28eb0350bd7e721866ccc1c14744e78ae5c650fda81e5f0eefb91de40ee4a76a" "4.xxz-heisenberg" = "9033fb104c3f658ccb1b8e335b986b7abda59e0b5359be086d3b62e1cc32ebd6" -"1.ising-cft" = "ee6512b8e92aaaf42142b80024b905e9396aff75d4d60f77a29c18b234d1f65c" +"1.ising-cft" = "3d34757eee7b95120b746c5e30e713203a876a87353ecd9937798f29183c9916" diff --git a/examples/Project.toml b/examples/Project.toml index 3a4751664..2e29ddd9c 100644 --- a/examples/Project.toml +++ b/examples/Project.toml @@ -14,3 +14,6 @@ QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" TensorKit = "07d1fe3e-3e46-537d-9eac-e9e13d0d4cec" TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2" + +[sources] +MPSKit = {path = ".."} diff --git a/examples/classic2d/1.hard-hexagon/main.jl b/examples/classic2d/1.hard-hexagon/main.jl index bdd6dc41a..3557caa24 100644 --- a/examples/classic2d/1.hard-hexagon/main.jl +++ b/examples/classic2d/1.hard-hexagon/main.jl @@ -1,5 +1,5 @@ md""" -# [The Hard Hexagon model](@id demo_hardhexagon) +# The Hard Hexagon model ![logo](hexagon.svg) diff --git a/examples/figure_externalization.jl b/examples/figure_externalization.jl new file mode 100644 index 000000000..54db91a87 --- /dev/null +++ b/examples/figure_externalization.jl @@ -0,0 +1,60 @@ +# Centralized figure externalization for the documentation examples. +# +# `Literate.markdown(...; execute = true)` embeds figures produced by the examples as +# base64 data URIs inside `@raw html` blocks, e.g. +# +# ```@raw html +# +# ``` +# +# which bloats the generated `index.md` files. The helpers here rewrite those blocks to +# standard markdown image references (`![](figure-N.png)`) and write the decoded image bytes +# to external files next to the page. File-referencing ``/`![]` tags (e.g. the committed +# `*.svg` diagrams) are left untouched — only `data:...;base64,` sources are externalized. + +using Base64 + +# A `@raw html` fenced block whose body is a single `` tag. +const _RAW_IMG_BLOCK = r"```@raw html[ \t]*\r?\n[ \t]*(]*>)[ \t]*\r?\n```" +# A base64 image data URI inside such a tag: capture the MIME subtype and the payload. +const _DATA_URI = r"data:image/([A-Za-z0-9.+-]+);base64,([A-Za-z0-9+/=]+)" + +_ext_for(fmt) = fmt == "svg+xml" ? "svg" : fmt + +""" + externalize_figures(content::AbstractString, dir; prefix="figure") -> String + +Rewrite base64 `@raw html` image blocks in `content` to `![](-N.)`, writing the +decoded bytes to `/-N.`. Blocks without a `data:...;base64,` source are left +unchanged. Returns the rewritten markdown. +""" +function externalize_figures(content::AbstractString, dir::AbstractString; prefix = "figure") + n = 0 + return replace( + content, _RAW_IMG_BLOCK => function (block) + m = match(_DATA_URI, block) + m === nothing && return block # e.g. an — leave it alone + ext = _ext_for(m.captures[1]) + n += 1 + fname = "$(prefix)-$(n).$(ext)" + mkpath(dir) + write(joinpath(dir, fname), base64decode(m.captures[2])) + return "![]($(fname))" + end + ) +end + +""" + externalize_figures!(index_md_path; prefix="figure") -> Int + +Apply [`externalize_figures`](@ref) to the file at `index_md_path` in place, writing the image +files into the page's own directory. Returns the number of figures externalized (0 leaves the +file untouched). Idempotent. +""" +function externalize_figures!(index_md_path::AbstractString; prefix = "figure") + content = read(index_md_path, String) + nfigs = length(collect(eachmatch(_DATA_URI, content))) + new = externalize_figures(content, dirname(index_md_path); prefix) + new != content && write(index_md_path, new) + return nfigs +end diff --git a/examples/make.jl b/examples/make.jl index d7242db42..c6c9cfd72 100644 --- a/examples/make.jl +++ b/examples/make.jl @@ -11,6 +11,8 @@ using MPSKit using Literate using TOML, SHA +include(joinpath(@__DIR__, "figure_externalization.jl")) + # ---------------------------------------------------------------------------------------- # # Caching # ---------------------------------------------------------------------------------------- # @@ -71,7 +73,9 @@ function build_example(root, name) return if !iscached(root, name) Literate.markdown( source_file, target_dir; execute = true, name = "index", - preprocess = attach_notebook_badge(root, name), mdstrings = true, + preprocess = attach_notebook_badge(root, name), + postprocess = content -> externalize_figures(content, target_dir), + mdstrings = true, nbviewer_root_url = "https://nbviewer.jupyter.org/github/QuantumKitHub/MPSKit.jl/blob/gh-pages/dev", binder_root_url = "https://mybinder.org/v2/gh/QuantumKitHub/MPSKit.jl/gh-pages?filepath=dev", credits = false, diff --git a/examples/quantum1d/1.ising-cft/main.jl b/examples/quantum1d/1.ising-cft/main.jl index c473b59b1..a3f45887e 100644 --- a/examples/quantum1d/1.ising-cft/main.jl +++ b/examples/quantum1d/1.ising-cft/main.jl @@ -47,7 +47,7 @@ through the use of the translation operator. This operator can be defined in MPO either diagramatically as ```@raw html -translation operator +translation operator ``` or in the code as: diff --git a/examples/quantum1d/2.haldane/main.jl b/examples/quantum1d/2.haldane/main.jl index 37e16ba90..98ac72a0e 100644 --- a/examples/quantum1d/2.haldane/main.jl +++ b/examples/quantum1d/2.haldane/main.jl @@ -1,5 +1,5 @@ md""" -# [The Haldane gap](@id demo_haldane) +# The Haldane gap In this tutorial we will calculate the Haldane gap (the energy gap in the ``S = 1`` Heisenberg model) in two different ways. To follow the tutorial you need the following packages: diff --git a/examples/quantum1d/3.ising-dqpt/main.jl b/examples/quantum1d/3.ising-dqpt/main.jl index b9232ae00..3d445cf58 100644 --- a/examples/quantum1d/3.ising-dqpt/main.jl +++ b/examples/quantum1d/3.ising-dqpt/main.jl @@ -1,5 +1,5 @@ md""" -# [DQPT in the Ising model](@id demo_dqpt) +# DQPT in the Ising model In this tutorial we will try to reproduce the results from [this paper](https://arxiv.org/pdf/1206.2505.pdf). The needed packages are @@ -61,7 +61,7 @@ function finite_sim(L; dt = 0.05, finaltime = 5.0) H₁ = transverse_field_ising(FiniteChain(L); g = -2.0) ψₜ = deepcopy(ψ₀) - envs = environments(ψₜ, H₁) + envs = environments(ψₜ, H₁, ψₜ) echos = [echo(ψₜ, ψ₀)] times = collect(0:dt:finaltime) @@ -126,7 +126,7 @@ function infinite_sim(dt = 0.05, finaltime = 5.0) ψ₀, _ = find_groundstate(ψ₀, H₀, VUMPS()) ψₜ = deepcopy(ψ₀) - envs = environments(ψₜ, H₁) + envs = environments(ψₜ, H₁, ψₜ) echos = [echo(ψₜ, ψ₀)] times = collect(0:dt:finaltime) diff --git a/examples/quantum1d/5.haldane-spt/main.jl b/examples/quantum1d/5.haldane-spt/main.jl index 7bccee8e4..528fd3067 100644 --- a/examples/quantum1d/5.haldane-spt/main.jl +++ b/examples/quantum1d/5.haldane-spt/main.jl @@ -1,5 +1,5 @@ md""" -# [Spin 1 Heisenberg model](@id spin1heisenberg) +# Spin 1 Heisenberg model The quantum Heisenberg model is a model often used in the study of critical points and phase transitions of magnetic systems, in which the spins are treated quantum mechanically. It diff --git a/examples/quantum1d/6.hubbard/main.jl b/examples/quantum1d/6.hubbard/main.jl index 155816c85..090c84324 100644 --- a/examples/quantum1d/6.hubbard/main.jl +++ b/examples/quantum1d/6.hubbard/main.jl @@ -1,7 +1,7 @@ using Markdown md""" -# [Hubbard chain at half filling](@id hubbard) +# Hubbard chain at half filling The Hubbard model is a model of interacting fermions on a lattice, which is often used as a somewhat realistic model for electrons in a solid. The Hamiltonian consists of two terms that describe competing forces of each electron: @@ -146,9 +146,9 @@ These excitations can be constructed as follows: alg = QuasiparticleAnsatz(; tol = 1.0e-3) momenta = range(-π, π; length = 33) psi_AB = psi -envs_AB = environments(psi_AB, H_u1_su2); +envs_AB = environments(psi_AB, H_u1_su2, psi_AB); psi_BA = circshift(psi, 1) -envs_BA = environments(psi_BA, H_u1_su2); +envs_BA = environments(psi_BA, H_u1_su2, psi_BA); spinon_charge = FermionParity(0) ⊠ U1Irrep(0) ⊠ SU2Irrep(1 // 2) E_spinon, ϕ_spinon = excitations( diff --git a/examples/windowmps.jl b/examples/windowmps.jl index df9226a9e..99506f7af 100644 --- a/examples/windowmps.jl +++ b/examples/windowmps.jl @@ -21,7 +21,7 @@ let @tensor mpco.AC[middle][-1 -2; -3] := mpco.AC[middle][-1, 1, -3] * sx[-2, 1] normalize!(mpco) - envs = environments(mpco, th) + envs = environments(mpco, th, mpco) szdat = [expectation_value(mpco, i => sz) for i in 1:length(mpco)] szdat = [szdat] diff --git a/src/algorithms/changebonds/randexpand.jl b/src/algorithms/changebonds/randexpand.jl index 183830e36..7445a0e21 100644 --- a/src/algorithms/changebonds/randexpand.jl +++ b/src/algorithms/changebonds/randexpand.jl @@ -21,7 +21,7 @@ $(TYPEDFIELDS) "algorithm used for the singular value decomposition" alg_svd::S = Defaults.alg_svd() - "algorithm used for [truncation](@extref MatrixAlgebraKit.TruncationStrategy] the expanded space" + "algorithm used for [truncation](@extref MatrixAlgebraKit.TruncationStrategy) of the expanded space" trscheme::TruncationStrategy end @@ -54,7 +54,7 @@ end changebonds(ψ::AbstractMPS, alg::RandExpand) = changebonds!(copy(ψ), alg) changebonds(ψ::MultilineMPS, alg::RandExpand) = changebonds!(copy(ψ), alg) -function changebonds(ψ, H, alg::RandExpand, envs) +function changebonds(ψ, H, alg::RandExpand, envs = nothing) newψ = changebonds(ψ, alg) return newψ, environments(newψ, H, newψ) end diff --git a/src/algorithms/changebonds/svdcut.jl b/src/algorithms/changebonds/svdcut.jl index a94dfb3c6..fbbcb757c 100644 --- a/src/algorithms/changebonds/svdcut.jl +++ b/src/algorithms/changebonds/svdcut.jl @@ -20,7 +20,7 @@ $(TYPEDFIELDS) "algorithm used for the singular value decomposition" alg_svd::S = Defaults.alg_svd() - "algorithm used for [truncation][@extref MatrixAlgebraKit.TruncationStrategy] of the gauge tensors" + "algorithm used for [truncation](@extref MatrixAlgebraKit.TruncationStrategy) of the gauge tensors" trscheme::TruncationStrategy end @@ -116,7 +116,7 @@ function changebonds(ψ::InfiniteMPS, alg::SvdCut) return normalize!(ψ) end -function changebonds(ψ, H, alg::SvdCut, envs) +function changebonds(ψ, H, alg::SvdCut, envs = nothing) newψ = changebonds(ψ, alg) return newψ, environments(newψ, H, newψ) end diff --git a/src/algorithms/changebonds/vumpssvd.jl b/src/algorithms/changebonds/vumpssvd.jl index a8e531e1b..75655f65a 100644 --- a/src/algorithms/changebonds/vumpssvd.jl +++ b/src/algorithms/changebonds/vumpssvd.jl @@ -20,7 +20,7 @@ $(TYPEDFIELDS) "algorithm used for the singular value decomposition" alg_svd = Defaults.alg_svd() - "algorithm used for [truncation][@extref MatrixAlgebraKit.TruncationStrategy] of the two-site update" + "algorithm used for [truncation](@extref MatrixAlgebraKit.TruncationStrategy) of the two-site update" trscheme::TruncationStrategy end diff --git a/src/algorithms/excitation/chepigaansatz.jl b/src/algorithms/excitation/chepigaansatz.jl index 2358ee4ab..68e6efc22 100644 --- a/src/algorithms/excitation/chepigaansatz.jl +++ b/src/algorithms/excitation/chepigaansatz.jl @@ -14,7 +14,7 @@ $(TYPEDFIELDS) ChepigaAnsatz(alg) Create a `ChepigaAnsatz` algorithm with the given eigensolver, or by passing the -keyword arguments to [`Arnoldi`][@extref KrylovKit.Arnoldi]. +keyword arguments to [`Arnoldi`](@extref KrylovKit.Arnoldi). ## References