Skip to content

Commit

Permalink
Update tensor docs, set up doc stubs for other modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
leburgel committed Feb 7, 2024
1 parent c8b5b81 commit 13d3f48
Show file tree
Hide file tree
Showing 87 changed files with 1,616 additions and 452 deletions.
32 changes: 31 additions & 1 deletion docs/src/lib/algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,43 @@ Algorithms

This section contains the API documentation for the :mod:`.algorithms` module.

Finite MPS algorithms
---------------------

.. autoclass:: src.algorithms.Dmrg
:no-members:
:members: fixedpoint


Infinite MPS algorithms
-----------------------

.. autoclass:: src.algorithms.Vumps
:no-members:
:members: fixedpoint

.. autoclass:: src.algorithms.IDmrg
:no-members:
:members: fixedpoint

.. autoclass:: src.algorithms.IDmrg2
:no-members:
:members: fixedpoint

.. autoclass:: src.algorithms.QPAnsatz
:no-members:
:members: excitations

.. autoclass:: src.algorithms.Vomps
:no-members:
:members: approximate

.. autoclass:: src.algorithms.Expand
:no-members:
:members: changebonds


Eigsolvers
----------

.. automodule:: src.algorithms.eigsolvers

2 changes: 1 addition & 1 deletion docs/src/lib/caches.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ This section contains the API documentation for the :mod:`.caches` module.

.. automodule:: src.caches


GetMD5
------

.. automodule:: src.caches.GetMD5

2 changes: 1 addition & 1 deletion docs/src/lib/environments.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Environments

This section contains the API documentation for the :mod:`.environments` module.

.. automodule:: src.environments
.. autoclass:: src.environments.FiniteEnvironment

29 changes: 28 additions & 1 deletion docs/src/lib/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,32 @@ Models

This section contains the API documentation for the :mod:`.models` module.

.. automodule:: src.models
.. Operators
.. ---------
.. Spin operators
.. ``````````````
.. .. autofunction:: src.models.spinoperators.sigma_min
.. .. autofunction:: src.models.spinoperators.sigma_plus
.. .. autofunction:: src.models.spinoperators.sigma_z
.. .. autofunction:: src.models.spinoperators.sigma_exhange
.. Fermion operators
.. `````````````````
.. .. autofunction:: src.models.fermionoperators.c_min
.. .. autofunction:: src.models.fermionoperators.c_plus
.. .. autofunction:: src.models.fermionoperators.c_number
.. Models
.. ------
.. autofunction:: src.models.quantum1dIsing
.. autofunction:: src.models.quantum1dHeisenberg
.. autofunction:: src.models.quantum1dHubbard

.. autofunction:: src.models.statmech2dIsing

20 changes: 19 additions & 1 deletion docs/src/lib/mps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,23 @@ MPS

This section contains the API documentation for the :mod:`.mps` module.

.. automodule:: src.mps
States
------

.. autoclass:: src.mps.MpsTensor
.. autoclass:: src.mps.FiniteMps
:no-members:
.. autoclass:: src.mps.UniformMps
.. autoclass:: src.mps.InfQP


Operators
---------

.. autoclass:: src.mps.MpoTensor
.. autoclass:: src.mps.FiniteMpo
.. autoclass:: src.mps.InfMpo
.. autoclass:: src.mps.InfJMpo
.. autoclass:: src.mps.PepsTensor
.. autoclass:: src.mps.PepsSandwich
:no-members:
3 changes: 2 additions & 1 deletion docs/src/lib/sparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ Sparse

This section contains the API documentation for the :mod:`.sparse` module.

.. automodule:: src.sparse
.. autoclass:: src.sparse.SparseTensor
:no-members:
39 changes: 32 additions & 7 deletions docs/src/lib/utility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,38 @@ Utility

This section contains the API documentation for the :mod:`.utility` module.

.. automodule:: src.utility
Options and verbosity
---------------------

.. autoclass:: src.utility.Options
.. autoclass:: src.utility.Verbosity

.. IO and converters
-----------------

.. .. autofunction:: src.utility.safesave
.. .. autofunction:: src.utility.clear_path
.. .. autofunction:: src.utility.mat2jl
.. .. autofunction:: src.utility.jl2mat
Toolbox
-------

.. autofunction:: src.utility.between
.. autofunction:: src.utility.colors
.. autofunction:: src.utility.dim2str
.. autofunction:: src.utility.diracdelta
.. autofunction:: src.utility.memsize
.. .. autofunction:: src.utility.mod1
.. .. autofunction:: src.utility.netcon
.. autofunction:: src.utility.randc
.. autofunction:: src.utility.randnc
.. autofunction:: src.utility.simulsort
.. autofunction:: src.utility.simulsortrows
.. autofunction:: src.utility.simulunique
.. autofunction:: src.utility.swapvars
.. autofunction:: src.utility.time2str


Indices
Expand All @@ -34,12 +65,6 @@ Sparse Arrays
.. automodule:: src.utility.sparse


Uninit
------

.. automodule:: src.utility.uninit


Validations
-----------

Expand Down
81 changes: 79 additions & 2 deletions src/algorithms/Dmrg.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,51 @@
classdef Dmrg
% Density Matrix Renormalisation Group algorithm for marix product states.
% `Density Matrix Renormalisation Group algorithm <https://journals.aps.org/prl/abstract/10.1103/PhysRevLett.69.2863>`_ for marix product states.
%
% Properties
% ----------
% tol : :class:`double`
% tolerance for convergence criterion, defaults to :code:`1e-10`.
%
% miniter : :class:`int`
% minimum number of iteration, defaults to 5.
%
% maxiter : :class:`int`
% maximum number of iteration, defaults to 100.
%
% verbosity : :class:`.Verbosity`
% verbosity level of the algorithm, defaults to :code:`Verbosity.iter`.
%
% doplot : :class:`logical`
% plot progress, defaults to :code:`false`.
%
% which : :class:`char`
% eigenvalue selector (passed as the :code:`sigma` argument to :func:`.eigsolve`),
% defaults to :code:`'largestabs'`.
%
% dynamical_tols : :class:`logical`
% indicate whether or not to use a dynamical tolerance scaling for the algorithm's
% subroutines based on the current error measure, defaults to :code:`false`
%
% tol_min : :class:`double`
% smallest allowed convergence tolerance for soubroutines, defaults to :code:`1e-12`.
%
% tol_max : :class:`double`
% highest allowed convergence tolerance for soubroutines, defaults to :code:`1e-10`.
%
% eigs_tolfactor : :class:`double`
% relative scaling factor for determining the convergence tolerance of the eigensolver
% subroutine based on the current error measure, defaults to :code:`1e-6`
%
% sweepstyle : :class:`char`
% sweep style indicating how to sweep through the MPS at each iteration, options are:
%
% - :code:`'f2f'`: (default) front-to-front, sweeping from site 1 to the end and back.
% - :code:`'b2b'`: back-to-back, sweeping from site N to the start and back.
% - :code:`'m2m'`: mid-to-mid, sweeping from the middle site to both ends and back.
%
% alg_eigs : :class:`.KrylovSchur` or :class:`.Arnoldi`
% algorithm used for the local eigsolver updates, defaults to
% :code:`KrylovSchur('MaxIter', 100, 'KrylovDim', 20)`.

%% Options
properties
Expand All @@ -22,7 +68,7 @@
saveMethod = 'full'
name = 'DMRG'

alg_eigs = KrylovSchur('MaxIter', 100, 'KrylovDim', 20) % TODO: Arnoldi has issues for DMRG specifically, need to figure out why
alg_eigs = KrylovSchur('MaxIter', 100, 'KrylovDim', 20)
end

properties (Access = private)
Expand All @@ -49,6 +95,37 @@
end

function [mps, envs, eta] = fixedpoint(alg, mpo, mps, envs)
% Find the fixed point MPS of a finite MPO, given an initial guess.
%
% Usage
% -----
% :code:`[mps, envs, eta] = fixedpoint(alg, mpo, mps, envs)`
%
% Arguments
% ---------
% alg : :class:`.Dmrg`
% DMRG algorithm.
%
% mpo : :class:`.FiniteMpo`
% matrix product operator.
%
% mps : :class:`.FiniteMps`
% initial guess for MPS fixed point.
%
% envs : :class:`.FiniteEnvironment`
% initial guess for the environments.
%
% Returns
% -------
% mps : :class:`.FiniteMps`
% MPS fixed point.
%
% envs : :class:`.FiniteEnvironment`
% corresponding environments.
%
% eta : :class:`double`
% final error measure at convergence.

arguments
alg
mpo
Expand Down
90 changes: 89 additions & 1 deletion src/algorithms/Expand.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,70 @@
classdef Expand
% Bond expansion algorithm for uniform matrix product states.
%
% Properties
% ----------
% bondsmethod : :class:`char`
% bond expansion method, options are:
%
% - :code:`'off'`: no bond expansion.
% - :code:`'factor'`: (default) multiply the bond dimsion in each sector by a fixed
% factor
% - :code:`'explicit'`: manually provide bond dimension expansion.
% - :code:`'extrapolate'`: extrapolate the bond dimension in each sector according to
% a pre-defined exponential distribution.
% - :code:`'twosite'`: expand bond dimension according to a truncated two-site update.
%
% chargesmethod : :class:`char`
% charge expansion method, options are:
%
% - :code:`'off'`: (default) no charge expansion.
% - :code:`'fusionproduct'`: expand virtual charges according to the fusion product of
% each previous virtual space with the corresponding physical space.
% - :code:`'twosite'`: expand virtual charges according to a truncated two-site
% update.
%
% schmidtcut : :class:`double`
% cut in singular values used in two-site update, defaults to :code:`1e-5`.
%
% notrunc : :class:`logical`
% disable truncation such that the bond dimension is only grown, defaults to
% :code:`false`.
%
% noisefactor : :class:`double`
% noise factor applied to expanded MPS entries in order to improve stability, defaults
% to :code:`1e-3`.
%
% which : :class:`char`
% eigenvalue selector used in two-site update routine (passed as the :code:`sigma`
% argument to :func:`.eigsolve`), defaults to :code:`'largestabs'`.
%
% minbond : :class:`int`
% minimal bond dimension in for each charge, defaults to :code:`1`
%
% maxbond : :class:`int`
% maximal bond dimension for each charge, defaults to :code:`1e9`.
%
% tolbond : :class:`double`
% tolerance on expanded bond dimension compared to their current values, defaults to
% :code:`0.2`.
%
% bondfactor : :class:`double`
% expansion factor used for the :code:`'factor'` bond expansion method, defaults to
% :code:`1.2`.
%
% cutfactor : :class:`double`
% cut factor used in bond dimension extrapolation for the :code:`'extrapolate'` bond
% expansion method, defaults to :code:`1`.
%
% explicitbonds : :class:`int`
% vector of integers indicating the bond dimsension to add/subtract for each charge,
% defaults to :code:`[]`.
%
% mincharges : :class:`int`
% minimal number of charges in eevery virtual space, defaults to :code:`2`.
%
% finalize : :class:`function_handle`
% optional finalization.

%% Options
properties
Expand Down Expand Up @@ -48,7 +113,30 @@
end

function [mps2, flag] = changebonds(alg, mpo, mps1)
% Change sectors and bond dimensions of mps virtual spaces.
% Change charges and bond dimensions of MPS virtual spaces.
%
% Usage
% -----
% :code:`[mps2, flag] = changebonds(alg, mpo, mps1)`
%
% Arguments
% ---------
% alg : :class:`.Expand`
% bond expansion algorithm.
%
% mpo : :class:`.InfMpo`
% matrix product operator.
%
% mps1 : :class:`.UniformMps`
% MPS to be expanded.
%
% Returns
% -------
% mps2 : :class:`.UniformMps`
% expanded MPS.
%
% flag : :class:`struct`
% explain.

% canonicalize before starting
for d = 1:depth(mps1)
Expand Down
Loading

0 comments on commit 13d3f48

Please sign in to comment.