summaryrefslogtreecommitdiff
path: root/ising.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ising.cpp')
-rw-r--r--ising.cpp35
1 files changed, 27 insertions, 8 deletions
diff --git a/ising.cpp b/ising.cpp
index 6939749..645c759 100644
--- a/ising.cpp
+++ b/ising.cpp
@@ -8,10 +8,11 @@ int main(int argc, char* argv[]) {
unsigned N = 1000;
double T = 2.0 / log(1.0 + sqrt(2.0));
double H = 1.0;
+ double ε = 0.1;
int opt;
- while ((opt = getopt(argc, argv, "N:L:T:H:")) != -1) {
+ while ((opt = getopt(argc, argv, "N:L:T:H:e:")) != -1) {
switch (opt) {
case 'N':
N = (unsigned)atof(optarg);
@@ -25,6 +26,9 @@ int main(int argc, char* argv[]) {
case 'H':
H = atof(optarg);
break;
+ case 'e':
+ ε = atof(optarg);
+ break;
default:
exit(1);
}
@@ -67,12 +71,10 @@ int main(int argc, char* argv[]) {
[] (model<signed, D, signed>& m, unsigned i0, spin<signed, D, signed> s1) -> std::set<unsigned> {
std::set<unsigned> nn;
if (i0 < m.s.size()) {
- std::set<unsigned> os1 = m.dict.on_site(s1.x);
- std::set<unsigned> nn0 = m.dict.nearest_neighbors(m.s[i0].x);
- std::set<unsigned> nn1 = m.dict.nearest_neighbors(s1.x);
+ std::set<unsigned> nn0 = m.dict.neighbors(m.s[i0].x, 1);
+ std::set<unsigned> nn1 = m.dict.neighbors(s1.x, 1);
nn.insert(nn0.begin(), nn0.end());
nn.insert(nn1.begin(), nn1.end());
- nn.insert(os1.begin(), os1.end());
nn.insert(m.s.size());
} else {
for (unsigned i = 0; i < m.s.size(); i++) {
@@ -119,7 +121,16 @@ int main(int argc, char* argv[]) {
}
*/
- ising.wolff(T, N, rng);
+ ising.update_energy();
+
+ while (true) {
+ ising.wolff(T, N, rng);
+ std::array<double, 2> τ = ising.Eq.τ();
+ std::cout << τ[0] << " " << τ[1] << " " << τ[1] / τ[0] << "\n";
+ if (τ[1] / τ[0] < ε) {
+ break;
+ }
+ }
std::vector<signed> output(pow(L, D));
@@ -128,13 +139,21 @@ int main(int argc, char* argv[]) {
output[L * rs.x(1) + rs.x(0)] = s.s;
}
+ std::ofstream outfile;
+ outfile.open("snap.dat");
+
for (unsigned i = 0; i < L; i++) {
for (unsigned j = 0; j < L; j++) {
unsigned out = output[L * i + j] == 1 ? 1 : 0;
- std::cout << out;
+ outfile << out << " ";
}
- std::cout << "\n";
+ outfile << "\n";
}
+ outfile.close();
+
+ std::array<double, 2> act = ising.Eq.τ();
+
+ std::cout << act[0] << " " << act[1] << "\n";
return 0;
}