Altering Total Concentration During a Simulation
Moderators: hines, wwlytton, ramcdougal
Altering Total Concentration During a Simulation
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.
Re: Altering Total Concentration During a Simulation
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;
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()
Re: Altering Total Concentration During a Simulation
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
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