In Mathematica documentation one is prompted to use a grid with points at the zeros of the Chebyshev polynomials so that Runge's phenomena arising from DifferenceOrder->"Pseudospectral" are eliminated.
Although there is an explicit example of how to construct such a grid
CGLGrid[x0_, L_, n_Integer /; n > 1] := x0 + 1/2 L (1 - Cos[π Range[0, n - 1]/(n - 1)])
cgrid = CGLGrid[-5, 10.,16];
I have not yet found how to introduce this grid in SpatialDiscretization option.
Can anyone post a simple example?
"DifferenceOrder" -> n, for an integern, one is effectively using piecewise interpolation overn+1point subgrids for the "finite difference derivatives." The use of a Chebyshev grid will hardly make a difference, unlessnis the full order. The"Pseudospectral"setting uses the full order plus the FFT to compute derivatives (the docs imply), which will perform better than the dense finite-difference-derivative matrices. – Michael E2 Oct 06 '19 at 12:33"SpatialDiscretization" -> {"TensorProductGrid", "Coordinates" -> cgrid, "DifferenceOrder" -> points}is mathematically equivalent to"SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> points, "MinPoints" -> points, "DifferenceOrder" -> "Pseudospectral", except that the algorithm used in the former case is less efficient ? – xzczd Oct 07 '19 at 05:12"DifferenceOrder" -> points - 1. (But numerically and with respect to speed,"Pseudospectral"should perform better.) – Michael E2 Oct 07 '19 at 09:46DifferenceOrderforFiniteDifferenceDerivativeseems to bepoints-d, wheredis derivative order. (FiniteDifferenceDerivativeautomatically reduces the order whenDifferenceOrderis too high, though. ) Test:grid = N[CGLGrid[0,5,points],32];d={2,3};dm=NDSolve\FiniteDifferenceDerivative[d, {grid,grid},DifferenceOrder->#][DifferentiationMatrix] &;mat = dm@Pseudospectral;mattest=dm[points-d];Union@Flatten@Chop@Normal[mat-mattest]. (And whenDifferenceOrderis an option forNDSolve`, this should be counted. ) – xzczd Jun 24 '20 at 01:41