Re: Finite differences for a PDE




<mark.t.douglas@xxxxxxxxx> wrote in message
news:1172222941.024085.10860@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Feb 23, 6:30 am, "Nasser Abbasi" <n...@xxxxxxxxx> wrote:
<mark.t.doug...@xxxxxxxxx> wrote in message

news:1172168566.656621.30510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



Hi,

I'm trying to solve the following pde for p(x,t) numerically:

d_t^2 p - c d_x^2 p - ( 2 c / x ) d_x^1 p - (c a / x^2) p = 0,

where d_y^n means "the nth y-derivative of...". c and a are positive
constants. Using finite differences of the form
p = p[k],

d_x = ( p [k+1] - p [k] ) / (dx) ,

d_x^2 = ( p [k+1] -2 p[k] + p[k-1] ) / (dx^2),

d_t^2 = ( p[n+1] - 2 p[n] + p [n-1] ) / (dt^2),

(where dx, dt are the mesh spacings, k and n are spatial and time
indexes, previous timesteps are kept, etc) leads to massive
oscillations, which shouldn't happen! Am I being boneheaded or is this
PDE not going to yield a numerical solution?

(I know it's analytical solution, which doesn't fit with the ICs well
at all!)

M

What is the size of the time step dt and the size of the space step dx
you
are using?

Nasser



dt/dx is of the order of 1e-3 (dx=1e+2, dt=1e-1).


Does the oscillation in the solution start to show after some time?

I could be wrong on this, its been sometime since I played with FDM's, so
take everything I write below with extreme skepticism :)

I think if you are using an explicit method, (it is not clear to me which
method you are using) you need to keep p(x,t)*dt/dt < some constant (I think
this constant depends on the equation, called courant number?).

Lets assume this constant is 1, that is the number I remember. Your
dt/dx=0.001, and if your initial p is small, so p*dt/dx is less than 1. But
as simulation keeps running, p will increase (the solution), then this will
eventually make p*dt/dx > 1 and the solution will become unstable.

Using an implicit method will help with the stability problem. implicit
methods are always stable (does not mean all are equally accurate), but
explicit schemes are always unstable if you run them long enough.

Are you using an explicit or an implicit method?

Nasser




.