diff options
Diffstat (limited to 'examples/src/models/potts/wolff_potts.cpp')
-rw-r--r-- | examples/src/models/potts/wolff_potts.cpp | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/examples/src/models/potts/wolff_potts.cpp b/examples/src/models/potts/wolff_potts.cpp index a1e9284..7b92ac1 100644 --- a/examples/src/models/potts/wolff_potts.cpp +++ b/examples/src/models/potts/wolff_potts.cpp @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { std::function <symmetric_t<POTTSQ>(std::mt19937&, potts_t<POTTSQ>)> gen_R = [] (std::mt19937& r, potts_t<POTTSQ> v) -> symmetric_t<POTTSQ> { symmetric_t<POTTSQ> rot; - std::uniform_int_distribution<q_t> dist(0, POTTSQ - 1); + std::uniform_int_distribution<q_t> dist(0, POTTSQ - 2); q_t j = dist(r); q_t swap_v; if (j < v.x) { @@ -134,14 +134,12 @@ int main(int argc, char *argv[]) { return rot; }; - FILE **outfiles = measure_setup_files(measurement_flags, timestamp); - - std::function <void(const sim_t&)> other_f; + std::function <void(const sim_t&, const wolff_research_measurements<symmetric_t<POTTSQ>, potts_t<POTTSQ>>&)> other_f; uint64_t sum_of_clusterSize = 0; if (N_is_sweeps) { - other_f = [&] (const sim_t& s) { - sum_of_clusterSize += s.last_cluster_size; + other_f = [&] (const sim_t& s, const wolff_research_measurements<symmetric_t<POTTSQ>, potts_t<POTTSQ>>& m) { + sum_of_clusterSize += m.last_cluster_size; }; } else if (draw) { #ifdef HAVE_GLUT @@ -155,7 +153,7 @@ int main(int argc, char *argv[]) { glLoadIdentity(); gluOrtho2D(0.0, L, 0.0, L); - other_f = [] (const sim_t& s) { + other_f = [] (const sim_t& s, const wolff_research_measurements<symmetric_t<POTTSQ>, potts_t<POTTSQ>>& m) { glClear(GL_COLOR_BUFFER_BIT); for (v_t i = 0; i < pow(s.L, 2); i++) { potts_t<POTTSQ> tmp_s = s.R.act_inverse(s.spins[i]); @@ -166,10 +164,10 @@ int main(int argc, char *argv[]) { }; #endif } else { - other_f = [] (const sim_t& s) {}; + other_f = [] (const sim_t& s, const wolff_research_measurements<symmetric_t<POTTSQ>, potts_t<POTTSQ>>& m) {}; } - std::function <void(const sim_t&)> measurements = measure_function_write_files(measurement_flags, outfiles, other_f); + wolff_research_measurements<symmetric_t<POTTSQ>, potts_t<POTTSQ>> m(measurement_flags, timestamp, other_f, s, silent); // add line to metadata file with run info { @@ -194,18 +192,17 @@ int main(int argc, char *argv[]) { count_t N_rounds = 0; printf("\n"); while (sum_of_clusterSize < N * s.nv) { - printf("\033[F\033[J\033[F\033[JWOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n", (count_t)((double)sum_of_clusterSize / (double)s.nv), N, s.E, s.last_cluster_size); - wolff(N, s, gen_R, measurements, rng, silent); + printf("\033[F\033[J\033[F\033[JWOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n", (count_t)((double)sum_of_clusterSize / (double)s.nv), N, m.E, m.last_cluster_size); + wolff(N, s, gen_R, m, rng); N_rounds++; } - printf("\033[F\033[J\033[F\033[JWOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n\n", (count_t)((double)sum_of_clusterSize / (double)s.nv), N, s.E, s.last_cluster_size); + printf("\033[F\033[J\033[F\033[JWOLFF: sweep %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n\n", (count_t)((double)sum_of_clusterSize / (double)s.nv), N, m.E, m.last_cluster_size); } else { - wolff(N, s, gen_R, measurements, rng, silent); + wolff(N, s, gen_R, m, rng); } // free the random number generator free(H_vec); - measure_free_files(measurement_flags, outfiles); return 0; |