summaryrefslogtreecommitdiff
path: root/src/get_conductivity.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jkentdobias@g.hmc.edu>2016-08-22 10:11:14 -0400
committerJaron Kent-Dobias <jkentdobias@g.hmc.edu>2016-08-22 10:11:14 -0400
commit2bb0740b68fdb62d45adc00204b3990ca42ade77 (patch)
treea52975e3460da781467ddb70aaa8d76840d01bb4 /src/get_conductivity.c
downloadfuse_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/get_conductivity.c')
-rw-r--r--src/get_conductivity.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/get_conductivity.c b/src/get_conductivity.c
new file mode 100644
index 0000000..7ef08a8
--- /dev/null
+++ b/src/get_conductivity.c
@@ -0,0 +1,24 @@
+
+#include "fracture.h"
+
+double get_conductivity(finst *inst, double *voltage, cholmod_common *c) {
+ if (inst->voltage_bound) {
+ double tot_cur = 0;
+ for (unsigned int i = 0; i < inst->network->num_spanning_edges; i++) {
+ unsigned int e = inst->network->spanning_edges[i];
+ if (!inst->fuses[e]) {
+ unsigned int v1 = inst->network->edges_to_verts[2*e];
+ unsigned int v2 = inst->network->edges_to_verts[2*e+1];
+ double v1y = inst->network->vert_coords[2 * v1 + 1];
+ double v2y = inst->network->vert_coords[2 * v2 + 1];
+ unsigned int s1 = v1y < v2y ? v1 : v2;
+ unsigned int s2 = v1y < v2y ? v2 : v1;
+ tot_cur += voltage[s1] - voltage[s2];
+ }
+ }
+
+ return fabs(tot_cur);
+ } else {
+ return 1 / fabs(voltage[inst->network->num_verts] - voltage[inst->network->num_verts + 1]);
+ }
+}