| 1 |
\name{deSolve-package} |
| 2 |
\alias{deSolve-package} |
| 3 |
\alias{deSolve} |
| 4 |
\docType{package} |
| 5 |
\title{ |
| 6 |
General Solvers for Initial Value Problems of Ordinary Differential Equations |
| 7 |
(ODE), Partial Differential Equations (PDE), Differential Algebraic |
| 8 |
Equations (DAE) and delay differential equations (DDE). |
| 9 |
} |
| 10 |
\description{ |
| 11 |
Functions that solve initial value problems of a system of |
| 12 |
first-order ordinary differential equations (ODE), of partial |
| 13 |
differential equations (PDE), of differential algebraic equations (DAE) |
| 14 |
and delay differential equations. |
| 15 |
|
| 16 |
The functions provide an interface to the FORTRAN functions lsoda, |
| 17 |
lsodar, lsode, lsodes of the ODEPACK collection, |
| 18 |
to the FORTRAN functions dvode, zvode and daspk, and a C-implementation of |
| 19 |
solvers of the Runge-Kutta family with fixed or variable time steps. |
| 20 |
|
| 21 |
The package contains routines designed for solving ODEs |
| 22 |
resulting from 1-D, 2-D and 3-D partial differential equations (PDE) |
| 23 |
that have been converted to ODEs by numerical differencing. |
| 24 |
It includes root-finding (or event location) and provides access to lagged |
| 25 |
variables and derivatives. |
| 26 |
|
| 27 |
The system of differential equations is written as an \R{} function or |
| 28 |
defined in compiled code that has been dynamically loaded, see |
| 29 |
package vignette \href{../doc/compiledCode.pdf}{compiledCode} for details. The |
| 30 |
solvers may be used as part of a modeling package for differential |
| 31 |
equations, or for parameter estimation using any appropriate |
| 32 |
modeling tool for non-linear models in \R{} such as |
| 33 |
\code{\link{optim}}, \code{\link{nls}}, \code{\link{nlm}} or |
| 34 |
\code{\link[nlme]{nlme}}, or \code{\link[FME]{FME}}. |
| 35 |
|
| 36 |
|
| 37 |
\bold{Package Vignettes, Examples, Online Resources} |
| 38 |
|
| 39 |
\itemize{ |
| 40 |
\item Solving Initial Value Differential Equations in R |
| 41 |
(\href{../doc/deSolve.pdf}{pdf}, \href{../doc/deSolve.R}{R code}) |
| 42 |
\item Writing Code in Compiled Languages |
| 43 |
(\href{../doc/compiledCode.pdf}{pdf}, \href{../doc/compiledCode.R}{R code}) |
| 44 |
\item Examples in R (\href{../doc/examples}{code}), and in Fortran or C |
| 45 |
(\href{../doc/dynload}{doc/dynload}, \href{../doc/dynload-dede}{doc/dynload-dede}) |
| 46 |
\item Mailing list: \url{mailto:[email protected]} |
| 47 |
} |
| 48 |
|
| 49 |
} |
| 50 |
\author{ |
| 51 |
Karline Soetaert, Thomas Petzoldt, R. Woodrow Setzer |
| 52 |
} |
| 53 |
\references{ |
| 54 |
|
| 55 |
Karline Soetaert, Thomas Petzoldt, R. Woodrow Setzer (2010): Solving |
| 56 |
Differential Equations in R: Package deSolve Journal of Statistical |
| 57 |
Software, 33(9), 1--25. \doi{10.18637/jss.v033.i09} |
| 58 |
|
| 59 |
Karline Soetaert, Thomas Petzoldt, R. Woodrow Setzer (2010): Solving |
| 60 |
differential equations in R. The R Journal 2(2), 5-15. |
| 61 |
\doi{10.32614/RJ-2010-013} |
| 62 |
|
| 63 |
Karline Soetaert, Thomas Petzoldt (2011): Solving ODEs, DAEs, DDEs and |
| 64 |
PDEs in R. Journal of Numerical Analysis, Industrial and Applied |
| 65 |
Mathematics (JNAIAM) 6(1-2), |
| 66 |
51-65. %\href{https://jnaiam.org/uploads/jnaiam_6_4.pdf}{pdf} |
| 67 |
|
| 68 |
Karline Soetaert, Jeff Cash, Francesca Mazzia, (2012): |
| 69 |
Solving Differential Equations in R. Springer, 248 pp. |
| 70 |
|
| 71 |
Alan C. Hindmarsh (1983): ODEPACK, A Systematized Collection of ODE |
| 72 |
Solvers, in Scientific Computing, R. S. Stepleman et al. (Eds.), |
| 73 |
North-Holland, Amsterdam, pp. 55-64. |
| 74 |
|
| 75 |
L. R. Petzold, (1983): A Description of DASSL: A Differential/Algebraic |
| 76 |
System Solver, in Scientific Computing, R. S. Stepleman et al. (Eds.), |
| 77 |
North-Holland, Amsterdam, pp. 65-68. |
| 78 |
|
| 79 |
P. N. Brown, G. D. Byrne, A. C. Hindmarsh (1989): VODE: A Variable |
| 80 |
Coefficient ODE Solver, SIAM J. Sci. Stat. Comput., 10, pp. 1038-1051. |
| 81 |
\doi{10.1137/0910062} |
| 82 |
|
| 83 |
See also the references given on the specific help pages of the |
| 84 |
different methods. |
| 85 |
|
| 86 |
} |
| 87 |
\seealso{ |
| 88 |
\code{\link{ode}} for a general interface to most of the ODE solvers, |
| 89 |
|
| 90 |
\code{\link{ode.band}} for solving models with a banded Jacobian, |
| 91 |
|
| 92 |
\code{\link{ode.1D}}, \code{\link{ode.2D}}, \code{\link{ode.3D}}, |
| 93 |
for integrating 1-D, 2-D and 3-D models, |
| 94 |
|
| 95 |
\code{\link{dede}} for a general interface to the delay differential |
| 96 |
equation solvers, |
| 97 |
|
| 98 |
\code{\link{lsoda}}, \code{\link{lsode}}, |
| 99 |
\code{\link{lsodes}}, \code{\link{lsodar}}, \code{\link{vode}}, |
| 100 |
for ODE solvers of the Livermore family, |
| 101 |
|
| 102 |
\code{\link{daspk}}, for a DAE solver up to index 1, of the Livermore family, |
| 103 |
|
| 104 |
\code{\link{radau}} for integrating DAEs up to index 3 using an implicit |
| 105 |
Runge-Kutta, |
| 106 |
|
| 107 |
\code{\link{rk}}, \code{\link{rkMethod}}, \code{\link{rk4}}, |
| 108 |
\code{\link{euler}} for Runge-Kutta solvers, |
| 109 |
|
| 110 |
\code{\link{DLLfunc}}, \code{\link{DLLres}}, for testing model implementations |
| 111 |
in compiled code, |
| 112 |
|
| 113 |
\code{\link{forcings}}, \code{\link{events}}, for how to implement forcing |
| 114 |
functions (external variables) and events (sudden changes in state variables), |
| 115 |
|
| 116 |
\code{\link{lagvalue}}, \code{\link{lagderiv}}, for how to get access to |
| 117 |
lagged values of state variables and derivatives. |
| 118 |
|
| 119 |
} |
| 120 |
|
| 121 |
\examples{ |
| 122 |
library(deSolve) |
| 123 |
|
| 124 |
## Chaos in the atmosphere |
| 125 |
Lorenz <- function(t, state, parameters) { |
| 126 |
with(as.list(c(state, parameters)), { |
| 127 |
dX <- a * X + Y * Z |
| 128 |
dY <- b * (Y - Z) |
| 129 |
dZ <- -X * Y + c * Y - Z |
| 130 |
list(c(dX, dY, dZ)) |
| 131 |
}) |
| 132 |
} |
| 133 |
|
| 134 |
parameters <- c(a = -8/3, b = -10, c = 28) |
| 135 |
state <- c(X = 1, Y = 1, Z = 1) |
| 136 |
times <- seq(0, 100, by = 0.01) |
| 137 |
|
| 138 |
out <- ode(y = state, times = times, func = Lorenz, parms = parameters) |
| 139 |
|
| 140 |
plot(out) |
| 141 |
|
| 142 |
## add a 3D figure if package scatterplot3D is available |
| 143 |
if (require(scatterplot3d)) |
| 144 |
scatterplot3d(out[,-1], type = "l") |
| 145 |
|
| 146 |
} |
| 147 |
\keyword{ package } |