From 2121e7cafcb26907f9e89b6929dcafd1db25e1ef Mon Sep 17 00:00:00 2001 From: Thorsten Hater <24411438+thorstenhater@users.noreply.github.com> Date: Mon, 19 Aug 2024 17:22:04 +0200 Subject: [PATCH] We _do_ need to check. --- arbor/fvm_layout.cpp | 17 ++++++++++------- python/test/unit/test_diffusion.py | 12 +++++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/arbor/fvm_layout.cpp b/arbor/fvm_layout.cpp index 19b49cdd4..6427a9459 100644 --- a/arbor/fvm_layout.cpp +++ b/arbor/fvm_layout.cpp @@ -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); - 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); + } + 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]; diff --git a/python/test/unit/test_diffusion.py b/python/test/unit/test_diffusion.py index 7fc7ee5b7..d46b879a5 100644 --- a/python/test/unit/test_diffusion.py +++ b/python/test/unit/test_diffusion.py @@ -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 @@ -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):