From 4239e2bfc6701f0b5170132d01af381129618b34 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 10 Oct 2018 00:08:11 -0400 Subject: added new compile flag NOFIELD, which when defined compiles a version of wolff for use with zero field --- lib/cluster.h | 23 ++++++++++++++++------- lib/state.h | 10 +++++++++- 2 files changed, 25 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/cluster.h b/lib/cluster.h index 9dcf50d..f57bb68 100644 --- a/lib/cluster.h +++ b/lib/cluster.h @@ -25,24 +25,28 @@ void flip_cluster(state_t& s, v_t v0, const R_t& r, gsl_rng *rand) { stack.pop(); if (!marks[v]) { // don't reprocess anyone we've already visited! + marks[v] = true; + X_t si_new; +#ifndef NOFIELD R_t R_new; - marks[v] = true; - bool v_is_ghost = (v == s.nv); // ghost site has the last index if (v_is_ghost) { R_new = r.act(s.R); // if we are, then we're moving the transformation - } else { + } else +#endif + { si_new = r.act(s.spins[v]); // otherwise, we're moving the spin at our site } for (const v_t &vn : s.g.v_adj[v]) { - bool vn_is_ghost = (vn == s.nv); // any of our neighbors could be the ghost - double dE, prob; +#ifndef NOFIELD + bool vn_is_ghost = (vn == s.nv); // any of our neighbors could be the ghost + if (v_is_ghost || vn_is_ghost) { // this is a ghost-involved bond X_t rs_old, rs_new; v_t non_ghost; @@ -69,7 +73,9 @@ void flip_cluster(state_t& s, v_t v0, const R_t& r, gsl_rng *rand) { s.update_magnetization(rs_old, rs_new); s.update_fourierZero(non_ghost, rs_old, rs_new); - } else { // this is a perfectly normal bond! + } else // this is a perfectly normal bond! +#endif + { dE = s.J(s.spins[v], s.spins[vn]) - s.J(si_new, s.spins[vn]); #ifdef FINITE_STATES @@ -88,9 +94,12 @@ void flip_cluster(state_t& s, v_t v0, const R_t& r, gsl_rng *rand) { } } +#ifndef NOFIELD if (v_is_ghost) { s.R = R_new; - } else { + } else +#endif + { s.spins[v] = si_new; nv++; } diff --git a/lib/state.h b/lib/state.h index 3bbed39..cad453c 100644 --- a/lib/state.h +++ b/lib/state.h @@ -29,14 +29,22 @@ class state_t { std::vector ImF; std::function J; +#ifndef NOFIELD std::function H; state_t(D_t D, L_t L, double T, std::function J, std::function H) : D(D), L(L), g(D, L), T(T), R(), J(J), H(H) { +#else + state_t(D_t D, L_t L, double T, std::function J) : D(D), L(L), g(D, L), T(T), R(), J(J) { +#endif nv = g.nv; ne = g.ne; - g.add_ext(); spins.resize(nv); +#ifndef NOFIELD + g.add_ext(); E = - (double)ne * J(spins[0], spins[0]) - (double)nv * H(spins[0]); +#else + E = - (double)ne * J(spins[0], spins[0]); +#endif M = spins[0] * nv; last_cluster_size = 0; ReF.resize(D); -- cgit v1.2.3-70-g09d2