summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-10-19 11:05:32 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-10-19 11:05:32 -0400
commit98916c597dcaafd8113547a39d1e66704ac62b82 (patch)
treef60031a509e1750afb193bcbc2439700aa9705dc
parentc41db143c477b627c8c690b621f7bb514e08bbbf (diff)
downloadc++-98916c597dcaafd8113547a39d1e66704ac62b82.tar.gz
c++-98916c597dcaafd8113547a39d1e66704ac62b82.tar.bz2
c++-98916c597dcaafd8113547a39d1e66704ac62b82.zip
added support for nonunitary x, so that bond probabilities can be changed as in the DGM paper
-rw-r--r--lib/include/wolff.hpp4
-rw-r--r--lib/include/wolff/cluster.hpp8
-rw-r--r--lib/include/wolff/system.hpp4
3 files changed, 8 insertions, 8 deletions
diff --git a/lib/include/wolff.hpp b/lib/include/wolff.hpp
index 7e909c8..7ad608f 100644
--- a/lib/include/wolff.hpp
+++ b/lib/include/wolff.hpp
@@ -10,7 +10,7 @@ namespace wolff{
template <class R_t, class X_t>
void system<R_t, X_t>::run_wolff(N_t N,
std::function <R_t(std::mt19937&, const system<R_t, X_t>&, v_t)> r_gen,
- measurement<R_t, X_t>& A, std::mt19937& rng) {
+ measurement<R_t, X_t>& A, std::mt19937& rng, double x) {
std::uniform_int_distribution<v_t> dist(0, nv - 1);
@@ -20,7 +20,7 @@ void system<R_t, X_t>::run_wolff(N_t N,
A.pre_cluster(n, N, *this, i0, r);
- this->flip_cluster(i0, r, rng, A);
+ this->flip_cluster(i0, r, rng, A, x);
A.post_cluster(n, N, *this);
}
diff --git a/lib/include/wolff/cluster.hpp b/lib/include/wolff/cluster.hpp
index b66f367..34d256a 100644
--- a/lib/include/wolff/cluster.hpp
+++ b/lib/include/wolff/cluster.hpp
@@ -13,7 +13,7 @@ namespace wolff {
template <class R_t, class X_t>
void system<R_t, X_t>::flip_cluster(v_t i0, const R_t& r,
- std::mt19937& rng, measurement<R_t, X_t>& A) {
+ std::mt19937& rng, measurement<R_t, X_t>& A, double x) {
std::uniform_real_distribution<double> dist(0.0, 1.0);
std::queue<v_t> queue;
@@ -69,7 +69,7 @@ void system<R_t, X_t>::flip_cluster(v_t i0, const R_t& r,
#endif
#ifdef WOLFF_FINITE_STATES
- p = finite_states_Bp[finite_states_enum(s0s_old)]
+ p = 1.0 - x + x * finite_states_Bp[finite_states_enum(s0s_old)]
[finite_states_enum(s0s_new)];
#endif
@@ -85,7 +85,7 @@ void system<R_t, X_t>::flip_cluster(v_t i0, const R_t& r,
#endif
#ifdef WOLFF_FINITE_STATES
- p = finite_states_Zp[finite_states_enum(s[i])]
+ p = 1.0 - x + x * finite_states_Zp[finite_states_enum(s[i])]
[finite_states_enum(si_new)]
[finite_states_enum(s[j])];
#endif
@@ -95,7 +95,7 @@ void system<R_t, X_t>::flip_cluster(v_t i0, const R_t& r,
}
#ifndef FINITE_STATES
- p = 1.0 - exp(-dE / T);
+ p = 1.0 - x * exp(-dE / T);
#endif
if (dist(rng) < p) {
diff --git a/lib/include/wolff/system.hpp b/lib/include/wolff/system.hpp
index 32ad38e..6e9c951 100644
--- a/lib/include/wolff/system.hpp
+++ b/lib/include/wolff/system.hpp
@@ -68,8 +68,8 @@ class system {
#endif
}
- void flip_cluster(v_t, const R_t&, std::mt19937&, measurement<R_t, X_t>&);
- void run_wolff(N_t, std::function <R_t(std::mt19937&, const system<R_t, X_t>&, v_t)> r_gen, measurement<R_t, X_t>& A, std::mt19937& rng);
+ void flip_cluster(v_t, const R_t&, std::mt19937&, measurement<R_t, X_t>&, double x = 1.0);
+ void run_wolff(N_t, std::function <R_t(std::mt19937&, const system<R_t, X_t>&, v_t)> r_gen, measurement<R_t, X_t>& A, std::mt19937& rng, double x = 1.0);
};
}