summaryrefslogtreecommitdiff
path: root/ising_animate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ising_animate.cpp')
-rw-r--r--ising_animate.cpp50
1 files changed, 7 insertions, 43 deletions
diff --git a/ising_animate.cpp b/ising_animate.cpp
index cd65b6b..f3ab314 100644
--- a/ising_animate.cpp
+++ b/ising_animate.cpp
@@ -1,45 +1,5 @@
+#include "animation.hpp"
#include "ising.hpp"
-#include <GL/glut.h>
-
-class Animation : public measurement<signed, D, TorusGroup<signed, D>, signed> {
-private:
- bool color;
-
-public:
- Animation(double L, unsigned w, bool tcolor, int argc, char* argv[]) {
- color = tcolor;
-
- 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(0, L, 0, L);
- }
-
- void post_cluster(const isingModel& m) override {
- glClearColor(1.0, 1.0, 1.0, 1.0);
- glClear(GL_COLOR_BUFFER_BIT);
- for (const Spin<signed, 2, signed>* s : m.s) {
- if (s->s == 1) {
- if (color)
- glColor3f(1.0, 0.0, 0.0);
- else
- glColor3f(1.0, 1.0, 1.0);
- } else if (s->s == -1) {
- if (color)
- glColor3f(0.0, 0.0, 1.0);
- else
- glColor3f(0.0, 0.0, 0.0);
- }
- Vector<signed, 2> xx = m.s0.inverse().act(*s).x;
- glRecti(xx(0), xx(1), xx(0) + 1, xx(1) + 1);
- }
- glFlush();
- }
-};
int main(int argc, char* argv[]) {
unsigned L = 32;
@@ -50,10 +10,11 @@ int main(int argc, char* argv[]) {
double T = 2.0 / log(1.0 + sqrt(2.0));
double H = 1.0;
bool color = false;
+ unsigned wait = N;
int opt;
- while ((opt = getopt(argc, argv, "N:L:T:H:m:r:p:c")) != -1) {
+ while ((opt = getopt(argc, argv, "N:L:T:H:m:r:p:cw:")) != -1) {
switch (opt) {
case 'N':
N = (unsigned)atof(optarg);
@@ -79,6 +40,9 @@ int main(int argc, char* argv[]) {
case 'c':
color = true;
break;
+ case 'w':
+ wait = atoi(optarg);
+ break;
default:
exit(1);
}
@@ -97,7 +61,7 @@ int main(int argc, char* argv[]) {
auto g = isingGen(L);
- Animation A(L, 750, color, argc, argv);
+ Animation<signed, D, TorusGroup<signed, D>, IsingSpin> A(L, 750, argc, argv, wait, true);
ising.wolff(T, {g}, A, N);