summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/include/clusters.hpp9
-rw-r--r--src/fracture.cpp14
-rw-r--r--src/measurements.cpp68
-rw-r--r--src/measurements.hpp4
4 files changed, 36 insertions, 59 deletions
diff --git a/lib/include/clusters.hpp b/lib/include/clusters.hpp
index 0c562d8..0728b3e 100644
--- a/lib/include/clusters.hpp
+++ b/lib/include/clusters.hpp
@@ -8,9 +8,7 @@ private:
std::vector<unsigned> o;
public:
- std::vector<unsigned> c;
-
- ClusterTree(unsigned n) : p(n, -1), o(n, 1), c(n, 0) { c[0] = n; }
+ ClusterTree(unsigned n) : p(n, -1), o(n, 1) {}
unsigned findroot(unsigned i) {
if (p[i] < 0)
@@ -20,17 +18,12 @@ public:
}
void join(unsigned i, unsigned j) {
- c[o[i] - 1]--;
- c[o[j] - 1]--;
-
if (o[i] < o[j]) {
p[i] = j;
o[j] += o[i];
- c[o[j] - 1]++;
} else {
p[j] = i;
o[i] += o[j];
- c[o[i] - 1]++;
}
}
diff --git a/src/fracture.cpp b/src/fracture.cpp
index 5ba60e2..b82abca 100644
--- a/src/fracture.cpp
+++ b/src/fracture.cpp
@@ -38,10 +38,9 @@ int main(int argc, char* argv[]) {
unsigned n = 128;
double a = 1.0;
bool use_aN = false;
- bool one_side = false;
double w = 0.5;
- while ((opt = getopt(argc, argv, "N:X:Y:b:n:a:w:o")) != -1) {
+ while ((opt = getopt(argc, argv, "N:X:Y:b:n:a:w:")) != -1) {
switch (opt) {
case 'N':
N = (unsigned)atof(optarg);
@@ -66,9 +65,6 @@ int main(int argc, char* argv[]) {
case 'w':
w = atof(optarg);
break;
- case 'o':
- one_side = true;
- break;
default:
exit(1);
}
@@ -81,7 +77,7 @@ int main(int argc, char* argv[]) {
std::mt19937 rng{seeds};
if (use_aN) {
- ma meas(n, a, beta, w, one_side);
+ ma meas(n, a, beta, w);
for (unsigned trial = 0; trial < N; trial++) {
while (true) {
@@ -89,7 +85,7 @@ int main(int argc, char* argv[]) {
graph G(n, a, rng);
elastic_network fuse_network(G, &c, w);
fuse_network.set_thresholds(beta, rng);
- fuse_network.fracture(meas, one_side);
+ fuse_network.fracture(meas);
break;
} catch (std::exception &e) {
std::cout << e.what() << '\n';
@@ -100,7 +96,7 @@ int main(int argc, char* argv[]) {
break;
}
} else {
- ma meas(Lx, Ly, beta, w, one_side);
+ ma meas(Lx, Ly, beta, w);
for (unsigned trial = 0; trial < N; trial++) {
while (true) {
@@ -108,7 +104,7 @@ int main(int argc, char* argv[]) {
graph G(Lx, Ly);
elastic_network fuse_network(G, &c, w);
fuse_network.set_thresholds(beta, rng);
- fuse_network.fracture(meas, one_side);
+ fuse_network.fracture(meas);
break;
} catch (std::exception &e) {
std::cout << e.what() << '\n';
diff --git a/src/measurements.cpp b/src/measurements.cpp
index 3004d7e..6d1b1f9 100644
--- a/src/measurements.cpp
+++ b/src/measurements.cpp
@@ -143,7 +143,7 @@ unsigned edge_r_to_ind(graph::coordinate r, double Lx, double Ly, unsigned Mx, u
return floor((Mx * r.x) / Lx) + Mx * floor((My * r.y) / Ly);
}
-ma::ma(unsigned n, double a, double beta, double weight, bool one) :
+ma::ma(unsigned n, double a, double beta, double weight) :
sn(2 * n),
ss(2 * n),
sm(2 * n),
@@ -169,15 +169,9 @@ ma::ma(unsigned n, double a, double beta, double weight, bool one) :
} else {
model_string = "fracture_" + std::to_string(n) + "_" + std::to_string(a) + "_INF_" + std::to_string(weight) + "_";
}
-
- if (one) {
- model_string = model_string + "o_";
- } else {
- model_string = model_string + "t_";
- }
}
-ma::ma(unsigned Lx, unsigned Ly, double beta, double weight, bool one) :
+ma::ma(unsigned Lx, unsigned Ly, double beta, double weight) :
sn(Lx * Ly / 2),
ss(Lx * Ly / 2),
sm(Lx * Ly / 2),
@@ -194,12 +188,6 @@ ma::ma(unsigned Lx, unsigned Ly, double beta, double weight, bool one) :
} else {
model_string = "fracture_" + std::to_string(Lx) + "_" + std::to_string(Ly) + "_INF_" + std::to_string(weight) + "_";
}
-
- if (one) {
- model_string = model_string + "o_";
- } else {
- model_string = model_string + "t_";
- }
}
ma::~ma() {
@@ -251,35 +239,36 @@ void ma::bond_broken(const network& net, const current_info& cur, unsigned i) {
}
void ma::post_fracture(network &n) {
-/* auto post_cracks = find_minimal_crack(G, n);
- if (post_cracks.size() > 2 || post_cracks.size() == 0) {
- throw badcycleex;
- }
+ auto crack = find_minimal_crack(n, avalanches.back().back());
- for (auto c : post_cracks) {
- std::list<graph::coordinate> cl_cs;
- sl[c.second.size() - 1]++;
- for (unsigned e : c.second) {
- cl_cs.push_back(n.G.dual_edges[e].r);
- }
- autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cl.size()), 2 * sqrt(cl.size()), cl, cl_cs, c.first);
+ std::list<graph::coordinate> cl_cs;
+ sl[crack.second.size() - 1]++;
+ for (unsigned e : crack.second) {
+ cl_cs.push_back(n.G.dual_edges[e].r);
}
+ autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cl.size()), 2 * sqrt(cl.size()), cl, cl_cs, crack.first);
+
+ std::vector<std::list<graph::coordinate>> components(n.G.dual_vertices.size());
for (unsigned i = 0; i < n.G.dual_vertices.size(); i++) {
- components[component[i]].push_back(n.G.dual_vertices[i].r);
+ components[n.C.findroot(i)].push_back(n.G.dual_vertices[i].r);
}
- for (unsigned i = 0; i < num; i++) {
- if (i != crack_component) {
- sm[components[i].size() - 1]++;
- autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cm.size()), 2 * sqrt(cm.size()), cm, components[i], post_cracks.front().first);
- autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cp.size()), 2 * sqrt(cp.size()), cp, components[i], {0, 1});
- } else {
- ss[components[i].size() - 1]++;
- autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cs.size()), 2 * sqrt(cs.size()), cs, components[i], post_cracks.front().first);
+ unsigned crack_component = n.C.findroot(n.G.dual_edges[avalanches.back().back()].v[0]);
+
+ for (unsigned i = 0; i < n.G.dual_vertices.size(); i++) {
+ if (components[i].size() > 0) {
+ if (i != crack_component) {
+ sm[components[i].size() - 1]++;
+ autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cm.size()), 2 * sqrt(cm.size()), cm, components[i], crack.first);
+ autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cp.size()), 2 * sqrt(cp.size()), cp, components[i], {0, 1});
+ } else {
+ ss[components[i].size() - 1]++;
+ autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cs.size()), 2 * sqrt(cs.size()), cs, components[i], crack.first);
+ }
+ sn[components[i].size() - 1]++;
+ autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cn.size()), 2 * sqrt(cn.size()), cn, components[i], crack.first);
}
- sn[components[i].size() - 1]++;
- autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cn.size()), 2 * sqrt(cn.size()), cn, components[i], post_cracks.front().first);
}
std::vector<bool> vertex_in(n.G.vertices.size());
@@ -303,7 +292,7 @@ void ma::post_fracture(network &n) {
}
sb[bb_size]++;
- autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cb.size()), 2 * sqrt(cb.size()), cb, cb_co, post_cracks.front().first);
+ autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cb.size()), 2 * sqrt(cb.size()), cb, cb_co, crack.first);
auto av_it = avalanches.rbegin();
av_it++;
@@ -314,7 +303,7 @@ void ma::post_fracture(network &n) {
for (unsigned e : (*av_it)) {
ca_co.push_back(n.G.edges[e].r);
}
- autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(ca.size()), 2 * sqrt(ca.size()), ca, ca_co, post_cracks.front().first);
+ autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(ca.size()), 2 * sqrt(ca.size()), ca, ca_co, crack.first);
autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cq.size()), 2 * sqrt(cq.size()), cq, ca_co, {0,1});
av_it++;
}
@@ -324,9 +313,8 @@ void ma::post_fracture(network &n) {
for (unsigned e : avalanches.back()) {
cA_co.push_back(n.G.edges[e].r);
}
- autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cA.size()), 2 * sqrt(cA.size()), cA, cA_co, post_cracks.front().first);
+ autocorrelation2(n.G.L.x, n.G.L.y, 2 * sqrt(cA.size()), 2 * sqrt(cA.size()), cA, cA_co, crack.first);
-*/
sd[num - 1]++;
}
diff --git a/src/measurements.hpp b/src/measurements.hpp
index 879f511..64cfce6 100644
--- a/src/measurements.hpp
+++ b/src/measurements.hpp
@@ -51,8 +51,8 @@ class ma : public hooks {
std::list<unsigned> last_avalanche;
std::string model_string;
- ma(unsigned Lx, unsigned Ly, double beta, double w, bool o);
- ma(unsigned n, double a, double beta, double w, bool o);
+ ma(unsigned Lx, unsigned Ly, double beta, double w);
+ ma(unsigned n, double a, double beta, double w);
~ma();
void pre_fracture(const network &) override;