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
79
80
81
82
83
84
85
86
87
|
#include "space_wolff.hpp"
int main(int argc, char* argv[]) {
const unsigned D = 2;
double L = 32;
unsigned N = 1000;
double T = 2.0 / log(1.0 + sqrt(2.0));
double H = 1.0;
unsigned n = 25;
int opt;
while ((opt = getopt(argc, argv, "n:N:L:T:H:")) != -1) {
switch (opt) {
case 'n':
n = (unsigned)atof(optarg);
break;
case 'N':
N = (unsigned)atof(optarg);
break;
case 'L':
L = atof(optarg);
break;
case 'T':
T = atof(optarg);
break;
case 'H':
H = atof(optarg);
break;
default:
exit(1);
}
}
std::function<double(const Spin<double, D, double>&, const Spin<double, D, double>&)> Z =
[L] (const Spin<double, D, double>& s1, const Spin<double, D, double>& s2) -> double {
Vector<double, D> d = diff(L, s1.x, s2.x);
double rad_sum = pow(s1.s + s2.s, 2);
bool overlap = d.transpose() * d < rad_sum;
if (overlap) {
return -1e8;
} else {
return 0;
}
};
std::function<double(Spin<double, D, double>)> B =
[L, H] (Spin<double, D, double> s) -> double {
return H * sin(2 * M_PI * 3 * s.x(0) / L);
};
Model<double, D, double> sphere(L, Z, B, std::floor(log2(L)), 2);
randutils::auto_seed_128 seeds;
std::mt19937 rng{seeds};
std::uniform_real_distribution<double> dist(0.0, L);
sphere.s.reserve(n);
for (unsigned i = 0; i < n; i++) {
Vector<double, D> pos = {dist(rng), dist(rng)};
sphere.s.push_back({pos, 0.5});
sphere.dict.insert(&sphere.s.back());
}
sphere.wolff(T, N, rng);
std::ofstream snapfile;
snapfile.open("sphere_snap.dat");
for (Spin<double, D, double> s : sphere.s) {
Spin<double, D, double> rs = sphere.s0.inverse().act(s);
snapfile << rs.x.transpose() << "\n";
}
snapfile.close();
return 0;
}
|