I'm using NDSolve to simulate the following model of phase separation:
where rho_T=rho_1+rho_2. The term with chi causes rho_1 and rho_2 to repel each other. However, there is a numerical instability at the interface which causes the solution to blow up:
Refining the mesh narrows the cusps, but they still diverge and cause the integration to halt. How can I use NDSolve to solve this system?
Here is the code in Mathematica 13.1. Note that decreasing chi allows NDSolve to converge, but you end up with a uniform solution instead of two domains.
rhoT = rho1[t, x] + rho2[t, x];
chi = 10.5;
vars = {{rho1[t, x], rho2[t, x]}, t, {x}};
op = D[vars[[1]], t] +
DiffusionPDETerm[
vars, {{alpha1/rhoT,
alpha1*(rho1[t, x]/rhoT)*chi}, {alpha2*(rho2[t, x]/rhoT)*chi,
alpha2/rhoT}}];
(*no-flux boundary conditions*)
bcConserved = NeumannValue[0, x == 0] + NeumannValue[0, x == l];
alpha1 = 1;
alpha2 = 1;
tF = 1;
e0 = 0.1;
l = 1;
(*initial conditions*)
f1[x_] := (e0/
l)*(20/(Log[20*(1 + E^(10*l))] - Log[20*(1 + E^(-10*l))]))/(1 +
E^(20*(x - l/2)));
f2[x_] := (e0/
l)*(-(20/(Log[20*E^(10*l) (1 + E^(10*l))] -
Log[20*(1 + E^(10*l))]))/(1 + E^(20*(x - l/2))) + 2);
ic1 = rho1[0, x] == f1[x];
ic2 = rho2[0, x] == f2[x];
sol = NDSolveValue[{op == {bcConserved, bcConserved}, ic1,
ic2}, {rho1, rho2}, {t, 0, tF}, {x, 0, l}];
{r1, r2} = sol;
Plot[{r1[tF, x], r2[tF, x]}, {x, 0, l}, PlotLegends -> {"1", "2"},
PlotRange -> {Automatic, Full}, LabelStyle -> Directive[Black, 10]]