From 452600249b16eb1239931b49f3d0fa795a611f5a Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 14 Feb 2020 07:44:50 -0500 Subject: Broken: attempt to implement dynamic matching of pair-flipped spheres. --- space_wolff.hpp | 2 +- transformation.hpp | 56 +++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/space_wolff.hpp b/space_wolff.hpp index 9d529a3..141396a 100644 --- a/space_wolff.hpp +++ b/space_wolff.hpp @@ -62,7 +62,7 @@ public: for (Spin* s : t->toConsider()) { double ΔE = t->ΔE(s); if (ΔE > 0 && 1.0 - exp(-ΔE / T) > rng.uniform(0, 1)) { - queue.push(t->createNew(s)); + queue.push(t->createNew(T, visited, s, rng)); } } diff --git a/transformation.hpp b/transformation.hpp index 0731ec9..fc1833e 100644 --- a/transformation.hpp +++ b/transformation.hpp @@ -12,7 +12,7 @@ public: virtual std::set*> current() const { return {NULL}; } virtual std::set*> toConsider() const { return {}; } virtual double ΔE(const Spin*) const { return 0; } - virtual Transformation* createNew(Spin*) const { return new Transformation(); } + virtual Transformation* createNew(double T, const std::set*>&, Spin*, Rng& rng) const { return new Transformation(); } virtual void apply(){}; }; @@ -56,7 +56,7 @@ public: } } - Transformation* createNew(Spin* s) const override; + Transformation* createNew(double, const std::set*>&, Spin* s, Rng&) const override; void apply() override { M.dict.remove(sOld); @@ -112,8 +112,8 @@ public: } } - Transformation* createNew(Spin* s) const; - Transformation* createNew(Spin* s) const; + Transformation* createNew(double T, const std::set*>& v, Spin* s, Rng&) const; + Transformation* createNew(double T, const std::set*>& v, Spin* s, Rng&) const; void apply() override { M.dict.remove(s1Old); @@ -150,11 +150,11 @@ public: return M.B(s0s_new) - M.B(s0s_old); } - Transformation* createNew(Spin* s) const { + Transformation* createNew(double T, const std::set*>& v, Spin* s, Rng&) const { return new SpinFlip(M, r, s); } - Transformation* createNew(Spin* s) const { + Transformation* createNew(double, const std::set*>&, Spin* s, Rng&) const { Vector v = r.act(*s).x; std::set*> on_site = M.dict.at(v); if (on_site.empty()) { @@ -168,25 +168,59 @@ public: }; template -Transformation* SpinFlip::createNew(Spin* s) const { +Transformation* SpinFlip::createNew(double T, const std::set*>& v, Spin* s, Rng& rng) const { if (s == NULL) { return new FieldFlip(M, r); } else { - return new SpinFlip(M, r, s); + SpinFlip* t = new SpinFlip(M, r, s); + Spin* sMax = NULL; + double ΔEMax = 0.0; + for (Spin* ss : t->toConsider()) { + if (ss != NULL && ss != s && !v.contains(ss)) { + double ΔE = t->ΔE(ss); + if (ΔE > ΔEMax) { + sMax = ss; + ΔEMax = ΔE; + } + } + } + if (sMax == NULL || 1.0 - exp(-ΔEMax / T) < rng.uniform(0, 1)) { + return t; + } else { + delete t; + return new PairFlip(M, r, s, sMax); + } } } template -Transformation* PairFlip::createNew(Spin* s) const { +Transformation* PairFlip::createNew(double T, const std::set*>& v, Spin* s, Rng& rng) const { if (s == NULL) { return new FieldFlip(M, r); } else { - return new SpinFlip(M, r, s); + SpinFlip* t = new SpinFlip(M, r, s); + Spin* sMax = NULL; + double ΔEMax = 0.0; + for (Spin* ss : t->toConsider()) { + if (ss != NULL && ss != s && !v.contains(ss)) { + double ΔE = t->ΔE(ss); + if (ΔE > ΔEMax) { + sMax = ss; + ΔEMax = ΔE; + } + } + } + if (sMax == NULL || 1.0 - exp(-ΔEMax / T) < rng.uniform(0, 1)) { + return t; + } else { + delete t; + return new PairFlip(M, r, s, sMax); + } } } template -Transformation* PairFlip::createNew(Spin* s) const { +Transformation* PairFlip::createNew(double, const std::set*>&, Spin* s, Rng&) const { if (s == NULL) { return new FieldFlip(M, r); } else { -- cgit v1.2.3-70-g09d2