summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/animate.cpp13
-rw-r--r--src/measurements.cpp2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/animate.cpp b/src/animate.cpp
index be0beef..9ba335b 100644
--- a/src/animate.cpp
+++ b/src/animate.cpp
@@ -15,7 +15,7 @@ animate::animate(double Lx, double Ly, unsigned window_size, int argc, char *arg
void animate::pre_fracture(const network &n) {
lv = std::numeric_limits<long double>::lowest();
- avalanches = {{}};
+ avalanches = {};
boost::remove_edge_if(trivial, G);
glClearColor(1.0f, 1.0f, 1.0f, 1.0f );
@@ -49,8 +49,8 @@ void animate::pre_fracture(const network &n) {
}
void animate::bond_broken(const network& n, const current_info& cur, unsigned i) {
- long double c = logl(cur.conductivity / fabs(cur.currents[i])) + n.thresholds[i];
- if (c > lv && avalanches.back().size() > 0) {
+ long double c = n.thresholds[i] - logl(fabs(cur.currents[i]));
+ if (c > lv) {
lv = c;
avalanches.push_back({i});
} else {
@@ -94,19 +94,18 @@ void animate::post_fracture(network &n) {
std::default_random_engine gen;
std::uniform_real_distribution<double> dis(0.0,1.0);
- bool cycle_present = true;
auto av_it = avalanches.rbegin();
- while (cycle_present) {
+ while (true) {
for (unsigned e : *av_it) {
boost::remove_edge(n.G.dual_edges[e].v[0], n.G.dual_edges[e].v[1], G);
n.fuses[e] = false;
}
auto cracks = find_minimal_crack(G, n);
- std::cout << cracks.size() << "\n";
+
if (cracks.size() == 0) {
- cycle_present = false;
+ break;
}
av_it++;
diff --git a/src/measurements.cpp b/src/measurements.cpp
index ffd814d..00643b3 100644
--- a/src/measurements.cpp
+++ b/src/measurements.cpp
@@ -172,7 +172,7 @@ void ma::pre_fracture(const network&) {
}
void ma::bond_broken(const network& net, const current_info& cur, unsigned i) {
- long double c = logl(cur.conductivity / fabs(cur.currents[i])) + net.thresholds[i];
+ long double c = n.thresholds[i] - logl(fabs(cur.currents[i]));
if (c > lv) {
if (avalanches.size() > 0) {
sa[avalanches.back().size() - 1]++;