From 5fe3e194a2d4690b541ecee8ea342681c4eeaa6c Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 21 Feb 2020 11:27:59 -0500 Subject: Fixed the periodic sphere code to work with the new backend and implemented saving cluster flip information --- spheres_infinite.cpp | 70 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 26 deletions(-) (limited to 'spheres_infinite.cpp') diff --git a/spheres_infinite.cpp b/spheres_infinite.cpp index 3f8747b..56abe77 100644 --- a/spheres_infinite.cpp +++ b/spheres_infinite.cpp @@ -36,28 +36,6 @@ public: gluOrtho2D(-L, L, -L, L); } - void plain_site_transformed(const model& m, const Transformation, double>& t) override { - if (n > wait) { - 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 pre_cluster(const model& m, unsigned, const Transformation, double>* t) override { s0_tmp = m.s0.inverse(); tmp = 0; @@ -71,26 +49,58 @@ public: Vector v2 = s0_tmp.act({r(0) - L * sin(θ), r(1) + L * cos(θ)}); glVertex2d(v1(0), v1(1)); glVertex2d(v2(0), v2(1)); + if (n > wait) + file << v1.transpose() << " " << v2.transpose() << std::endl; glEnd(); for (const Spin* s : m.s) { glBegin(GL_POLYGON); unsigned n_points = 50; glColor3f(0.0f, 0.0f, 0.0f); + if (n > wait) + file << s << " " << s->s << " " << s0_tmp.act(*s).x.transpose() << " "; 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(); } + if (n > wait) + file << std::endl; glLineWidth(3); glFlush(); } + void plain_site_transformed(const model& m, const Transformation, double>& t) override { + if (n > wait) { + 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) { + file << s << " " << s0_tmp.act(t.r.act(*s)).x.transpose() << " "; + 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(); + } else { + file << s << " " << s0_tmp.act({0, 0}).transpose() << " "; + } + } + } + tmp++; + } + void post_cluster(const model& m) override { - glFlush(); t1 += tmp; t2 += tmp * tmp; if (n > wait) { + file << std::endl; + glFlush(); sleep(2); } n++; @@ -280,10 +290,18 @@ int main(int argc, char* argv[]) { return H * s.x.norm(); }; + std::function)> B_hard = [L, H](Spin s) -> double { + if (fabs(s.x(0)) < 3 * L / 4 && fabs(s.x(1)) < 3 * L / 4) { + return 0; + } else { + return std::numeric_limits::infinity(); + } + }; + auto g1 = eGen(1); auto g2 = mGen(0.1); auto g3 = tGen(0.1); - auto g4 = rGen(1); + auto g4 = rGen(0); auto tag = std::chrono::high_resolution_clock::now(); @@ -303,8 +321,8 @@ int main(int argc, char* argv[]) { unsigned nx = floor(sqrt(n)); for (unsigned i = 0; i < sphere.s.size(); i++) { Spin* ss = new Spin(); - ss->x = {(i / nx) * L / nx, (i % nx) * L / nx}; - ss->s = rng.pick({0.5, 0.5}); + ss->x = {(i / nx) * L / nx - L / 2, (i % nx) * L / nx - L / 2}; + ss->s = rng.pick({0.45, 0.45}); sphere.s[i] = ss; sphere.dict.insert(ss); } -- cgit v1.2.3-54-g00ecf