diff options
author | pants <jaron@kent-dobias.com> | 2016-09-07 15:53:43 -0400 |
---|---|---|
committer | pants <jaron@kent-dobias.com> | 2016-09-07 15:53:43 -0400 |
commit | 2f7a5084aaca7c741dc6bdd3768a65a6e021ba96 (patch) | |
tree | 8b9f2c9280324e09681d95ce3c308745a06f6f48 /src | |
parent | 00cbec2eab9c12810869def33843fc51cca1d0b1 (diff) | |
download | fuse_networks-2f7a5084aaca7c741dc6bdd3768a65a6e021ba96.tar.gz fuse_networks-2f7a5084aaca7c741dc6bdd3768a65a6e021ba96.tar.bz2 fuse_networks-2f7a5084aaca7c741dc6bdd3768a65a6e021ba96.zip |
cleaned up get_conductivity
Diffstat (limited to 'src')
-rw-r--r-- | src/get_conductivity.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/get_conductivity.c b/src/get_conductivity.c index 8c4d228..23b7056 100644 --- a/src/get_conductivity.c +++ b/src/get_conductivity.c @@ -1,24 +1,35 @@ #include "fracture.h" -double get_conductivity(net_t *inst, double *voltage, cholmod_common *c) { - if (inst->voltage_bound) { +double get_conductivity(net_t *net, double *voltages, cholmod_common *c) { + if (net->voltage_bound) { + // the voltage drop across the network is fixed to one with voltage + // boundary conditions, so the conductivity is the total current flowing double tot_cur = 0; - for (unsigned int i = 0; i < inst->graph->num_spanning_edges; i++) { - unsigned int e = inst->graph->spanning_edges[i]; - if (!inst->fuses[e]) { - unsigned int v1 = inst->graph->ev[2*e]; - unsigned int v2 = inst->graph->ev[2*e+1]; - double v1y = inst->graph->vx[2 * v1 + 1]; - double v2y = inst->graph->vx[2 * v2 + 1]; - unsigned int s1 = v1y < v2y ? v1 : v2; - unsigned int s2 = v1y < v2y ? v2 : v1; - tot_cur += voltage[s1] - voltage[s2]; + for (uint_t i = 0; i < net->graph->num_spanning_edges; i++) { + uint_t e = net->graph->spanning_edges[i]; + + if (!net->fuses[e]) { + uint_t v1, v2, s1, s2; + double v1y, v2y; + + v1 = net->graph->ev[2 * e]; + v2 = net->graph->ev[2 * e + 1]; + + v1y = net->graph->vx[2 * v1 + 1]; + v2y = net->graph->vx[2 * v2 + 1]; + + s1 = v1y < v2y ? v1 : v2; + s2 = v1y < v2y ? v2 : v1; + + tot_cur += voltages[s1] - voltages[s2]; } } return fabs(tot_cur); } else { - return 1 / fabs(voltage[inst->graph->nv] - voltage[inst->graph->nv + 1]); + // the current across the network is fixed to one with current boundary + // conditions, so the conductivity is the inverse of the total voltage drop + return 1 / fabs(voltages[net->graph->nv] - voltages[net->graph->nv + 1]); } } |