Source code:


The goal of this tutorial (given at the 2013 summer school on quantum spin liquids, in Trieste, Italy) is to present the density-matrix renormalization group (DMRG) in its traditional formulation (i.e. without using matrix product states). DMRG is a numerical method that allows for the efficient simulation of quantum model Hamiltonians. Since it is a low-entanglement approximation, it often works quite well for one-dimensional systems, giving results that are nearly exact.

Typical implementations of DMRG in C++ or Fortran can be tens of thousands of lines long. Here, we have attempted to strike a balance between clear, simple code, and including many features and optimizations that would exist in a production code. One thing that helps with this is the use of Python. We have tried to write the code in a very explicit style, hoping that it will be (mostly) understandable to somebody new to Python. (See also the included Python cheatsheet, which lists many of the Python features used by simple-dmrg, and which should be helpful when trying the included exercises.)

The four modules build up DMRG from its simplest implementation to more complex implementations and optimizations. Each file adds lines of code and complexity compared with the previous version.

  1. Infinite system algorithm (~180 lines, including comments)
  2. Finite system algorithm (~240 lines)
  3. Conserved quantum numbers (~310 lines)
  4. Eigenstate prediction (~370 lines)

Throughout the tutorial, we focus on the spin-1/2 Heisenberg XXZ model, but the code could easily be modified (or expanded) to work with other models.


  • James R. Garrison (UCSB)
  • Ryan V. Mishmash (UCSB)

Licensed under the MIT license. If you plan to publish work based on this code, please contact us to find out how to cite us.