3

I want to solve a system of Pde (2D) reaction diffusion type using NDSolve

enter image description here

whose boundary conditions are

enter image description here

and the initial conditions are

enter image description here

or

enter image description here

I thought of the following code

(*parameters*)

L = 5;
T = 10;

(*system of nonlinear PDE*)

pde = {D[N1[t, x, y], t] == 
    D[N1[t, x, y], x, x] + 
     D[N1[t, x, y], y, 
      y] + (1 - N1[t, x, y] - 0.5 N2[t, x, y]) N1[t, x, y], 
   D[N2[t, x, y], t] == 
    D[N2[t, x, y], x, x] + 
     D[N2[t, x, y], y, 
      y] + (1 - N2[t, x, y] - 0.5 N1[t, x, y]) N2[t, x, y]};

(*periodic boundary condition*)

bc = {N1[t, -L, y] == N1[t, L, y], N1[t, x, -L] == N1[t, x, L], 
   N2[t, -L, y] == N2[t, L, y], N2[t, x, -L] == N2[t, x, L]};

(*initial condition*)

ic = {N1[0, x, y] == If[-0.5 <= x <= 1 && -0.5 <= y <= 1, 1, 0], 
   N2[0, x, y] == If[-0.5 <= x <= 1 && -0.5 <= y <= 1, 0, 1]};
eqns = Flatten@{pde, bc, ic};

{N1, N2} = 
 NDSolve[eqns, {N1, N2}, {t, 0, T}, {x, -L, L}, {y, -L, L}, 
  Method -> {"MethodOfLines", 
    "SpatialDiscretization" -> {"TensorProductGrid"}}]

However, the following errors appear.

enter image description here

Also, when constructing the plot (by DensityPlot), I verify that there is a failure in the initial condition, as shows

enter image description here

Can someone help me?

Chris K
  • 20,207
  • 3
  • 39
  • 74
SAC
  • 1,335
  • 8
  • 17
  • 1
  • You need e.g. {solN1, solN2} = NDSolveValue[…… instead of {N1, N2} = NDSolve[…. 2. Try Plot3D instead of DensityPlot, or setting a larger PlotPoints for DensityPlot.
  • – xzczd Nov 30 '17 at 02:40