# [R] PDE

Fri Sep 29 15:42:36 CEST 2006

```No, you don't solve D d2c/dx2 + v dc/dx = 0.

You discretize the spatial derivatives using finite differences (typically,
central difference), at a given time.  Let us say x goes from 0 to 1.
Divide this into intervals of length delta x, such that x(i+1) = x (i) +
delta x, i = 0, ..., N-1.  Let c(i,t) denote the concentration at x(i) at
time t.  So you now have:

dc(i,t)/dt = D (c(i+1,t) - 2 c(i,t) + c(i-1,t)) / (delta x) ^2 + v (c(i+1,t)
-  c(i-1,t)) / (2 * delta x), for i = 1, ..., N.

The above is a coupled system of N equations, with only time t as the
independent variable.  You can solve this system using any of the methods
for initial value problem, e.g. Euler's or classical 4-th order Runge-Kuttta
(you can use the Odesolve package in R for this task).  The initial values
c(i,t=0) must be specified as an input, as well as the boundary conditions
at c(x=0,t) and c(x=1,t) for all t.

Hope this is clear.  You should also consult a basic numerical analysis
text, for example, Burden and Faires (2001, 7th Edition, pages 704 - ...).

Best,
Ravi.

----------------------------------------------------------------------------
-------

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

----------------------------------------------------------------------------
--------

-----Original Message-----
From: Christophe Nguyen [mailto:Christophe.Nguyen at bordeaux.inra.fr]
Sent: Friday, September 29, 2006 7:12 AM
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] PDE

Dear Ravi,
Many thanks for your help. I guess the PDE I am interested in is
parabolic: it is a diffusion+advection equation: dc/dt=D d2c/dx2 + vdc/dx
Do you mean that I have to solve D d2c/dx2 + vdc/dx=0 for  each time
step, taking as initial condition at step n+1 the value of c at step n?
Does the ODE package sollve second order differential equation?
Best regards,
Chris

> Hi Christophe,
>
> What is the PDE that you are trying to solve?  Is it
> parabolic/hyperbolic/elliptical/somethingelse?  Is it linear/nonlinear?
>
> If time is one of the independent variables, you can transform the PDE
into
> an initial value problem (system of ODEs) by using finite difference
> approximations of the partial derivatives of other independent variables
> (typically, these are spatial coordinates).  Starting with an initial set
of
> values on a grid of points (also known as initial conditions, which are
part
> of the problem specification), you update them at different times, using
> fixed or varying time steps.
>
> R has very limited functionality for handling differential equations.  So,
> you should look for FORTRAN libraries, from which you can create DLLs to
be
> used in R.
>
> Hope this help,
> Ravi.
>
>
----------------------------------------------------------------------------
> -------
>
>
> Assistant Professor, The Center on Aging and Health
>
> Division of Geriatric Medicine and Gerontology
>
> Johns Hopkins University
>
> Ph: (410) 502-2619
>
> Fax: (410) 614-9625
>
>
>
>
>
>
----------------------------------------------------------------------------
> --------
>
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Christophe Nguyen
> Sent: Wednesday, September 27, 2006 10:39 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] PDE
>
> Dear all,
> Does any know how to solve PDE with R? The archive list refers to the
> use of ODE if PDE are parabolic. I am not a mathematician and this does
> not mean anything for me!
> help would be very appreciated.
> Many thanks
>
>

--
___________________________________________________

Christophe NGUYEN

UMR 1220 INRA-ENITAB
Transfert sol-plante et cycle des éléments minéraux
dans les écosystèmes cultivés"

Centre INRA de Bordeaux-Aquitaine
71, avenue Edouard Bourlaux, BP 81
33883 Villenave d'Ornon, FRANCE

Tel : 00 33 (0)5 57 12 25 07
Fax : 00 33 (0)5 57 12 25 15

email : Christophe.Nguyen at bordeaux.inra.fr
page infoservice: http://www.bordeaux.inra.fr/tcem

__________m°O°m____________________________________

```