summaryrefslogtreecommitdiff
path: root/ciamarra.cpp
blob: 6b932bf7021e5c43ccd589cb6025c99b7e30f8ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>

#include "glass.hpp"


void print(const CiamarraSystem<2>& s) {
  for (const Vertex<2, CiamarraState<2>>& v : s.vertices) {
    if (v.state(0) == 1 && v.state(1) == 0) {
      std::cerr << "▶";
    } else if (v.state(0) == -1 && v.state(1) == 0) {
      std::cerr << "◀";
    } else if (v.state(0) == 0 && v.state(1) == -1) {
      std::cerr << "▲";
    } else if (v.state(0) == 0 && v.state(1) == 1) {
      std::cerr << "▼";
    } else if (v.state(0) == 0 && v.state(1) == 0) {
      std::cerr << " ";
    } else {
      std::cerr << "X";
    }

    if (v.position(0) == s.L - 1) {
      std::cerr << std::endl;
    }
  }
}

template <unsigned D> Vector<D> randomVector(unsigned L, Rng& r) {
  Vector<D> x;
  for (unsigned i = 0; i < D; i++) {
    x[i] = r.uniform((unsigned)0, L - 1);
  }
  return x;
}

int main() {
  const unsigned D = 3;
  unsigned L = 15;
  unsigned Nmin = 2e2;
  unsigned Nmax = 2e5;
  double Tmin = 0.04;
  double Tmax = 0.2;
  double δT = 0.02;

  CiamarraSystem<D> s(L);

  Rng r;

  double z = exp(1 / 0.08);

  while (s.density() < 0.818) {
    s.sweepGrandCanonical(z, r);
  }

  if (!s.compatible()) {
    std::cerr << "Net compatible!" << std::endl;
    return 1;
  } 

  std::cerr << "Found state with appropriate density." << std::endl;
    if (!s.compatible()) {
      std::cerr <<"whoops!" << std::endl;
    }

  CiamarraSystem<D> s0 = s;

  std::vector<Matrix<D>> ms = generateTorusMatrices<D>();

  unsigned n = 1;
  for (unsigned i = 0; i < 1e5; i++) {
    if (n < 20 * log(i + 1)) {
      n++;
      std::cout << i << " " << s.overlap(s0) << std::endl;
    }
//    s.sweepLocal(r);
//    s.sweepSwap(r);
    s.swendsenWang(Transformation<D>(L, ms, r), r);
  }

  return 0;
}