the NONLINEAR block does work in this context but you will need to use proper scoping for the variables. Consider test.mod
Code: Select all
NEURON {
POINT_PROCESS Test
}
ASSIGNED {w}
STATE {x}
PROCEDURE foo() {
SOLVE find_x
}
NONLINEAR find_x {
~ w*x = exp(-x) - 2
}
NET_RECEIVE(ww, xx) {
w = ww
foo()
xx = x
printf("t=%g w=%g x=%g, w*x-(exp(-x)-2)=%g\n", t, w, x, w*x -(exp(-x)-2))
}
and the corresponding test.hoc
Code: Select all
load_file("nrngui.hoc")
create soma
access soma
objref test, nc, fih, nil
test = new Test(.5)
nc = new NetCon(nil, test)
fih = new FInitializeHandler("ev()")
proc ev() {
printf("t=%g weight[0]=%g weight[1]=%g\n", t, nc.weight[0], nc.weight[1])
nc.weight=t
nc.event(t+.5)
cvode.event(t+1, "ev()")
}
run()