0
$\begingroup$

I am trying to plot the residuals of a pde solution, using LogPlot.

Clear[pde1]
pde1 = D[u[t, x], t] - (D[u[t, x], x]) == 
   D[D[u[t, x], x], x] + 
    D[u[t, x], x]^2*D[D[u[t, x], x], x] - (u[t, x] - u0);
ics = {u[0, x] == 0};
bcs = {{u[t, 0] == 1 + l1*Derivative[0, 1][u][t, 0]}, {u[t, lb] == 
     u0}};

mol[n_Integer, o_: "Pseudospectral"] := {"MethodOfLines", 
  "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n, 
    "MinPoints" -> n, "DifferenceOrder" -> o}}
mol[tf : False | True, sf_: Automatic] := {"MethodOfLines", 
  "DifferentiateBoundaryConditions" -> {tf, "ScaleFactor" -> sf}}

l1 = 0.5; u0 = 0; tend = 15; lb = 5;

pts = 120;

{sol} = NDSolve[{pde1, ics, bcs}, {u}, {x, 0, lb}, {t, 0, tend}, 
   Method -> Union[mol[pts, 4], mol[True, 100]]];

pp1 = LogPlot[
  Subtract @@ (D[u[t, x], t] - (D[u[t, x], x]) == 
        D[D[u[t, x], x], x] + 
         D[u[t, x], x]^2*D[D[u[t, x], x], x] - (u[t, x] - u0)) /. 
     sol /. t -> 15 // Evaluate, {x, 0, lb}, PlotRange -> All]

enter image description here

In the above plot there are breaks, How can I avoid these?

$\endgroup$
  • $\begingroup$ They indicate areas of pure negative values. Use Plot rather than LogPlot and you can see that. $\endgroup$ – Bill Watts Dec 29 '18 at 7:34
1
$\begingroup$

The plotargument is negative, Log[] cannot evaluate a real value:

If you increase the WorkingPrecision in NDSolve

{sol} = NDSolve[{pde1, ics, bcs}, {u}, {x, 0, lb},{t, 0, tend},Method -> Union[mol[pts, 4], mol[True, 100]]
,WorkingPrecision -> 10];

enter image description here

one gap disappears!

remark

check the messages of NDSolve NDSolve::femnonlinear: Nonlinear coefficients are not supported in this version of NDSolve. ...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.