dae(y, times, parms, dy, res = NULL, func = NULL,
method = c("mebdfi", "daspk", "radau", "gamd", "bimd"), ...)
y
has a name attribute, the names will be used to label the
output matrix.times
must be the initial time.res
func
should be an R-function that computes the
values of the derivatives in the ODE system (the model
definition) at timt
, or a character string giving the
name of a compiled function in a dynamically loaded shared library.
"mebdfi"
,
"daspk"
), "radau"
, "gamd"
or a function that performs integration.deSolve
with up to as many rows as elements in
times
and as many
columns as elements in y
plus the number of "global" values
returned in the second element of the return from res
, plus an
additional column (the first) for the time value. There will be one
row for each element in times
unless the integrator returns
with an unrecoverable error. If y
has a names attribute, it
will be used to label the columns of the output value.ode
for a wrapper around the ode solvers,ode.band
for solving models with a banded
Jacobian,ode.1D
for integrating 1-D models,ode.2D
for integrating 2-D models,ode.3D
for integrating 3-D models,mebdfi
,daspk
,radau
,gamd
,bimd
, for the dae solversdiagnostics
to print diagnostic messages.## =======================================================================
## Chemical problem
## =======================================================================
daefun <- function(t, y, dy, parms) {
with (as.list(c(y, dy, parms)), {
res1 <- dA + dAB + lambda * A
res2 <- dAB + dB
alg <- B * A - K * AB
list(c(res1, res2, alg), sumA = A + AB)
})
}
parms <- c(lambda = 0.1, K = 1e-4)
yini <- with(as.list(parms),
c(A = 1, AB = 1, B = K))
dyini <- c(dA = 0, dAB = 0, dB = 0)
times <- 0:100
print(system.time(
out <-dae (y=yini, dy = dyini, times = times, res = daefun,
parms = parms, method = "daspk")
))
plot(out, ylab = "conc.", xlab = "time", lwd = 2)
mtext("IVP DAE", side = 3, outer = TRUE, line = -1)
Run the code above in your browser using DataLab