summaryrefslogtreecommitdiff
path: root/space_wolff.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'space_wolff.hpp')
-rw-r--r--space_wolff.hpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/space_wolff.hpp b/space_wolff.hpp
index 196b3b5..4c935db 100644
--- a/space_wolff.hpp
+++ b/space_wolff.hpp
@@ -31,6 +31,42 @@ public:
virtual void post_cluster(const Model<U, D, R, S>&){};
};
+template <class U, int D, class R, class S> using Gen = std::function<R(const Model<U, D, R, S>&, randutils::mt19937_rng&)>;
+
+template <class U, int D, class R, class S> class Model;
+
+template <class U, int D, class R, class S> class Transformation {
+ public:
+ virtual void ready() {};
+ virtual double p(const Transformation&) const { return 0; }
+ virtual void apply() {};
+ virtual std::set<Transformation*> to_consider() const {};
+};
+
+template <class U, int D, class R, class S> class SpinFlip : public Transformation<U, D, R, S> {
+ private:
+ Model<U, D, R, S>& M;
+ Spin<U, D, S>& s;
+ const R& r;
+ Spin<U, D, S> s_new;
+ public:
+ SpinFlip(Model<U, D, R, S>& M, Spin<U, D, S>& s, const R& r) : M(M), s(s), r(r) {}
+
+ void ready() override {
+ s_new = r.act(s);
+ };
+
+ double p(const SpinFlip& sf, double T) const override {
+ return 1.0 - exp(-(M.Z(s, sf.s) - M.Z(s_new, sf.s)) / T);
+ }
+
+ double p(const SpinFlip& sf, double T) const override {
+ return 1.0 - exp(-(M.Z(s, sf.s) - M.Z(s_new, sf.s)) / T);
+ }
+
+
+};
+
template <class U, int D, class R, class S> class Model {
public:
U L;
@@ -108,9 +144,10 @@ public:
void resize(double T, double P) {}
- void wolff(double T, std::function<R(const Model<U, D, R, S>&, randutils::mt19937_rng&)> g,
+ void wolff(double T, std::vector<Gen<U, D, R, S>> gs,
measurement<U, D, R, S>& A, unsigned N) {
for (unsigned i = 0; i < N; i++) {
+ Gen<U, D, R, S>& g = rng.pick(gs);
R r = g(*this, rng);
unsigned ind = rng.uniform((unsigned)0, (unsigned)(s.size() - 1));