ALPS 2.1 Tutorials:MC-02 Susceptibilities

From ALPS
Jump to: navigation, search


In this tutorial we will learn to calculate susceptibilities for classical and quantum Heisenberg models and contrast the behavior of chains and ladders as well as classical and quantum models. The parameter files, Python scripts and Vistrails files for this tutorial are available in the directory mc-02-susceptibilities


Susceptibility of classical one-dimensional Heisenberg models

The one-dimensional Heisenberg classical chain

Preparing and running the simulation from the command line

The parameter file parm2a sets up Monte Carlo simulations of the classical Heisenberg model on a one-dimensional chain with 60 sites for a couple of temperatures (T=0.05, 0.1, ..., 1.5) using cluster updates.To set up and run the simulation on the command line you first create a parameter file :

LATTICE="chain lattice"
L=60
J=-1
THERMALIZATION=15000
SWEEPS=500000 
UPDATE="cluster" 
MODEL="Heisenberg"
{T=0.05;}
{T=0.1;}
{T=0.2;}
{T=0.3;}
{T=0.4;}
{T=0.5;}
{T=0.6;}
{T=0.7;}
{T=0.8;}
{T=0.9;}
{T=1.0;}
{T=1.25;}
{T=1.5;}

and then run the simulation by using the standard sequence of commands

parameter2xml parm2a
spinmc --Tmin 10 --write-xml parm2a.in.xml

To extract the results we recommend the Python evaluation tools discussed below

Preparing and running the simulation using Python

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

import pyalps
import matplotlib.pyplot as plt
import pyalps.plot
parms = []
for t in [0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.25, 1.5, 1.75, 2.0]:
   parms.append(
       { 
         'LATTICE'        : "chain lattice", 
         'T'              : t,
         'J'              : -1 ,
         'THERMALIZATION' : 10000,
         'SWEEPS'         : 500000,
         'UPDATE'         : "cluster",
         'MODEL'          : "Heisenberg",
         'L'              : 60
       }
   )

To run this, launch your python interpreter using the convenience scripts alpspython or vispython.


We next convert this into a job file in XML format and run the simulation:

input_file = pyalps.writeInputFiles('parm2a',parms)
pyalps.runApplication('spinmc',input_file,Tmin=5,writexml=True)

We now have the same output files as in the command line version.

Evaluating the simulation and preparing plots using Python

To load the results and prepare plots we load the results from the output files and collect the susceptibility as a function of temperature from all output files starting with parm2a. The script is again in tutorial2a.py

data = pyalps.loadMeasurements(pyalps.getResultFiles(prefix='parm2a'),'Susceptibility')
susceptibility = pyalps.collectXY(data,x='T',y='Susceptibility')

To make plots we call the pyalps.plot.plot and then set some nice labels, a title, and a range of y-values:

plt.figure()
pyalps.plot.plot(susceptibility)
plt.xlabel('Temperature $T/J$')
plt.ylabel('Susceptibility $\chi J$')
plt.ylim(0,0.22)
plt.title('Classical Heisenberg chain')
plt.show()

Setting up and running the simulation in Vistrails

To run the simulation in Vistrails open the file mc-02-susceptibilities.vt and look at the workflow labeled "Classical Heisenberg chain". Click on "Execute" to prepare the input file, run the simulation and create the output figure.

The one-dimensional classical Heisenberg ladder

The Heisenberg ladder is simulated in a very similar way. The main differences (besides naming the files parm2b*) is a change of the LATTICE and that we have two couplings J0 and J1.

To set up and run the simulation on the command line you first create a parameter file parm2b :

LATTICE="ladder"
L=60
J0=-1
J1=-1
THERMALIZATION=15000
SWEEPS=150000
UPDATE="cluster"
MODEL="Heisenberg"
...

The rest of the input file is as above and simulations are run in the same way.

To set up and run the simulation in Python we use the script tutorial2b.py. The changes are again just

  • renaming parm2a into parm2b
  • changing the parameter LATTICE to ladder
  • setting two couplings J0 and J1

To run the simulation in Vistrails open the file mc-02-susceptibilities.vt and execute the workflow labeled "Classical Heisenberg ladder".

Questions

  • How does the susceptibility depend on the lattice?
  • Bonus: You can study larger system sizes and different types of lattices ("cubic lattice", "triangular lattice", check the file lattices.xml), as well.


Susceptibility of one-dimensional quantum Heisenberg models

The one-dimensional quantum Heisenberg chain

The main change when going to quantum models is that we use the ALPS model library to specify the model, and the ALPS looper QMC code to run the simulations. Note also that in quantum models there is usually a different sign convention for the couplings: positive couplings refer to the antiferromagnet

Preparing and running the simulation from the command line

To set up and run the simulation on the command line you first create a parameter file parm2c :


   LATTICE="chain lattice" 
   MODEL="spin"
   local_S=1/2
   L=60
   J=1
   THERMALIZATION=15000
   SWEEPS=150000
   ALGORITHM="loop"
   {T=0.05;}
   {T=0.1;}
   {T=0.2;}
   {T=0.3;}
   {T=0.4;}
   {T=0.5;}
   {T=0.6;}
   {T=0.7;}
   {T=0.75;}
   {T=0.8;}
   {T=0.9;}
   {T=1.0;}
   {T=1.25;}
   {T=1.5;}
   {T=1.75;}
   {T=2.0;}

The looper code requires the additional ALGORITHM parameter to choose the algorithm and representation.

The simulation is then run as:

 parameter2xml parm3a
 loop parm3a.in.xml

Preparing and running the simulation using Python

To set up and run the simulation in Python we use the script tutorial2c.py. The first part of the script is as above except for the change in filename to parm2c and the change in parameters:

input_file = pyalps.writeInputFiles('parm2c',parms)
pyalps.runApplication('loop',input_file)

Evaluating the simulation and preparing plots using Python or Vistrails

The plotting is again nearly identical to before - up to a change in title and file names. The script is script is again in tutorial2c.py.

To run the simulation in Vistrails open the file mc-02-susceptibilities.vt and look at the workflow labeled "chain magnetization". Click on "Execute" to prepare the input file, run the simulation and create the output figure.

The one-dimensional quantum Heisenberg ladder

We finally look at a quantum Heisenberg ladder. By now you should be an expert ALPS user so that we only give the input files and scripts.

To set up and run the simulation on the command line you first create a parameter file parm2d . Change the LATTICE parameter and set two couplings, J0 and J1 both to +1. Run the simulations as for the chain above

Also the Python script tutorial2d.py only needs changes in the file name and the parameters.

To run the simulation in Vistrails open the file mc-02-susceptibilities.vt and look at the workflow labeled "ladder magnetization".

Combining all simulations

We finally want to combine all four plots.

Using Python

After running all four simulations you can use the script tutorial2full.py.

First load all results and flatten the data structure to one list of results:

import pyalps
import matplotlib.pyplot as plt
import pyalps.plot
data = pyalps.loadMeasurements(pyalps.getResultFiles(),'Susceptibility')
data = pyalps.flatten(data)

Then collect the susceptibility as a function of temperature, into different data sets depending on the value of the LATTICE and MODEL parameters:

susceptibility = pyalps.collectXY(data,x='T',y='Susceptibility',foreach=['MODEL','LATTICE'])

Next, write some Python code to set some sensible labels, and print the properties of each set to show the parameters:

for s in susceptibility:
  if s.props['LATTICE']=='chain lattice':
    s.props['label'] = "chain"
  elif s.props['LATTICE']=='ladder':
    s.props['label'] = "ladder"
  if s.props['MODEL']=='spin':
    s.props['label'] = "quantum " + s.props['label']
  elif s.props['MODEL']=='Heisenberg':
    s.props['label'] = "classical " + s.props['label']

Finally make a plot:

plt.figure()
pyalps.plot.plot(susceptibility)
plt.xlabel('Temperature $T/J$')
plt.ylabel('Susceptibility $\chi J$')
plt.ylim(0,0.25)
plt.legend()
plt.show()

Using Vistrails

The same plot can also be easily created in Vistrails in the file mc-02-susceptibilities.vt by executing the workflow labeled "all combined".

Questions

  • Is there a difference between the classical and quantum calculation?
  • How does the susceptibility depend on the lattice?
  • Why does the susceptibility change?

For your reference, here is a plot created by the last workflow which combines all four calculations:

vt_id:3 version:37


© 2003-2010 by Simon Trebst, Fabien Alet, Matthias Troyer, Synge Todo, and Emanuel Gull