This is a simplest demo of Matrix product state (MPS) based density matrix renormalization group (DMRG) with detailed comments, particularly suitable for new-learners to quickly get the idea of how MPS works at code level. For sophisticated and production-ready MPS packages, I recommend pytenet and quimb.
Density matrix renormalization group (DMRG) is a powerful method to simulate one-dimensional strongly correlated quantum systems. During recent years, combining DMRG with matrix product state (MPS) has allowed further understanding of the DMRG method. SimpleMPS aims to provide a demo for MPS based DMRG to solve the Heisenberg model. The ground state of the Heisenberg model could be obtained iteratively (see the image below, 
The phase transition of transverse field Ising (TFI) model is also provided as a further example (see the image below, 20 sites. Analytical result is based on periodic boundary condition).

The implementation is largely inspired by The density-matrix renormalization group in the age of matrix product states. Understanding the first 6 parts of the article is crucial to understanding the code.
A Julia alternative to the project can be found here.
./SimpleMPS/mps.pyImplements the MPS based DMRG method./SimpleMPS/paulimat.pyDefines the Pauli matrices used in Heiserberg and Ising model./SimpleMPS/heisenberg.pyDefines the hamiltonian and matrix product operator of the Heisenberg model then searches for the ground state./SimpleMPS/ising.pyDefines the hamiltonian and matrix product operator of the transverse field Ising model and then studies the phase diagram and phase transition../SimpleMPS/test_heisenberg.pyContains a simple test for the programs based on Heisenberg model../Notebook/analyze_ising.ipynbAnalyzes the result calculated by./SimpleMPS/ising.py
-
python heisenberg.pyto see the energy of the system during each iteration. There are 3 parameters hard-coded inheisenberg.py:-
SITE_NUMwhich is the number of sites in the model. -
MAX_BOND_DIMENSIONwhich is the maximum dimension of the bond degree in matrix product state. The higher bond dimension, the higher accuracy and computational cost. -
ERROR_THRESHOLDwhich is the threshold for error when compressing matrix product state by SVD. The lower the threshold, the higher accuracy and computational cost. - One and only one of
MAX_BOND_DIMENSIONorERROR_THRESHOLDshould be provided.
-
-
python ising.pyto see the relation between$M_x$ and$h$ when$J$ is fixed to 1 and$h$ varies from 0 to 2. The parameters inising.pyis the same as those inheisenberg.py. If you want to calculate the phase diagram, callcalc_phase_diagramin the file, which typically takes hours. - Modify the codes to explore DMRG and MPS!