summaryrefslogtreecommitdiff
path: root/lib/wolff.h
blob: bd49bf0956a636fa3c7f99773255e7487c3e414f (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

#pragma once

#include <assert.h>
#include <fftw3.h>
#include <float.h>
#include <getopt.h>
#include <gsl/gsl_randist.h>
#include <gsl/gsl_rng.h>
#include <inttypes.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <sys/types.h>

#include <jst/graph.h>
#include <jst/rand.h>

#include "queue.h"

typedef enum {
  WOLFF,
  WOLFF_GHOST,
  METROPOLIS
} sim_t;

typedef struct {
  graph_t *g;
  bool *spins;
  int32_t M;
  double H;
} ising_state_t;

typedef struct {
  uint32_t nv;
  int32_t dJb;
  int32_t dHb;
  bool hit_ghost;
} cluster_t;

typedef struct {
  uint64_t n;
  double x;
  double dx;
  double x2;
  double m2;
  double m4;
  double c;
  double dc;
} meas_t;

int32_t sign(double x);

cluster_t *flip_cluster(const graph_t *g, const double *ps, bool *x, bool stop_on_ghost,
                        gsl_rng *r);

graph_t *graph_add_ext(const graph_t *g);

uint32_t wolff_step(double T, double H, ising_state_t *s, sim_t sim, gsl_rng *r,
                    double *ps);

void update_meas(meas_t *m, double x);

double add_to_avg(double mx, double x, uint64_t n);