Abstract
R has three packages that are useful for solving partial differential equations. The R package ReacTran offers grid generation routines and the discretization of the advective-diffusive transport terms on these grids. In this way, the PDEs are either rewritten as a set of ODEs or as a set of algebraic equations. When solving the PDEs with the method of lines (MOL), the time integration can be performed using specially-designed initial value problem solvers from the R package deSolve. When all derivatives have been approximated, functions from the R package rootSolve can efficiently solve the algebraic equations. We show how to solve in R the well-known heat equation (parabolic), the wave equation (hyperbolic), Laplace’s equation (elliptic), and the advection equation. We then give some more complex examples. Most partial differential equations are defined in cartesian coordinates, but some problems are much better represented in other coordinate systems. These problems can be solved efficiently in R as well.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Notes
- 1.
- 2.
The latter requirement is unfortunate and it may require some trial and error to find a good value; however, if too little memory is allocated, the solver may stop with a message telling the size this vector should minimally have.
- 3.
From http://en.wikipedia.org/wiki/Laplace’s_equation.
References
Burchard, H., Bolding, K., & Villarreal, M. R. (1999). GOTM, a general ocean turbulence model. Theory, applications and test cases (Tech Rep EUR 18745 EN). European Commission.
Hundsdorfer, W., & Verwer, J. G. (2003). Numerical solution of time-dependent advection-diffusion-reaction equations. Springer series in computational mathematics. Berlin: Springer.
Kachroo, P., Ozbay, K., & Hobeika, A. G. (2001). Real-time travel time estimation using macroscopic traffic flow models. In 2001 IEEE intelligent transportation systems conference proceedings, Oakland (pp. 132–137).
Lefever, R., Nicolis, G., & Prigogine, I. (1967). On the occurrence of oscillations around the steady state in systems of chemical reactions far from equilibrium. Journal of Chemical Physics, 47, 1045–1047.
Leonard, B. P. (1988). Simple high accuracy resolution programs for convective modeling of discontinuities. International Journal for Numerical Methods in Fluids, 8, 1291–1318.
Pearson, J. (1993). Complex patterns in a simple system. Science, 261, 189–192.
Roe, P. L. (1985). Some contributions to the modeling of discontinuous flows. Lectures Notes in Applied Mathematics, 22, 163–193. Amer. Math. Soc., Providence.
Sanz-Serna, J. M. (1984). Methods for the numerical solution of the nonlinear Schrodinger equation. Mathematics of Computation, 43, 21–27.
Soetaert, K. (2011). rootSolve: Nonlinear root finding, equilibrium and steady-state analysis of ordinary differential equations. R package version 1.6.2.
Soetaert, K., & Meysman, F. (2011). ReacTran: Reactive transport modelling in 1D, 2D and 3D. R package version 1.3.2.
Soetaert, K., & Meysman, F. (2012). Reactive transport in aquatic ecosystems: Rapid model prototyping in the open source software R. Environmental Modelling and Software, 32, 49–60.
Soetaert, K., Petzoldt, T., & Setzer, R. W. (2010). Solving differential equations in R: Package deSolve. Journal of Statistical Software, 33(9), 1–25.
Turing, A. M. (1952). The chemical basis of morphogenesis. Philosophical Transactions of the Royal Society of London Series B, 237, 37–72.
van Leer, B. (1979). Towards the ultimate conservative difference scheme V. A second order sequel to Godunov’s method. Journal of Computational Physics, 32, 101–136.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this chapter
Cite this chapter
Soetaert, K., Cash, J., Mazzia, F. (2012). Solving Partial Differential Equations in R. In: Solving Differential Equations in R. Use R!. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-28070-2_9
Download citation
DOI: https://doi.org/10.1007/978-3-642-28070-2_9
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-28069-6
Online ISBN: 978-3-642-28070-2
eBook Packages: Mathematics and StatisticsMathematics and Statistics (R0)