deSolve-package | R Documentation |
Functions that solve initial value problems of a system of first-order ordinary differential equations (ODE), of partial differential equations (PDE), of differential algebraic equations (DAE) and delay differential equations.
The functions provide an interface to the FORTRAN functions lsoda, lsodar, lsode, lsodes of the ODEPACK collection, to the FORTRAN functions dvode, zvode and daspk, and a C-implementation of solvers of the Runge-Kutta family with fixed or variable time steps.
The package contains routines designed for solving ODEs resulting from 1-D, 2-D and 3-D partial differential equations (PDE) that have been converted to ODEs by numerical differencing. It includes root-finding (or event location) and provides access to lagged variables and derivatives.
The system of differential equations is written as an R function or
defined in compiled code that has been dynamically loaded, see
package vignette compiledCode for details. The
solvers may be used as part of a modeling package for differential
equations, or for parameter estimation using any appropriate
modeling tool for non-linear models in R such as
optim
, nls
, nlm
or
nlme
, or FME
.
Package Vignettes, Examples, Online Resources
Solving Initial Value Differential Equations in R (pdf, R code)
Examples in R (code), and in Fortran or C (doc/dynload, doc/dynload-dede)
deSolve homepage: https://desolve.r-forge.r-project.org (Papers, Books, PDFs)
Mailing list: mailto:r-sig-dynamic-models@r-project.org
Karline Soetaert, Thomas Petzoldt, R. Woodrow Setzer
Karline Soetaert, Thomas Petzoldt, R. Woodrow Setzer (2010): Solving Differential Equations in R: Package deSolve Journal of Statistical Software, 33(9), 1–25. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v033.i09")}
Karline Soetaert, Thomas Petzoldt, R. Woodrow Setzer (2010): Solving differential equations in R. The R Journal 2(2), 5-15. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.32614/RJ-2010-013")}
Karline Soetaert, Thomas Petzoldt (2011): Solving ODEs, DAEs, DDEs and PDEs in R. Journal of Numerical Analysis, Industrial and Applied Mathematics (JNAIAM) 6(1-2), 51-65.
Karline Soetaert, Jeff Cash, Francesca Mazzia, (2012): Solving Differential Equations in R. Springer, 248 pp.
Alan C. Hindmarsh (1983): ODEPACK, A Systematized Collection of ODE Solvers, in Scientific Computing, R. S. Stepleman et al. (Eds.), North-Holland, Amsterdam, pp. 55-64.
L. R. Petzold, (1983): A Description of DASSL: A Differential/Algebraic System Solver, in Scientific Computing, R. S. Stepleman et al. (Eds.), North-Holland, Amsterdam, pp. 65-68.
P. N. Brown, G. D. Byrne, A. C. Hindmarsh (1989): VODE: A Variable Coefficient ODE Solver, SIAM J. Sci. Stat. Comput., 10, pp. 1038-1051. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1137/0910062")}
See also the references given on the specific help pages of the different methods.
ode
for a general interface to most of the ODE solvers,
ode.band
for solving models with a banded Jacobian,
ode.1D
, ode.2D
, ode.3D
,
for integrating 1-D, 2-D and 3-D models,
dede
for a general interface to the delay differential
equation solvers,
lsoda
, lsode
,
lsodes
, lsodar
, vode
,
for ODE solvers of the Livermore family,
daspk
, for a DAE solver up to index 1, of the Livermore family,
radau
for integrating DAEs up to index 3 using an implicit
Runge-Kutta,
rk
, rkMethod
, rk4
,
euler
for Runge-Kutta solvers,
DLLfunc
, DLLres
, for testing model implementations
in compiled code,
forcings
, events
, for how to implement forcing
functions (external variables) and events (sudden changes in state variables),
lagvalue
, lagderiv
, for how to get access to
lagged values of state variables and derivatives.
library(deSolve)
## Chaos in the atmosphere
Lorenz <- function(t, state, parameters) {
with(as.list(c(state, parameters)), {
dX <- a * X + Y * Z
dY <- b * (Y - Z)
dZ <- -X * Y + c * Y - Z
list(c(dX, dY, dZ))
})
}
parameters <- c(a = -8/3, b = -10, c = 28)
state <- c(X = 1, Y = 1, Z = 1)
times <- seq(0, 100, by = 0.01)
out <- ode(y = state, times = times, func = Lorenz, parms = parameters)
plot(out)
## add a 3D figure if package scatterplot3D is available
if (require(scatterplot3d))
scatterplot3d(out[,-1], type = "l")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.