Skip to content

MC-04 Measurements

Beyond thermodynamic averages such as energy and magnetization, QMC simulations can measure spatial correlation functions and their Fourier transforms. This tutorial demonstrates these measurements using the directed-loop SSE code on the S=1/2S = 1/2 Heisenberg model on a small square lattice.

The spin-spin correlation function C(r)=S0zSrzC(\mathbf{r}) = \langle S^z_0 S^z_\mathbf{r} \rangle describes how spin orientations at two sites separated by r\mathbf{r} are correlated. For the antiferromagnetic Heisenberg model at low temperature, correlations alternate in sign with distance, reflecting the tendency towards Néel order. The structure factor S(q)=reiqrC(r)S(\mathbf{q}) = \sum_\mathbf{r} e^{i\mathbf{q}\cdot\mathbf{r}} C(\mathbf{r}) is the Fourier transform of the correlations; it peaks at the antiferromagnetic wavevector q=(π,π)\mathbf{q} = (\pi, \pi).

Two-dimensional Heisenberg square lattice

We simulate the S=1/2S = 1/2 Heisenberg model on a 4×44 \times 4 square lattice at temperature T=0.3T = 0.3 with a small field h=0.1h = 0.1 to weakly break the spin-rotation symmetry. The small system size allows a fast simulation; finite-size effects are significant at this scale.

Command line

The parameter file parm4 enables three additional measurement flags alongside the standard parameters:

MODEL="spin"
LATTICE="square lattice"
local_S=1/2
MEASURE[Correlations]=true
MEASURE[Structure Factor]=true
MEASURE[Green Function]=true
THERMALIZATION=10000
SWEEPS=500000
J=1
L=4
W=4
T=0.3
{h=0.1;}

MEASURE[Correlations] records SizSjz\langle S^z_i S^z_j \rangle for all site pairs. MEASURE[Structure Factor] records S(q)S(\mathbf{q}) at all wavevectors compatible with the lattice. MEASURE[Green Function] records the imaginary-time Green function, which can be analytically continued to obtain spectral information.

Convert and run:

parameter2xml parm4
dirloop_sse --Tmin 10 --write-xml parm4.in.xml

--Tmin 10 sets the checkpoint interval to 10 seconds; --write-xml writes XML output files that pyalps can read alongside the HDF5 results.

Python

The script tutorial4.py:

import pyalps

parms = [{
    'LATTICE'                   : "square lattice",
    'MODEL'                     : "spin",
    'MEASURE[Correlations]'     : True,
    'MEASURE[Structure Factor]' : True,
    'MEASURE[Green Function]'   : True,
    'local_S'                   : 0.5,
    'T'                         : 0.3,
    'J'                         : 1,
    'THERMALIZATION'            : 10000,
    'SWEEPS'                    : 500000,
    'L'                         : 4,
    'W'                         : 4,
    'h'                         : 0.1
}]

input_file = pyalps.writeInputFiles('parm4', parms)
pyalps.runApplication('dirloop_sse', input_file, Tmin=10)

Evaluating the results

Load all measurements from the output files and print them:

import pyalps

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm4'))

for s in pyalps.flatten(data):
    if len(s.x) == 1:
        print(s.props['observable'], ':', s.y[0])
    else:
        for (x, y) in zip(s.x, s.y):
            print(s.props['observable'], x, ':', y)

Scalar observables (energy, magnetization, susceptibility) are printed on a single line. Vector observables (correlations, structure factor, Green function) are printed one entry per line, with their index — site pair, wavevector, or imaginary-time point — shown alongside the value.

Plotting the spin-spin correlations

To visualize the correlation function, load the Sz Correlations observable and plot it:

import pyalps
import matplotlib.pyplot as plt
import pyalps.plot

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm4'), 'Sz Correlations')
correlations = pyalps.collectXY(data, x='d', y='Sz Correlations')

plt.figure()
pyalps.plot.plot(correlations)
plt.xlabel('Distance $r$')
plt.ylabel('$\\langle S^z_0 S^z_r \\rangle$')
plt.title('Spin correlations, $4\\times 4$ Heisenberg model')
plt.show()

The correlations should alternate in sign with distance, with the nearest-neighbour value negative (antiferromagnetic) and its magnitude decreasing with rr.

Plotting the structure factor

import pyalps
import matplotlib.pyplot as plt
import pyalps.plot

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm4'), 'Sz Structure Factor')
structure_factor = pyalps.collectXY(data, x='q', y='Sz Structure Factor')

plt.figure()
pyalps.plot.plot(structure_factor)
plt.xlabel('Wavevector $q$')
plt.ylabel('$S^z(q)$')
plt.title('Structure factor, $4\\times 4$ Heisenberg model')
plt.show()

The largest value should appear at the antiferromagnetic wavevector q=(π,π)\mathbf{q} = (\pi, \pi), corresponding to the alternating spin pattern of Néel order.

Questions

  • At which wavevector is the structure factor largest? What pattern of spin correlations does this correspond to?
  • How do the correlations S0zSrz\langle S^z_0 S^z_r \rangle decay with distance rr? Do they remain significant across the whole 4×44 \times 4 lattice?
  • Repeat the simulation at a lower temperature, e.g. T=0.1T = 0.1. How do the correlations and structure factor change?
  • Increase the system size to L=8L = 8. How does the peak of the structure factor scale with LL? What does this tell you about the presence or absence of long-range order at finite temperature?
  • What is the physical meaning of the Green function G(τ)G(\tau)? How could it be used to obtain dynamical information about the system?