summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-10-10 00:08:11 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-10-10 00:08:11 -0400
commit4239e2bfc6701f0b5170132d01af381129618b34 (patch)
treef3429fc52a950f5fbd756d6fa0e5863e52b35393 /lib
parentb01aedbf7d9cb6bdcdd291e6d4a66f3ef8fa7eb4 (diff)
downloadc++-4239e2bfc6701f0b5170132d01af381129618b34.tar.gz
c++-4239e2bfc6701f0b5170132d01af381129618b34.tar.bz2
c++-4239e2bfc6701f0b5170132d01af381129618b34.zip
added new compile flag NOFIELD, which when defined compiles a version of wolff for use with zero field
Diffstat (limited to 'lib')
-rw-r--r--lib/cluster.h23
-rw-r--r--lib/state.h10
2 files changed, 25 insertions, 8 deletions
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<R_t, X_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<R_t, X_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<R_t, X_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<typename X_t::F_t> ImF;
std::function <double(const X_t&, const X_t&)> J;
+#ifndef NOFIELD
std::function <double(const X_t&)> H;
state_t(D_t D, L_t L, double T, std::function <double(const X_t&, const X_t&)> J, std::function <double(const X_t&)> 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 <double(const X_t&, const X_t&)> 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);