summaryrefslogtreecommitdiff
path: root/spheres_infinite.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2020-02-16 21:02:25 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2020-02-16 21:02:25 -0500
commit2ebf2f181edac37bfb932dbb353101e37e97223a (patch)
tree29a2d0dbd729c4044063afefa43373fd4e537bcb /spheres_infinite.cpp
parent9437ed889390e04a1e693a5dfa5290cd90ae150e (diff)
downloadspace_wolff-2ebf2f181edac37bfb932dbb353101e37e97223a.tar.gz
space_wolff-2ebf2f181edac37bfb932dbb353101e37e97223a.tar.bz2
space_wolff-2ebf2f181edac37bfb932dbb353101e37e97223a.zip
More work on new transformations, and animation of cluster formation
Diffstat (limited to 'spheres_infinite.cpp')
-rw-r--r--spheres_infinite.cpp69
1 files changed, 51 insertions, 18 deletions
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<double, D> 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<double, D>&) override { tmp = 0; }
-
- void plain_site_transformed(const model&, const Spin<double, D, double>*,
- const Spin<double, D, double>&) override {
+ void plain_site_transformed(const model& m, const Transformation<double, D, Euclidean<double, D>, 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<double, 2, double>* 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, D, Euclidean<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);
+ /*
+ glBegin(GL_LINE);
+ Vector<double, 2> r_center = s0_tmp.act({t->r.t, 0});
+ glEnd();
+ */
for (const Spin<double, 2, double>* 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, D, Euclidean<double, D>, double> mGen(double ε) {
Spin<double, D, double>* s1 = rng.pick(M.s);
Spin<double, D, double>* s2 = rng.pick(M.s);
-
- while (s1 == s2) {
- s2 = rng.pick(M.s);
- }
-
Vector<double, D> t1 = s1->x;
Vector<double, D> t2 = s2->x;
Vector<double, D> t12 = t1 - t2;
+
+ while (s1 == s2 || 1 / t12.norm() < rng.uniform<double>(0, 1)) {
+ s1 = rng.pick(M.s);
+ s2 = rng.pick(M.s);
+ t1 = s1->x;
+ t2 = s2->x;
+ t12 = t1 - t2;
+ }
+
Vector<double, D> t = (t1 + t2) / 2;
- double θ = atan2(t12[1], t12[0]) + rng.variate<double, std::normal_distribution>(0.0, ε);
+ double θ = atan2(t12[1], t12[0]) + rng.variate<double, std::normal_distribution>(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");