summaryrefslogtreecommitdiff
path: root/free_energy.cpp
blob: 5cfaae13e6aecb0d79fcb318efad743aafe0413a (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
#include <iomanip>
#include <iostream>

#include "aztec.hpp"

int main(int argc, char* argv[]) {
  unsigned n = 100;
  unsigned m = 100;
  Real T0 = 1;
  Real T1 = 10;
  Real ΔT = 1;

  int opt;

  while ((opt = getopt(argc, argv, "n:m:0:1:d:")) != -1) {
    switch (opt) {
    case 'n':
      n = atoi(optarg);
      break;
    case 'm':
      m = (unsigned)atof(optarg);
      break;
    case '0':
      T0 = atof(optarg);
      break;
    case '1':
      T1 = atof(optarg);
      break;
    case 'd':
      ΔT = atof(optarg);
      break;
    default:
      exit(1);
    }
  }

  Rng r;
  AztecDiamond a(n);
  a.setWeights(r);

  for (Real T = T0; T <= T1; T += ΔT) {
    Real avgFreeEnergy = 0;

    for (unsigned i = 0; i < m; i++) {
      a.computeWeights(T);
      avgFreeEnergy += a.computeProbabilities();
    }

    std::cout << std::setprecision(20) << T << " " << -T * avgFreeEnergy / m / a.vertices.size()
              << std::endl;
  }

  return 0;
}