Skip to main content
4 of 4
added 27 characters in body

Incorrect solution of diffusion equation with Neumann boundary conditions

I want to set up a PDE model, which takes a two-dimensional diffusion equation into account. The key problem is that I have some trouble in solving the two-dimensional diffusion equation numerically. Consider the following code:

L = 10;
T = 10;
system = {
   D[c[x, y, t], {t, 1}] == D[c[x, y, t], {x, 2}] + D[c[x, y, t], {y, 2}],
   Derivative[1, 0, 0][c][0, y, t] == 0,
   Derivative[1, 0, 0][c][L, y, t] == 0,
   c[x, 0, t] == c[x, L, t],
   c[x, y, 0] == 1
   };
sol = NDSolve[system, c, {x, 0, L}, {y, 0, L}, {t, 0, T}];
Manipulate[Plot3D[Evaluate[c[x, y, t] /. sol], {x, 0, L}, {y, 0, L}], {{t,T}, 0, T}]

Mathematica graphics

As you can see for t = 10 there are artifacts at the two edges where the Neumann conditions were applied.

Obviously, c[x, y, t] = 1 solves the system and since this is the initial condition Mathematica should have no trouble to compute it numerically. It tried various ODE solvers ("ImplicitRungeKutta", "BDF", "Adams"), but it seems that there is some problem with the spatial discretization, perhaps because of the Neumann boundary condition for the variable x.

Any suggestions how to fix it?