#include "space_wolff.hpp" #include class animation : public measurement { public: animation(double L, unsigned w, int argc, char *argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(w, w); glutCreateWindow("wolff"); glClearColor(0.0,0.0,0.0,0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(-1, L + 1, -1 , L + 1); } void post_cluster(const Model& m) override { glClearColor(1.0f, 1.0f, 1.0f, 1.0f ); glClear(GL_COLOR_BUFFER_BIT); for (const Spin& s : m.s) { glBegin(GL_POLYGON); unsigned n_points = 50; glColor3f(0.0f, 0.0f, 0.0f); for (unsigned i = 0; i < n_points; i++) { glVertex2d(m.s0.inverse().act(s).x(0) + s.s * cos(2 * i * M_PI / n_points), m.s0.inverse().act(s).x(1) + s.s * sin(2 * i * M_PI / n_points)); } glEnd(); } glFlush(); getchar(); } }; 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&, const Spin&)> Z = [L] (const Spin& s1, const Spin& s2) -> double { Vector 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)> B = [L, H] (Spin s) -> double { return H * sin(2 * M_PI * 3 * s.x(0) / L); }; animation A(L, 750, argc, argv); Model sphere(L, Z, B, std::floor(log2(L)), 2, A); randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; std::uniform_real_distribution dist(0.0, L); sphere.s.reserve(n); for (unsigned i = 0; i < n; i++) { Vector pos = {dist(rng), dist(rng)}; sphere.s.push_back({pos, dist(rng) / L}); sphere.dict.insert(&sphere.s.back()); } sphere.wolff(T, N, rng); std::ofstream snapfile; snapfile.open("sphere_snap.dat"); for (Spin s : sphere.s) { Spin rs = sphere.s0.inverse().act(s); snapfile << rs.x.transpose() << "\n"; } snapfile.close(); return 0; }