Discontinuous parameters in NMODL

Physical System

Pulse current injection electrode

Model

A current source with abrupt start and stop

Simulation

To work properly with variable time step methods, models that change parameters discontinuously during a simulation must notify NEURON when such events take place. This exercise illustrates the kinds of problems that occur when models do not use the notification function, "at_time". 1) Copy the built-in current clamp pulse model to a file with a new name, say stim1.mod. (the original is in nrn-4.3.1/src/nrnoc/stim.mod (UNIX) or c:\nrn\src\nrnoc\stim.mod (MSWin). It is probably easier, though to copy it from this copy of stim.mod.

The substantive portions of stim.mod looks like:

...
NEURON {
        POINT_PROCESS IClamp
        RANGE del, dur, amp, i
        ELECTRODE_CURRENT i
}
...
BREAKPOINT {
        at_time(del)
        at_time(del+dur)

        if (t < del + dur && t > del) {
                i = amp
        }else{  
                i = 0
        }
}
2) Edit stim1.mod and change its POINT_PROCESS name to BadPulse and also comment out the two at_time call in the BREAKPOINT block. Before the closing brace of the BREAKPOINT block it will also be helpful to print t, v, and i.

3) Do a "Lipid Bilayer" style simulation with the BadPulse with

del = 1, dur = 1, amp = 0.1
when CVode is used as the integration method. Notice that the pulse is completely missed since it lies entirely within one of the large integration intervals used by CVode.

4) Change the duration of the BadPulse to a very large number and rerun with CVode. Notice the inefficient search for the location of the discontinuities.

5) Uncomment the at_time calls (but leave in the printf statement) By notifying NEURON when the discontinuities occur, CVode stops just before them and restarts just after. To print the return value of at_time I use a BREAKPOINT block of:

BREAKPOINT { LOCAL adel, adur
        adel = at_time(del)
        adur = at_time(del+dur)

        if (t < del + dur && t > del) {
                i = amp
        }else{
                i = 0
        }
printf("adel=%g adur=%g ", adel, adur)
printf("t=%g t-del=%g v=%g i=%g\n", t, t-del, v, i)
}


NEURON hands-on course
Copyright © 1998-2001 by N.T. Carnevale and M.L. Hines, all rights reserved.