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_heisenberg.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'src/wolff_heisenberg.cpp') diff --git a/src/wolff_heisenberg.cpp b/src/wolff_heisenberg.cpp index 83ea503..f38fa96 100644 --- a/src/wolff_heisenberg.cpp +++ b/src/wolff_heisenberg.cpp @@ -1,6 +1,7 @@ #include +#include #include int main(int argc, char *argv[]) { @@ -87,8 +88,51 @@ int main(int argc, char *argv[]) { fclose(outfile_info); - - wolff , vector_t <3, double>> (N, D, L, T, dot <3, double>, std::bind(H_vector <3, 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 <3, double>> *)> *measurements = (std::function , vector_t <3, double>> *)> *)malloc(4 * sizeof(std::function , vector_t <3, double>> *)>)); + + measurements[0] = [&](const state_t , vector_t <3, double>> *s) { + float smaller_E = (float)s->E; + fwrite(&smaller_E, sizeof(float), 1, outfile_E); + }; + measurements[1] = [&](const state_t , vector_t <3, double>> *s) { + float smaller_X = (float)correlation_length(s); + fwrite(&smaller_X, sizeof(float), 1, outfile_X); + }; + measurements[2] = [&](const state_t , vector_t <3, double>> *s) { + write_magnetization(s->M, outfile_M); + }; + measurements[3] = [&](const state_t , vector_t <3, double>> *s) { + fwrite(&(s->last_cluster_size), sizeof(uint32_t), 1, outfile_S); + }; + + wolff , vector_t <3, double>> (N, D, L, T, dot <3, double>, std::bind(H_vector <3, 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