Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 3 additions & 5 deletions docs/src/examples/bose_hubbard/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@ optimizer_alg = (; tol = 1.0e-4, alg = :lbfgs, maxiter = 150, ls_maxiter = 2, ls
general-purpose set of settings which will always work, so instead one has to adjust
the simulation settings for each specific application. For example, it might help to
switch between the CTMRG flavors `alg=:simultaneous` and `alg=:sequential` to
improve convergence. The evaluation of the CTMRG gradient can be instable, so there it
is advised to try the different `iterscheme=:diffgauge` and `iterscheme=:fixed` schemes
as well as different `alg` keywords. Of course the tolerances of the algorithms and
their subalgorithms also have to be compatible. For more details on the available
options, see the [`fixedpoint`](@ref) docstring.
improve convergence. Of course the tolerances of the algorithms and their subalgorithms
also have to be compatible. For more details on the available options, see the
[`fixedpoint`](@ref) docstring.

Keep in mind that the PEPS is constructed from a unit cell of spaces, so we have to make a
matrix of `V_peps` spaces:
Expand Down
144 changes: 71 additions & 73 deletions docs/src/examples/bose_hubbard/main.ipynb
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"cells": [
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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 @@ -21,23 +22,23 @@
"environment - made possible through TensorKit.\n",
"\n",
"But first let's seed the RNG and import the required modules:"
],
"metadata": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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 @@ -48,62 +49,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": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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 @@ -126,43 +127,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": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"boundary_alg = (; tol = 1.0e-8, alg = :simultaneous, trunc = (; alg = :fixedspace))\n",
"gradient_alg = (; tol = 1.0e-6, maxiter = 10, alg = :linsolver, iterscheme = :fixed)\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 @@ -171,89 +172,86 @@
" general-purpose set of settings which will always work, so instead one has to adjust\n",
" the simulation settings for each specific application. For example, it might help to\n",
" switch between the CTMRG flavors `alg=:simultaneous` and `alg=:sequential` to\n",
" improve convergence. The evaluation of the CTMRG gradient can be instable, so there it\n",
" is advised to try the different `iterscheme=:diffgauge` and `iterscheme=:fixed` schemes\n",
" as well as different `alg` keywords. Of course the tolerances of the algorithms and\n",
" their subalgorithms also have to be compatible. For more details on the available\n",
" options, see the `fixedpoint` docstring.\n",
" improve convergence. Of course the tolerances of the algorithms and their subalgorithms\n",
" also have to be compatible. For more details on the available options, see the\n",
" [`fixedpoint`](@ref) docstring.\n",
"\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": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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": {}
]
},
{
"outputs": [],
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"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.12.5",
"language": "julia",
"name": "julia-1.12"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.12.5"
},
"kernelspec": {
"name": "julia-1.12",
"display_name": "Julia 1.12.5",
"language": "julia"
}
},
"nbformat": 4
}
"nbformat": 4,
"nbformat_minor": 3
}
5 changes: 2 additions & 3 deletions docs/src/man/precompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ using PrecompileTools
SequentialCTMRG(; maxiter, projector_alg=:halfinfinite, verbosity),
]
gradient_algs = [
LinSolver(; solver_alg=BiCGStab(; tol=gradtol), iterscheme=:fixed),
LinSolver(; solver_alg=BiCGStab(; tol=gradtol), iterscheme=:diffgauge),
EigSolver(; solver_alg=Arnoldi(; tol=gradtol, eager=true), iterscheme=:fixed),
LinSolver(; solver_alg=BiCGStab(; tol=gradtol)),
EigSolver(; solver_alg=Arnoldi(; tol=gradtol, eager=true)),
]

# Initialize OhMyThreads scheduler (precompilation occurs before __init__ call)
Expand Down
10 changes: 4 additions & 6 deletions examples/bose_hubbard/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ algorithms and their tolerances:
"""

boundary_alg = (; tol = 1.0e-8, alg = :simultaneous, trunc = (; alg = :fixedspace))
gradient_alg = (; tol = 1.0e-6, maxiter = 10, alg = :linsolver, iterscheme = :fixed)
gradient_alg = (; tol = 1.0e-6, maxiter = 10, alg = :linsolver)
optimizer_alg = (; tol = 1.0e-4, alg = :lbfgs, maxiter = 150, ls_maxiter = 2, ls_maxfg = 2);

md"""
Expand All @@ -99,11 +99,9 @@ md"""
general-purpose set of settings which will always work, so instead one has to adjust
the simulation settings for each specific application. For example, it might help to
switch between the CTMRG flavors `alg=:simultaneous` and `alg=:sequential` to
improve convergence. The evaluation of the CTMRG gradient can be instable, so there it
is advised to try the different `iterscheme=:diffgauge` and `iterscheme=:fixed` schemes
as well as different `alg` keywords. Of course the tolerances of the algorithms and
their subalgorithms also have to be compatible. For more details on the available
options, see the [`fixedpoint`](@ref) docstring.
improve convergence. Of course the tolerances of the algorithms and their subalgorithms
also have to be compatible. For more details on the available options, see the
[`fixedpoint`](@ref) docstring.
Keep in mind that the PEPS is constructed from a unit cell of spaces, so we have to make a
matrix of `V_peps` spaces:
Expand Down
3 changes: 1 addition & 2 deletions src/Defaults.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ Module containing default algorithm parameter values and arguments.
* `gradient_eigsolver_eager=$(Defaults.gradient_eigsolver_eager)` : Enables `EigSolver` algorithm to finish before the full Krylov dimension is reached.
* `gradient_iterscheme=:$(Defaults.gradient_iterscheme)` : Scheme for differentiating one CTMRG iteration.
- `:fixed` : the differentiated CTMRG iteration uses a pre-computed SVD with a fixed set of gauges
- `:diffgauge` : the differentiated iteration consists of a CTMRG iteration and a subsequent gauge-fixing step such that the gauge-fixing procedure is differentiated as well
* `gradient_alg=:$(Defaults.gradient_alg)` : Algorithm variant for computing the gradient fixed-point.

## Optimization
Expand Down Expand Up @@ -152,7 +151,7 @@ const gradient_verbosity = -1
const gradient_linsolver = :bicgstab # ∈ {:gmres, :bicgstab}
const gradient_eigsolver = :arnoldi
const gradient_eigsolver_eager = true
const gradient_iterscheme = :fixed # ∈ {:fixed, :diffgauge}
const gradient_iterscheme = :fixed
const gradient_alg = :eigsolver # ∈ {:geomsum, :manualiter, :linsolver, :eigsolver}

# Optimization
Expand Down
Loading
Loading