Altering Total Concentration During a Simulation

Extending NEURON to handle reaction-diffusion problems.

Moderators: hines, wwlytton, ramcdougal

Post Reply
amerg
Posts: 4
Joined: Wed Jul 31, 2019 5:14 pm

Altering Total Concentration During a Simulation

Post by amerg » Thu Aug 01, 2019 3:09 pm

I was wondering if there is some way to cause an abrupt change in concentration. My attempts at changing the concentration mid simulation by directly setting the concentration value of a node doesn't seem to have any effect. I also attempted to alter the rate of an rxd.Rate object mid simulation, but this also doesn't seem to work. I have found a method to manipulate concentrations by altering the forward/backward rate of reactions during a simulation, but that option seems limited/clunky.

adamjhn
Posts: 34
Joined: Tue Apr 18, 2017 10:05 am

Re: Altering Total Concentration During a Simulation

Post by adamjhn » Thu Aug 01, 2019 5:17 pm

You can change the concentrations via the rxd nodes. If you use variable step you must call h.CVode().re_init() after changing the values.

For example;

Code: Select all

from neuron import h, rxd
from neuron.units import μM, mV, ms
from matplotlib import pyplot
h.load_file('stdrun.hoc')

# define a very simple rxd model
dend = h.Section('dend')
dend.nseg = 101
cyt = rxd.Region(h.allsec(), name='cyt', nrn_region='i')
ca = rxd.Species(cyt, name="ca", d=1.0, charge=2, initial=60 * μM)

h.CVode().active(True)

# record
tvec = h.Vector().record(h._ref_t)
cavec = h.Vector().record(dend(0.5)._ref_cai)


def abrupt_change():
        # change the concentration via the nodes
        # to change all the concentration use 
        # ca.nodes.concentration = 100
        
        # to change the concentration for a region use
        # ca.nodes(cyt).concentration = 100e-3
        
        # to change them for a specific section use
        # ca.nodes(dend).concentration = 100e-3
        # to change for a specific segment use
        ca.nodes(dend(0.5)).concentration = 100 * μM
 
        # calling  h.CVode().re_init() is a general NEURON requirement
        # anytime a state is changed during variable step
        h.CVode().re_init() 

# declare events
def setup_events():
    h.CVode().event(5 * ms, abrupt_change)

fih = h.FInitializeHandler(setup_events)

# initialize and run
h.finitialize(-70 * mV)
h.continuerun(10 * ms)

# plot the result
pyplot.plot(tvec, cavec)
pyplot.xlabel('time (ms)')
pyplot.ylabel('concentration (μM)')
pyplot.show()

Darshan
Posts: 36
Joined: Tue Jul 02, 2013 5:11 am

Re: Altering Total Concentration During a Simulation

Post by Darshan » Sun Aug 04, 2019 1:07 pm

Hi,

If you are interested in clamping concentration to a particular value using a mod mechanism, see this code: https://github.com/darshanmandge/Tools/ ... /ConcClamp.

Screenshot here: https://github.com/darshanmandge/Tools/ ... /README.md (2. Ionic Concentration Clamp)


Cheers,
Darshan

Post Reply