diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-02-10 12:19:46 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-02-10 12:19:46 -0500 |
commit | 0ef0c0ce1d904be2b4e1f4da62dc029d8572c983 (patch) | |
tree | 12978013d870186240c08d1fdd6a7ce8781bca93 /lib/net_conductivity.c | |
parent | 9a93a3b88a604672f557950e6c7f3fe815bcf163 (diff) | |
parent | 901b9f16494f37890be17ef4bb66e6efc6873340 (diff) | |
download | fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.gz fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.bz2 fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.zip |
Merge branch 'tmp'
Diffstat (limited to 'lib/net_conductivity.c')
-rw-r--r-- | lib/net_conductivity.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/net_conductivity.c b/lib/net_conductivity.c new file mode 100644 index 0000000..e9325bb --- /dev/null +++ b/lib/net_conductivity.c @@ -0,0 +1,35 @@ + +#include "fracture.h" + +double net_conductivity(const net_t *net, const double *voltages) { + 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 (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 { + // 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]); + } +} |