Why do I need to mention the variable in RANGE?
Posted: Thu Oct 24, 2013 11:36 am
So I was trying to implement a current based synapse. Simple right?
I started with this code
I didn't include "factor" as a RANGE variable, as the user would never need to access it, and it doesn't vary over space (again, I thought I was being virtuous). However, I normally got a crash with no warning, though occasionally I got the "convergence failed repeatedly or with |h| = hmin" error. The crash was not especially reproducible, I could insert one or two of the point processes, and the simulation would run fine.
But, as soon as factor was set as a RANGE, everything went fine. I'm sure there is a perfectly fine reason, but I can't think of it. What was going on? (during each run of the simulation, tau1 and tau2 were the same, i.e. factor was constant at each instance of the point process)
I started with this code
Code: Select all
NEURON {
POINT_PROCESS isyn
RANGE del, amp, tau1, tau2, i
ELECTRODE_CURRENT i
}
UNITS {
(nA) = (nanoamp)
(mV) = (millivolt)
}
PARAMETER {
del=0 (ms)
tau1=.5 (ms) <1e-3,1e6>
tau2=1 (ms) <1e-3,1e6>
amp=0 (nA) <0,1e9>
factor
}
ASSIGNED {
v (mV)
i (nA)
}
INITIAL {
if (tau1==tau2) {
tau1 = tau1*0.999
}
factor = -1*((tau2/tau1)^(tau2/(tau1-tau2)))*((tau2-tau1)/tau1)
}
BREAKPOINT {
if (amp) { at_time(del) }
i = twoexp( (t - del) )
}
FUNCTION twoexp(x(ms)) (nA) {
if (x < 0 || x/tau2 > 10) {
twoexp = 0
}else{
twoexp = -amp/factor*(exp(-x/tau2)-exp(-x/tau1))
}
}
But, as soon as factor was set as a RANGE, everything went fine. I'm sure there is a perfectly fine reason, but I can't think of it. What was going on? (during each run of the simulation, tau1 and tau2 were the same, i.e. factor was constant at each instance of the point process)