From a66e8e2d7a1e9d5eb51f4954435513f6ecb8383c Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sat, 14 Jan 2017 11:59:39 -0500 Subject: tried to fix voltage boundary conditions --- src/gen_laplacian.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/gen_laplacian.c') diff --git a/src/gen_laplacian.c b/src/gen_laplacian.c index 42134f0..04f1f9b 100644 --- a/src/gen_laplacian.c +++ b/src/gen_laplacian.c @@ -102,11 +102,11 @@ cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c, uint_t num_gedges; if (voltage_bound) { - num_gedges = 0; + num_gedges = network->bound_inds[num_bounds]; } else { num_gedges = network->bound_inds[num_bounds] + (num_bounds - 2) * 2; } - if (network->boundary == TORUS_BOUND) num_gedges = bound_inds[1]; + if (network->boundary == TORUS_BOUND) num_gedges = 3 * bound_inds[1]; uint_t num_gverts = network->break_dim; uint_t nnz = num_gverts + 2 * num_gedges; @@ -147,6 +147,24 @@ cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c, acoo[num_gverts + 2*i+1] = -1; acoo[vv]++; acoo[network->nv + i]++; + + rowind[num_gverts + 2 * network->bound_inds[1] + 2*i] = network->nv + i; + colind[num_gverts + 2 * network->bound_inds[1] + 2*i] = network->nv + network->bound_inds[1]; + acoo[num_gverts + 2 * network->bound_inds[1] + 2*i] = -1; + rowind[num_gverts + 2 * network->bound_inds[1] + 2*i+1] = network->nv + network->bound_inds[1]; + colind[num_gverts + 2 * network->bound_inds[1] + 2*i+1] = network->nv + i; + acoo[num_gverts + 2 * network->bound_inds[1] + 2*i+1] = -1; + acoo[network->nv + i]++; + acoo[network->nv + network->bound_inds[1]]++; + + rowind[num_gverts + 4 * network->bound_inds[1] + 2*i] = vv; + colind[num_gverts + 4 * network->bound_inds[1] + 2*i] = network->nv + network->bound_inds[1]; + acoo[num_gverts + 4 * network->bound_inds[1] + 2*i] = -1; + rowind[num_gverts + 4 * network->bound_inds[1] + 2*i+1] = network->nv + network->bound_inds[1]; + colind[num_gverts + 4 * network->bound_inds[1] + 2*i+1] = vv; + acoo[num_gverts + 4 * network->bound_inds[1] + 2*i+1] = -1; + acoo[vv]++; + acoo[network->nv + network->bound_inds[1]]++; } acoo[bound_verts[0]]++; } @@ -158,6 +176,12 @@ cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c, for (uint_t i = 0; i < num_bounds; i++) { for (uint_t j = 0; j < bound_inds[i + 1] - bound_inds[i]; j++) { acoo[bound_verts[bound_inds[i] + j]]++; + rowind[num_gverts + 2 * (bound_inds[i] + j)] = network->nv; + colind[num_gverts + 2 * (bound_inds[i] + j)] = bound_verts[bound_inds[i] + j]; + rowind[num_gverts + 2 * (bound_inds[i] + j) + 1] = bound_verts[bound_inds[i] + j]; + colind[num_gverts + 2 * (bound_inds[i] + j) + 1] = network->nv; + acoo[network->nv]++; + acoo[bound_verts[bound_inds[i] + j]]++; } } } else { -- cgit v1.2.3-70-g09d2