// at this point, IClamp[0].del is 0
//IClamp[0].del = 1e9 // so it doesn't interfere with initialization
load_file("vsrc.ses") // creates Vsource[0]
IHOLD = 0 // is set to a nonzero value by the following proc init()
// this is the current in nA that must be applied at the injection site
// in order to hold v at that location to the desired potential
proc init() { local dtsav, tstopsav, temp
pyr3_.inj1_.del = 1e9
IHOLD = 0
pyr3_.ihold_.amp = IHOLD
//print "V0 = ", V0, " INITDUR = ",INITDUR
finitialize(v_init)
dtsav = dt
//dt = 0.05 // or something larger if stability and accuracy are OK
//t = -1e4
t = -5000
tstopsav = tstop
tstop = t+INITDUR
temp = cvode.active()
if (temp!=0) { cvode.active(0) }
Vsource[0].rs = 0.01
Vsource[0].toff = 0
Vsource[0].amp = V0
while (t<tstop) {
fadvance()
}
IHOLD = Vsource[0].i
pyr3_.ihold_.amp = IHOLD
// print "IHOLD ", IHOLD
Vsource[0].rs = 1e9 // so the current it delivers during a run is miniscule
// this is a "suspenders & belt" approach because Vsource[0].toff = 0
// should prevent it from delivering nonzero current when t>0.
// restore simulation parameters
dt = dtsav
tstop = 0
t = -500
while (t<tstop) {
fadvance()
}
t = 0
tstop = 2015
pyr3_.inj1_.del = 15
// restore and re-init cvode if necessary
if (temp!=0) {
cvode.active(1)
cvode.re_init()
} else {
fcurrent()
}
frecord_init()
}