summaryrefslogtreecommitdiff
path: root/lib/include/wolff.hpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-10-10 21:45:32 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-10-10 21:45:32 -0400
commita43ff1f98e9b9814f858bccb11c174b418458491 (patch)
treeae7e094d914eddb8a1ae9548420ba8c2f329ffae /lib/include/wolff.hpp
parent6e264d243f0b29d90e90b605b6cdeab8227129c9 (diff)
downloadc++-a43ff1f98e9b9814f858bccb11c174b418458491.tar.gz
c++-a43ff1f98e9b9814f858bccb11c174b418458491.tar.bz2
c++-a43ff1f98e9b9814f858bccb11c174b418458491.zip
big rearrangement of files to make libraries and example (research) files clearer, and changed to c++ std lib random numbers
Diffstat (limited to 'lib/include/wolff.hpp')
-rw-r--r--lib/include/wolff.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/include/wolff.hpp b/lib/include/wolff.hpp
new file mode 100644
index 0000000..c10a211
--- /dev/null
+++ b/lib/include/wolff.hpp
@@ -0,0 +1,35 @@
+
+#include "wolff/cluster.hpp"
+#include "wolff/state.hpp"
+
+template <class R_t, class X_t>
+void wolff(count_t N, state_t <R_t, X_t>& s, std::function <R_t(std::mt19937&, X_t)> gen_R, std::function <void(const state_t <R_t, X_t>&)> measurements, std::mt19937& r, bool silent) {
+
+#ifdef FINITE_STATES
+#ifdef NOFIELD
+ initialize_probs(s.J, s.T);
+#else
+ initialize_probs(s.J, s.H, s.T);
+#endif
+#endif
+
+ std::uniform_int_distribution<v_t> dist(0, s.nv);
+
+ if (!silent) printf("\n");
+ for (count_t steps = 0; steps < N; steps++) {
+ if (!silent) printf("\033[F\033[JWOLFF: step %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n", steps, N, s.E, s.last_cluster_size);
+
+ v_t v0 = dist(r);
+ R_t step = gen_R(r, s.spins[v0]);
+ flip_cluster <R_t, X_t> (s, v0, step, r);
+
+ measurements(s);
+ }
+
+ if (!silent) {
+ printf("\033[F\033[J");
+ }
+ printf("WOLFF: step %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n", N, N, s.E, s.last_cluster_size);
+
+}
+