From 88086fc222e1802d2a68edf5f1097cf9685ec42c Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 9 Jul 2018 14:29:16 -0400 Subject: removed some references to the specific form of the magnetization for vector models from wolff.h --- lib/orthogonal.h | 12 ++++++++++++ lib/wolff.h | 11 +++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/orthogonal.h b/lib/orthogonal.h index 0a2b5c7..2d0e1a1 100644 --- a/lib/orthogonal.h +++ b/lib/orthogonal.h @@ -161,4 +161,16 @@ void generate_rotation (gsl_rng *r, orthogonal_t *ptr) { } } +template +void write_magnetization(vector_t M, FILE *outfile) { + fwrite(M.x, sizeof(double), q, outfile); +} + +template // save some space and don't write whole doubles +void write_magnetization(vector_t M, FILE *outfile) { + for (q_t i = 0; i < q; i++) { + float M_tmp = (float)M.x[i]; + fwrite(&M_tmp, sizeof(float), 1, outfile); + } +} diff --git a/lib/wolff.h b/lib/wolff.h index 81830ee..caf413b 100644 --- a/lib/wolff.h +++ b/lib/wolff.h @@ -40,7 +40,7 @@ void wolff(count_t N, D_t D, L_t L, double T, std::function J if (!silent) printf("\n"); for (count_t steps = 0; steps < N; steps++) { - if (!silent) printf("\033[F\033[JWOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, M_0 = %.2f, S = %" PRIv "\n", steps, N, s.E, s.M.x[0], cluster_size); + if (!silent) printf("\033[F\033[JWOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n", steps, N, s.E, cluster_size); v_t v0 = gsl_rng_uniform_int(r, s.nv); @@ -51,15 +51,18 @@ void wolff(count_t N, D_t D, L_t L, double T, std::function J free_spin(step); - fwrite(&(s.E), sizeof(double), 1, outfile_E); - fwrite(s.M.x, sizeof(double), 2, outfile_M); + { + float smaller_E = (float)s.E; + fwrite(&smaller_E, sizeof(float), 1, outfile_E); + } + write_magnetization(s.M, outfile_M); fwrite(&cluster_size, sizeof(uint32_t), 1, outfile_S); } if (!silent) { printf("\033[F\033[J"); } - printf("WOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, M_0 = %.2f, S = %" PRIv "\n", N, N, s.E, s.M.x[0], cluster_size); + printf("WOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n", N, N, s.E, cluster_size); fclose(outfile_M); fclose(outfile_E); -- cgit v1.2.3-70-g09d2