I have trouble with solving the PDE with periodic boundary condition, which appears to be stiff somewhere, so I tried "StiffnessSwitching". But the code still doesn't work.
k = 3/100; L = 2*Pi; tm = 4;
usol = First[u /.NDSolve[{D[u[x, t], t] + u[x, t]*D[u[x, t], x] +
D[u[x, t], {x, 2}] + k*D[u[x, t], {x, 4}] == 0,
u[0, t] == u[L, t], u[x, 0] == -Sin[x]},
u, {x, 0, L}, {t, 0, tm},
Method -> {"StiffnessSwitching", "NonstiffTest" -> Automatic},
MaxSteps -> \[Infinity](*,
AccuracyGoal -> Infinity, WorkingPrecision -> 20*)]]
NDSolve::ndsz: At t == 0.7462410870827023`, step size is effectively zero; singularity or stiff system suspected.
Here, I also used a sub-method "NonstiffTest" -> Automatic, which allows the Method to switch back from a stiff to a nonstiff method to save time and for better flexibility (if it is the case with Automatic, I am not sure.). Even though I went through Stiffness Detection, I have no idea which option is appropriate for the problem: False, "NormBound", "Direct", SubspaceIteration, "KrylovIteration", Automatic. So I just used Automatic for more flexible. (Am I right?)
Problems:
Assuming the equation has been solved, and how to plot a function
f[t]of the solutionu[x,t]:f[t_?NumericQ] := NIntegrate[usol[x, t]^2, {x, 0, L}], in this fashionParametricPlot[Evaluate[{f[t], f'[t]}], {t, 0, tm}, PlotRange -> All, Frame -> True]In addition, if I added
AccuracyGoal -> Infinity, WorkingPrecision -> 20inNDSolve, the code gives another warning insteadEncountered non-numerical value for a derivative at t == 0.
Why is that? I do not understand the error, because the initial condition and bounary condition are given.
Any comment is very welcome.


