From 8a6109a78a6f7b9e9585cd89e8a10d1f626b3af1 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Tue, 17 Jul 2018 22:37:57 -0400 Subject: made many changes to implement alternate reflection generators, this is broken --- lib/state.h | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lib/state.h (limited to 'lib/state.h') diff --git a/lib/state.h b/lib/state.h new file mode 100644 index 0000000..8d4265b --- /dev/null +++ b/lib/state.h @@ -0,0 +1,53 @@ + +#pragma once + +#include + +#include "types.h" +#include "graph.h" + +template +class state_t { + public: + D_t D; + L_t L; + v_t nv; + v_t ne; + graph_t *g; + double T; + X_t *spins; + R_t R; + double E; + X_t M; // the "sum" of the spins, like the total magnetization + + std::function J; + std::function H; + + state_t(D_t D, L_t L, double T, std::function J, std::function H) : D(D), L(L), T(T), J(J), H(H) { + graph_t *h = graph_create_square(D, L); + nv = h->nv; + ne = h->ne; + g = graph_add_ext(h); + graph_free(h); + spins = (X_t *)malloc(nv * sizeof(X_t)); + for (v_t i = 0; i < nv; i++) { + init (&(spins[i])); + } + init (&R); + E = - (double)ne * J(spins[0], spins[0]) - (double)nv * H(spins[0]); + M = scalar_multiple (nv, spins[0]); + } + + ~state_t() { + graph_free(g); + for (v_t i = 0; i < nv; i++) { + free_spin(spins[i]); + } + free(spins); + free_spin(R); + free_spin(M); + } +}; + + + -- cgit v1.2.3-70-g09d2