From 3044b71aa308c0fae90ae5655bda8bc76f6619dd Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 10 Feb 2020 15:32:19 -0500 Subject: began transition to more general transformations --- space_wolff.hpp | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'space_wolff.hpp') 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&){}; }; +template using Gen = std::function&, randutils::mt19937_rng&)>; + +template class Model; + +template class Transformation { + public: + virtual void ready() {}; + virtual double p(const Transformation&) const { return 0; } + virtual void apply() {}; + virtual std::set to_consider() const {}; +}; + +template class SpinFlip : public Transformation { + private: + Model& M; + Spin& s; + const R& r; + Spin s_new; + public: + SpinFlip(Model& M, Spin& 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 Model { public: U L; @@ -108,9 +144,10 @@ public: void resize(double T, double P) {} - void wolff(double T, std::function&, randutils::mt19937_rng&)> g, + void wolff(double T, std::vector> gs, measurement& A, unsigned N) { for (unsigned i = 0; i < N; i++) { + Gen& g = rng.pick(gs); R r = g(*this, rng); unsigned ind = rng.uniform((unsigned)0, (unsigned)(s.size() - 1)); -- cgit v1.2.3-70-g09d2