ALPS 2 Tutorials:ED-06 FullDiagonalization

Jump to: navigation, search

Full Diagonalization of a Quantum Hamiltonian

In this tutorial we will use the fulldiag application to calculate the full spectrum of quantum chains and from it thermodynamic quantities.

Thermodynamics for one-dimensional spin models

The spin-1 Heisenberg chain

Our first simulation will be for a spin-1 Heisenberg quantum antiferromagnetic chain.

Using the command line

The parameter file parm6a sets up a full diagonalization for a spin-1 Heisenberg quantum antiferromagnet on a one-dimensional chain with 8 sites.

LATTICE="chain lattice"
local_S = 1
J       = 1
{L = 8}

The CONSERVED_QUANTUMNUMBERS parameter helps fulldiag split the Hilbert space into invariant subspaces and diagonalize them separately.

Using the standard sequence of commands you can first convert the input parameters to XML and then compute the full spectrum of this quantum Hamiltonian using fulldiag:

parameter2xml parm1
fulldiag --write-xml

The output file now contains results for all the eigenvectors and you can produce XML plot files for the thermodynamic and magnetic observables using fulldiag_evaluate:

Now you can produce XML plot files for the thermodynamic and magnetic observables using fulldiag_evaluate:

fulldiag_evaluate --T_MIN 0.1 --T_MAX 10 --DELTA_T  0.1  parm6a.task1.out.xml

This will generate the following XML plot files:

To extract the calculated results from the XML plot files generated by qwl_evaluate, you can use the plot2text tool, and then view this data with your favorite plotting tool. For example, to extact the data of the energy density vs. temperature, use


In a similar way, you can extract the data from the other XML plot files.

When Grace is your favorite plotting tool, you can also directly generate a Grace project file from the XML plot file using the plot2xmgr tool. For example, to generate a Grace project file of the energy vs. temperature, use

plot2xmgr > energy.agr

Similarly the tool plot2gp produces Gnuplot scripts and plot2text converts the file to plain text. However, the preferred method for data evaluation and plotting is using Python.

Using Python

To set up and run the simulation in Python we use the script The first parts of this script imports the required modules and then prepares the input files as a list of Python dictionaries, and then runs the simulation

import pyalps
import matplotlib.pyplot as plt
import pyalps.pyplot
import numpy as np
parms = [{ 
         'LATTICE'                   : "chain lattice", 
         'MODEL'                     : "spin",
         'local_S'                   : 1,
         'J'                         : 1,
         'L'                         : 8
input_file = pyalps.writeInputFiles('parm6a',parms)
res = pyalps.runApplication('fulldiag',input_file)

We next run the evaluation program on all output files

data = pyalps.evaluateFulldiagVersusT(pyalps.getResultFiles(prefix='parm6a'),DELTA_T=0.1, T_MIN=0.1, T_MAX=10.0)

and finally show all the plots:

for s in pyalps.flatten(data):
  plt.title("Antiferromagnetic Heisenberg chain")

Using Vistrails

To run the simulation in Vistrails open the file ed-06-fulldiag.vr and look at the workflow labeled "antiferromagnetic chain". Click on "Execute" to prepare the input file, run the simulation and create the output figure.


  • Repeat the computation of the susceptibility, but for L=9 (this will take a few minutes, use L=7 if you are impatient), and compare the result with the one for L=8 ! Recall that all steps starting with parameter2xml ... must be repeated.
  • Give a rough estimate of the temperature range in which one may use the finite-size result for an infinite chain.

The spin-1/2 Heisenberg ladder

We now change the model to a ladder of length L=6, setting the parameter LATTICE to "ladder" and the couplings J0 and J1 to 1. The parameters are in parm6b, the Python script in and the Vistrails workflow is in ed-06-fulldiag.vt.


  • Discuss the position of the maximum of the specific heat (hint: the infinite ladder has a gap of approximately J/2) !
  • Repeat this computation for 7 rungs (or 5 rungs, if you are impatient).
  • What can you infer from the comparison about the temperature range where the finite-size results are a good approximation to the infinite system ?

Remarks: If you are familiar with Quantum Monte Carlo (QMC) simulations, you will know that larger systems can be treated and hence better approximations to the thermodynamic limit obtained. (Try it ! You may find that it is in fact not so easy to do better with QMC than with full diagonalization for the above examples.)

Exact diagonalization definitely remains the method of choice under certain conditions. Firstly, if the system is intrinsically finite (and possibly small), full diagonalization yields the exact result at once. Secondly, exact diagonalization does not suffer from the sign problem such that it can also be used for fermionic or frustrated models without any additional constraint. Both conditions are simultaneously satisfied in the models for magnetic molecules which will be discussed in the second part.

Thermodynamics of magnetic molecules

We will now use fulldiag to simulate the exact thermodynamics of small spin clusters, by calculating their complete spectrum.

Two coupled dimers

Setting up a custom lattice/graph and model

Consider the following system of two coupled dimers:

First, we need a graph to represent this problem. This is defined by the following entry in the file dd-graph.xml:

<GRAPH name="double dimer" vertices="4">
 <VERTEX id="1" type="0"></VERTEX>
 <VERTEX id="2" type="0"></VERTEX>
 <VERTEX id="3" type="1"></VERTEX>
 <VERTEX id="4" type="1"></VERTEX>
 <EDGE type="0" source="1" target="2"/>
 <EDGE type="0" source="3" target="4"/>
 <EDGE type="1" source="1" target="3"/>
 <EDGE type="1" source="1" target="4"/>
 <EDGE type="1" source="2" target="3"/>
 <EDGE type="1" source="2" target="4"/>

Then we also want to assign different Heisenberg exchanges J0 and J1 to the edges of type 0 and 1, respectively. This is achieved by the following entry in the file model-dspin.xml:

<HAMILTONIAN name="dimerized spin">
 <PARAMETER name="J" default="1"/>
 <PARAMETER name="h" default="0"/>
 <BASIS ref="spin"/>
 <SITETERM site="i">
 <PARAMETER name="h#" default="h"/>
 <BONDTERM source="i" target="j">
 <PARAMETER name="J#" default="J"/>

Note that we do not really need this definition since the ,,spin" Hamiltonian in the default models.xml file already contains suitable definitions. Nevertheless, the above example illustrates how to automatically assign exchange constants Jn to a bond of type n, using the hash symbol (#).

In passing we have also assigned different types to vertices 1,2 and 3,4. Therefore, we are able to assign different local spins to the upper and lower dimer by specifying the corresponding values via local_S0 and local_S1, respectively.

We will now compute the magnetization curve for local spins S0=1 (upper dimer) and S1=1/2 (lower dimer), J0=1, J1=0.4 at a temperature T=0.02.

Using the command line

The parameter file parm6c sets up the simulation:

LATTICE="double dimer"
MODEL="dimerized spin"
J0      = 1
J1      = 0.4
h       = 0 
{T = 0.02}

Note the new parameters LATTICE_LIBRARY and MODEL_LIBRARY that point to the files containing our custom lattice and model.

The computation is performed with the following sequence of commands:

parameter2xml parm3
fulldiag_evaluate --H_MIN 0 --H_MAX 4 --DELTA_H 0.025 --versus h parm3.task1.out.xml

Note that here we have used fulldiag_evaluate with commandline arguments to specify a magnetic field range. In particular the commandline argument --versus h puts the magnetic field on the x-axis rather than temperature, as in the previous examples.

Using Python or Vistrails

In both Python and Vistrails we need to prepare the same lattice and model file, and the rest is as usual. The Python script is and the Vistrails workflow is in ed-06-fulldiag.vt.

Note that in Vistrails we have two different versions. In one version we create a lattice and model file locally through a Vistrails module. In the other one we download the files from the web.


  • Plot and interpret the result!

Hint: The spectrum of of two coupled S0=1 and S1=1/2 dimers can be found analytically. The energies are (with some degeneracies):

  • -11J0/4, -3J0/4-2J1 for total spin Stotal=0;
  • -7J0/4, -3J0/4-J1, 5J0/4-3J1 for Stotal=1;
  • -3J0/4+J1, J0/4, 5J0/4-J1 for Stotal=2;
  • 5J0/4+2J1 for Stotal=3.

The molecular complex V15

The final example is a simplified model for the molecular complex V15 which consists of 15 spins 1/2 coupled in the following manner:


The associated graph is defined in v15-graph.xml.

For the simulations we will make the simplifying assumption of equal Heisenberg exchange J along all edges. Running the simulations now proceeds as above. The parameters are in parm6d, the Python script in and the Vistrails workflow is in ed-06-fulldiag.vt.


  • How do you explain the low-temperature behavior of the magnetic susceptibility?

Note that this computation is already a bit challenging and will take a while. So, it may be a good idea to have a break before you come back and look at the result.

Additional Exercises

Hubbard model on a square lattice

  • Set up a parameter file for the Hubbard model on a square lattice.
    • Find the lattice that you would like to use. You could use either a square lattice or a chain. Pay attention to the boundary conditions!
    • Find the Hubbard model in the model library. Make sure you understand its terms.
    • Switch on the symmetries: conserved are momenta (in x and y direction) and particles.
    • Pick trial parameters that you can check (e.g. t=0, or U=0), and run the simulation.
    • How would you introduce a t'?

© 2004-2010 by Andreas Honecker, Emanuel Gull, and Matthias Troyer