[R-sig-dyn-mod] Turbidostat Model
Hello Uta,
deSolve provides several mechanisms to approach this. I would suggest to
use forcing functions:
signal <- approxfun(1:10, rep(c(1, 0.1), each=5))
growth <- function(t, x, parms) {
korr <- signal(t) # interpolates linearly
with(as.list(c(x, parms)), {
dy <- r * korr * x
list(dy)
})
}
times <- seq(1, 10, 0.1)
parms <- c(r=1)
y <- 1
out <- ode(y, times, growth, parms)
plot(out)
This interpolates linearly between the values specified in the signal
and you can, of course, also use other interpolation rules as well.
Alternatively, abrupt changes can also be modelled with events. Then,
korr has to be an additional state variable with derivative zero (dkorr
<-0) and events are used to manipulate it as needed.
Thomas Petzoldt
Dr. Thomas Petzoldt Technische Universitaet Dresden Fakulty of Forest, Geo and Hydro Sciences Institute of Hydrobiology 01062 Dresden, Germany http://tu-dresden.de/Members/thomas.petzoldt