21 Feb 12:23 2013

## using and event in deSolve

Jannetta Steyn <jannetta <at> henning.org>

2013-02-21 11:23:44 GMT

2013-02-21 11:23:44 GMT

Hi All Having been pointed the use of events and roots in deSolve, I was able to implement the Izchikevich model of spiking neurons. However, I'm not too sure of defining the event. The deSolve documentation says: An event is triggered when the ball hits the ground (height = 0) Then velocity (y2) is reversed and reduced by 10 percent. The root function, y[1] = 0, triggers the event: > root <- function(t, y, parms) y[1] Firstly I couldn't see where y[1] became 0, but I implemented Izchikevich as follows: library(deSolve); Izhikevich <- function(time, init, parms) { with(as.list(c(init, parms)),{ dv <- (0.04*v^2)+(5*v)+140-u+I; du <- a*(b*v-u); #if (v>=30) v<-c else v<-u+d; list( c(dv, du)) })} parms=c( a=0.02, b=0.2, c=-65, d=2, I=10); times=seq(from=1, to=1000, by=0.1); init=c(v=-65, u=0.2); root <- function(time, init, parms) { return(init[1]-30) }(Continue reading)