NonLinear system for chemotaxis
If you use the Finite Element Method, no flux
is the default boundary condition, so there is no need to specify. An alternative to Daniel's answer would be:
(* Define parameters *)
l = 6;
tend = 0.1;
parms = {d -> 2, da -> 5.5, h -> 0.5, k -> 0.5, x0 -> 0.2};
(* Create Parametric PDE operators for n and a *)
parmnop =
D[n[t, x], t] - d D[n[t, x], x, x] + x0 D[n[t, x] D[a[t, x], x], x];
parmaop = D[a[t, x], t] - da D[a[t, x], x, x] + k a[t, x] - h n[t, x];
(* Setup PDE System *)
pden = (parmnop == 0) /. parms;
pdea = (parmaop == 0) /. parms;
icn = n[0, x] == Exp[-x^2];
ica = a[0, x] == Cos[π x];
(* Solve System *)
{nif, aif} =
NDSolveValue[{pden, pdea, icn, ica}, {n, a}, {t, 0, tend}, {x, -l,
l}, Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"FiniteElement",
"MeshOptions" -> MaxCellMeasure -> 0.1}}];
(* Display results *)
Manipulate[
Plot[{nif[t, x], aif[t, x]}, {x, -l, l}, PlotRange -> All], {t, 0,
tend}, ControlPlacement -> Top]
Here is my code. Unfortunately, at t==0.1, it does not duplicate your result. I hope I did not make a mistake.
eq = {D[n[x, t], t] ==
d D[n[x, t], {x, 2}] - c0 D[n[x, t] D[a[x, t], x], x],
D[a[x, t], t] == h n[x, t ] - k a[x, t] + da D[a[x, t], {x, 2}],
(D[n[x, t], x] /. x -> -6) == 0, (D[a[x, t], x] /. x -> -6) ==
0, (D[n[x, t], x] /. x -> 6) ==
0, (D[a[x, t], x] /. x -> 6) == 0,
n[x, 0] == Exp[-x^2], a[x, 0] == Cos[Pi x]} /. {d -> 2, da -> 5.5,
h -> 0.5, k -> 0.5, c0 -> 0.2};
sol[x_] = {n[x, 0.1], a[x, 0.1]} /.
NDSolve[eq, {n, a}, {t, 0, 0.1}, {x, -6, 6}][[1]]
Plot[sol[x], {x, -6, 6}, PlotRange -> All]