I'm trying numerically solve a PDE using NDSolve
. I keep getting the following error:
"NDSolve::ndnum: "Encountered non-numerical value for a derivative at t == 0.."
It seems that I only get this error due to the presence of Abs[D[f[x,y,t],x]]
or Conjugate[D[f[x,y,t],x]]
. I created a very simple function to demonstrate this problem.
This will work:
noAbs = D[f[x, t], t] == f[x, t] f[x, t] D[f[x, t], x, x]
xrange = \[Pi]; trange = 5;
forSolve = {noAbs, f[x, 0] == Exp[I x], f[-xrange, t] == f[xrange, t]}
frul = NDSolve[forSolve, f, {x, -xrange, xrange}, {t, 0, trange},
MaxStepSize -> 0.007, Method -> "MethodOfLines" ];
This won't work (note the only difference is that we don't have an Abs).
withAbs = D[f[x, t], t] == f[x, t] f[x, t] Abs[D[f[x, t], x, x]];
forSolve = {withAbs, f[x, 0] == Exp[I x],
f[-xrange, t] == f[xrange, t]}
frul = NDSolve[forSolve, {f}, {x, -xrange, xrange}, {t, 0, trange},
MaxStepSize -> 0.007, Method -> "MethodOfLines" ];
Plot3D[Re[f[x, t]] /. frul, {x, -xrange, xrange}, {t, 0, trange}]
Right now I'm guessing Mathematica tried to take derivatives of my expressions and finds that it doesn't know how to derive Abs
function. Am I right in assuming this, and how does one get around this problem?