This is a DMRG code for finite systems, using MPS and MPO representations for the wavefunction and Hamiltonian. As such it is very flexible - it is easy to change the Hamiltonian to do a different model. You can get the source code here
This Python code follows closely how a 'serious' MPS code works, although it is not as fast as the C++ code in the Matrix Product Toolkit. The initial version of the code was very slow, and this was due to the inefficient implementation of the numpy.einsum() function that doesn’t optimize the tensor contractions. Breaking up the expression into pair-wise contractions speeds up the code by a factor 100x. Some other aspects that differ from a 'professional' MPS code:
- The MPO is stored in a dense structure. This is inappropriate for an MPO because it only has very few non-zero matrix elements (eg for the Heisenberg model, the MPO is 5x5 on a 2x2 local Hilbert space, for a total of 100 matrix elements. But all except for 12 of the matrix elements are zero.)
- The
np.einsum
function is not particularly efficient, it doesn't use an optimized matrix multiply to do the tensor contractions (but this will probably be fixed in a later version of NumPy).
- It would be better to control the number of iterations used by the eigensolver, either by restricting it to a small number (eg 4 - 10 iterations) or selecting an appropriate tolerance. This can be done adaptively, eg using the truncation error or wavefunction fidelity.
- No symmetries are implemented. The Heisenberg model has {$SU(2)$} symmetry, which improves the efficiency by around a factor 100x. Using just {$U(1)$} improves the efficiency by about a factor 10x.