I want to code a mechanism with a conductance that raises and then decreases exponentially. As it's a simple exponential, I don't want to use differential equations but rather an exponential function changing the initial and steady state value. However, the initial value has to be the actual g value at time=onset (or onset + duration) because it may not always reach steady state. The important part of the code is the following:
Code: Select all
INITIAL {
g0=minG
ginf=minG
calcG()
tref=0
}
BREAKPOINT {
if(at_time(onset)) {
g0=g
ginf=maxG
tref=onset
}
if(at_time(onset+dur)) {
g0=g
ginf=minG
tref=onset+dur
}
calcG()
i = g*(v-e)
}
PROCEDURE calcG() {
if (t < onset) {
g=minG
}
if (t >= onset) {
g = ginf - (ginf - g0)*exp(-(t-tref)/tau)
}
}
However, what I see in the simulation is that whenever t=>onset, g0 keeps being updated each time step. What is the correct way of making something to happen only once, at a given time?
I'll welcome any alternative method to accomplish what I want, but still I'd like to know why at_time() is not working the way it is supposed to.
Thank you