summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spheres_infinite.cpp59
1 files changed, 30 insertions, 29 deletions
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 <fstream>
#include <iostream>
+#include <chrono>
#include "space_wolff.hpp"
#include <GL/glut.h>
@@ -17,9 +18,10 @@ private:
unsigned wait;
double L;
Euclidean<double, D> 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<double, 2> r = t->r.t / 2;
+ double θ = atan2(r(1), r(0));
+ Vector<double, 2> v1 = s0_tmp.act({r(0) + L * sin(θ), r(1) - L * cos(θ)});
+ Vector<double, 2> 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<double, 2, double>* 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<double, D> r_tmp = t->r;
- Vector<double, 2> r_center = r_tmp.t / 2;
- double θ = atan2(r_center(1), r_center(0));
- Vector<double, 2> v1 = s0_tmp.act({r_center(0) + 50*L * sin(θ), r_center(1) - 50*L * cos(θ)});
- Vector<double, 2> 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<double, 2, double>* ss = new Spin<double, 2, double>();
ss->x = {(i / nx) * L / nx, (i % nx) * L / nx};
- ss->s = rng.uniform<double>(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<double, D, double>* s : sphere.s) {
Spin<double, D, double> rs = sphere.s0.inverse().act(*s);
- snapfile << rs.x.transpose() << "\n";
+ snapfile << rs.s << " " << rs.x.transpose() << "\n";
delete s;
}