summaryrefslogtreecommitdiff
path: root/src/fracture.c
diff options
context:
space:
mode:
authorJaron <jaron@kent-dobias.com>2016-11-08 10:18:15 -0500
committerJaron <jaron@kent-dobias.com>2016-11-08 10:18:15 -0500
commit0cf3090b05aa4c35ba20f3773db4f95d4600b55e (patch)
tree620bbc5ca8b42715e76e16837b90894ac9909534 /src/fracture.c
parentc5b44e1604456ea42899c7e6cb3bde14b5bb88da (diff)
downloadfuse_networks-0cf3090b05aa4c35ba20f3773db4f95d4600b55e.tar.gz
fuse_networks-0cf3090b05aa4c35ba20f3773db4f95d4600b55e.tar.bz2
fuse_networks-0cf3090b05aa4c35ba20f3773db4f95d4600b55e.zip
restarted all data generation to correct for errors, made certain data (stress, energy, thresholds) longs
Diffstat (limited to 'src/fracture.c')
-rw-r--r--src/fracture.c106
1 files changed, 20 insertions, 86 deletions
diff --git a/src/fracture.c b/src/fracture.c
index 7ee82fb..59bd424 100644
--- a/src/fracture.c
+++ b/src/fracture.c
@@ -10,8 +10,8 @@ int main(int argc, char *argv[]) {
uint32_t N;
uint_t L, refactor_every;
double beta, inf, cutoff, crack_len;
- bool crack_growth_crit, save_data, save_cluster_dist, use_voltage_boundaries, use_dual, save_network,
- save_crit_stress, save_stress_field, save_voltage_field, save_toughness, save_energy, save_conductivity,
+ bool save_data, save_cluster_dist, use_voltage_boundaries, use_dual, save_network,
+ save_crit_stress, save_stress_field, save_voltage_field, save_energy, save_conductivity,
save_damage, save_damage_field, save_threshold;
bound_t boundary;
lattice_t lattice;
@@ -33,7 +33,6 @@ int main(int argc, char *argv[]) {
cutoff = 1e-9;
boundary = FREE_BOUND;
lattice = VORONOI_LATTICE;
- crack_growth_crit = false;
save_data = false;
save_cluster_dist = false;
use_voltage_boundaries = false;
@@ -45,7 +44,6 @@ int main(int argc, char *argv[]) {
save_damage = false;
save_damage_field = false;
save_conductivity = false;
- save_toughness = false;
save_energy = true;
save_threshold = false;
@@ -59,7 +57,7 @@ int main(int argc, char *argv[]) {
// get commandline options
- while ((opt = getopt(argc, argv, "n:L:b:B:q:dVcoNsCrtDSvel:gTER:")) != -1) {
+ while ((opt = getopt(argc, argv, "n:L:b:B:q:dVcoNsCrDSvel:TER:")) != -1) {
switch (opt) {
case 'n':
N = atoi(optarg);
@@ -119,9 +117,6 @@ int main(int argc, char *argv[]) {
exit(EXIT_FAILURE);
}
break;
- case 'g':
- crack_growth_crit = true;
- break;
case 'd':
save_damage = true;
break;
@@ -156,9 +151,6 @@ int main(int argc, char *argv[]) {
case 'r':
save_conductivity = true;
break;
- case 't':
- save_toughness = true;
- break;
case 'E':
save_energy = true;
break;
@@ -222,9 +214,9 @@ int main(int argc, char *argv[]) {
}
}
- double *crit_stress;
+ long double *crit_stress;
if (save_crit_stress) {
- crit_stress = (double *)malloc(N * sizeof(double));
+ crit_stress = (long double *)malloc(N * sizeof(long double));
}
double *stress_field;
@@ -268,19 +260,14 @@ int main(int argc, char *argv[]) {
}
}
- double *toughness;
- if (save_toughness) {
- toughness = (double *)malloc(N * sizeof(double));
- }
-
- double *energy;
+ long double *energy;
if (save_energy) {
- energy = (double *)malloc(N * sizeof(double));
+ energy = (long double *)malloc(N * sizeof(long double));
}
- double *thresholds;
+ long double *thresholds;
if (save_threshold) {
- thresholds = (double *)malloc(N * sizeof(double));
+ thresholds = (long double *)malloc(N * sizeof(long double));
}
@@ -311,7 +298,7 @@ int main(int argc, char *argv[]) {
net_free(tmp_net, &c);
uint_t max_pos = 0;
- double max_val = 0;
+ long double max_val = 0;
double cond0;
{
@@ -321,7 +308,7 @@ int main(int argc, char *argv[]) {
}
for (uint_t j = 0; j < data->num_broken; j++) {
- double val = data->extern_field[j];
+ long double val = data->extern_field[j];
if (val > max_val) {
max_pos = j;
@@ -330,41 +317,15 @@ int main(int argc, char *argv[]) {
}
uint_t av_size = 0;
- double cur_val = 0;
- uint_t notch_mark = 0;
-
- if (crack_growth_crit) {
- uint_t n_edge = UINT_MAX;
- for (uint_t j = 0; j < g->ne; j++) {
- // right now the only fuses broken are from a notch
- if (net->fuses[j]) {
- n_edge = j;
- break;
- }
- }
-
- if (n_edge < UINT_MAX) {
- uint_t n_vert = g->dev[2 * n_edge];
- notch_mark = net->dual_marks[n_vert];
- }
- }
+ long double cur_val = 0;
for (uint_t j = 0; j < max_pos; j++) {
uint_t next_broken = data->break_list[j];
- bool attached_to_notch = net->dual_marks[g->dev[2*next_broken]] == notch_mark;
- bool grew_forward = g->ex[2 * next_broken] > crack_len;
-
- if (crack_growth_crit && attached_to_notch && grew_forward) {
- printf("whoops\n\n");
- max_pos = j;
- break;
- }
-
bool refactor = ((j + 1) % refactor_every) == 0;
break_edge(net, next_broken, &c, refactor);
- double val = data->extern_field[j];
+ long double val = data->extern_field[j];
if (save_cluster_dist) {
if (val < cur_val) {
av_size++;
@@ -422,12 +383,12 @@ int main(int argc, char *argv[]) {
}
if (save_energy) {
- double tmp_energy = 0;
+ long double tmp_energy = 0;
if (max_pos > 0) {
- double sigma1 = data->extern_field[0];
+ long double sigma1 = data->extern_field[0];
double cond1 = cond0;
for (uint_t j = 0; j < max_pos - 1; j++) {
- double sigma2 = data->extern_field[j+1];
+ long double sigma2 = data->extern_field[j+1];
double cond2 = data->conductivity[j];
if (sigma2 > sigma1) {
tmp_energy += 0.5 * gsl_pow_2(sigma1) * (1 - cond2 / cond1) / cond1;
@@ -439,23 +400,6 @@ int main(int argc, char *argv[]) {
energy[i] = tmp_energy;
}
- if (save_toughness) {
- double tmp_toughness = 0;
- if (max_pos > 0) {
- double sigma1 = data->extern_field[0];
- double epsilon1 = sigma1 / data->conductivity[0];
- for (uint_t j = 0; j < max_pos - 1; j++) {
- double sigma2 = data->extern_field[j+1];
- double epsilon2 = sigma2 / data->conductivity[j+1];
- if (epsilon2 > epsilon1) {
- tmp_toughness += (sigma1 + sigma2) * (epsilon2 - epsilon1) / 2;
- sigma1 = sigma2; epsilon1 = epsilon2;
- }
- }
- }
- toughness[i] = tmp_toughness;
- }
-
if (save_threshold) {
thresholds[i] = net->thres[data->break_list[max_pos]];
}
@@ -499,7 +443,7 @@ int main(int argc, char *argv[]) {
if (save_data) {
for (uint_t j = 0; j < data->num_broken; j++) {
- fprintf(data_out, "%u %g %g ", data->break_list[j],
+ fprintf(data_out, "%u %Lg %g ", data->break_list[j],
data->extern_field[j], data->conductivity[j]);
}
fprintf(data_out, "\n");
@@ -566,21 +510,11 @@ int main(int argc, char *argv[]) {
free(conductivity);
}
- if (save_toughness) {
- char *tough_filename = (char *)malloc(filename_len * sizeof(char));
- snprintf(tough_filename, filename_len, "tuff_%c_%c_%c_%c_%d_%g_%g.dat", lattice_c, dual_c, boundc, boundc2, L, beta, crack_len);
- FILE *tough_file = fopen(tough_filename, "ab");
- fwrite(toughness, sizeof(double), N, tough_file);
- fclose(tough_file);
- free(tough_filename);
- free(toughness);
- }
-
if (save_energy) {
char *tough_filename = (char *)malloc(filename_len * sizeof(char));
snprintf(tough_filename, filename_len, "enrg_%c_%c_%c_%c_%d_%g_%g.dat", lattice_c, dual_c, boundc, boundc2, L, beta, crack_len);
FILE *tough_file = fopen(tough_filename, "ab");
- fwrite(energy, sizeof(double), N, tough_file);
+ fwrite(energy, sizeof(long double), N, tough_file);
fclose(tough_file);
free(tough_filename);
free(energy);
@@ -590,7 +524,7 @@ int main(int argc, char *argv[]) {
char *thres_filename = (char *)malloc(filename_len * sizeof(char));
snprintf(thres_filename, filename_len, "thrs_%c_%c_%c_%c_%d_%g_%g.dat", lattice_c, dual_c, boundc, boundc2, L, beta, crack_len);
FILE *thres_file = fopen(thres_filename, "ab");
- fwrite(thresholds, sizeof(double), N, thres_file);
+ fwrite(thresholds, sizeof(long double), N, thres_file);
fclose(thres_file);
free(thres_filename);
free(thresholds);
@@ -612,7 +546,7 @@ int main(int argc, char *argv[]) {
char *str_filename = (char *)malloc(filename_len * sizeof(char));
snprintf(str_filename, filename_len, "strs_%c_%c_%c_%c_%d_%g_%g.dat", lattice_c, dual_c, boundc, boundc2, L, beta, crack_len);
FILE *str_file = fopen(str_filename, "ab");
- fwrite(crit_stress, sizeof(double), N, str_file);
+ fwrite(crit_stress, sizeof(long double), N, str_file);
fclose(str_file);
free(str_filename);
free(crit_stress);