diff options
Diffstat (limited to 'spheres_infinite.cpp')
-rw-r--r-- | spheres_infinite.cpp | 181 |
1 files changed, 91 insertions, 90 deletions
diff --git a/spheres_infinite.cpp b/spheres_infinite.cpp index f2f998a..dba7ab3 100644 --- a/spheres_infinite.cpp +++ b/spheres_infinite.cpp @@ -1,4 +1,7 @@ +#include <fstream> +#include <iostream> + #include "space_wolff.hpp" #include <GL/glut.h> @@ -6,67 +9,66 @@ const unsigned D = 2; typedef Model<double, D, Euclidean<double, D>, double> model; class animation : public measurement<double, 2, Euclidean<double, D>, double> { - private: - uint64_t t1; - uint64_t t2; - unsigned n; - unsigned tmp; - public: - animation(double L, unsigned w, int argc, char *argv[]) { - t1 = 0; - t2 = 0; - n = 0; - - glutInit(&argc, argv); - glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); - glutInitWindowSize(w, w); - glutCreateWindow("wolff"); - glClearColor(0.0,0.0,0.0,0.0); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluOrtho2D(-L, L, -L , L); - } +private: + uint64_t t1; + uint64_t t2; + unsigned n; + unsigned tmp; + +public: + animation(double L, unsigned w, int argc, char* argv[]) { + t1 = 0; + t2 = 0; + n = 0; + + glutInit(&argc, argv); + glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); + glutInitWindowSize(w, w); + glutCreateWindow("wolff"); + glClearColor(0.0, 0.0, 0.0, 0.0); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + gluOrtho2D(-L, L, -L, L); + } - void pre_cluster(const model&, unsigned, const Euclidean<double, D>&) override { - tmp = 0; - } + 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 { - tmp++; - } + void plain_site_transformed(const model&, const Spin<double, D, double>*, + const Spin<double, D, double>&) override { + tmp++; + } - void post_cluster(const model& m) override { - glClearColor(1.0f, 1.0f, 1.0f, 1.0f ); - glClear(GL_COLOR_BUFFER_BIT); - 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)); - } - glEnd(); + void post_cluster(const model& m) override { + glClearColor(1.0f, 1.0f, 1.0f, 1.0f); + glClear(GL_COLOR_BUFFER_BIT); + 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)); } - glFlush(); - - t1 += tmp; - t2 += tmp * tmp; - n++; + glEnd(); } + glFlush(); - void clear() { - t1 = 0; - t2 = 0; - n = 0; - } + t1 += tmp; + t2 += tmp * tmp; + n++; + } - double var() { - return (t2 - t1 * t1 / (double)n) / (double)n; - } + void clear() { + t1 = 0; + t2 = 0; + n = 0; + } + + double var() { return (t2 - t1 * t1 / (double)n) / (double)n; } }; std::function<Euclidean<double, D>(const model&, randutils::mt19937_rng&)> eGen(double ε) { - return [ε] (const model& M, randutils::mt19937_rng& rng) -> Euclidean<double, 2> { + return [ε](const model& M, randutils::mt19937_rng& rng) -> Euclidean<double, 2> { Vector<double, D> t; Matrix<double, D> m; @@ -85,7 +87,6 @@ std::function<Euclidean<double, D>(const model&, randutils::mt19937_rng&)> eGen( Euclidean<double, D> g(t, m); return g; }; - } int main(int argc, char* argv[]) { @@ -101,51 +102,50 @@ int main(int argc, char* argv[]) { while ((opt = getopt(argc, argv, "n:N:L:T:H:")) != -1) { switch (opt) { - case 'n': - n = (unsigned)atof(optarg); - break; - case 'N': - N = (unsigned)atof(optarg); - break; - case 'L': - L = atof(optarg); - break; - case 'T': - T = atof(optarg); - break; - case 'H': - H = atof(optarg); - break; - default: - exit(1); + case 'n': + n = (unsigned)atof(optarg); + break; + case 'N': + N = (unsigned)atof(optarg); + break; + case 'L': + L = atof(optarg); + break; + case 'T': + T = atof(optarg); + break; + case 'H': + H = atof(optarg); + break; + default: + exit(1); } } - double k = 1e2; - double a = 0.05; + double k = 1e8; + double a = 0.0; std::function<double(const Spin<double, D, double>&, const Spin<double, D, double>&)> Z = - [L, a, k] (const Spin<double, D, double>& s1, const Spin<double, D, double>& s2) -> double { - Vector<double, D> d = s1.x - s2.x; - - double σ = s1.s + s2.s; - double δ = σ - sqrt(d.transpose() * d); - - if (δ > - a * σ) { - return 0.5 * k * (2 * pow(a * σ, 2) - pow(δ, 2)); - } else if (δ > - 2 * a * σ) { - return 0.5 * k * pow(δ + 2 * a * σ, 2); - } else { - return 0; - } - }; + [L, a, k](const Spin<double, D, double>& s1, const Spin<double, D, double>& s2) -> double { + Vector<double, D> d = s1.x - s2.x; + + double σ = s1.s + s2.s; + double δ = σ - sqrt(d.transpose() * d); + + if (δ > -a * σ) { + return 0.5 * k * (2 * pow(a * σ, 2) - pow(δ, 2)); + } else if (δ > -2 * a * σ) { + return 0.5 * k * pow(δ + 2 * a * σ, 2); + } else { + return 0; + } + }; - std::function<double(Spin<double, D, double>)> B = - [L, H] (Spin<double, D, double> s) -> double { - return H * s.x.norm(); - }; + std::function<double(Spin<double, D, double>)> B = [L, H](Spin<double, D, double> s) -> double { + return H * s.x.norm(); + }; - auto g = eGen(1); + auto g = eGen(0.25); animation A(L, 750, argc, argv); model sphere(1, Z, B); @@ -187,3 +187,4 @@ int main(int argc, char* argv[]) { return 0; } + |