dae {deTestSet} | R Documentation |
Solves a system of differential algebraic equations; a wrapper around the implemented DAE solvers
dae(y, times, parms, dy, res = NULL, func = NULL, method = c("mebdfi", "daspk", "radau", "gamd", "bimd"), ...)
y |
the initial (state) values for the DAE system, a vector. If
|
times |
time sequence for which output is wanted; the first
value of |
parms |
vector or list of parameters used in |
dy |
the initial derivatives of the state variables of the DAE system. |
func |
to be used if the model is an ODE, or a DAE written in linearly
implicit form (M y' = f(t, y)).
The return value of |
res |
either an R-function that computes the
residual function F(t,y,y') of the DAE system (the model
defininition) at time If Here The return value of If |
method |
the solver to use, either a string ( |
... |
additional arguments passed to the solvers. |
This is simply a wrapper around the various dae solvers.
See package vignette for information about specifying the model in compiled code.
See the selected integrator for the additional options.
A matrix of class 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.
Karline Soetaert <karline.soetaert@nioz.nl>
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,
diagnostics
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)