Skip to main content

Solving Partial Differential Equations in R

  • Chapter
  • First Online:
Solving Differential Equations in R

Part of the book series: Use R! ((USE R))

  • 9970 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 49.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 64.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    From http://www.scholarpedia.org/article/Partial_differential_equation/Approximate_and_Numerical_Methods.

  2. 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. 3.

    From http://en.wikipedia.org/wiki/Laplace’s_equation.

References

  1. 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.

    Google Scholar 

  2. Hundsdorfer, W., & Verwer, J. G. (2003). Numerical solution of time-dependent advection-diffusion-reaction equations. Springer series in computational mathematics. Berlin: Springer.

    Google Scholar 

  3. 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).

    Google Scholar 

  4. 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.

    Google Scholar 

  5. Leonard, B. P. (1988). Simple high accuracy resolution programs for convective modeling of discontinuities. International Journal for Numerical Methods in Fluids, 8, 1291–1318.

    Google Scholar 

  6. Pearson, J. (1993). Complex patterns in a simple system. Science, 261, 189–192.

    Google Scholar 

  7. Roe, P. L. (1985). Some contributions to the modeling of discontinuous flows. Lectures Notes in Applied Mathematics, 22, 163–193. Amer. Math. Soc., Providence.

    Google Scholar 

  8. Sanz-Serna, J. M. (1984). Methods for the numerical solution of the nonlinear Schrodinger equation. Mathematics of Computation, 43, 21–27.

    Google Scholar 

  9. Soetaert, K. (2011). rootSolve: Nonlinear root finding, equilibrium and steady-state analysis of ordinary differential equations. R package version 1.6.2.

    Google Scholar 

  10. Soetaert, K., & Meysman, F. (2011). ReacTran: Reactive transport modelling in 1D, 2D and 3D. R package version 1.3.2.

    Google Scholar 

  11. 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.

    Google Scholar 

  12. Soetaert, K., Petzoldt, T., & Setzer, R. W. (2010). Solving differential equations in R: Package deSolve. Journal of Statistical Software, 33(9), 1–25.

    Google Scholar 

  13. Turing, A. M. (1952). The chemical basis of morphogenesis. Philosophical Transactions of the Royal Society of London Series B, 237, 37–72.

    Google Scholar 

  14. 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.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints 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

Publish with us

Policies and ethics