summaryrefslogtreecommitdiff
path: root/lib/include/wolff/system.hpp
blob: 6e9c951b4f4bf39c601372f5c2b5f7a2cfba7f10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

#ifndef WOLFF_STATE_H
#define WOLFF_STATE_H

#include <functional>
#include <vector>
#include <random>

#include "graph.hpp"

namespace wolff {

#include "types.h"

template <class R_t, class X_t>
class measurement;

template <class R_t, class X_t>
class system {
  public:
    v_t nv; // number of vertices
    v_t ne; // number of edges
    graph G; // the graph defining the lattice with ghost
    double T; // the temperature
    std::vector<X_t> s; // the state of the ordinary spins

#ifdef WOLFF_BOND_DEPENDENCE
    std::function <double(v_t, const X_t&, v_t, const X_t&)> Z; // coupling between sites
#else
    std::function <double(const X_t&, const X_t&)> Z; // coupling between sites
#endif

#ifndef WOLFF_NO_FIELD
    R_t s0; // the current state of the ghost site
#ifdef WOLFF_SITE_DEPENDENCE
    std::function <double(v_t, const X_t&)> B; // coupling with the external field
#else
    std::function <double(const X_t&)> B; // coupling with the external field
#endif
#endif

    system(graph g, double T,
#ifdef WOLFF_BOND_DEPENDENCE
        std::function <double(v_t, const X_t&, v_t, const X_t&)> Z
#else
        std::function <double(const X_t&, const X_t&)> Z
#endif
#ifndef WOLFF_NO_FIELD
#ifdef WOLFF_SITE_DEPENDENCE
        , std::function <double(v_t, const X_t&)> B
#else
        , std::function <double(const X_t&)> B
#endif
#endif
        ) : G(g), T(T), Z(Z)
#ifndef WOLFF_NO_FIELD
             , s0(), B(B)
#endif
    {
      nv = G.nv;
      ne = G.ne;
      s.resize(nv);
#ifndef WOLFF_NO_FIELD
      G.add_ghost();
#endif
#ifdef WOLFF_FINITE_STATES
      finite_states_init(*this);
#endif
    }

    void flip_cluster(v_t, const R_t&, std::mt19937&, measurement<R_t, X_t>&, double x = 1.0);
    void run_wolff(N_t, std::function <R_t(std::mt19937&, const system<R_t, X_t>&, v_t)> r_gen, measurement<R_t, X_t>& A, std::mt19937& rng, double x = 1.0);
};

}

#endif