Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "PEPSKit"
uuid = "52969e89-939e-4361-9b68-9bc7cde4bdeb"
authors = ["Paul Brehmer", "Lander Burgelman", "Lukas Devos <ldevos98@gmail.com>"]
version = "0.6.1"
version = "0.7.0"

[deps]
Accessors = "7d9f7c33-5ae7-4f3b-8dc6-eff91059b697"
Expand Down
329 changes: 173 additions & 156 deletions docs/src/examples/bose_hubbard/index.md

Large diffs are not rendered by default.

138 changes: 69 additions & 69 deletions docs/src/examples/bose_hubbard/main.ipynb
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"using Markdown #hide"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Optimizing the $U(1)$-symmetric Bose-Hubbard model\n",
"\n",
Expand All @@ -22,23 +21,23 @@
"environment - made possible through TensorKit.\n",
"\n",
"But first let's seed the RNG and import the required modules:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"using Random\n",
"using TensorKit, PEPSKit\n",
"using MPSKit: add_physical_charge\n",
"Random.seed!(2928528935);"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Defining the model\n",
"\n",
Expand All @@ -49,62 +48,62 @@
"ground state to be well approximated by a PEPS with a manifest global $U(1)$ symmetry.\n",
"Furthermore, we'll impose a cutoff at 2 bosons per site, set the chemical potential to zero\n",
"and use a simple $1 \\times 1$ unit cell:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"t = 1.0\n",
"U = 30.0\n",
"cutoff = 2\n",
"mu = 0.0\n",
"lattice = InfiniteSquare(1, 1);"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, we impose an explicit global $U(1)$ symmetry as well as a fixed particle number\n",
"density in our simulations. We can do this by setting the `symmetry` argument of the\n",
"Hamiltonian constructor to `U1Irrep` and passing one as the particle number density\n",
"keyword argument `n`:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"symmetry = U1Irrep\n",
"n = 1\n",
"H = bose_hubbard_model(ComplexF64, symmetry, lattice; cutoff, t, U, n);"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Before we continue, it might be interesting to inspect the corresponding lattice physical\n",
"spaces (which is here just a $1 \\times 1$ matrix due to the single-site unit cell):"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"physical_spaces = physicalspace(H)"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that the physical space contains $U(1)$ charges -1, 0 and +1. Indeed, imposing a\n",
"particle number density of +1 corresponds to shifting the physical charges by -1 to\n",
Expand All @@ -127,43 +126,43 @@
"with a model at unit filling our physical space only contains integer $U(1)$ irreps.\n",
"Therefore, we'll build our PEPS and environment spaces using integer $U(1)$ irreps centered\n",
"around the zero charge:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"V_peps = U1Space(0 => 2, 1 => 1, -1 => 1)\n",
"V_env = U1Space(0 => 6, 1 => 4, -1 => 4, 2 => 2, -2 => 2);"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Finding the ground state\n",
"\n",
"Having defined our Hamiltonian and spaces, it is just a matter of plugging this into the\n",
"optimization framework in the usual way to find the ground state. So, we first specify all\n",
"algorithms and their tolerances:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"boundary_alg = (; tol = 1.0e-8, alg = :simultaneous, trunc = (; alg = :fixedspace))\n",
"gradient_alg = (; tol = 1.0e-6, maxiter = 10, alg = :eigsolver, iterscheme = :diffgauge)\n",
"optimizer_alg = (; tol = 1.0e-4, alg = :lbfgs, maxiter = 150, ls_maxiter = 2, ls_maxfg = 2);"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"!!! note\n",
"\tTaking CTMRG gradients and optimizing symmetric tensors tends to be more problematic\n",
Expand All @@ -180,80 +179,81 @@
"\n",
"Keep in mind that the PEPS is constructed from a unit cell of spaces, so we have to make a\n",
"matrix of `V_peps` spaces:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"virtual_spaces = fill(V_peps, size(lattice)...)\n",
"peps₀ = InfinitePEPS(randn, ComplexF64, physical_spaces, virtual_spaces)\n",
"env₀, = leading_boundary(CTMRGEnv(peps₀, V_env), peps₀; boundary_alg...);"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"And at last, we optimize (which might take a bit):"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"peps, env, E, info = fixedpoint(\n",
" H, peps₀, env₀; boundary_alg, gradient_alg, optimizer_alg, verbosity = 3\n",
")\n",
"@show E;"
]
],
"metadata": {},
"execution_count": null
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can compare our PEPS result to the energy obtained using a cylinder-MPS calculation\n",
"using a cylinder circumference of $L_y = 7$ and a bond dimension of 446, which yields\n",
"$E = -0.273284888$:"
]
],
"metadata": {}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"cell_type": "code",
"source": [
"E_ref = -0.273284888\n",
"@show (E - E_ref) / E_ref;"
]
],
"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.11.5",
"language": "julia",
"name": "julia-1.11"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.11.5"
"version": "1.11.7"
},
"kernelspec": {
"name": "julia-1.11",
"display_name": "Julia 1.11.7",
"language": "julia"
}
},
"nbformat": 4,
"nbformat_minor": 3
}
"nbformat": 4
}
Loading