Solving Differential Equations in R: Package deSolve

被引:1150
作者
Soetaert, Karline [1 ]
Petzoldt, Thomas [2 ]
Setzer, R. Woodrow
机构
[1] Netherlands Inst Ecol NIOO, Ctr Estuarine & Marine Ecol CEME, NL-4401 NT Yerseke, Netherlands
[2] Tech Univ Dresden, Inst Hydrobiol, D-01062 Dresden, Germany
来源
JOURNAL OF STATISTICAL SOFTWARE | 2010年 / 33卷 / 09期
关键词
ordinary differential equations; partial differential equations; differential algebraic equations; initial value problems; R; Fortran; C; SYSTEMS;
D O I
10.18637/jss.v033.i09
中图分类号
TP39 [计算机的应用];
学科分类号
081203 ; 0835 ;
摘要
In this paper we present the R package deSolve to solve initial value problems (IVP) written as ordinary differential equations (ODE), differential algebraic equations (DAE) of index 0 or 1 and partial differential equations (PDE), the latter solved using the method of lines approach. The differential equations can be represented in R code or as compiled code. In the latter case, R is used as a tool to trigger the integration and post-process the results, which facilitates model development and application, whilst the compiled code significantly increases simulation speed. The methods implemented are efficient, robust, and well documented public-domain Fortran routines. They include four integrators from the ODEPACK package (LSODE, LSODES, LSODA, LSODAR), DVODE and DASPK2.0. In addition, a suite of Runge-Kutta integrators and special-purpose solvers to efficiently integrate 1-, 2- and 3-dimensional partial differential equations are available. The routines solve both stiff and non-stiff systems, and include many options, e. g., to deal in an efficient way with the sparsity of the Jacobian matrix, or finding the root of equations. In this article, our objectives are threefold: (1) to demonstrate the potential of using R for dynamic modeling, (2) to highlight typical uses of the different methods implemented and (3) to compare the performance of models specified in R code and in compiled code for a number of test cases. These comparisons demonstrate that, if the use of loops is avoided, R code can efficiently integrate problems comprising several thousands of state variables. Nevertheless, the same problem may be solved from 2 to more than 50 times faster by using compiled code compared to an implementation using only R code. Still, amongst the bene fits of R are a more flexible and interactive implementation, better readability of the code, and access to R's high-level procedures. deSolve is the successor of packageo desolve which will be deprecated in the future; it is free software and distributed under the GNU General Public License, as part of the R software project.
引用
收藏
页码:1 / 25
页数:25
相关论文
共 35 条
[1]  
[Anonymous], R NEWS
[2]  
[Anonymous], ODESOLVE PACKAGE SOL
[3]  
[Anonymous], R NEWS
[4]  
[Anonymous], 2007, Numerical Recipes
[5]  
[Anonymous], BVPSOLVE SOLVERS BOU
[6]  
[Anonymous], 2020, emdbook: Ecological Models and Data in R, DOI DOI 10.2307/J.CTVCM4G37.7
[7]  
ASHER U.M., 1998, Computer Methods for Ordinary Differential Equations and Differential-AlgebraicEquations
[8]  
Bogacki P., 1989, APPL MATH LETT, V2, P1
[9]  
Brenan K.E., 1996, SIAM Classics in Applied Mathematics Series, Vsecond
[10]   USING KRYLOV METHODS IN THE SOLUTION OF LARGE-SCALE DIFFERENTIAL-ALGEBRAIC SYSTEMS [J].
BROWN, PN ;
HINDMARSH, AC ;
PETZOLD, LR .
SIAM JOURNAL ON SCIENTIFIC COMPUTING, 1994, 15 (06) :1467-1488