summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-21 13:47:01 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-21 13:47:01 -0400
commit6b8448e5f80a7fa623678c532d1cceba0d19ac11 (patch)
tree8757a7a4d791503a525d249ca68b46763d82301b /src
parent0c69763278ed102d0e37aa1fb4feda5827c26c62 (diff)
downloadc++-6b8448e5f80a7fa623678c532d1cceba0d19ac11.tar.gz
c++-6b8448e5f80a7fa623678c532d1cceba0d19ac11.tar.bz2
c++-6b8448e5f80a7fa623678c532d1cceba0d19ac11.zip
made wolff-ising header files more pedogogical
Diffstat (limited to 'src')
-rw-r--r--src/wolff_ising.cpp36
1 files changed, 31 insertions, 5 deletions
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 <z2_t, ising_t> s(D, L, T, ising_dot, std::bind(scalar_field, std::placeholders::_1, H));
+ // define spin-spin coupling
+ std::function <double(ising_t, ising_t)> Z = [] (ising_t s1, ising_t s2) -> double {
+ if (s1.x == s2.x) {
+ return 1.0;
+ } else {
+ return -1.0;
+ }
+ };
- std::function <z2_t(gsl_rng *, const state_t <z2_t, ising_t> *)> gen_R = generate_ising_rotation;
+ // define spin-field coupling
+ std::function <double(ising_t)> B = [=] (ising_t s) -> double {
+ if (s.x) {
+ return -H;
+ } else {
+ return H;
+ }
+ };
- double average_M = 0;
+ // initialize state object
+ state_t <z2_t, ising_t> s(D, L, T, Z, B);
- typedef std::function <void(const state_t <z2_t, ising_t> *)> meas_func;
+ // define function that generates self-inverse rotations
+ std::function <z2_t(gsl_rng *, const state_t <z2_t, ising_t> *)> gen_R = [] (gsl_rng *, const state_t <z2_t, ising_t> *) -> z2_t {
+ z2_t rot;
+ rot.x = true;
+ return rot;
+ };
- meas_func measurement = [&] (const state_t <z2_t, ising_t> *s) {
+ // define function that updates any number of measurements
+ double average_M = 0;
+ std::function <void(const state_t <z2_t, ising_t> *)> measurement = [&] (const state_t <z2_t, ising_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, <M> = %g\n", N, D, L, T, H, average_M);
+ // free the random number generator
gsl_rng_free(r);
return 0;
+
}