summaryrefslogtreecommitdiff
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
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
-rw-r--r--CMakeLists.txt4
-rw-r--r--lib/cluster.h23
-rw-r--r--lib/state.h10
-rw-r--r--src/wolff_On.cpp4
4 files changed, 33 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 568585f..89c55a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,7 @@ add_executable(wolff_3clock src/wolff_clock.cpp ${CPPSOURCES} ${CSOURCES})
add_executable(wolff_5clock src/wolff_clock.cpp ${CPPSOURCES} ${CSOURCES})
add_executable(wolff_planar src/wolff_On.cpp ${CPPSOURCES} ${CSOURCES})
add_executable(wolff_planar_2D src/wolff_On.cpp ${CPPSOURCES} ${CSOURCES})
+add_executable(wolff_planar_2D_0 src/wolff_On.cpp ${CPPSOURCES} ${CSOURCES})
add_executable(wolff_heisenberg src/wolff_On.cpp ${CPPSOURCES} ${CSOURCES})
add_executable(analyze_correlations src/analyze_correlations.cpp ${CPPSOURCES} ${CSOURCES})
@@ -34,6 +35,7 @@ SET_TARGET_PROPERTIES(wolff_3clock PROPERTIES COMPILE_FLAGS "-DPOTTSQ=3")
SET_TARGET_PROPERTIES(wolff_5clock PROPERTIES COMPILE_FLAGS "-DPOTTSQ=5")
SET_TARGET_PROPERTIES(wolff_planar PROPERTIES COMPILE_FLAGS "-DN_COMP=2")
SET_TARGET_PROPERTIES(wolff_planar_2D PROPERTIES COMPILE_FLAGS "-DN_COMP=2 -DDIMENSION=2")
+SET_TARGET_PROPERTIES(wolff_planar_2D_0 PROPERTIES COMPILE_FLAGS "-DN_COMP=2 -DDIMENSION=2 -DNOFIELD")
SET_TARGET_PROPERTIES(wolff_heisenberg PROPERTIES COMPILE_FLAGS "-DN_COMP=3")
find_library(GSL REQUIRED NAMES gsl)
@@ -57,6 +59,7 @@ if (${GLUT} MATCHES "GLUT-NOTFOUND")
target_link_libraries(wolff_heisenberg cblas gsl m)
target_link_libraries(wolff_planar cblas gsl m)
target_link_libraries(wolff_planar_2D cblas gsl m)
+ target_link_libraries(wolff_planar_2D_0 cblas gsl m)
else()
target_link_libraries(wolff_ising cblas gsl m glut GL GLU)
target_link_libraries(wolff_dgm cblas gsl m glut GL GLU)
@@ -69,6 +72,7 @@ else()
target_link_libraries(wolff_heisenberg cblas gsl m glut GL GLU)
target_link_libraries(wolff_planar cblas gsl m glut GL GLU)
target_link_libraries(wolff_planar_2D cblas gsl m glut GL GLU)
+ target_link_libraries(wolff_planar_2D_0 cblas gsl m glut GL GLU)
target_compile_definitions(wolff_ising PUBLIC HAVE_GLUT)
target_compile_definitions(wolff_dgm PUBLIC HAVE_GLUT)
target_compile_definitions(wolff_cgm PUBLIC HAVE_GLUT)
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);
diff --git a/src/wolff_On.cpp b/src/wolff_On.cpp
index 2356875..f6661af 100644
--- a/src/wolff_On.cpp
+++ b/src/wolff_On.cpp
@@ -241,7 +241,11 @@ int main(int argc, char *argv[]) {
gsl_rng *r = gsl_rng_alloc(gsl_rng_taus2);
gsl_rng_set(r, rand_seed());
+#ifndef NOFIELD
state_t <orthogonal_R_t, vector_R_t> s(D, L, T, dot <N_COMP, double>, H);
+#else
+ state_t <orthogonal_R_t, vector_R_t> s(D, L, T, dot <N_COMP, double>);
+#endif
if (N_is_sweeps) {
count_t N_rounds = 0;