summaryrefslogtreecommitdiff
path: root/examples/ising_random_field.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/ising_random_field.cpp')
-rw-r--r--examples/ising_random_field.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/examples/ising_random_field.cpp b/examples/ising_random_field.cpp
index b37b0ce..9284797 100644
--- a/examples/ising_random_field.cpp
+++ b/examples/ising_random_field.cpp
@@ -4,21 +4,18 @@
#include <chrono>
#define WOLFF_SITE_DEPENDENCE
+#include <wolff_models/ising.hpp>
#include "simple_measurement.hpp"
-#include <wolff/models/ising.hpp>
-
-#include <wolff.hpp>
-
using namespace wolff;
int main(int argc, char *argv[]) {
// set defaults
- N_t N = (N_t)1e4;
- D_t D = 2;
- L_t L = 128;
+ unsigned N = (unsigned)1e4;
+ unsigned D = 2;
+ unsigned L = 128;
double T = 2.26918531421;
double H = 0.0;
@@ -28,7 +25,7 @@ int main(int argc, char *argv[]) {
while ((opt = getopt(argc, argv, "N:D:L:T:H:")) != -1) {
switch (opt) {
case 'N': // number of steps
- N = (N_t)atof(optarg);
+ N = (unsigned)atof(optarg);
break;
case 'D': // dimension
D = atoi(optarg);
@@ -52,29 +49,29 @@ int main(int argc, char *argv[]) {
return (double)(s1 * s2);
};
- // initialize the lattice
- graph G(D, L);
+ // initialize the lattice. vertex_prop is set to double and will contain the
+ // value of the random field at that site
+ graph<double> G(D, L);
// initialize the random number generator
auto seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng{seed};
// define the spin-field coupling
- std::vector<double> H_vals(G.nv);
std::normal_distribution<double> distribution(0.0, H);
- for (v_t i = 0; i < G.nv; i++) {
- H_vals[i] = distribution(rng);
+ for (auto &v : G.vertices) {
+ v.prop = distribution(rng);
}
- std::function <double(v_t, const ising_t&)> B = [&] (v_t i, const ising_t& s) -> double {
- return H_vals[i] * s;
+ std::function <double(const graph<double>::vertex&, const ising_t&)> B = [] (const graph<double>::vertex& v, const ising_t& s) -> double {
+ return v.prop * s;
};
// initialize the system
- system<ising_t, ising_t> S(G, T, Z, B);
+ system<ising_t, ising_t, graph<double>> S(G, T, Z, B);
// define function that generates self-inverse rotations
- std::function <ising_t(std::mt19937&, const system<ising_t, ising_t>&, v_t)> gen_r = gen_ising;
+ std::function <ising_t(std::mt19937&, const system<ising_t, ising_t, graph<double>>&, const graph<double>::vertex&)> gen_r = gen_ising<graph<double>>;
// initailze the measurement object
simple_measurement A(S);