Solving an equation from a NETRECEIVE block

Moderator: wwlytton

Post Reply
Raj
Posts: 219
Joined: Thu Jun 09, 2005 1:09 pm
Location: Hanze University of Applied Sciences
Contact:

Solving an equation from a NETRECEIVE block

Post by Raj » Mon Sep 26, 2005 12:47 pm

Dear Forum,

I would like to solve an equation from a NET_RECEIVE block, basically like this:

Code: Select all

NONLINEAR find_x {
	~ x = C_t*exp(x)-1
}

NET_RECEIVE(weight,x_tp, s_tp){
      ...
[i] solve equation find_x using newton[/i]
...

}
The documentation suggests that this is not possible, unless I implement my own newton method. Is that true or can I use a solver included in NEURON to do the job?

Also I have found no examples of the use of the NONLINEAR keyword, is it still current?

hines
Site Admin
Posts: 1577
Joined: Wed May 18, 2005 3:32 pm

Post by hines » Mon Sep 26, 2005 5:08 pm

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()


Post Reply