From 6b8448e5f80a7fa623678c532d1cceba0d19ac11 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sat, 21 Jul 2018 13:47:01 -0400 Subject: made wolff-ising header files more pedogogical --- src/wolff_ising.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/wolff_ising.cpp') diff --git a/src/wolff_ising.cpp b/src/wolff_ising.cpp index fd2f0bb..e9d0185 100644 --- a/src/wolff_ising.cpp +++ b/src/wolff_ising.cpp @@ -45,24 +45,50 @@ int main(int argc, char *argv[]) { gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937); gsl_rng_set(r, rand_seed()); - state_t s(D, L, T, ising_dot, std::bind(scalar_field, std::placeholders::_1, H)); + // define spin-spin coupling + std::function Z = [] (ising_t s1, ising_t s2) -> double { + if (s1.x == s2.x) { + return 1.0; + } else { + return -1.0; + } + }; - std::function *)> gen_R = generate_ising_rotation; + // define spin-field coupling + std::function B = [=] (ising_t s) -> double { + if (s.x) { + return -H; + } else { + return H; + } + }; - double average_M = 0; + // initialize state object + state_t s(D, L, T, Z, B); - typedef std::function *)> meas_func; + // define function that generates self-inverse rotations + std::function *)> gen_R = [] (gsl_rng *, const state_t *) -> z2_t { + z2_t rot; + rot.x = true; + return rot; + }; - meas_func measurement = [&] (const state_t *s) { + // define function that updates any number of measurements + double average_M = 0; + std::function *)> measurement = [&] (const state_t *s) { average_M += (double)s->M / (double)N / (double)s->nv; }; + // run wolff for N cluster flips wolff(N, &s, gen_R, measurement, r, silent); + // tell us what we found! printf("%" PRIcount " Ising runs completed. D = %" PRID ", L = %" PRIL ", T = %g, H = %g, = %g\n", N, D, L, T, H, average_M); + // free the random number generator gsl_rng_free(r); return 0; + } -- cgit v1.2.3-70-g09d2