From c1b5cb662930965f1f4401c3c5759fb460ec24ea Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Fri, 26 Apr 2019 13:02:47 -0400 Subject: actually measuring avalanche sizes correctly --- src/measurements.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/measurements.cpp b/src/measurements.cpp index fa5189f..5a79bd7 100644 --- a/src/measurements.cpp +++ b/src/measurements.cpp @@ -172,11 +172,8 @@ void ma::pre_fracture(const network&) { } void ma::bond_broken(const network& net, const current_info& cur, unsigned i) { - long double c = net.thresholds[i] - logl(fabs(cur.currents[i])); + long double c = net.thresholds[i] - logl(cur.currents[i]); if (c > lv) { - if (avalanches.size() > 0) { - sa[avalanches.back().size() - 1]++; - } lv = c; avalanches.push_back({i}); } else { @@ -232,5 +229,12 @@ void ma::post_fracture(network &n) { for (unsigned i = 0; i < num; i++) { sc[new_components[i].size() - 1]++; } + + av_it++; + + while (av_it != avalanches.rend()) { + sa[(*av_it).size() - 1]++; + av_it++; + } } -- cgit v1.2.3-70-g09d2