From 6bf9f10081c62809633528c4ef7fef7020cc03e9 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 12 Mar 2018 19:32:56 -0400 Subject: changes --- src/wolff_potts.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/src/wolff_potts.c b/src/wolff_potts.c index 8dc4471..b525e0b 100644 --- a/src/wolff_potts.c +++ b/src/wolff_potts.c @@ -19,12 +19,14 @@ int main(int argc, char *argv[]) { bool pretend_ising = false; bool planar_potts = false; bool silent = false; + bool snapshots = false; + bool snapshot = false; int opt; q_t J_ind = 0; q_t H_ind = 0; - while ((opt = getopt(argc, argv, "N:n:D:L:q:T:J:H:m:e:Ips")) != -1) { + while ((opt = getopt(argc, argv, "N:n:D:L:q:T:J:H:m:e:IpsSP")) != -1) { switch (opt) { case 'N': N = (count_t)atof(optarg); @@ -67,6 +69,12 @@ int main(int argc, char *argv[]) { case 's': silent = true; break; + case 'S': + snapshots = true; + break; + case 'P': + snapshot = true; + break; default: exit(EXIT_FAILURE); } @@ -205,6 +213,26 @@ int main(int argc, char *argv[]) { } update_meas(clust, tmp_flips); + + if (snapshots) { + FILE *snapfile = fopen("snapshots.m", "a"); + fprintf(snapfile, "{{"); + for (L_t i = 0; i < L; i++) { + fprintf(snapfile, "{"); + for (L_t j = 0; j < L; j++) { + fprintf(snapfile, "%" PRIq, dihedral_inverse_act(q, s->R, s->spins[L * i + j])); + if (j != L - 1) { + fprintf(snapfile, ","); + } + } + fprintf(snapfile, "}"); + if (i != L - 1) { + fprintf(snapfile, ","); + } + } + fprintf(snapfile, "},{%" PRIq ",%d}} ", s->R->i, s->R->r); + fclose(snapfile); + } } for (q_t i = 0; i < q; i++) { @@ -231,6 +259,31 @@ int main(int argc, char *argv[]) { ", dH/H = %.4f, dM/M = %.4f, dC/C = %.4f, dX/X = %.4f, cps: %.1f\n", n_runs, fabs(E->dx / E->x), M[0]->dx / M[0]->x, E->dc / E->c, M[0]->dc / M[0]->c, h->nv / clust->x); + if (snapshots) { + FILE *snapfile = fopen("snapshots.m", "a"); + fprintf(snapfile, "\n"); + } + + if (snapshot) { + FILE *snapfile = fopen("snapshot.m", "a"); + fprintf(snapfile, "{{"); + for (L_t i = 0; i < L; i++) { + fprintf(snapfile, "{"); + for (L_t j = 0; j < L; j++) { + fprintf(snapfile, "%" PRIq, dihedral_inverse_act(q, s->R, s->spins[L * i + j])); + if (j != L - 1) { + fprintf(snapfile, ","); + } + } + fprintf(snapfile, "}"); + if (i != L - 1) { + fprintf(snapfile, ","); + } + } + fprintf(snapfile, "},{%" PRIq ",%d}}\n", s->R->i, s->R->r); + fclose(snapfile); + } + FILE *outfile = fopen("out.m", "a"); fprintf(outfile, "<|D->%" PRID ",L->%" PRIL ",q->%" PRIq ",T->%.15f,J->{", D, L, q, T); -- cgit v1.2.3-70-g09d2