Conflict between CVode.maxstep, NetCon instances, and extracellular

Anything that doesn't fit elsewhere.
Post Reply
ngreiner
Posts: 9
Joined: Tue Feb 28, 2017 8:12 am

Conflict between CVode.maxstep, NetCon instances, and extracellular

Post by ngreiner » Thu Oct 11, 2018 11:13 am

Dear all,

I have encountered a conflict between the use of the variable time step method and instances of NetCon objects when using the extracellular mechanism. I found a workaround while writing this post but I decided to share my finding anyway.

The problem, materialised by the MWE below, is that when a NetCon objet is instantiated after the calls

Code: Select all

cvode_active(1)
cvode.maxstep(some_value)
then the specified maxstep value is ignored during simulation.

If you execute the code below

Code: Select all

from neuron import h
h.load_file('stdrun.hoc')

# Create section
s = h.Section()
s.insert('hh')
s.insert('extracellular')

# Record time
t = h.Vector()
t.record(h._ref_t)

# Simulation parameters
h.tstop = 10.0
h.cvode_active(1)
h.cvode.maxstep(0.05)

# NetCon to record spike times
nc = h.NetCon(s(0.5)._ref_v, None, sec=s)
spikeTimes = h.Vector()
nc.record(spikeTimes)

# Run simulation
h.finitialize()
h.cvode.solve(h.tstop)

# Print time steps
for ti in t.to_python():
	print ti
you should get something similar to
/usr/local/bin/python /Users/ngreiner/Desktop/test.py
NEURON -- VERSION 7.5 master (c693a84) 2017-12-07
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

0.0
0.0329775041477
0.0659550082954
0.131910016591
0.263820033182
0.527640066363
1.05528013273
1.43128916059
1.80729818845
2.18330721631
2.55931624417
3.31133429989
4.06335235562
4.81537041134
5.56738846706
6.31940652278
7.21133984489
8.103273167
8.9060131569
9.77325478068
10.0
Notice that the gaps between two consecutive time points is sometimes way larger than 0.05.

Conversely, the problem does not arise when the NetCon instantiation is done before the calls

Code: Select all

cvode_active(1)
cvode.maxstep(some_value)
If you execute the code below (where the NetCon object declaration has been moved before the mentioned calls) you should see that the gap between two consecutive time points always stay <= 0.05.

Code: Select all

from neuron import h
h.load_file('stdrun.hoc')

# Create section
s = h.Section()
s.insert('hh')
s.insert('extracellular')

# Record time
t = h.Vector()
t.record(h._ref_t)

# NetCon to record spike times
nc = h.NetCon(s(0.5)._ref_v, None, sec=s)
spikeTimes = h.Vector()
nc.record(spikeTimes)

# Simulation parameters
h.tstop = 10.0
h.cvode_active(1)
h.cvode.maxstep(0.05)

# Run simulation
h.finitialize()
h.cvode.solve(h.tstop)

# Print time steps
for ti in t.to_python():
	print ti
/usr/local/bin/python /Users/ngreiner/Desktop/test.py
NEURON -- VERSION 7.5 master (c693a84) 2017-12-07
Duke, Yale, and the BlueBrain Project -- Copyright 1984-2016
See http://neuron.yale.edu/neuron/credits

0.0
0.0329775041477
0.0659550082954
0.131910016591
0.263820033182
0.313820033182
0.363820033182
0.413820033182
0.463820033182
0.513820033182
0.563820033182
0.613820033182
0.663820033182
0.713820033182
0.763820033182
0.813820033182
0.863820033182
0.913820033182
0.963820033182
1.01382003318
1.06382003318
1.11382003318
1.16382003318
1.21382003318
1.26382003318
1.31382003318
1.36382003318
1.41382003318
1.46382003318
.
.
.
9.16382003318
9.21382003318
9.26382003318
9.31382003318
9.36382003318
9.41382003318
9.46382003318
9.51382003318
9.56382003318
9.61382003318
9.66382003318
9.71382003318
9.76382003318
9.81382003318
9.86382003318
9.91382003318
9.96382003318
10.0
Importantly, this difference of behavior is not observed when the extracellular mechanism is not included (you can verify it for yourself by replacing insert(‘extracellular’) by insert(‘pas’) in the previous code examples).

If anybody knows why this order is important, I’d be grateful to get an explanation.

With regards,

Nathan

hines
Site Admin
Posts: 1527
Joined: Wed May 18, 2005 3:32 pm

Re: Conflict between CVode.maxstep, NetCon instances, and extracellular

Post by hines » Fri Oct 12, 2018 1:58 pm

That is an oversight. cvode wraps ida and the former is persistent while the latter is destroyed/created whenever the model topology, or if
the model requires a differential algebraic solver, changes. Extacellular requires ida.
I forgot to make all the ida calls to reflect the existing cvode style fields when ida is reinstantiated.

Post Reply