Addressing a specific variable in SpatialNeuron

Description of problem

Hi again,
I have a SpatialNeuron with variable surface and volume between different compartments and I would like to specify that in the model equations. Meaning that I’d like that the model equation calls the right surface and volume based on which compartment is being evaluated.
And I haven’t find a way to solve that.

I know how to specifically set the volume and area of just one of the compartment with the indexing.
But what if I want that in each compartment the area and volume of the actual compartment is used?

I suspect the solution has to be easy., but I couldn’t find any yet. Any help would be appreciated.

Barbara

Minimal code to reproduce problem

SVR = np.arange(1., 41., 6.7)/umeter
dicr = 2/SVR

morpho = Soma(diameter=90*um)

morpho.L = Section(diameter=dicr, length=[20, 20, 20, 20, 20]*um, n=5)

S_N = morpho.area
Vol_N = morpho.volume

model_eq = '''
.
some other code not relevant
.
dKi/dt = (-S_N/(F*Vol_N))*(IKd + IM - 2*IPump)                   : mmolar 
'''

Error I got:
An error occurred when preparing an object. KeyError: ‘Variable S_N was found in the namespace, but is not a scalar value’

What you have already tried

Adding the indexing:

S_N = morpho.area[i]

Full traceback of error (if relevant)

Error I got (as expected since the indexing was not defined anywhere):
An error occurred when preparing an object. KeyError: ‘The identifier “S_N” could not be resolved.’

Hi Barbara,
it is very possible that we do not document this anywhere, but the equations SpatialNeuron have direct access to all the variables from the Morphology. So you can have your equations directly refer to area, volume, diameter, length, etc., and this will refer to the respective values for each compartment. The definition of external variables (as S_N in your example`) only works for scalar values. But again, no need to do anything to get access to these values, something like

dKi/dt = (-area/volume)*(IKd + IM - 2*IPump) : mmolar

should work.