diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-21 13:21:49 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-21 13:21:49 -0400 |
commit | 0c69763278ed102d0e37aa1fb4feda5827c26c62 (patch) | |
tree | 0227d36b272c1243cde6827dcde6f2b3014abb95 /src/wolff_ising.cpp | |
parent | f14e6eb0e8cb01ee29f98db9797ac37f3e690cb8 (diff) | |
download | c++-0c69763278ed102d0e37aa1fb4feda5827c26c62.tar.gz c++-0c69763278ed102d0e37aa1fb4feda5827c26c62.tar.bz2 c++-0c69763278ed102d0e37aa1fb4feda5827c26c62.zip |
simplified the way that measurements work
Diffstat (limited to 'src/wolff_ising.cpp')
-rw-r--r-- | src/wolff_ising.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/wolff_ising.cpp b/src/wolff_ising.cpp index 1812527..fd2f0bb 100644 --- a/src/wolff_ising.cpp +++ b/src/wolff_ising.cpp @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) { case 'T': // temperature T = atof(optarg); break; - case 'H': // external field. nth call couples to state n + case 'H': // external field H = atof(optarg); break; case 's': // don't print anything during simulation. speeds up slightly @@ -49,21 +49,18 @@ int main(int argc, char *argv[]) { std::function <z2_t(gsl_rng *, const state_t <z2_t, ising_t> *)> gen_R = generate_ising_rotation; - unsigned int n_measurements = 1; - double average_M = 0; - std::function <void(const state_t <z2_t, ising_t> *)> *measurements = (std::function <void(const state_t <z2_t, ising_t> *)> *)calloc(1, sizeof(std::function <void(const state_t <z2_t, ising_t> *)>)); + typedef std::function <void(const state_t <z2_t, ising_t> *)> meas_func; - measurements[0] = [&] (const state_t <z2_t, ising_t> *s) { + meas_func measurement = [&] (const state_t <z2_t, ising_t> *s) { average_M += (double)s->M / (double)N / (double)s->nv; }; - wolff(N, &s, gen_R, n_measurements, measurements, r, silent); + wolff(N, &s, gen_R, measurement, r, silent); printf("%" PRIcount " Ising runs completed. D = %" PRID ", L = %" PRIL ", T = %g, H = %g, <M> = %g\n", N, D, L, T, H, average_M); - free(measurements); gsl_rng_free(r); return 0; |