diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-18 15:37:27 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-18 15:37:27 -0400 |
commit | cd85d3696be4a7ee65b0cf6669fc62dc4841aef3 (patch) | |
tree | 6429963091115b7b1ff0a0684ff8f01274a32042 /src | |
parent | 722bc71ed8d4e1ae5616c5c8284fbffe21c4ffa4 (diff) | |
download | c++-cd85d3696be4a7ee65b0cf6669fc62dc4841aef3.tar.gz c++-cd85d3696be4a7ee65b0cf6669fc62dc4841aef3.tar.bz2 c++-cd85d3696be4a7ee65b0cf6669fc62dc4841aef3.zip |
- added support for computing spatial fourier transforms
- measurements now are functions passed to wolff in array
Diffstat (limited to 'src')
-rw-r--r-- | src/wolff_heisenberg.cpp | 48 | ||||
-rw-r--r-- | src/wolff_planar.cpp | 50 |
2 files changed, 94 insertions, 4 deletions
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 <getopt.h> +#include <correlation.h> #include <wolff.h> int main(int argc, char *argv[]) { @@ -87,8 +88,51 @@ int main(int argc, char *argv[]) { fclose(outfile_info); - - wolff <orthogonal_t <3, double>, 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 <void(const state_t <orthogonal_t <3, double>, vector_t <3, double>> *)> *measurements = (std::function <void(const state_t <orthogonal_t <3, double>, vector_t <3, double>> *)> *)malloc(4 * sizeof(std::function <void(const state_t <orthogonal_t <3, double>, vector_t <3, double>> *)>)); + + measurements[0] = [&](const state_t <orthogonal_t <3, double>, vector_t <3, double>> *s) { + float smaller_E = (float)s->E; + fwrite(&smaller_E, sizeof(float), 1, outfile_E); + }; + measurements[1] = [&](const state_t <orthogonal_t <3, double>, 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 <orthogonal_t <3, double>, vector_t <3, double>> *s) { + write_magnetization(s->M, outfile_M); + }; + measurements[3] = [&](const state_t <orthogonal_t <3, double>, vector_t <3, double>> *s) { + fwrite(&(s->last_cluster_size), sizeof(uint32_t), 1, outfile_S); + }; + + wolff <orthogonal_t <3, double>, 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); 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 <getopt.h> #include <wolff.h> +#include <correlation.h> int main(int argc, char *argv[]) { @@ -88,8 +89,53 @@ int main(int argc, char *argv[]) { fclose(outfile_info); - - wolff <orthogonal_t <2, double>, 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 <void(const state_t <orthogonal_t <2, double>, vector_t <2, double>> *)> *measurements = (std::function <void(const state_t <orthogonal_t <2, double>, vector_t <2, double>> *)> *)calloc(4, sizeof(std::function <void(const state_t <orthogonal_t <2, double>, vector_t <2, double>> *)>)); + + measurements[0] = (std::function <void(const state_t <orthogonal_t <2, double>, vector_t <2, double>> *)>)[&](const state_t <orthogonal_t <2, double>, vector_t <2, double>> *s) { + float smaller_E = (float)s->E; + fwrite(&smaller_E, sizeof(float), 1, outfile_E); + }; + measurements[1] = [&](const state_t <orthogonal_t <2, double>, 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 <orthogonal_t <2, double>, vector_t <2, double>> *s) { + write_magnetization(s->M, outfile_M); + }; + measurements[3] = [&](const state_t <orthogonal_t <2, double>, vector_t <2, double>> *s) { + fwrite(&(s->last_cluster_size), sizeof(uint32_t), 1, outfile_S); + }; + + + + wolff <orthogonal_t <2, double>, 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); |