diff options
author | Jaron Kent-Dobias <jkentdobias@g.hmc.edu> | 2016-08-22 10:11:14 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jkentdobias@g.hmc.edu> | 2016-08-22 10:11:14 -0400 |
commit | 2bb0740b68fdb62d45adc00204b3990ca42ade77 (patch) | |
tree | a52975e3460da781467ddb70aaa8d76840d01bb4 /src/update_beta.c | |
download | fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.tar.gz fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.tar.bz2 fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.zip |
started repo again without all the data files gunking the works
Diffstat (limited to 'src/update_beta.c')
-rw-r--r-- | src/update_beta.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/update_beta.c b/src/update_beta.c new file mode 100644 index 0000000..4c1bf65 --- /dev/null +++ b/src/update_beta.c @@ -0,0 +1,34 @@ + +#include "fracture.h" + +double f(double damage) { + assert(damage <= 1 && damage >= 0); + return sqrt(1 - sqrt(1 - damage)); + // return 0.5 - 0.68182 * (0.5 - damage); +} + +double update_beta(double beta, unsigned int width, const double *stress, + const double *damage, double bound_total) { + + double total = 0; + unsigned int num_totaled = 0; + + for (unsigned int i = 0; i < pow(width, 2); i++) { + unsigned int stress_index = + width / 4 + (width / 4 + (i / width) / 2) * width + (i % width) / 2; + double outer_damage = f(pow(fabs(stress[i]), beta)); + double inner_stress = fabs(2 * stress[stress_index] / bound_total); + + if (outer_damage > 0 && inner_stress > 0 && inner_stress != 1) { + total += log(outer_damage) / log(inner_stress); + num_totaled++; + } + } + + assert(num_totaled > 0); + assert(total == total); + + double new_beta = total / num_totaled; + + return new_beta; +} |