Wolff Cluster Algorithm

In contrast to the Metropolis algorithm, this is our implemementation of a as general as possible cluster update according to the Wolff algorithm. In case the needs are not covered for your particular model, it is possible to provide a partial class specialization.

Writing your own specialization for your newly written Hamiltonian “MYHamiltonian” that still works on all lattices, is easy, you can start with just copying the default Wolff template from wolff.h and empty it from everything you don’t need and you end up with something like this:

namespace MARQOV
{
    template <Lattice>
    struct Wolff<class MYHamiltonian, class Lattice>
    {
        template <class RNGType, class StateSpace>
        inline int move(const Hamiltonian& ham, const Lattice& grid, StateSpace& statespace, RNGCache<RNGType>& rng, double beta, int rsite);
        {
            int clustersize = 0;

            /*INSERT YOUR HIGHLY ADAPTED WOLFF UPDATE HERE!*/

            return clustersize;
        }
        std::vector<int> cstack = std::vector<int>(4096/sizeof(int), 0);///< the size of the stack is meant to be preserved across different cluster processes.
    };
}

The Wolff update uses a full class which enables you to preserve state across the runs of a Wolff update. MARQOV by default uses this to save reallocations of the “cstack” array as you see in the previous example. Another use-case for specializing the Wolff update is if your model allows heavy optimizations that can be exploited, as e.g. in the Ising model.

template<class Hamiltonian, class Lattice>
struct MARQOV::Wolff

This class serves as an entry point for easily defining your own specializations of the Wolff algorithm of your Hamiltonians.

To that end it has the two prototypical template parameters:

Template Parameters
  • Hamiltonian: The Hamiltonian that the Wolff algo will use.

  • Lattice: The Lattice, that the Wolff algo should use.

Public Functions

template<class RNGType, class StateSpace>
int move(const Hamiltonian &ham, const Lattice &grid, StateSpace &statespace, RNGCache<RNGType> &rng, double beta, int rsite)

This is the function that we call in the Monte Carlo and which has to be present in the class specialization that can be provided by a user.

Return

the cluster size of the final, grown wolff cluster.

Parameters
  • ham: the hamiltonian

  • grid: the lattice

  • statespace: The Statespace

  • rng: a random number generator

  • beta: the inverse temperature

  • rsite: the randomized site wher we start the growth

Public Members

std::vector<int> cstack = std::vector<int>(4096 / sizeof(int), 0)

the size of the stack is meant to be preserved across different cluster processes.

template<class Hamiltonian, class Lattice>
class MARQOV::Embedder

The default Embedder.

Projects the model onto one of the SymD Cartesian dimensions.

Note

This default Embedder will also work, i.e. lead to a code which compiles and runs, however it might not be physically reasonable for models other than standard O(N) models. Therefore, make sure to implement your own embedder when using more complex models or disable cluster updates, in which case it will not be executed.

Template Parameters
  • Hamiltonian: the type of the Hamiltonian

  • Lattice: the type of the Lattice

Public Functions

template<class RNG>
void draw(RNG &rng, StateVector &sv)

Set new embedding variable.

Typically, this function is executed once before every cluster update. The variable can be drawn randomly (for which case an RNG is provided), but of course can also follow some sequental scheme.

Template Parameters
  • RNG: the type of the random number generator

Parameters
  • rng: the random number generator

auto coupling(int pos1, int pos2) const

Computes the Wolff coupling when attempting to add a spin to the cluster.

Return

The scalar Wolff coupling (the type of the state space components)

Parameters
  • pos1: The position (index) of the current state vector (which is already in the cluster)

  • pos2: The position (index) of a neighbour being checked whether it will become part of the cluster

void flip(StateVector &sv) const

Specifies how a spin flip in the embedded (reduced) model is performed.

Parameters
  • sv: the spin to flipped