diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-09 14:29:16 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-09 14:29:16 -0400 |
commit | 88086fc222e1802d2a68edf5f1097cf9685ec42c (patch) | |
tree | 46a6830da96fa213ac93c6a952af9f9cb9f403b3 | |
parent | 466812e61e2ccec7750c791835111b402938411c (diff) | |
download | c++-88086fc222e1802d2a68edf5f1097cf9685ec42c.tar.gz c++-88086fc222e1802d2a68edf5f1097cf9685ec42c.tar.bz2 c++-88086fc222e1802d2a68edf5f1097cf9685ec42c.zip |
removed some references to the specific form of the magnetization for vector models from wolff.h
-rw-r--r-- | lib/orthogonal.h | 12 | ||||
-rw-r--r-- | lib/wolff.h | 11 |
2 files changed, 19 insertions, 4 deletions
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 <q, double> *ptr) { } } +template <q_t q, class T> +void write_magnetization(vector_t <q, T> M, FILE *outfile) { + fwrite(M.x, sizeof(double), q, outfile); +} + +template <q_t q> // save some space and don't write whole doubles +void write_magnetization(vector_t <q, double> 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 <double(X_t, X_t)> 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 <double(X_t, X_t)> 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); |