summaryrefslogtreecommitdiff
path: root/spheres.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'spheres.cpp')
-rw-r--r--spheres.cpp109
1 files changed, 2 insertions, 107 deletions
diff --git a/spheres.cpp b/spheres.cpp
index 4235d66..0067cc8 100644
--- a/spheres.cpp
+++ b/spheres.cpp
@@ -5,116 +5,11 @@
#include "space_wolff.hpp"
#include "torus_symmetries.hpp"
+#include "animation.hpp"
const unsigned D = 2;
typedef Model<double, D, TorusGroup<double, D>, double> model;
-class animation : public measurement<double, 2, TorusGroup<double, D>, double> {
-private:
- uint64_t t1;
- uint64_t t2;
- unsigned n;
- unsigned tmp;
- unsigned wait;
- double L;
- TorusGroup<double, D> s0_tmp;
- std::ofstream& file;
-
-public:
- 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;
-
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(w, w);
- glutCreateWindow("wolffWindow");
- glClearColor(0.0, 0.0, 0.0, 0.0);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- gluOrtho2D(-1, L+1, -1, L+1);
- }
-
- void pre_cluster(const model& m, unsigned, const Transformation<double, D, TorusGroup<double, D>, double>* t) override {
- s0_tmp = m.s0.inverse();
- 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));
- if (n > wait)
- file << v1.transpose() << " " << v2.transpose() << std::endl;
- glEnd();
- for (const Spin<double, 2, double>* 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, D, TorusGroup<double, D>, 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<double, 2, double>* 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 {
- t1 += tmp;
- t2 += tmp * tmp;
- if (n > wait) {
- file << std::endl;
- glFlush();
- sleep(2);
- }
- n++;
- }
-
- void clear() {
- t1 = 0;
- t2 = 0;
- n = 0;
- }
-
- double var() { return (t2 - t1 * t1 / (double)n) / (double)n; }
-};
-
Gen<double, D, TorusGroup<double, D>, double> eGen(double L) {
std::vector<Vector<double, 2>> torusVectors = torus_vecs<double, 2>(L);
std::vector<Matrix<double, 2>> torusMatrices = torus_mats<double, 2>();
@@ -196,7 +91,7 @@ int main(int argc, char* argv[]) {
auto g = eGen(L);
std::ofstream ofile("test.dat");
- animation A(L, 750, argc, argv, 1000, ofile);
+ Animation<double, D, TorusGroup<double, D>, Radius> A(L, 750, argc, argv, 1000, true);
model sphere(L, Z, B);
randutils::mt19937_rng rng;