# MatrixCodeTutorial

Jump to: navigation, search

This first draft of a tutorial should give a user's introduction to the hybridization matrix code. Please feel free to ask questions to Philipp or Emanuel.

# Building a lattice

You will need to start by building a lattice for your problem. You should use the ALPS lattice library to do this. In most cases, the lattice is very simple. You can find example files in the 'test' directory.

For a single site problem, you just have one vertex and no bonds: Use a 'site' lattice, as it is defined in the lattice library:

``` //ALPS Lattice Library Parameters
LATTICE_LIBRARY="./lattices.xml";
LATTICE="site";
```

If you then use our printgraph tool (for some obscure reason you'll have to remove the {} at the end of the parameter file), you'll see the graph:

```<GRAPH dimension="1" vertices="1" edges="0">
<VERTEX id="1" type="0"><COORDINATE>0</COORDINATE></VERTEX>
</GRAPH>
```

For a slightly more complicated example, you can look at the 3-orbital model:

``` //Lattice Library
LATTICE_LIBRARY="./lattices.xml";
LATTICE="chain lattice";
L=3;
W=1;
```

As expected, the graph (type printgraph 3orbital) has three vertices and three edges:

```<GRAPH dimension="1" vertices="3" edges="3">
<VERTEX id="1" type="0"><COORDINATE>0</COORDINATE></VERTEX>
<VERTEX id="2" type="0"><COORDINATE>1</COORDINATE></VERTEX>
<VERTEX id="3" type="0"><COORDINATE>2</COORDINATE></VERTEX>
<EDGE source="1" target="2" id="1" type="0" vector="1"/>
<EDGE source="2" target="3" id="2" type="0" vector="1"/>
<EDGE source="3" target="1" id="3" type="0" vector="1"/>
</GRAPH>
```

here, we define the three orbital lattice as three different sites on a chain. In this case we have three vertices (namely the three orbitals) and three edges connecting the three vertices.

For Cluster DMFT, it is convenient to define a cluster in real space:

``` //Lattice Library
LATTICE_LIBRARY = ../4site_tprime.xml;
LATTICE = "frustrated square lattice";
L = 2;
W = 2;
```

In this case, the lattice is a frustrated square lattice with periodic boundary conditions.

# Building a Hamiltonian

Once we have a lattice (or a graph) that represents the geometry of our problem, we need to define a Hamiltonian (or model) for that problem. Before you proceed, you should familiarize yourself with the ALPS model library.

The model library takes the graph that has been generated from the lattice above and builds a Hamiltonian out of it.

Two models are frequently used:

- the Hubbard model

``` //ALPS Model Library Parameters
MODEL_LIBRARY="./models.xml";
MODEL="fermion Hubbard";
```

- A multiorbital implementation of the Hubbard model

```//ALPS Model Library Parameters
MODEL_LIBRARY="./models.xml";
MODEL="multiorbital";
```

Have a look at the file models.xml at the section where the Hamiltonians are defined to see how this works. If your model does not fit, you can always change an existing model or build your Hamiltonian matrix from scratch.

# Getting the symmetries right

Most local Hamiltonians have additional symmetries, e.g. conserved total particle number and conserved total Sz. In addition to that, some lattices have translational symmetries. If we can make use of this, ALPS can automatically build block-diagonal Hamiltonians. This greatly improves the speed of the algorithm. To switch on symmetries, try:

``` //Symmetries
TRANSLATION_SYMMETRY=1;
CONSERVED_QUANTUMNUMBERS="Nup, Ndown";
```

If you have translational symmetry, or

``` //Symmetries
TRANSLATION_SYMMETRY=0;
CONSERVED_QUANTUMNUMBERS="Nup, Ndown";
```

to switch off translation symmetry. Note: we don't handle complex matrices!

# MC control parameters

To control the Monte Carlo processes, the code needs the following parameters:

```//MC Parameters
SEED=20;            //Random number seed
SWEEPS=1000;        //Total number of sweeps
THERMALIZATION=100; //Thermalization sweeps
N_ORDER=50;
N_MEAS=500;         //Number of measurements until the measurements are stored in the ALPS measurements container
N_SHIFT=0;          //Shift moves to perform per insertion/removal move
OVERLAP=0;
CORR_A=0;
N=300;              //Number of time 'slices' for the binning
```

# Physics parameters

```BETA=30;              //Inverse Temperature
H=0;                  //Magnetic Field
SEMICIRCLE=1;         //Selfconsistency information in this case we're reading in a G and computing F=t^2G.
QUARTERBANDWIDTH=0.5; //semicircular t
t=0;                  //cluster hopping
SITES=1;              //Cluster Sites
SPINS=2;              //Cluster Spins
FLAVORS=2;            //Sites x Spins
U=3;                  //Hubbard interaction
MU=1.5;               //Chemical Potential
```

Depending on your model you'll have to specify t, t' (or t0, t1) as well as U, J, U', V, ... to get the right Hamiltonian.

# Running the code

Start by changing one of the test input files. You can find them in the 'test' directory. Type

```parameter2xml parameter_file
solver --T run_time parameter_file.in.xml
```

You will find the observables along with some status information in the file parameter_file.task1.out.xml

You can then use the evaluate program

```evaluate parameter_file G
```

To extract properties like the Green's function.

# Self consistency conditions

To see what a self consistency loop including k-summation, Fourier transforms and extraction of the Green's function from the xml and binary output files looks like, have a look at the DCA self consistency loop for the t-t'-plaquette. The program is called

```DCA_SC.C
```