Reaction Not Proceeding

Extending NEURON to handle reaction-diffusion problems.

Moderators: hines, wwlytton, ramcdougal

Post Reply
Posts: 3
Joined: Thu Jul 27, 2017 2:09 pm

Reaction Not Proceeding

Post by npatel » Mon Jul 31, 2017 11:13 am

Hello all,

I have recently started using NEURON and have been facing difficulties running basic reactions in that the concentrations of generated species never deviate from the initial concentrations. I am using NEURON v 7.4 and executing my models out of the Spyder interface downloaded through Anaconda. Simulations without reactions run fine and produce reasonable output. I have been largely trying to execute the basic hydration reaction from the tutorial posted. I have included the code I have been using as well as some commented alternative methods I have tried to execute the reactions.

Code: Select all

from neuron import h, rxd
from matplotlib import pyplot

#h.CVode().active(1) <- if uncommented gives unreasonable time steps
#h.initnrn(0, 0.025)

dend = h.Section()
r = rxd.Region(h.allsec())
#r = rxd.Region(h.allsec(), nrn_region='i')

hydrogen = rxd.Species(r, initial=1)
oxygen = rxd.Species(r, initial=1)
water = rxd.Species(r, initial=0)

reaction = rxd.Reaction(2 * hydrogen + oxygen > water, 1)
#reaction = rxd.Reaction(2 * hydrogen + oxygen > water, 1, regions=r)


heading = '{t:>10s}  {h:>10s}  {o:>10s}  {h2o:>10s}'
data = '{t:10g}  {h:10g}  {o:10g}  {h2o:10g}'

def advance_a_bit():
    for i in xrange(5):
        print data.format(t=h.t, h=hydrogen.nodes[0].concentration,

print heading.format(t='t', h='hydrogen', o='oxygen', h2o='H2O')
print heading.format(t='-', h='--------', o='------', h2o='---')


Method 2: Printing Concentrations Adapted form 'Calcium Waves in RxD'

time = []
concentration = []

def save():
    print 't=', h.t, 'conc=', water.nodes[0].concentration #dend.wateri
for t in xrange(0, 1000, 10):
    h.CVode().event(t, save)


Method 3: Using recording variables

#Set up recording variables
v_vec = h.Vector()     #Membrane potential vector
t_vec = h.Vector()     #Time stamp vector

#Run the simulation
h.tstop = 40.0

#Plot the results
from matplotlib import pyplot
pyplot.plot(t_vec, v_vec)
pyplot.xlabel('Time (ms)')
I appreciate the help greatly, thank you much!

Posts: 122
Joined: Fri Nov 28, 2008 3:38 pm
Location: Yale School of Medicine

Re: Reaction Not Proceeding

Post by ramcdougal » Mon Jul 31, 2017 1:45 pm

What operating system?

I just tried it on my Windows machine through Spyder, and it worked for me.

Could you try installing the latest alpha version ( and seeing if that solves the problem?

Posts: 3
Joined: Thu Jul 27, 2017 2:09 pm

Re: Reaction Not Proceeding

Post by npatel » Mon Jul 31, 2017 3:18 pm

I am using Windows 10, I will try installing the latest alpha version. Thanks!

Posts: 3
Joined: Thu Jul 27, 2017 2:09 pm

Re: Reaction Not Proceeding

Post by npatel » Tue Aug 01, 2017 8:42 am

I wanted to provide an update on the situation. I tried updating the latest alpha version and the reactions now execute as expected. Thank you much!

Post Reply