Skip to content

Commit

Permalink
We _do_ need to check.
Browse files Browse the repository at this point in the history
  • Loading branch information
thorstenhater committed Aug 19, 2024
1 parent d900fc6 commit 2121e7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
17 changes: 10 additions & 7 deletions arbor/fvm_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,23 +428,26 @@ fvm_cv_discretize(const cable_cell& cell, const cable_cell_parameter_set& global
cv_length += embedding.integrate_length(cable);
}

arb_assert(cv_length > 0);
D.diam_um[i] = D.cv_area[i]/(cv_length*math::pi<double>);
D.cv_volume[i] = 0.25*D.cv_area[i]*D.diam_um[i];
bool has_parent = p != -1;
double A = D.cv_area[i];

if (D.cv_area[i]>0) {
auto A = D.cv_area[i];
if (cv_length > 0) {
D.diam_um[i] = A/(cv_length*math::pi<double>);
}
D.cv_volume[i] = 0.25*A*D.diam_um[i];

if (A > 0) {
D.init_membrane_potential[i] /= A;
D.temperature_K[i] /= A;
// If parent is trivial, and there is no grandparent, then we can use values from this CV
// to get initial values for the parent. (The other case, when there is a grandparent, is
// caught below.)
if (p!=-1 && D.geometry.cv_parent[p]==-1 && D.cv_area[p]==0) {
if (has_parent && D.geometry.cv_parent[p] == -1 && D.cv_area[p] == 0) {
D.init_membrane_potential[p] = D.init_membrane_potential[i];
D.temperature_K[p] = D.temperature_K[i];
}
}
else if (p!=-1) {
else if (has_parent) {
// Use parent CV to get a sensible initial value for voltage and temp on zero-size CVs.
D.init_membrane_potential[i] = D.init_membrane_potential[p];
D.temperature_K[i] = D.temperature_K[p];
Expand Down
12 changes: 7 additions & 5 deletions python/test/unit/test_diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import numpy as np
from .. import fixtures

print(A.__path__)

"""
Tests for the concentration and amount of diffusive particles across time and morphology.
Three different morphological structures are considered: 1 segment ("soma only"), 2 segments
Expand Down Expand Up @@ -33,12 +35,12 @@ def __init__(self, cat, cell, probes, inject_remove):
self.the_cell = cell
self.the_probes = probes
self.the_props = A.neuron_cable_properties()
self.the_props.catalogue = (
cat # use the provided catalogue of diffusion mechanisms
)
# use the provided catalogue of diffusion mechanisms
self.the_props.catalogue = cat
# use diffusive particles "s"
self.the_props.set_ion(
"s", valence=1, int_con=0 * U.mM, ext_con=0 * U.mM, diff=0 * U.m2 / U.s
) # use diffusive particles "s"
"s", valence=1, int_con=0 * U.mM, ext_con=0 * U.mM, rev_pot=0 * U.mV
)
self.inject_remove = inject_remove

def num_cells(self):
Expand Down

0 comments on commit 2121e7c

Please sign in to comment.