Altering Total Concentration During a Simulation

Extending NEURON to handle reaction-diffusion problems.

Moderators: hines, wwlytton, ramcdougal

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

Altering Total Concentration During a Simulation

Post by amerg »

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.
Posts: 43
Joined: Tue Apr 18, 2017 10:05 am

Re: Altering Total Concentration During a Simulation

Post by adamjhn »

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

# 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)


# 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

# 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)')
Posts: 40
Joined: Tue Jul 02, 2013 5:11 am

Re: Altering Total Concentration During a Simulation

Post by Darshan »


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

Screenshot here: ... / (2. Ionic Concentration Clamp)

Post Reply