From 2ebf2f181edac37bfb932dbb353101e37e97223a Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sun, 16 Feb 2020 21:02:25 -0500 Subject: More work on new transformations, and animation of cluster formation --- spheres_infinite.cpp | 69 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 18 deletions(-) (limited to 'spheres_infinite.cpp') diff --git a/spheres_infinite.cpp b/spheres_infinite.cpp index b39f164..77a3582 100644 --- a/spheres_infinite.cpp +++ b/spheres_infinite.cpp @@ -14,9 +14,10 @@ private: uint64_t t2; unsigned n; unsigned tmp; + Euclidean s0_tmp; public: - animation(double L, unsigned w, int argc, char* argv[]) { + animation(double L, unsigned w, int argc, char* argv[]) : s0_tmp(0) { t1 = 0; t2 = 0; n = 0; @@ -31,30 +32,58 @@ public: gluOrtho2D(-L, L, -L, L); } - void pre_cluster(const model&, unsigned, const Euclidean&) override { tmp = 0; } - - void plain_site_transformed(const model&, const Spin*, - const Spin&) override { + void plain_site_transformed(const model& m, const Transformation, double>& t) override { + if (n > 5000) { + if (t.current().size() > 1) { + glColor3f(0.0f, 0.0f, 1.0f); + } else { + glColor3f(0.0f, 1.0f, 0.0f); + } + for (const Spin* s : t.current()) { + if (s != NULL) { + glBegin(GL_POLYGON); + unsigned n_points = 50; + for (unsigned i = 0; i < n_points; i++) { + glVertex2d(s0_tmp.act(*s).x(0) + s->s * cos(2 * i * M_PI / n_points), + s0_tmp.act(*s).x(1) + s->s * sin(2 * i * M_PI / n_points)); + } + glEnd(); + } + } + } tmp++; } - void post_cluster(const model& m) override { + void pre_cluster(const model& m, unsigned, const Transformation, double>* t) override { + s0_tmp = m.s0.inverse(); + tmp = 0; glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); + /* + glBegin(GL_LINE); + Vector r_center = s0_tmp.act({t->r.t, 0}); + glEnd(); + */ 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)); + glVertex2d(s0_tmp.act(*s).x(0) + s->s * cos(2 * i * M_PI / n_points), + s0_tmp.act(*s).x(1) + s->s * sin(2 * i * M_PI / n_points)); } glEnd(); } glFlush(); + } + void post_cluster(const model& m) override { + glFlush(); t1 += tmp; t2 += tmp * tmp; + if (n > 5000) { + sleep(2); + } n++; } @@ -95,17 +124,21 @@ Gen, double> mGen(double ε) { Spin* s1 = rng.pick(M.s); Spin* s2 = rng.pick(M.s); - - while (s1 == s2) { - s2 = rng.pick(M.s); - } - Vector t1 = s1->x; Vector t2 = s2->x; Vector t12 = t1 - t2; + + while (s1 == s2 || 1 / t12.norm() < rng.uniform(0, 1)) { + s1 = rng.pick(M.s); + s2 = rng.pick(M.s); + t1 = s1->x; + t2 = s2->x; + t12 = t1 - t2; + } + Vector t = (t1 + t2) / 2; - double θ = atan2(t12[1], t12[0]) + rng.variate(0.0, ε); + double θ = atan2(t12[1], t12[0]) + rng.variate(0.0, ε) / t12.norm(); m(0, 0) = -cos(2 * θ); m(1, 1) = cos(2 * θ); @@ -201,9 +234,9 @@ int main(int argc, char* argv[]) { return H * s.x.norm(); }; - auto g1 = eGen(2); - auto g2 = mGen(0.5); - auto g3 = rGen(5); + auto g1 = eGen(0.5); + auto g2 = mGen(0.05); + auto g3 = rGen(1); animation A(L, 750, argc, argv); model sphere(1.0, Z, B); @@ -220,7 +253,7 @@ int main(int argc, char* argv[]) { sphere.dict.insert(ss); } - sphere.wolff(T, {g1, g2, g3}, A, N); + sphere.wolff(T, {g1, g2}, A, N); std::ofstream outfile; outfile.open("test.dat"); -- cgit v1.2.3-54-g00ecf