diff options
Diffstat (limited to 'spheres.cpp')
-rw-r--r-- | spheres.cpp | 50 |
1 files changed, 17 insertions, 33 deletions
diff --git a/spheres.cpp b/spheres.cpp index b0f4fb4..633a26a 100644 --- a/spheres.cpp +++ b/spheres.cpp @@ -34,65 +34,49 @@ int main(int argc, char* argv[]) { } } - std::function<double(spin<double, D, double>, spin<double, D, double>, spin<double, D, double>)> Z = - [L] (spin<double, D, double> s1, spin<double, D, double> s2, spin<double, D, double> s1_new) -> double { - vector<double, D> diff_old = diff(L, s1.x, s2.x); - vector<double, D> diff_new = diff(L, s1_new.x, s2.x); + std::function<double(const Spin<double, D, double>&, const Spin<double, D, double>&)> Z = + [L] (const Spin<double, D, double>& s1, const Spin<double, D, double>& s2) -> double { + Vector<double, D> d = diff(L, s1.x, s2.x); double rad_sum = pow(s1.s + s2.s, 2); - bool old_overlap = diff_old.transpose() * diff_old < rad_sum; - bool new_overlap = diff_new.transpose() * diff_new < rad_sum; + bool overlap = d.transpose() * d < rad_sum; - if (new_overlap) { - return 1.0; + if (overlap) { + return -1e8; } else { - return 0.0; + return 0; } }; - std::function<double(spin<double, D, double>)> B = - [L, H] (spin<double, D, double> s) -> double { + std::function<double(Spin<double, D, double>)> B = + [L, H] (Spin<double, D, double> s) -> double { return H * sin(2 * M_PI * 3 * s.x(0) / L); }; - std::function<std::set<unsigned>(model<double, D, double>&, unsigned, spin<double, D, double>)> neighbors = - [] (model<double, D, double>& m, unsigned i0, spin<double, D, double> s1) -> std::set<unsigned> { - std::set<unsigned> nn; - if (i0 < m.s.size()) { - std::set<unsigned> n_old = m.dict.neighbors(m.s[i0].x, 1); - std::set<unsigned> n_new = m.dict.neighbors(s1.x, 1);; - nn.insert(n_old.begin(), n_old.end()); - nn.insert(n_new.begin(), n_new.end()); - nn.insert(m.s.size()); - } else { - for (unsigned i = 0; i < m.s.size(); i++) { - nn.insert(i); - } - } - return nn; - }; - - model<double, D, double> sphere(L, Z, B, neighbors); + Model<double, D, double> sphere(L, Z, B, std::floor(log2(L)), 2); randutils::auto_seed_128 seeds; std::mt19937 rng{seeds}; std::uniform_real_distribution<double> dist(0.0, L); + sphere.s.reserve(n); + for (unsigned i = 0; i < n; i++) { - vector<double, D> pos = {dist(rng), dist(rng)}; + Vector<double, D> pos = {dist(rng), dist(rng)}; sphere.s.push_back({pos, 0.5}); - sphere.dict.record<double>(pos, i); + sphere.dict.insert(&sphere.s.back()); } + sphere.wolff(T, N, rng); std::ofstream snapfile; snapfile.open("sphere_snap.dat"); - for (spin<double, D, double> s : sphere.s) { - spin<double, D, double> rs = sphere.s0.inverse().act(s); + for (Spin<double, D, double> s : sphere.s) { + Spin<double, D, double> rs = sphere.s0.inverse().act(s); snapfile << rs.x.transpose() << "\n"; } |