diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-01-16 01:31:10 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2017-01-16 01:31:10 -0500 |
commit | 1e1fdfc2e3892667bccaf317a01defd8832041c7 (patch) | |
tree | cc5ef9adbfe4a8f11744f4b7afd23a37cfdd74d4 /src/net_currents.c | |
parent | 57857b9ebfb2c0a78c2eb1128d3fb4ed8d597ec4 (diff) | |
download | fuse_networks-1e1fdfc2e3892667bccaf317a01defd8832041c7.tar.gz fuse_networks-1e1fdfc2e3892667bccaf317a01defd8832041c7.tar.bz2 fuse_networks-1e1fdfc2e3892667bccaf317a01defd8832041c7.zip |
fixed voltage and torus conditions, current and free boundaries and broken right now
Diffstat (limited to 'src/net_currents.c')
-rw-r--r-- | src/net_currents.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/net_currents.c b/src/net_currents.c index 431818f..9bb2874 100644 --- a/src/net_currents.c +++ b/src/net_currents.c @@ -3,7 +3,7 @@ double *net_currents(const net_t *net, const double *voltages, cholmod_common *c) { uint_t ne = net->graph->ne; - uint_t dim = net->graph->break_dim; + uint_t dim = net->graph->nv; cholmod_sparse *voltcurmat = net->graph->voltcurmat; cholmod_dense *x = CHOL_F(allocate_dense)(dim, 1, dim, CHOLMOD_REAL, c); @@ -27,6 +27,22 @@ double *net_currents(const net_t *net, const double *voltages, cholmod_common *c } } + if (net->graph->boundary == TORUS_BOUND) { + for (uint_t i = 0; i < net->graph->bi[1]; i++) { + uint_t e = net->graph->b[i]; + uint_t v1 = net->graph->ev[2 * e]; + uint_t v2 = net->graph->ev[2 * e + 1]; + double v1y = net->graph->vx[2 * v1 + 1]; + double v2y = net->graph->vx[2 * v2 + 1]; + + if (v1y > v2y) { + currents[e] += 1; + } else { + currents[e] -= 1; + } + } + } + x->x = tmp_x; CHOL_F(free_dense)(&x, c); CHOL_F(free_dense)(&y, c); |