From 1da9ba0af64dd1ff07c9fda6226689b4e8701e43 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 25 Feb 2020 15:23:41 -0500 Subject: Minor refactoring of sphere commands and animation class, and introduction of Dimers --- dimers.cpp | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 dimers.cpp (limited to 'dimers.cpp') diff --git a/dimers.cpp b/dimers.cpp new file mode 100644 index 0000000..4416333 --- /dev/null +++ b/dimers.cpp @@ -0,0 +1,122 @@ + +#include +#include +#include + +#include "animation.hpp" +#include "space_wolff.hpp" +#include "spheres.hpp" + +const unsigned D = 2; +typedef Model, Dimer> model; + +int main(int argc, char* argv[]) { + const unsigned D = 2; + + double L = 32; + unsigned N = 1000; + double T = 2.0 / log(1.0 + sqrt(2.0)); + double H = 1.0; + unsigned n = 25; + unsigned wait = 1000; + + double k = 1e2; + double a = 0.1; + + int opt; + + while ((opt = getopt(argc, argv, "n:N:L:T:H:a:k:w:")) != -1) { + switch (opt) { + case 'n': + n = (unsigned)atof(optarg); + break; + case 'N': + N = (unsigned)atof(optarg); + break; + case 'L': + L = atof(optarg); + break; + case 'T': + T = atof(optarg); + break; + case 'H': + H = atof(optarg); + break; + case 'a': + a = atof(optarg); + break; + case 'k': + k = atof(optarg); + break; + case 'w': + wait = atoi(optarg); + break; + default: + exit(1); + } + } + + auto zSingle = zSpheres(a, k); + + std::function>&, + const Spin>&)> + Z = [zSingle, a, k](const Spin>& s1, + const Spin>& s2) -> double { + Spin s11 = {.x = s1.x + s1.s.relativePosition, .s = s1.s.radius}; + Spin s12 = {.x = s1.x - s1.s.relativePosition, .s = s1.s.radius}; + Spin s21 = {.x = s2.x + s2.s.relativePosition, .s = s2.s.radius}; + Spin 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 g1 = nudgeGen>(1); + auto g2 = swapGen>(0.1); + auto g3 = accrossGen>(0.1); + auto g4 = centerGen>(0); + + auto tag = std::chrono::high_resolution_clock::now(); + + std::string filename = "flips_" + std::to_string(n) + "_" + std::to_string(T) + "_" + + std::to_string(H) + "_" + std::to_string(a) + "_" + std::to_string(k) + + "_" + std::to_string(tag.time_since_epoch().count()) + ".dat"; + + std::ofstream file; + file.open(filename); + + Animation, Dimer> A(L, 750, argc, argv, wait); + model sphere(1.0, Z, bCenter>(H)); + + Rng rng; + + sphere.s.resize(n); + + unsigned nx = floor(sqrt(n)); + for (unsigned i = 0; i < sphere.s.size(); i++) { + Spin>* ss = new Spin>(); + ss->x = {(i / nx) * L / nx - L / 2, (i % nx) * L / nx - L / 2}; + ss->s = Dimer{.relativePosition = {0.2, 0}, .radius = 0.25}; + sphere.s[i] = ss; + sphere.dict.insert(ss); + } + + sphere.wolff(T, {g1, g2, g3, g4}, A, N); + + file.close(); + + /* + std::ofstream snapfile; + snapfile.open("sphere_snap.dat"); + + for (Spin* s : sphere.s) { + Spin rs = sphere.s0.inverse().act(*s); + snapfile << rs.s << " " << rs.x.transpose() << "\n"; + delete s; + } + + snapfile.close(); + */ + + return 0; +} + -- cgit v1.2.3-54-g00ecf