Recommended resources
The freely available resources this lesson will direct you to.
Hello! Welcome to the next step in your exploration of advanced computational methods.
In our previous lesson, we established the conceptual foundation of the Density Matrix Renormalization Group (DMRG). You learned that DMRG is a variational method that sidesteps the exponential complexity of many-body systems by working with Matrix Product States (MPS). We saw how the reduced density matrix provides the optimal criterion for truncating the Hilbert space of a block, keeping only the most probable states in the context of a larger system.
Today, we transition from the "why" to the "how." Your learning outcome is to implement the infinite-system DMRG algorithm to find the ground state of a one-dimensional quantum lattice model. We will deconstruct this algorithm into a concrete, step-by-step procedure and examine a Python implementation. This "infinite-system" or "warm-up" phase is the first stage of any DMRG calculation, designed to grow the system from a few sites to its target size while generating a good initial MPS.
1. From Concepts to Algorithm: The Infinite-System Loop
Recall from our last session that the core failure of early numerical renormalization methods was treating blocks in isolation. DMRG solves this by embedding the growing blocks within a superblock. For the infinite algorithm, this superblock typically has a four-part structure: Left Block - Site - Site - Right Block.
The algorithm iteratively grows the Left and Right blocks until the chain reaches the desired length. At each step, the chain grows by two sites. Let's outline the process for a single iteration.
The Infinite-DMRG Iteration:
-
Form the Superblock Hamiltonian: We construct the Hamiltonian for the entire
Left Block - Site - Site - Right Blockstructure. For a nearest-neighbor model like the Heisenberg chain (), this Hamiltonian consists of:- The internal Hamiltonian of the Left Block ().
- The internal Hamiltonian of the Right Block ().
- The interaction between the Left Block and the first site.
- The interaction between the two central sites.
- The interaction between the second site and the Right Block.
Symbolically, this looks like:
Where the interaction terms couple the boundaries of the blocks and sites.
-
Find the Ground State: We diagonalize . Since this matrix can be large, but we only need the ground state (the lowest eigenstate), we use an iterative eigensolver like the Lanczos algorithm. This gives us the ground state vector .
-
Calculate the Reduced Density Matrix: To update our Left Block, we need to know which of its states are most important for forming . We form a new, larger block,
Left-Block + Site, and find its reduced density matrix by tracing out theSite + Right-Blockenvironment:Computationally, this is done by reshaping the vector into a matrix and computing .
-
Truncate and Build the New Basis: We diagonalize to find its eigenvalues and eigenvectors . The eigenvectors with the largest eigenvalues form the optimal, truncated basis for the new Left Block. We construct a transformation matrix whose columns are these eigenvectors.
-
Renormalize Operators: We transform all operators for the new Left Block into this new truncated basis. For example, the new block Hamiltonian becomes:
We must also transform the operators at the right edge of the block (e.g., , ) as they will be needed to construct the superblock Hamiltonian in the next iteration.
-
Repeat: The new, renormalized Left Block becomes the
Left Blockfor the next cycle. In the simplest infinite-DMRG scheme, we assume reflection symmetry and take the new Right Block to be a mirror image of the new Left Block. The process repeats, and the chain grows.
The Density Matrix Renormalization Group I - White
Before we dive into a code implementation, let's revisit Steven White's explanation of the initial, flawed algorithm and its fix. This will reinforce the logic behind the steps we just outlined, particularly the importance of correctly handling the block boundaries.
Watch the segment from 06:04 to 20:09. This covers the simple iterative procedure: combine blocks, diagonalize, truncate, and renormalize. This is the essence of the infinite algorithm's growth step, which we are about to implement.
2. A Practical Implementation in Python
Theory is essential, but seeing the algorithm in code makes it concrete. We will now examine a Python implementation that performs infinite-system DMRG for the spin-1/2 Heisenberg model. Your strong background in Python and NumPy will make the code's structure easy to follow.
Tutorials / SimpleDMRG - Matrix Product Toolkit
The SimpleDMRG tutorial by Ian McCulloch provides a clear, minimal Python implementation of the infinite-system algorithm. It's an excellent starting point for understanding the practical details.
First, read the introductory text to understand the code's purpose and its dependencies (NumPy, SciPy). Then, click the 'Get Code' link to view or download the simple_dmrg.py source file. We will walk through this code together.
Let's dissect the main loop of the simple_dmrg.py script. The logic directly maps to the five steps we just discussed.
Code Walkthrough (simple_dmrg.py)
-
Initialization: The script starts by defining the single-site operators (
s_p,s_m,s_z,s_ident) and initializing the block operators (H_block,Sz_block,Sp_block) for a single-site block. -
The Main Loop: The
for n_steps in range(...)loop executes the iterative growth.-
Form Superblock Hamiltonian (
H_super):# Construct the superblock Hamiltonian H_super = (np.kron(H_block, s_ident2) + np.kron(s_ident_block, H_site2) + np.kron(s_ident_block, H_block).T + J * (np.kron(Sz_block, s_z) + 0.5 * (np.kron(Sp_block, s_m) + np.kron(Sp_block.T, s_p))) + J * (np.kron(s_z, Sz_block) + 0.5 * (np.kron(s_p, Sp_block.T) + np.kron(s_m, Sp_block))))This code builds the superblock Hamiltonian for a
block-site-site-blockstructure, assuming reflection symmetry (the right block is a transpose of the left block). You can see the terms for the block Hamiltonians and the interactions at the boundaries. -
Find Ground State:
vals, vecs = eigsh(H_super, k=1, which='SA') psi = vecs[:, 0]scipy.sparse.linalg.eigshis the iterative eigensolver. It efficiently finds the ground state vectorpsi(SAstands for 'Smallest Algebraic'). -
Calculate Reduced Density Matrix (
rho):psi = psi.reshape(m_block*2, -1) rho = np.dot(psi, psi.T)The ground state vector is reshaped into a matrix where rows correspond to the new enlarged left block (
block-site) and columns to the environment (site-block). The density matrixrhois then calculated. -
Truncate (
U):evals, evecs = np.linalg.eigh(rho) U = evecs[:, -m_new:]rhois diagonalized. The columns ofUare populated with the eigenvectors corresponding to them_newlargest eigenvalues. -
Renormalize Operators:
H_block_new = U.T.dot(np.kron(H_block, s_ident) + ... ).dot(U) Sz_block_new = U.T.dot(np.kron(s_ident_block, s_z)).dot(U) Sp_block_new = U.T.dot(np.kron(s_ident_block, s_p)).dot(U)The Hamiltonian for the enlarged
block-sitesystem is constructed and then transformed into the new truncated basis usingU. The boundary operators are also transformed. These new operators (H_block_new, etc.) then replace the old ones for the next iteration.
-
This loop is the heart of the infinite-DMRG algorithm. It demonstrates how the abstract concepts are translated into concrete matrix operations.
3. Reinforcing the Algorithmic Structure
To solidify your understanding, it's helpful to see the same logic expressed in a different context. The following resource provides C++ code for DMRG, and its description of the algorithm is exceptionally clear.
Density Matrix Renormalization Group
This blog post on computational physics provides a well-commented C++ implementation of DMRG. Focus on the textual description of the infinite algorithm and the code for constructing the superblock.
First, read the bulleted list in the section 'Infinite size'. This is a perfect summary of the algorithm's steps. Then, look at the C++ function CalculateSuperblock in the 'Algorithm implementation' section. Notice how it combines the block and interaction Hamiltonians using Kronecker products, just like the Python code.
The CalculateSuperblock function from the C++ resource shows the structure with striking clarity:H_superblock = H_system + H_interaction + H_environment
This reinforces that regardless of the programming language, the underlying physics and algorithmic structure remain the same.
Test your understanding!
In the renormalization step, why is it crucial to transform not only the block Hamiltonian but also the boundary operators like and ?
Show answer
The boundary operators are needed to construct the interaction part of the superblock Hamiltonian in the next iteration. When we grow the chain again, the new Left Block will need to interact with a new site. The interaction Hamiltonian, e.g., , requires the matrix representation of in the current truncated basis of the Left Block. If we didn't transform these boundary operators at each step, we couldn't build the correct Hamiltonian for the next, larger system.
4. Your Turn: Implement and Experiment
Now it is time to put your knowledge into practice. Your task is to work with the SimpleDMRG code.
- Download and Run: Get the
simple_dmrg.pyscript from the Matrix Product Toolkit and ensure you can run it. - Analyze the Output: The script prints the ground state energy and truncation error at each step. The energy is for the entire superblock. Modify the code to calculate and print the ground state energy per site at each step (
energy / (2 * m_block + 2)). - Visualize Convergence: Plot the ground state energy per site versus the number of DMRG steps. You should see it converge towards the known value for the infinite Heisenberg chain ().
- Experiment: Change the number of states kept,
m_new. Try values like 10, 20, and 50. How does this parameter affect the final converged energy and the speed of convergence?
This hands-on exercise will move you from passively understanding the code to actively using and modifying it, which is the core of this lesson's objective.
Conclusion
In this lesson, we have bridged the gap between the concept and the implementation of the infinite-system DMRG algorithm. You have dissected the iterative loop that allows the system to grow while keeping the basis size manageable, and you have seen how this translates directly into Python code.
Key Takeaways:
- The infinite-DMRG algorithm iteratively grows a 1D system from a small core.
- Each step involves a sequence of operations: forming a superblock Hamiltonian, finding its ground state via an iterative eigensolver, calculating the reduced density matrix, using its eigenvectors to truncate the basis, and finally renormalizing all relevant block operators into this new basis.
- The entire process is a practical application of the concepts of entanglement and optimal basis selection that we discussed previously.
- The number of states kept,
m(orm_new), is a crucial parameter that controls the trade-off between accuracy and computational cost.
Preview of the Next Lesson:
The infinite-system algorithm provides a good approximation of the ground state and, more importantly, a good set of MPS tensors. However, the basis states for blocks at the beginning of the growth process were optimized for a much smaller environment. To achieve high accuracy, we need to refine these tensors in the context of the full-size chain. In our next lesson, we will implement the finite-system DMRG algorithm, which uses the output of the infinite algorithm as a starting point and "sweeps" back and forth across the chain to variationally optimize the MPS and converge to a highly accurate ground state.