Skip to content

Commit 6176525

Browse files
authored
Minor updates to examples.rst
1 parent 5bcb408 commit 6176525

File tree

1 file changed

+41
-51
lines changed

1 file changed

+41
-51
lines changed

docs/source/examples.rst

+41-51
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@
44
Examples
55
========
66

7-
We provide some examples how to use the code to calculate a variational
8-
optimization for typical 2d many-body problems in the `examples/ folder of the
9-
variPEPS Git repository
10-
<https://github.com/variPEPS/variPEPS_Python/tree/main/examples>`_.
7+
We provide several examples in the `examples/ folder of the variPEPS Git repository <https://github.com/variPEPS/variPEPS_Python/tree/main/examples>`_ that demonstrate how to use the code for variational energy optimization in typical 2D many-body problems.
118

12-
In this section we want to elaborately walk through the example for the
13-
Heisenberg AFM on the 2d square lattice to explain a typical usage of the
14-
library.
9+
.. In this section we want to elaborately walk through the example for the Heisenberg AFM on the 2d square lattice to explain a typical usage of the library.
1510
1611
Heisenberg antiferromagnet on the square lattice
1712
------------------------------------------------
@@ -49,8 +44,8 @@ Loading of relevant Python modules
4944
First of all we have to load the relevant Python modules for our simulation. The
5045
:obj:`varipeps` module includes the full library to perform the variational
5146
optimization. Internally it is based on the :obj:`jax` framework and its
52-
:obj:`numpy`-like interface to execute the calculations. Since we need to define
53-
arrays later to define for example the Hamiltonian, we need to load this numpy
47+
:obj:`numpy`-like interface to execute the calculations. Since we will need
48+
arrays to define for example the Hamiltonian, we load this numpy
5449
interface as well.
5550

5651
variPEPS config settings
@@ -59,33 +54,39 @@ variPEPS config settings
5954
.. code-block:: python
6055
6156
# Config Setting
57+
6258
## Set maximal steps for the CTMRG routine
63-
varipeps.config.ad_custom_max_steps = 100
64-
## Set maximal steps for the fix point routine in the gradient calculation
6559
varipeps.config.ctmrg_max_steps = 100
6660
## Set convergence threshold for the CTMRG routine
6761
varipeps.config.ctmrg_convergence_eps = 1e-7
62+
## Select the method used to calculate the (full) projectors in the CTMRG routine
63+
varipeps.config.ctmrg_full_projector_method = (
64+
varipeps.config.Projector_Method.FISHMAN
65+
)
66+
## Enable dynamic increase of CTMRG environment bond dimension
67+
varipeps.config.ctmrg_heuristic_increase_chi = True
68+
## Increase CTMRG enviroment bond dimension if truncation error exceeds this value
69+
varipeps.config.ctmrg_heuristic_increase_chi_threshold = 1e-4
70+
71+
## Set maximal steps for the fix point routine in the gradient calculation
72+
varipeps.config.ad_custom_max_steps = 100
6873
## Set convergence threshold for the fix point routine in the gradient calculation
6974
varipeps.config.ad_custom_convergence_eps = 5e-8
75+
7076
## Enable/Disable printing of the convergence of the single CTMRG/gradient fix point steps.
7177
## Useful to enable this during debugging, should be disabled for batch runs
7278
varipeps.config.ctmrg_print_steps = True
7379
varipeps.config.ad_custom_print_steps = False
80+
7481
## Select the method used to calculate the descent direction during optimization
7582
varipeps.config.optimizer_method = varipeps.config.Optimizing_Methods.CG
76-
## Select the method used to calculate the (full) projectors in the CTMRG routine
77-
varipeps.config.ctmrg_full_projector_method = (
78-
varipeps.config.Projector_Method.FISHMAN
79-
)
80-
## Set maximal steps for the optimization routine
83+
## Set maximal number of steps for the optimization routine
8184
varipeps.config.optimizer_max_steps = 2000
82-
## Increase enviroment bond dimension if truncation error is below this value
83-
varipeps.config.ctmrg_heuristic_increase_chi_threshold = 1e-4
8485
85-
The :obj:`varipeps` library allows to configure a large amount of numerical
86-
parameters to fine-tune the simulation. In this example we include some common
87-
options someone can set for a optimization run. For a long and detailed
88-
description of the config option we want to point to the API description of the
86+
The :obj:`varipeps` library allows to configure a large number of numerical
87+
parameters to fine-tune the simulation. In this example we include several
88+
options commonly used in an optimization run. For a detailed
89+
description of the configurable options we refer to the API description of the
8990
config class: :obj:`varipeps.config.VariPEPS_Config`.
9091

9192
Model parameters
@@ -106,18 +107,7 @@ Model parameters
106107
# Start value for enviroment bond dimension
107108
startChi = chiB**2 if chiB**2 < maxChi else maxChi
108109
109-
In this block we define some parameters for the model we want to simulate as the
110-
interaction strength, the physical dimension of our tensor network and the iPEPS
111-
bond dimension. In the last two lines the start and the maximal enviroment bond
112-
dimension is defined. A feature of the variPEPS library is that it not only
113-
supports simulation at a fixed enviroment bond dimension but also a heurisitic
114-
increase/decrease of the dimension up to a maximal value if the maximal
115-
truncation error in the CTMRG project calculation is above/below some
116-
threshold. See in the config block above the parameter
117-
``ctmrg_heuristic_increase_chi_threshold`` which sets for example the threshold
118-
when to increase the refinement parameter. The maximal bond dimension ensures
119-
that the parameter does no increase to too large values where the memory and
120-
computational resources are exhausted.
110+
In this block we define imporant parameters for the model we want to simulate, such as as the interaction strength, the physical dimension of our tensor network and the iPEPS bond dimension. In the last two lines the initial and the maximal enviroment bond dimension is defined. A feature of the variPEPS library is that it not only supports simulation at a fixed enviroment bond dimension, but also a heurisitic increase/decrease of the dimension up to a maximal value. The dynamic change is controlled by the truncation error in the CTMRG projector calculation (increase if the truncation errror becomes too large, decrease if it becomes insignificant). For example, in the config block above the parameter ``ctmrg_heuristic_increase_chi_threshold`` is set to the threshold at which to increase the refinement parameter. The maximal bond dimension ``maxChi`` ensures that the parameter does now grow unbounded, to the point where the memory and computational resources are exhausted.
121111

122112
Constructing the Hamiltonian
123113
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -140,12 +130,12 @@ Constructing the Hamiltonian
140130
)
141131
142132
Here the Hamiltonian is constructed for our model. The Heisenberg AFM on the
143-
square lattice can be described by the sum of the spin-spin interactions over
144-
the horizontal and vertical bonds. Since we assume in our example a constant
145-
interaction strength for all bonds, the expectation value can be calculated by
146-
the same two site interaction tensor applied in all nearest neighbor
133+
square lattice can be described by the sum of the spin-spin interactions on
134+
the horizontal and vertical bonds. Since we assume a constant
135+
interaction strength for all bonds in our example, the expectation value can be calculated by
136+
the same two-site interaction gate applied in all nearest neighbor
147137
directions. The expectation function ``exp_func`` is later used in the
148-
optimization to calculate the energy which is used as cost function to obtain
138+
optimization to calculate the energy expectation value, which in turn is used as cost function to obtain
149139
the ground state.
150140

151141
Initial unit cell construction
@@ -158,7 +148,7 @@ Initial unit cell construction
158148
159149
Here we define the unit cell structure which is used to simulate our model. In
160150
this example we assume a
161-
:math:`\scriptsize{\begin{matrix}A&B\\B&A\end{matrix}}`-structure.
151+
:math:`\scriptsize{\begin{matrix}A&B\\B&A\end{matrix}}`-structure, i.e. a two-site antiferromagnetic state.
162152

163153
.. code-block:: python
164154
@@ -174,8 +164,8 @@ this example we assume a
174164
175165
Using the unit cell structure and the model parameter defined above, we can
176166
generate an initial unit cell. Here we initialize the iPEPS tensors with random
177-
numbers. Of course one could use other ways to initialize the tensors, for
178-
example results from a simple update calculation.
167+
numbers. Other ways to initialize the tensors are provided, for example loading results
168+
from a simple update calculation.
179169

180170
Run the optimization
181171
^^^^^^^^^^^^^^^^^^^^
@@ -189,12 +179,12 @@ Run the optimization
189179
autosave_filename=f"data/autosave_square_chiB_{chiB:d}.hdf5",
190180
)
191181
192-
This function call executes the main function of the library, the variational
193-
optimization run to obtain a good ground state candidate. The function has
194-
several option to adapt the optimization for different ansätze (for example the
195-
spiral iPEPS approach). In our example we just need to supply the initial unit
196-
cell, the function to calculate the energy expectation value and to allow to
197-
restore an aborted simulation a file name for autosaves of the optimization.
182+
This function call executes the main function of the library, the variational energy
183+
optimization to obtain a good ground state candidate. The function offers several options
184+
to customize the optimization for different iPEPS ansätze, such as the spiral iPEPS
185+
approach. In our example, we only need to provide the initial unit cell, the function
186+
for calculating the energy expectation value, and a file path for autosaving the
187+
optimization process, enabling the restoration of interrupted simulations.
198188

199189
Evaluate the results
200190
^^^^^^^^^^^^^^^^^^^^
@@ -219,7 +209,7 @@ In this section we show some exemplary evaluation of the result of the optimizat
219209
220210
magnetic_exp_values = calc_magnetic(result.unitcell)
221211
222-
We assume for our example that we are interested in the single-site magnetic
212+
We assume for our example that we are interested in the single-site spin
223213
expectation values. These could be used to analyse the :math:`z`-magnetization
224214
or the staggered magnetization of our model at/near the ground state.
225215

@@ -245,8 +235,8 @@ or the staggered magnetization of our model at/near the ground state.
245235
)
246236
247237
Finally, we want to save the unit cell with the optimized tensors to a file for
248-
later further evaluation. The library allows to store the data directly into a
249-
HDF5 file along with user-supplied auxiliary data. Here for example not only
238+
further analysis. The library allows to store the data directly into a
239+
HDF5 file along with user-supplied auxiliary data. Here, for example, we not only
250240
want to store the plain tensors but also the calculated energy, meta information
251241
from the optimization run (e.g. energy per step or the runtime per step) and the
252242
calculated magnetic expectation values. At a later examination of the results,

0 commit comments

Comments
 (0)