summaryrefslogtreecommitdiff
path: root/free_energy.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'free_energy.cpp')
-rw-r--r--free_energy.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/free_energy.cpp b/free_energy.cpp
new file mode 100644
index 0000000..6bfdf19
--- /dev/null
+++ b/free_energy.cpp
@@ -0,0 +1,53 @@
+#include <iostream>
+#include <iomanip>
+
+#include "rbmp.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);
+
+ for (Real T = T0; T <= T1; T += ΔT) {
+ Real avgFreeEnergy = 0;
+
+ for (unsigned i = 0; i < m; i++) {
+ a.setWeights(r);
+ a.computeWeights(T);
+ avgFreeEnergy += a.computeProbabilities();
+ }
+
+ std::cout << std::setprecision(20) << T << " " << - T * avgFreeEnergy / m / a.vertices.size() << std::endl;
+ }
+
+ return 0;
+}