## Solving an equation from a NETRECEIVE block

Moderator: wwlytton

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

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
}

...
[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
Posts: 1590
Joined: Wed May 18, 2005 3:32 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
}

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

``````