I am now dealing with the 1D PDE with periodic boundary condition given by the following:
$$ \partial_{t}u(t,x) = \partial_{x}u(t,x). \quad \text{with}\quad u(0,x)=\frac{1}{\sqrt{2\pi}}e^{-(x-\pi/4)^2/2}\quad u(t,-\pi)=u(t,\pi) $$
ufun = NDSolveValue[{\!\(
\*SubscriptBox[\(\[PartialD]\), \(t\)]\(u[t, \[Theta]]\)\) + \!\(
\*SubscriptBox[\(\[PartialD]\), \(\[Theta]\)]\(u[t, \[Theta]]\)\) ==
0, u[0, \[Theta]] == Exp[-(\[Theta] - \[Pi]/4)^2],
u[t, -\[Pi]] == u[t, \[Pi]]},
u, {t, 0, 0.1, 20}, {\[Theta], -\[Pi], \[Pi]},
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid",
"MinPoints" -> 200}}, PrecisionGoal -> 1];
plots = Table[Plot[ufun[t, \[Theta]], {\[Theta], -\[Pi], \[Pi]},PlotRange -> {0, 1}, ColorFunction -> "LakeColors"], {t, 0,
20, .1}];
ListAnimate[plots]
Although there is no error, the solution is not expected.
I have tried the solution here 2D Heat equation: inconsistent boundary and initial conditions.
Method -> {"MethodOfLines",
"SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 20}}
It seems doesn't work. Any suggestion?
"SpatialDiscretization" -> {"TensorProductGrid", "MinPoints" -> 200, "MaxPoints" -> 200}
? That fixed it for me. Also, isPrecisionGoal -> 1
necessary? $\endgroup$ – Chris K Aug 15 '18 at 17:20Using maximum number of grid points 10000
. Such a fine mesh size may mean that time steps need to be quite small to satisfy the Courant condition. I suppose numerically solving PDEs is a hard problem for Mathematica to make the right decisions on, so sometimes the user has to make the appropriate choice of numerical parameters. $\endgroup$ – Chris K Aug 15 '18 at 17:58