summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2020-02-25 23:12:31 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2020-02-25 23:12:31 -0500
commit98350b34d1826e1d6687f18c45b0fbc6a3488742 (patch)
treeaf80185b5db866ad596f9791dc349a9a7e4256bd
parenta1c5f64f3c8c9812cb0b4658630f79dab1856c0c (diff)
downloadspace_wolff-98350b34d1826e1d6687f18c45b0fbc6a3488742.tar.gz
space_wolff-98350b34d1826e1d6687f18c45b0fbc6a3488742.tar.bz2
space_wolff-98350b34d1826e1d6687f18c45b0fbc6a3488742.zip
More fixes on new features
-rw-r--r--dimers_torus.cpp26
-rw-r--r--euclidean.hpp5
-rw-r--r--spheres.cpp27
-rw-r--r--torus_symmetries.hpp24
4 files changed, 31 insertions, 51 deletions
diff --git a/dimers_torus.cpp b/dimers_torus.cpp
index f304564..74cf47e 100644
--- a/dimers_torus.cpp
+++ b/dimers_torus.cpp
@@ -11,28 +11,6 @@
const unsigned D = 2;
typedef Model<double, D, TorusGroup<double, D>, Dimer<double, 2>> model;
-Gen<double, D, TorusGroup<double, D>, Dimer<double, D>> eGen(double L) {
- std::vector<Vector<double, 2>> torusVectors = torus_vecs<double, 2>(L);
- std::vector<Matrix<double, 2>> torusMatrices = torus_mats<double, 2>();
- return [L, torusVectors,
- torusMatrices](Model<double, D, TorusGroup<double, D>, Dimer<double, D>>& M,
- Rng& r) -> Transformation<double, D, TorusGroup<double, D>, Dimer<double, D>>* {
- Matrix<double, 2> m;
- Vector<double, 2> t;
-
- m = r.pick(torusMatrices);
- t(0) = r.uniform<double>(0, L);
- t(1) = r.uniform<double>(0, L);
- t = t - m * t;
-
- TorusGroup<double, 2> g = TorusGroup<double, 2>({(double)L, t, m});
-
- Spin<double, 2, Dimer<double, 2>>* ss = r.pick(M.s);
-
- return new SpinFlip<double, 2, TorusGroup<double, 2>, Dimer<double, 2>>(M, g, ss);
- };
-}
-
int main(int argc, char* argv[]) {
const unsigned D = 2;
@@ -97,7 +75,7 @@ int main(int argc, char* argv[]) {
return H * s.x(1);
};
- auto g1 = eGen(L);
+ auto g1 = uniformGenTorus<D, Dimer<double, D>>(L);
auto tag = std::chrono::high_resolution_clock::now();
@@ -111,7 +89,7 @@ int main(int argc, char* argv[]) {
unsigned nx = floor(sqrt(n));
for (unsigned i = 0; i < sphere.s.size(); i++) {
Spin<double, 2, Dimer<double, D>>* ss = new Spin<double, 2, Dimer<double, D>>();
- ss->x = {(i / nx) * L / nx - L / 2, (i % nx) * L / nx - L / 2};
+ ss->x = {(i / nx) * L / nx, (i % nx) * L / nx};
ss->s = Dimer<double, D>{.relativePosition = {0.2, 0}, .radius = 0.25};
sphere.s[i] = ss;
sphere.dict.insert(ss);
diff --git a/euclidean.hpp b/euclidean.hpp
index f0e54d4..acf65ac 100644
--- a/euclidean.hpp
+++ b/euclidean.hpp
@@ -56,7 +56,8 @@ public:
Euclidean(const Affine<T, D>& a) : Affine<T, D>(a) {}
Euclidean(Vector<T, D> t0, Matrix<T, D> r0) : Affine<T, D>(t0, r0) {}
- Euclidean act(const Euclidean& t) const { return Affine<T, D>::actA(t); };
+ Euclidean act(const Euclidean& t) const { return Euclidean(Affine<T, D>::actA(t)); };
+ Euclidean inverse() const { return Euclidean(Affine<T, D>::inverse()); }
using Affine<T, D>::act;
};
@@ -78,8 +79,8 @@ protected:
public:
TorusGroup(T L) : Affine<T, D>(), L(L) {}
- TorusGroup(T L, Vector<T, D> t0, Matrix<T, D> r0) : Affine<T, D>(), L(L) {}
TorusGroup(T L, const Affine<T, D>& t) : Affine<T, D>(t), L(L) {}
+ TorusGroup(T L, Vector<T, D> t0, Matrix<T, D> r0) : Affine<T, D>(t0, r0), L(L) {}
TorusGroup act(const TorusGroup& t) const { return TorusGroup(L, Affine<T, D>::actA(t)); }
TorusGroup inverse() const { return TorusGroup(L, Affine<T, D>::inverse()); }
diff --git a/spheres.cpp b/spheres.cpp
index 0067cc8..9ca2036 100644
--- a/spheres.cpp
+++ b/spheres.cpp
@@ -8,30 +8,7 @@
#include "animation.hpp"
const unsigned D = 2;
-typedef Model<double, D, TorusGroup<double, D>, double> model;
-
-Gen<double, D, TorusGroup<double, D>, double> eGen(double L) {
- std::vector<Vector<double, 2>> torusVectors = torus_vecs<double, 2>(L);
- std::vector<Matrix<double, 2>> torusMatrices = torus_mats<double, 2>();
- return [L, torusVectors,
- torusMatrices](Model<double, D, TorusGroup<double, D>, double>& M,
- Rng& r) -> Transformation<double, D, TorusGroup<double, D>, double>* {
- Matrix<double, 2> m;
- Vector<double, 2> t;
-
- m = r.pick(torusMatrices);
- t(0) = r.uniform<double>(0, L);
- t(1) = r.uniform<double>(0, L);
- t = t - m * t;
-
- TorusGroup<double, 2> g = TorusGroup<double, 2>({(double)L, t, m});
-
- Spin<double, 2, double>* ss = r.pick(M.s);
-
- return new SpinFlip<double, 2, TorusGroup<double, 2>, double>(M, g, ss);
- };
-}
-
+typedef Model<double, D, TorusGroup<double, D>, Radius> model;
int main(int argc, char* argv[]) {
const unsigned D = 2;
@@ -89,7 +66,7 @@ int main(int argc, char* argv[]) {
return H * s.x(1);
};
- auto g = eGen(L);
+ auto g = uniformGenTorus<D, Radius>(L);
std::ofstream ofile("test.dat");
Animation<double, D, TorusGroup<double, D>, Radius> A(L, 750, argc, argv, 1000, true);
model sphere(L, Z, B);
diff --git a/torus_symmetries.hpp b/torus_symmetries.hpp
index 7bcb70b..53f61ac 100644
--- a/torus_symmetries.hpp
+++ b/torus_symmetries.hpp
@@ -7,6 +7,8 @@
#include "matrix.hpp"
#include "vector.hpp"
+#include "euclidean.hpp"
+#include "transformation.hpp"
template <int D> void one_sequences(std::list<std::array<double, D>>& sequences, unsigned level) {
if (level > 0) {
@@ -98,3 +100,25 @@ template <class U, int D> std::vector<Matrix<U, D>> torus_mats() {
return mats;
}
+template <int D, class S>
+Gen<double, D, TorusGroup<double, D>, S> uniformGenTorus(double L) {
+ std::vector<Vector<double, D>> torusVectors = torus_vecs<double, D>(L);
+ std::vector<Matrix<double, D>> torusMatrices = torus_mats<double, D>();
+ return [L, torusVectors,
+ torusMatrices](Model<double, D, TorusGroup<double, D>, S>& M,
+ Rng& r) -> Transformation<double, D, TorusGroup<double, D>, S>* {
+ Matrix<double, D> m = r.pick(torusMatrices);
+
+ Vector<double, D> t;
+ for (unsigned i = 0; i < D; i++) {
+ t(i) = r.uniform<double>(0, L);
+ }
+
+ TorusGroup<double, D> g = TorusGroup<double, D>({(double)L, t - m * t, m});
+
+ Spin<double, D, S>* ss = r.pick(M.s);
+
+ return new SpinFlip<double, D, TorusGroup<double, D>, S>(M, g, ss);
+ };
+}
+