diff options
Diffstat (limited to 'src/measurements.cpp')
-rw-r--r-- | src/measurements.cpp | 68 |
1 files changed, 28 insertions, 40 deletions
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]++; } |