summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2020-02-26 09:14:04 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2020-02-26 09:14:04 -0500
commit468c25eabd1aaac7d02988fef97b66bb378988b3 (patch)
tree9e457e7f68af65729b32354584423153c8799164
parent6461165f4daea01c5baa1d969ee5c726fb4c559e (diff)
downloadspace_wolff-468c25eabd1aaac7d02988fef97b66bb378988b3.tar.gz
space_wolff-468c25eabd1aaac7d02988fef97b66bb378988b3.tar.bz2
space_wolff-468c25eabd1aaac7d02988fef97b66bb378988b3.zip
More cleanup and temperary saving routines for presentation
-rw-r--r--dimers.cpp23
-rw-r--r--dimers_torus.cpp28
-rw-r--r--spheres.hpp55
-rw-r--r--spheres_infinite.cpp57
4 files changed, 92 insertions, 71 deletions
diff --git a/dimers.cpp b/dimers.cpp
index d5cfdf4..722c33c 100644
--- a/dimers.cpp
+++ b/dimers.cpp
@@ -57,18 +57,7 @@ int main(int argc, char* argv[]) {
}
auto zSingle = zSpheres<D>(a, k);
-
- std::function<double(const Spin<double, D, Dimer<double, D>>&,
- const Spin<double, D, Dimer<double, D>>&)>
- Z = [zSingle, a, k](const Spin<double, D, Dimer<double, D>>& s1,
- const Spin<double, D, Dimer<double, D>>& s2) -> double {
- Spin<double, D, Radius> s11 = {.x = s1.x + s1.s.relativePosition, .s = s1.s.radius};
- Spin<double, D, Radius> s12 = {.x = s1.x - s1.s.relativePosition, .s = s1.s.radius};
- Spin<double, D, Radius> s21 = {.x = s2.x + s2.s.relativePosition, .s = s2.s.radius};
- Spin<double, D, Radius> s22 = {.x = s2.x - s2.s.relativePosition, .s = s2.s.radius};
-
- return zSingle(s11, s21) + zSingle(s12, s21) + zSingle(s11, s22) + zSingle(s12, s22);
- };
+ auto Z = zDimers(zSingle);
auto g1 = nudgeGen<D, Dimer<double, D>>(1);
auto g2 = swapGen<D, Dimer<double, D>>(0.1);
@@ -104,18 +93,16 @@ int main(int argc, char* argv[]) {
file.close();
- /*
std::ofstream snapfile;
- snapfile.open("sphere_snap.dat");
+ snapfile.open("dimers_field_snap.dat");
- for (Spin<double, D, double>* s : sphere.s) {
- Spin<double, D, double> rs = sphere.s0.inverse().act(*s);
- snapfile << rs.s << " " << rs.x.transpose() << "\n";
+ for (Spin<double, D, Dimer<double, D>>* s : sphere.s) {
+ Spin<double, D, Dimer<double, D>> rs = sphere.s0.inverse().act(*s);
+ snapfile << rs.s.radius << " " << rs.x.transpose() << " " << rs.s.relativePosition.transpose() << "\n";
delete s;
}
snapfile.close();
- */
return 0;
}
diff --git a/dimers_torus.cpp b/dimers_torus.cpp
index ec7c73a..4b44a83 100644
--- a/dimers_torus.cpp
+++ b/dimers_torus.cpp
@@ -58,22 +58,10 @@ int main(int argc, char* argv[]) {
}
auto zSingle = zSpheresTorus<D>(L, a, k);
+ auto Z = zDimers(zSingle);
- std::function<double(const Spin<double, D, Dimer<double, D>>&,
- const Spin<double, D, Dimer<double, D>>&)>
- Z = [L, zSingle, a, k](const Spin<double, D, Dimer<double, D>>& s1,
- const Spin<double, D, Dimer<double, D>>& s2) -> double {
- Spin<double, D, Radius> s11 = {.x = s1.x + s1.s.relativePosition, .s = s1.s.radius};
- Spin<double, D, Radius> s12 = {.x = s1.x - s1.s.relativePosition, .s = s1.s.radius};
- Spin<double, D, Radius> s21 = {.x = s2.x + s2.s.relativePosition, .s = s2.s.radius};
- Spin<double, D, Radius> s22 = {.x = s2.x - s2.s.relativePosition, .s = s2.s.radius};
-
- return zSingle(s11, s21) + zSingle(s12, s21) + zSingle(s11, s22) + zSingle(s12, s22);
- };
-
- std::function<double(Spin<double, D, Dimer<double, D>>)> B = [L, H](Spin<double, D, Dimer<double, D>> s) -> double {
- return H * s.x(1);
- };
+ std::function<double(Spin<double, D, Dimer<double, D>>)> B =
+ [L, H](Spin<double, D, Dimer<double, D>> s) -> double { return H * s.x(1); };
auto g1 = uniformGenTorus<D, Dimer<double, D>>(L);
@@ -97,18 +85,16 @@ int main(int argc, char* argv[]) {
sphere.wolff(T, {g1}, A, N);
- /*
std::ofstream snapfile;
- snapfile.open("sphere_snap.dat");
+ snapfile.open("dimers_torus_snap.dat");
- for (Spin<double, D, double>* s : sphere.s) {
- Spin<double, D, double> rs = sphere.s0.inverse().act(*s);
- snapfile << rs.s << " " << rs.x.transpose() << "\n";
+ for (Spin<double, D, Dimer<double, D>>* s : sphere.s) {
+ Spin<double, D, Dimer<double, D>> rs = sphere.s0.inverse().act(*s);
+ snapfile << rs.s.radius << " " << rs.x.transpose() << " " << rs.s.relativePosition.transpose() << "\n";
delete s;
}
snapfile.close();
- */
return 0;
}
diff --git a/spheres.hpp b/spheres.hpp
index 60154f6..2ca0851 100644
--- a/spheres.hpp
+++ b/spheres.hpp
@@ -1,26 +1,26 @@
#include "space_wolff.hpp"
-template <int D>
-double softPotential(double a, double k, const Vector<double, D>& diff, double σ) {
- double δ = σ - sqrt(diff.transpose() * diff);
-
- if (δ > -a * σ) {
- return 0.5 * k * (2 * pow(a * σ, 2) - pow(δ, 2));
- } else if (δ > -2 * a * σ) {
- return 0.5 * k * pow(δ + 2 * a * σ, 2);
- } else {
- return 0;
- }
+template <int D> using Sphere = Spin<double, D, Radius>;
+
+template <int D> double softPotential(double a, double k, const Vector<double, D>& diff, double σ) {
+ double δ = σ - sqrt(diff.transpose() * diff);
+
+ if (δ > -a * σ) {
+ return 0.5 * k * (2 * pow(a * σ, 2) - pow(δ, 2));
+ } else if (δ > -2 * a * σ) {
+ return 0.5 * k * pow(δ + 2 * a * σ, 2);
+ } else {
+ return 0;
+ }
}
-template <int D>
-double hardPotential(const Vector<double, D>& diff, double σ) {
- if (pow(σ, 2) < diff.transpose() * diff) {
- return 0;
- } else {
- return -std::numeric_limits<double>::infinity();
- }
+template <int D> double hardPotential(const Vector<double, D>& diff, double σ) {
+ if (pow(σ, 2) < diff.transpose() * diff) {
+ return 0;
+ } else {
+ return -std::numeric_limits<double>::infinity();
+ }
}
template <int D>
@@ -35,8 +35,23 @@ zSpheres(double a, double k) {
template <int D>
std::function<double(const Spin<double, D, Radius>&, const Spin<double, D, Radius>&)>
zSpheresTorus(double L, double a, double k) {
- return [L, a, k](const Spin<double, D, double>& s1, const Spin<double, D, double>& s2) -> double {
- return softPotential(a, k, diff(L, s1.x, s2.x), s1.s + s2.s);
+ return [L, a, k](const Spin<double, D, double>& s1, const Spin<double, D, double>& s2) -> double {
+ return softPotential(a, k, diff(L, s1.x, s2.x), s1.s + s2.s);
+ };
+}
+
+template <int D>
+std::function<double(const Spin<double, D, Dimer<double, D>>&,
+ const Spin<double, D, Dimer<double, D>>&)>
+zDimers(std::function<double(const Sphere<D>&, const Sphere<D>&)> zSingle) {
+ return [zSingle](const Spin<double, D, Dimer<double, D>>& s1,
+ const Spin<double, D, Dimer<double, D>>& s2) -> double {
+ Spin<double, D, Radius> s11 = {.x = s1.x + s1.s.relativePosition, .s = s1.s.radius};
+ Spin<double, D, Radius> s12 = {.x = s1.x - s1.s.relativePosition, .s = s1.s.radius};
+ Spin<double, D, Radius> s21 = {.x = s2.x + s2.s.relativePosition, .s = s2.s.radius};
+ Spin<double, D, Radius> s22 = {.x = s2.x - s2.s.relativePosition, .s = s2.s.radius};
+
+ return zSingle(s11, s21) + zSingle(s12, s21) + zSingle(s11, s22) + zSingle(s12, s22);
};
}
diff --git a/spheres_infinite.cpp b/spheres_infinite.cpp
index af91427..3fd6da2 100644
--- a/spheres_infinite.cpp
+++ b/spheres_infinite.cpp
@@ -10,6 +10,46 @@
const unsigned D = 2;
typedef Model<double, D, Euclidean<double, D>, double> model;
+class SaveFlip : public measurement<double, D, Euclidean<double, D>, Radius> {
+ std::ofstream snapfile;
+ unsigned n;
+
+ public:
+ SaveFlip() {}
+
+ void pre_cluster(const Model<double, D, Euclidean<double, D>, Radius>& m, unsigned,
+ const Transformation<double, D, Euclidean<double, D>, Radius>* t) override {
+ snapfile.open("sphere_flip.dat");
+ n = 0;
+ for (const Sphere<D>* s : m.s) {
+ snapfile << s << " " << s->s << " " << s->x.transpose() << " ";
+ }
+ snapfile << "\n";
+ }
+
+ void plain_site_transformed(const Model<double, D, Euclidean<double, D>, Radius>& m,
+ const Transformation<double, D, Euclidean<double, D>, Radius>& t) override {
+ for (const Sphere<D>* s : t.current()) {
+ snapfile << s << " ";
+ }
+ snapfile << "\n";
+ n++;
+ }
+
+ void post_cluster(const Model<double, D, Euclidean<double, D>, Radius>& m) override {
+ for (const Sphere<D>* s : m.s) {
+ snapfile << s << " " << s->s << " " << s->x.transpose() << " ";
+ }
+ snapfile << "\n";
+ snapfile.close();
+ std::cout << n << "\n";
+ if (2 < n && n < 20) {
+ getchar();
+ }
+ }
+
+};
+
int main(int argc, char* argv[]) {
const unsigned D = 2;
@@ -65,7 +105,7 @@ int main(int argc, char* argv[]) {
};
auto g1 = nudgeGen<D, Radius>(1);
- auto g2 = swapGen<D, Radius>(0.1);
+ auto g2 = swapGen<D, Radius>(0.01);
auto g3 = accrossGen<D, Radius>(0.1);
auto g4 = centerGen<D, Radius>(0);
@@ -93,20 +133,13 @@ int main(int argc, char* argv[]) {
sphere.dict.insert(ss);
}
- sphere.wolff(T, {g1, g2, g3, g4}, A, N);
-
- file.close();
+ measurement<double, D, Euclidean<double, D>, Radius> A_tmp;
- std::ofstream snapfile;
- snapfile.open("sphere_snap.dat");
+ sphere.wolff(T, {g1, g2, g3, g4}, A_tmp, N);
- for (Spin<double, D, double>* s : sphere.s) {
- Spin<double, D, double> rs = sphere.s0.inverse().act(*s);
- snapfile << rs.s << " " << rs.x.transpose() << "\n";
- delete s;
- }
+ SaveFlip A_new;
+ sphere.wolff(T, {g2}, A_new, 10000);
- snapfile.close();
return 0;
}