From cd85d3696be4a7ee65b0cf6669fc62dc4841aef3 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 18 Jul 2018 15:37:27 -0400 Subject: - added support for computing spatial fourier transforms - measurements now are functions passed to wolff in array --- src/wolff_planar.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'src/wolff_planar.cpp') diff --git a/src/wolff_planar.cpp b/src/wolff_planar.cpp index 2a3d02b..4f26471 100644 --- a/src/wolff_planar.cpp +++ b/src/wolff_planar.cpp @@ -2,6 +2,7 @@ #include #include +#include int main(int argc, char *argv[]) { @@ -88,8 +89,53 @@ int main(int argc, char *argv[]) { fclose(outfile_info); - - wolff , vector_t <2, double>> (N, D, L, T, dot <2, double>, std::bind(H_vector <2, double>, std::placeholders::_1, H), gen_R, timestamp, silent); + char *filename_M = (char *)malloc(255 * sizeof(char)); + char *filename_E = (char *)malloc(255 * sizeof(char)); + char *filename_S = (char *)malloc(255 * sizeof(char)); + char *filename_X = (char *)malloc(255 * sizeof(char)); + + sprintf(filename_M, "wolff_%lu_M.dat", timestamp); + sprintf(filename_E, "wolff_%lu_E.dat", timestamp); + sprintf(filename_S, "wolff_%lu_S.dat", timestamp); + sprintf(filename_X, "wolff_%lu_X.dat", timestamp); + + FILE *outfile_M = fopen(filename_M, "wb"); + FILE *outfile_E = fopen(filename_E, "wb"); + FILE *outfile_S = fopen(filename_S, "wb"); + FILE *outfile_X = fopen(filename_X, "wb"); + + free(filename_M); + free(filename_E); + free(filename_S); + free(filename_X); + + std::function , vector_t <2, double>> *)> *measurements = (std::function , vector_t <2, double>> *)> *)calloc(4, sizeof(std::function , vector_t <2, double>> *)>)); + + measurements[0] = (std::function , vector_t <2, double>> *)>)[&](const state_t , vector_t <2, double>> *s) { + float smaller_E = (float)s->E; + fwrite(&smaller_E, sizeof(float), 1, outfile_E); + }; + measurements[1] = [&](const state_t , vector_t <2, double>> *s) { + float smaller_X = (float)correlation_length(s); + fwrite(&smaller_X, sizeof(float), 1, outfile_X); + }; + measurements[2] = [&](const state_t , vector_t <2, double>> *s) { + write_magnetization(s->M, outfile_M); + }; + measurements[3] = [&](const state_t , vector_t <2, double>> *s) { + fwrite(&(s->last_cluster_size), sizeof(uint32_t), 1, outfile_S); + }; + + + + wolff , vector_t <2, double>> (N, D, L, T, dot <2, double>, std::bind(H_vector <2, double>, std::placeholders::_1, H), gen_R, 4, measurements, silent); + + free(measurements); + + fclose(outfile_M); + fclose(outfile_E); + fclose(outfile_S); + fclose(outfile_X); free(H); -- cgit v1.2.3-70-g09d2