Dear list,
 
I am working with the following problem:
 
s <-20
z <-0.392
d <-0.487
l <-0.647
pars <- list(d = d, z = z, l = l, s = s)
state <-c(y=0,b=0)
intimes <- c(0,0.05,8.00,8.05,16.00,16.05,24.00,24.05,32.00,32.05,40.00)
input   <- c(20000,0,20000,0,20000,0,20000,0,20000,0,0)

forc <- approxfun(intimes, input, method="constant",rule=2)
derivs <- function(t, state, pars) {
  inp <- forc(t)
  dy1 <- inp/pars$s - pars$d* state[1] - pars$z * state[1]+ pars$l * state[2]
  dy2 <- pars$d * state[1] - pars$l *state[2]
  return(list(c(dy1,dy2)))
}
model <- function(pars, times=c(seq(0, 40, by = 0.01),41)) {
  state <- c(y=0,b=0)
  return(ode(y = state, times = times, func = derivs, parms = pars,method="lsoda",rtol = 1e-8,atol =1e-8))
}
plot(model(pars))

as you can see, the system seems to skip the events at time 8 and time 24. I got as far as to think the issue is related to handling of rate of input (if I adjust the rate and the time to a slower input for the same amount then the problem seems to disappear), or if I change the solver to radau, and decrease the tolerance, then again get reasonable results.  
Do you have any other thoughts as to how to fix this problem other then using a different solver and manipulating the tolerance values? Although my solution seems to work with this example, I do not believe it is a sustainable solution,
 
appreciate your help
 
sincerely,
 
Andras 
	[[alternative HTML version deleted]]

