From 5c8ee653bf9fa7ea6381d4313b3f80ea31d442a8 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 19 Feb 2020 19:37:23 -0500 Subject: Started implementing support for saving flip information for later visualization. --- spheres_infinite.cpp | 59 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 29 deletions(-) (limited to 'spheres_infinite.cpp') diff --git a/spheres_infinite.cpp b/spheres_infinite.cpp index f7e11ad..3f8747b 100644 --- a/spheres_infinite.cpp +++ b/spheres_infinite.cpp @@ -1,6 +1,7 @@ #include #include +#include #include "space_wolff.hpp" #include @@ -17,9 +18,10 @@ private: unsigned wait; double L; Euclidean s0_tmp; + std::ofstream& file; public: - animation(double L, unsigned w, int argc, char* argv[]) : s0_tmp(0), wait(1000), L(L) { + animation(double L, unsigned w, int argc, char* argv[], unsigned wait, std::ofstream& file) : s0_tmp(0), wait(wait), L(50 * L), file(file) { t1 = 0; t2 = 0; n = 0; @@ -61,6 +63,15 @@ public: tmp = 0; glClearColor(1.0f, 1.0f, 1.0f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); + glColor3d(1.0, 0.0, 0.0); + glBegin(GL_LINES); + Vector r = t->r.t / 2; + double θ = atan2(r(1), r(0)); + Vector v1 = s0_tmp.act({r(0) + L * sin(θ), r(1) - L * cos(θ)}); + Vector v2 = s0_tmp.act({r(0) - L * sin(θ), r(1) + L * cos(θ)}); + glVertex2d(v1(0), v1(1)); + glVertex2d(v2(0), v2(1)); + glEnd(); for (const Spin* s : m.s) { glBegin(GL_POLYGON); unsigned n_points = 50; @@ -71,17 +82,7 @@ public: } glEnd(); } - glColor3d(1.0, 0.0, 0.0); glLineWidth(3); - glBegin(GL_LINES); - Euclidean r_tmp = t->r; - Vector r_center = r_tmp.t / 2; - double θ = atan2(r_center(1), r_center(0)); - Vector v1 = s0_tmp.act({r_center(0) + 50*L * sin(θ), r_center(1) - 50*L * cos(θ)}); - Vector v2 = s0_tmp.act({r_center(0) - 50*L * sin(θ), r_center(1) + 50*L * cos(θ)}); - glVertex2d(v1(0), v1(1)); - glVertex2d(v2(0), v2(1)); - glEnd(); glFlush(); } @@ -221,13 +222,14 @@ int main(int argc, char* argv[]) { double T = 2.0 / log(1.0 + sqrt(2.0)); double H = 1.0; unsigned n = 25; + unsigned wait = 1000; double k = 1e2; double a = 0.1; int opt; - while ((opt = getopt(argc, argv, "n:N:L:T:H:a:k:")) != -1) { + while ((opt = getopt(argc, argv, "n:N:L:T:H:a:k:w:")) != -1) { switch (opt) { case 'n': n = (unsigned)atof(optarg); @@ -250,6 +252,9 @@ int main(int argc, char* argv[]) { case 'k': k = atof(optarg); break; + case 'w': + wait = atoi(optarg); + break; default: exit(1); } @@ -279,7 +284,16 @@ int main(int argc, char* argv[]) { auto g2 = mGen(0.1); auto g3 = tGen(0.1); auto g4 = rGen(1); - animation A(L, 750, argc, argv); + + auto tag = std::chrono::high_resolution_clock::now(); + + std::string filename = "flips_" + std::to_string(n) + "_" + std::to_string(T) + "_" + std::to_string(H) + "_" + std::to_string(a) + "_" + std::to_string(k) + "_" + + std::to_string(tag.time_since_epoch().count()) + ".dat"; + + std::ofstream file; + file.open(filename); + + animation A(L, 750, argc, argv, wait, file); model sphere(1.0, Z, B); Rng rng; @@ -290,34 +304,21 @@ int main(int argc, char* argv[]) { 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.uniform(0.45, 0.45); + ss->s = rng.pick({0.5, 0.5}); sphere.s[i] = ss; sphere.dict.insert(ss); } sphere.wolff(T, {g1, g2, g3, g4}, A, N); - std::ofstream outfile; - outfile.open("test.dat"); - - /* - for (signed i = -10; i <= 10; i++) { - A.clear(); - double ε = pow(2, -4 + i / 2.0); - auto gn = eGen(ε); - sphere.wolff(T, gn, A, N); - outfile << ε << " " << A.var() / sphere.s.size() << std::endl; - std::cout << ε << " " << A.var() / sphere.s.size() << std::endl; - } - */ - outfile.close(); + file.close(); 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 << rs.s << " " << rs.x.transpose() << "\n"; delete s; } -- cgit v1.2.3-54-g00ecf