From 1586d6b2247c510c11d9a4847bde67cb0947243d Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 14 Aug 2019 11:45:12 -0400 Subject: fixed bugs in Ising, p for bonds pre-computed --- spheres.cpp | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) (limited to 'spheres.cpp') diff --git a/spheres.cpp b/spheres.cpp index 106ce4e..b0f4fb4 100644 --- a/spheres.cpp +++ b/spheres.cpp @@ -34,20 +34,20 @@ int main(int argc, char* argv[]) { } } - std::function, spin)> Z = - [L] (spin s1, spin s2) -> double { - vector diff = s1.x - s2.x; - for (unsigned i = 0; i < D; i++) { - if (fabs(diff(i)) > L / 2) { - diff(i) = L - fabs(diff(i)); - } else { - diff(i) = fabs(diff(i)); - } - } - if (diff.transpose() * diff < pow(s1.s + s2.s, 2)) { - return -std::numeric_limits::infinity(); + std::function, spin, spin)> Z = + [L] (spin s1, spin s2, spin s1_new) -> double { + vector diff_old = diff(L, s1.x, s2.x); + vector diff_new = diff(L, s1_new.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; + + if (new_overlap) { + return 1.0; } else { - return 0; + return 0.0; } }; @@ -60,16 +60,10 @@ int main(int argc, char* argv[]) { [] (model& m, unsigned i0, spin s1) -> std::set { std::set nn; if (i0 < m.s.size()) { - std::set os1 = m.dict.on_site(s1.x); - std::set nn0 = m.dict.nearest_neighbors(m.s[i0].x); - std::set nn1 = m.dict.nearest_neighbors(s1.x); - std::set nnn0 = m.dict.next_nearest_neighbors(m.s[i0].x); - std::set nnn1 = m.dict.next_nearest_neighbors(s1.x); - nn.insert(nn0.begin(), nn0.end()); - nn.insert(nn1.begin(), nn1.end()); - nn.insert(nnn0.begin(), nnn0.end()); - nn.insert(nnn1.begin(), nnn1.end()); - nn.insert(os1.begin(), os1.end()); + std::set n_old = m.dict.neighbors(m.s[i0].x, 1); + std::set 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++) { @@ -94,11 +88,16 @@ int main(int argc, char* argv[]) { sphere.wolff(T, N, rng); + std::ofstream snapfile; + snapfile.open("sphere_snap.dat"); + for (spin s : sphere.s) { spin rs = sphere.s0.inverse().act(s); - std::cout << s.x.transpose() << "\n"; + snapfile << rs.x.transpose() << "\n"; } + snapfile.close(); + return 0; } -- cgit v1.2.3-54-g00ecf