summaryrefslogtreecommitdiff
path: root/examples/include
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-10-17 19:33:25 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-10-17 19:33:25 -0400
commitf2f7a072216dfafab89851e4ff3e0b2c3eb16663 (patch)
treef9c7e1e4e91ce8b0ec9cef9f2423029fe7b7f049 /examples/include
parent1343a3fe6bd17a2487f12a0d61be8dc83cd722a0 (diff)
downloadc++-f2f7a072216dfafab89851e4ff3e0b2c3eb16663.tar.gz
c++-f2f7a072216dfafab89851e4ff3e0b2c3eb16663.tar.bz2
c++-f2f7a072216dfafab89851e4ff3e0b2c3eb16663.zip
removed a lot of research code to simplify library and examples for publication
Diffstat (limited to 'examples/include')
-rw-r--r--examples/include/colors.h34
-rw-r--r--examples/include/correlation.hpp23
-rw-r--r--examples/include/measure.hpp159
m---------examples/include/randutils0
4 files changed, 0 insertions, 216 deletions
diff --git a/examples/include/colors.h b/examples/include/colors.h
deleted file mode 100644
index abf137c..0000000
--- a/examples/include/colors.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#pragma once
-
-#include <wolff/types.h>
-
-double hue_to_R(double theta) {
- if (((M_PI / 3 <= theta) && (theta < 2 * M_PI / 3)) || ((4 * M_PI / 3 <= theta) && (theta < 5 * M_PI / 3))) {
- return 1.0 - fabs(fmod(theta / (2 * M_PI / 6), 2) - 1.0);
- } else if (((0 <= theta) && (theta < M_PI / 3)) || ((5 * M_PI / 3 <= theta) && (theta <= 2 * M_PI))) {
- return 1.0;
- } else {
- return 0.0;
- }
-}
-
-double hue_to_G(double theta) {
- if (((0 <= theta) && (theta < M_PI / 3)) || ((M_PI <= theta) && (theta < 4 * M_PI / 3))) {
- return 1.0 - fabs(fmod(theta / (2 * M_PI / 6), 2) - 1.0);
- } else if (((M_PI / 3 <= theta) && (theta < 2 * M_PI / 3)) || ((2 * M_PI / 3 <= theta) && (theta < M_PI))) {
- return 1.0;
- } else {
- return 0.0;
- }
-}
-
-double hue_to_B(double theta) {
- if (((2 * M_PI / 3 <= theta) && (theta < M_PI)) || ((5 * M_PI / 3 <= theta) && (theta <= 2 * M_PI))) {
- return 1.0 - fabs(fmod(theta / (2 * M_PI / 6), 2) - 1.0);
- } else if (((M_PI <= theta) && (theta < 4 * M_PI / 3)) || ((4 * M_PI / 3 <= theta) && (theta < 5 * M_PI / 3))) {
- return 1.0;
- } else {
- return 0.0;
- }
-}
-
diff --git a/examples/include/correlation.hpp b/examples/include/correlation.hpp
deleted file mode 100644
index da8ab7f..0000000
--- a/examples/include/correlation.hpp
+++ /dev/null
@@ -1,23 +0,0 @@
-
-#pragma once
-
-#include <wolff/types.h>
-#include <wolff/state.hpp>
-
-#include <fftw3.h>
-
-template <class X_t>
-double correlation_length(const std::vector<typename X_t::F_t>& ReF, const std::vector<typename X_t::F_t>& ImF, D_t D) {
- double total = 0;
-
-#ifdef DIMENSION
- for (D_t j = 0; j < DIMENSION; j++) {
-#else
- for (D_t j = 0; j < D; j++) {
-#endif
- total += norm_squared(ReF[j]) + norm_squared(ImF[j]);
- }
-
- return total / D;
-}
-
diff --git a/examples/include/measure.hpp b/examples/include/measure.hpp
deleted file mode 100644
index bf8baab..0000000
--- a/examples/include/measure.hpp
+++ /dev/null
@@ -1,159 +0,0 @@
-
-#pragma once
-
-#include <wolff/state.hpp>
-#include <wolff/meas.h>
-#include "correlation.hpp"
-#include <functional>
-
-#define POSSIBLE_MEASUREMENTS 4
-const unsigned char measurement_energy = 1 << 0;
-const unsigned char measurement_clusterSize = 1 << 1;
-const unsigned char measurement_magnetization = 1 << 2;
-const unsigned char measurement_fourierZero = 1 << 3;
-
-char const *measurement_labels[] = {"E", "S", "M", "F"};
-
-template <class R_t, class X_t>
-class wolff_research_measurements : public wolff_measurement<R_t, X_t> {
- private:
- std::vector<std::vector<double>> precomputed_sin;
- std::vector<std::vector<double>> precomputed_cos;
- FILE **files;
- D_t D;
- unsigned char flags;
- std::function <void(const state_t <R_t, X_t>&, const wolff_research_measurements<R_t, X_t>&)> other_f;
- bool silent;
- public:
- v_t last_cluster_size;
- double E;
- typename X_t::M_t M;
- std::vector<typename X_t::F_t> ReF;
- std::vector<typename X_t::F_t> ImF;
-
- wolff_research_measurements(unsigned char flags, unsigned long timestamp, std::function <void(const state_t <R_t, X_t>&, const wolff_research_measurements<R_t, X_t>&)> other_f, state_t<R_t, X_t>& s, bool silent) : flags(flags), D(s.D), other_f(other_f), silent(silent) {
- FILE **files = (FILE **)calloc(POSSIBLE_MEASUREMENTS, sizeof(FILE *));
-
- for (uint8_t i = 0; i < POSSIBLE_MEASUREMENTS; i++) {
- if (flags & (1 << i)) {
- char *filename = (char *)malloc(255 * sizeof(char));
- sprintf(filename, "wolff_%lu_%s.dat", timestamp, measurement_labels[i]);
- files[i] = fopen(filename, "wb");
- free(filename);
- }
- }
-
-#ifdef BOND_DEPENDENCE
- E = 0;
- for (v_t v = 0; v < s.nv; v++) {
- for (const v_t &vn : s.g.v_adj[v]) {
- if (v < vn) {
- E -= s.J(v, s.spins[v], vn, s.spins[vn]);
- }
- }
- }
-#else
- E = - (double)s.ne * s.J(s.spins[0], s.spins[0]);
-#endif
-
-#ifndef NOFIELD
-#ifdef SITE_DEPENDENCE
- for (v_t i = 0; i < s.nv; i++) {
- E -= s.H(i, s.spins[i]);
- }
-#else
- E -= (double)s.nv * s.H(s.spins[0]);
-#endif
-#endif
-
- M = s.spins[0] * s.nv;
-
- ReF.resize(s.D);
- ImF.resize(s.D);
- for (D_t i = 0; i < s.D; i++) {
- ReF[i] = s.spins[0] * 0.0;
- ImF[i] = s.spins[0] * 0.0;
- }
- precomputed_cos.resize(s.nv);
- precomputed_sin.resize(s.nv);
- for (v_t i = 0; i < s.nv; i++) {
- precomputed_cos[i].resize(s.D);
- precomputed_sin[i].resize(s.D);
- for (D_t j = 0; j < s.D; j++) {
- precomputed_cos[i][j] = cos(2 * M_PI * s.g.coordinate[i][j] / (double)s.L);
- precomputed_sin[i][j] = sin(2 * M_PI * s.g.coordinate[i][j] / (double)s.L);
- }
- }
-
- if (!silent) printf("\n");
-
- }
-
- void pre_cluster(const state_t<R_t, X_t>& s, count_t step, count_t N, v_t v0, const R_t& R) {
- last_cluster_size = 0;
- if (!silent) printf("\033[F\033[JWOLFF: step %" PRIu64 " / %" PRIu64 ": E = %.2f, S = %" PRIv "\n", step, N, E, last_cluster_size);
-
- }
-
- void plain_bond_added(v_t vi, const X_t& si_old, const X_t& si_new, v_t vn, const X_t& sn, double dE) {
- E += dE;
- }
-
- void ghost_bond_added(v_t v, const X_t& rs_old, const X_t& rs_new, double dE) {
- E += dE;
- M += rs_new - rs_old;
-
-#ifdef DIMENSION
- for (D_t i = 0; i < DIMENSION; i++)
-#else
- for (D_t i = 0; i < D; i++)
-#endif
- {
- ReF[i] += (rs_new - rs_old) * precomputed_cos[v][i];
- ImF[i] += (rs_new - rs_old) * precomputed_sin[v][i];
- }
- }
-
- void plain_site_transformed(v_t v, const X_t& s_old, const X_t& s_new) {
- last_cluster_size++;
- }
-
- void ghost_site_transformed(const R_t& r_old, const R_t& r_new) {
- }
-
- void post_cluster(const state_t<R_t, X_t>& s, count_t step, count_t N) {
- if (flags & measurement_energy) {
- float smaller_E = (float)E;
- fwrite(&smaller_E, sizeof(float), 1, files[0]);
- }
- if (flags & measurement_clusterSize) {
- fwrite(&(last_cluster_size), sizeof(uint32_t), 1, files[1]);
- }
- if (flags & measurement_magnetization) {
- write_magnetization(M, files[2]);
- }
- if (flags & measurement_fourierZero) {
- float smaller_X = (float)correlation_length<X_t>(ReF, ImF, D);
- fwrite(&smaller_X, sizeof(float), 1, files[3]);
- }
-
- other_f(s, *this);
-
- }
-
- ~wolff_research_measurements() {
- for (uint8_t i = 0; i < POSSIBLE_MEASUREMENTS; i++) {
- if (flags & (1 << i)) {
- fclose(files[i]);
- }
- }
-
- if (!silent) {
- printf("\033[F\033[J");
- }
- printf("WOLFF COMPLETE: E = %.2f, S = %" PRIv "\n", E, last_cluster_size);
-
- free(files);
- }
-};
-
diff --git a/examples/include/randutils b/examples/include/randutils
deleted file mode 160000
-Subproject 8486a610a954a8248c12485fb4cfc390a5f5f85