After studying during these days, now I could answer the question myself.
I admit that both my solution and code are far from good and efficient, even some mistakes or making an unnecessary move. Please give your suggestion if you see anything.
We first create $2M$ equidistant grid points $x_m=(m-M)h$ with $m=1,2,...,2M$.
The x-position of the grid points is stored in xtab:
M = 40; L = 10; h = L/M;
xtab = Table[(m - M) h, {m, 1, 2*M}];
Then we should discretize the solution of PDE along $x$ into $2M$ solutions of a set of coupled ODEs. u[m][t] denotes the solution of function $u(x,t)$ at point $x_m$. Here, I didn't include the left end-point, since it can be set to be u[0][t]=u[2*M][t] according to the periodicity.
U[t_] = Table[u[m][t], {m, 1, 2*M}];
The spatial derivatives are discretized using 2nd-order central differences,
here the periodic condition should be applied.
Because I didn't know how to generate these derivatives using ListCorrelate both for boundary points and internal points in one-line command, I manually add the derivatives near the boundary. Please give me some advice if you know how to do this.
1st-derivative wrt x:
internaldUdx = ListCorrelate[{-1, 0, 1}/(2 h), U[t]]; (* for 2<= m <= 19*)
dUdx = Join[{(u[2][t] - u[2*M][t])/(2 h)},
internaldUdx, {(u[1][t] - u[2*M - 1][t])/(2 h)}];
2nd-derivative wrt x:
internaldUdxx = ListCorrelate[{1, -2, 1}/h^2, U[t]]; (* for 2<= m<=19 *)
dUdxx = Join[{(u[2][t] - 2*u[1][t] + u[2*M][t])/h^2},
internaldUdxx, {(u[1][t] - 2 u[2*M][t] + u[2*M - 1][t])/h^2}];
3rd-derivative wrt x
internaldUdxxx = ListCorrelate[{-1, 2, 0, -2, 1}/(2 h^3), U[t]]; (*for 3<= m <= 2*M-2*)
dUdxxx = Join[{(-u[2 M - 1][t] + 2 u[2 M][t] - 2 u[2][t] + u[3][t])/(2 h^3), (-u[2*M][t] + 2 u[1][t] - 2 u[3][t] + u[4][t])/(2 h^3)},
internaldUdxxx, {(-u[2*M - 1 - 2][t] + 2*u[2*M - 1 - 1][t] - 2*u[2*M - 1 + 1][t] + u[1][t])/(2 h^3), (-u[2*M - 2][t] + 2 u[2*M - 1][t] - 2 u[1][t] + u[2][t])/(2 h^3)}];
4th-derivative wrt x:
internaldUdxxxx = ListCorrelate[{1, -4, 6, -4, 1}/h^4, U[t]]; (*for 3 <= m <= 2M-2*)
dUdxxxx = Join[{(u[2*M - 1][t] - 4*u[2*M][t] + 6*u[1][t] - 4*u[1 + 1][t] +
u[1 + 2][t])/h^4, (u[2*M][t] - 4*u[1][t] + 6*u[2][t] - 4*u[2 + 1][t] + u[2 + 2][t])/h^4},
internaldUdxxxx, {(u[2*M - 3][t] - 4*u[2*M - 2][t] + 6*u[2*M - 1][t] - 4*u[2*M][t] + u[1][t])/h^4, (u[2*M - 2][t] - 4*u[2*M - 1][t] + 6*u[2*M][t] - 4 u[1][t] + u[2][t])/h^4}];
To discretize the integral, we may introduce the mid-points: $x_{m+1/2}=(x_m+x_{m+1})/2$ for $m=1,2,....,2M-1$ with $x_{1/2}=(-L+x_1)/2$.
midxtab = Join[{(-L + (1 - M) h)/2}, Table[((m - M) h + (m + 1 - M) h)/2, {m, 1, 2*M - 1}]];
int[midP_] := h/(2 L)*dUdxxxIntP.Cot[\[Pi]*(midxtab[[midP]] - xtab)/(2*L)]
Constructing the system of ODEs and the discrete initial condition:
eqns = Thread[D[U[t], t] == -U[t]*dUdx - dUdxx - dUdxxxx -
Join[Table[1/2*(int[midP] + int[midP + 1]), {midP, 1, 2*M - 1}], {int[2*M] + int[1]}]];
initc = Thread[U[0] == 1/10*Cos[\[Pi]/L*xtab]];
The original PDE now can be solved numerically:
tmax = 10;
lines = NDSolveValue[{eqns, initc}, U[t], {t, 0, tmax},
Method -> {"EquationSimplification" -> "Solve"}] // Flatten;
Then, we can plot by interpolating (appreciating @bbgodfrey's answer to a related question)
surf = Flatten[Table[{(line - M)*h, t, lines[[line]]}, {line, 1, 2*M}, {t, 0,
tmax, 0.2}], 1];
ListPlot3D[surf, PlotRange -> All, AxesLabel -> {"x", "t", "u"}, ImageSize -> Large, LabelStyle -> {Black, Bold, Medium}]
D[NIntegrate[...]]toNIntegrate[D[...]]. This would mean replacingD[Integrate[u[xp, t]*Cot[\[Pi] (x - xp)/(2*L)], {xp, -L, L}], {x, 3}]withNIntegrate[-((\[Pi]^3 (2 + Cos[(\[Pi] (x - xp))/L]) Csc[(\[Pi] (x - xp))/(2 L)]^4 u[xp, t])/(4 L^3)), {xp, -L, L}], where the integrand in the second form was found withD[u[xp, t]*Cot[\[Pi] (x - xp)/(2*L)], {x, 3}] // FullSimplify. – Roman Feb 26 '19 at 13:31xis equal to an end point±L? There is no principal value there. I take it though thatu[x, t]is to be periodic inxand if we shift the interval of integration, the principal value would become well-defined. Is that correct and what you want? – Michael E2 Mar 06 '19 at 13:56PrincipalValueto avoid a singularity atx=xp. In the answer,M=40corresponds to the time-integrating line along+L(right end of a periodic interval). If the integral is discretized at mid-points, it appears not to blow up. Thus there seems no need of principal value in the current method. Yes,u[x,t]is periodic inx. The periodicity has been imposed through the derivatives near the ends of an interval, and thus the solution at-Lis the same as that of+L. – user55777 Mar 06 '19 at 15:43NIntegratecall, whenx == L, say, you're integrating over-L <= xp <= L, you can't find the principal value because you only have half of the singularity. The part wherex > L, which would cancel out the part wherex < Lin the principal value sense, is not integrated. CompareNIntegrate[Cot[t], {t, 0, Pi, Pi}, Method -> "PrincipalValue"]withNIntegrate[Cot[t], {t, 2, Pi, 2 + Pi}, Method -> "PrincipalValue", AccuracyGoal -> 100]. If we can shift the integration domain because the integrand is periodic, then I have a solution. – Michael E2 Mar 06 '19 at 16:25