0
$\begingroup$

This question already has an answer here:

I solve the PDE system analytically and numerically and get totally different results. Should there be a solution to the problem of the numerical solution, one must ask oneself - do you know the correct result beforehand? Unfortunately, Mathematica is still very weak in solving analytical PDEs.

pde = D[u[x, t], t] == D[u[x, t], x, x];
bcs = {Derivative[1, 0][u][0, t] == 0, Derivative[1, 0][u][1, t] == 0};
ic = u[x, 0] == x;
sol = First@DSolve[{pde, bcs, ic}, u, {x, t}] /. K[1] -> n

enter image description here

U[x_, t_] = u[x, t] /. sol /. \[Infinity] -> 20 // Activate;
Plot3D[U[x, t], {x, 0, 1}, {t, 0, 0.5}, PlotRange -> All, BoxRatios -> {1, 1, 0.8}, PlotTheme -> "Default"]

enter image description here

Check the boundary conditions for compliance.

Derivative[1, 0][U][0, t]
0
Derivative[1, 0][U][1, t]
0

Now the numerical solution attempt:

nsol = First@NDSolve[{pde, bcs, ic}, u, {x, 0, 1}, {t, 0, 0.5}]

enter image description here

Plot3D[u[x, t] /. nsol, {x, 0, 1}, {t, 0, 0.5}, PlotRange -> All, BoxRatios -> {1, 1, 0.8}, PlotTheme -> "Default"]

enter image description here

To the left of the error warning (...), there are sources that can help with problem solving. Unfortunately I did not find any.

$\endgroup$

marked as duplicate by xzczd differential-equations Jun 7 at 16:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Is this just a statement..or is there a specific question...sorry, im not sure what you’re looking for. $\endgroup$ – morbo Jun 7 at 16:27
  • $\begingroup$ I want to solve it numericaly. $\endgroup$ – rmw Jun 7 at 16:28
  • 2
    $\begingroup$ To be more specific, add Method -> {"MethodOfLines", "DifferentiateBoundaryConditions" -> {True, "ScaleFactor" -> 100}} will resolve your problem. $\endgroup$ – xzczd Jun 7 at 16:38
  • $\begingroup$ @xzczd I found the source in "The Numerical Method of Lines," but not without your help, thank you. I think Maple is more helpful in solving PDEs in many cases. $\endgroup$ – rmw Jun 7 at 17:25
  • $\begingroup$ Indeed, Maple is more good at symbolic PDE solving: 12000.org/my_notes/pde_in_CAS/maple_2019_and_mma_12/index.htm , at least now. But its numeric PDE solver isn't that good, AFAIK. $\endgroup$ – xzczd Jun 7 at 18:00