diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-04-27 18:02:58 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-04-27 18:02:58 -0400 |
commit | 7f7bfc7789c7c0d5b8a8daeda82b349ee1ea52a0 (patch) | |
tree | db215fb3e4d69036e78e4a6db685bbbb29116c90 /lib/src | |
parent | 63dd7320fbef9c9a95bf6953770072baf735c34e (diff) | |
download | fuse_networks-7f7bfc7789c7c0d5b8a8daeda82b349ee1ea52a0.tar.gz fuse_networks-7f7bfc7789c7c0d5b8a8daeda82b349ee1ea52a0.tar.bz2 fuse_networks-7f7bfc7789c7c0d5b8a8daeda82b349ee1ea52a0.zip |
fixed problems with the current cutoff
Diffstat (limited to 'lib/src')
-rw-r--r-- | lib/src/network.cpp | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/src/network.cpp b/lib/src/network.cpp index 712bf07..0cacdf9 100644 --- a/lib/src/network.cpp +++ b/lib/src/network.cpp @@ -296,21 +296,26 @@ void elastic_network::fracture(hooks& m, double weight, double cutoff) { current_info cx = hook_x.solve(fuses); current_info cy = hook_y.solve(fuses); - current_info ctot; - - ctot.conductivity = sqrt(pow((1 - weight) * cx.conductivity, 2) + pow(weight * cy.conductivity, 2)); + bool done_x = cx.conductivity < cutoff * G.vertices.size() || cx.conductivity != cx.conductivity; + bool done_y = cy.conductivity < cutoff * G.vertices.size() || cy.conductivity != cy.conductivity; - if (ctot.conductivity < cutoff * G.vertices.size()) { + if (done_x && done_y) { break; } + current_info ctot; ctot.currents.resize(G.edges.size()); - for (unsigned i = 0; i < G.edges.size(); i++) { - if (cx.conductivity < cutoff * G.vertices.size()) { - ctot.currents[i] = cy.currents[i] / cy.conductivity; - } else if (cy.conductivity < cutoff * G.vertices.size()) { - ctot.currents[i] = cx.currents[i] / cx.conductivity; - } else { + + if (done_x) { + for (unsigned i = 0; i < G.edges.size(); i++) { + ctot.currents[i] = weight * fabs(cy.currents[i]) / cy.conductivity; + } + } else if (done_y) { + for (unsigned i = 0; i < G.edges.size(); i++) { + ctot.currents[i] = (1 - weight) * fabs(cx.currents[i]) / cx.conductivity; + } + } else { + for (unsigned i = 0; i < G.edges.size(); i++) { ctot.currents[i] = sqrt(pow((1 - weight) * cx.currents[i] / cx.conductivity, 2) + pow(weight * cy.currents[i] / cy.conductivity, 2)); } } @@ -319,8 +324,8 @@ void elastic_network::fracture(hooks& m, double weight, double cutoff) { long double max_val = std::numeric_limits<long double>::lowest(); for (unsigned i = 0; i < G.edges.size(); i++) { - if (!fuses[i] && fabs(ctot.currents[i]) > cutoff) { - long double val = logl(fabs(ctot.currents[i])) - thresholds[i]; + if (!fuses[i] && ctot.currents[i] > cutoff) { + long double val = logl(ctot.currents[i]) - thresholds[i]; if (val > max_val) { max_val = val; max_pos = i; |