In order to solve for as few unknowns as possible, we use a Chebyshev discretization of the domain. The core idea is to formulate collocation equations at the grid points based on discrete approximations of (13.4.2) and (13.4.3). If the PDE is nonlinear, then these equations are also nonlinear and are to be solved by a quasi-Newton iteration. Function 13.4.1 is our implementation.
Function 13.4.1 first defines the discretization and then computes all the values of g at the boundary nodes. It uses Function 4.6.3 as the nonlinear solver, and it translates back and forth between vector and grid shapes for the unknowns. After the discrete PDE is collocated at the grid points, the boundary terms are replaced by the boundary residual.
Lines 38–41, which produce the value returned by Function 13.4.1, provide a function that evaluates the numerical solution anywhere in the domain, as is explained next.
A Chebyshev grid is clustered close to the boundary of the domain, and the grid values may be accurate even for modest grid sizes. As a result, simple piecewise interpolation to evaluate off the grid, as is done by plotting routines, may be unacceptably inaccurate. Instead, we should use the global polynomial interpolation that is foundational to the Chebyshev spectral method.
Let U be a matrix of solution values on the Chebyshev grid, defining a function u(x,y), and let (ξ,η) be a point where we want to evaluate u(x,y). Column uj of the grid matrix represents values spanning all the xi while y is fixed at yj. Therefore, we can define an interpolating polynomial pj(x) based on the values in uj.
Now let vj=pj(ξ) for j=1,…,n. The vector v is a discretization of u(ξ,y) at the Chebyshev nodes in y. It defines an interpolating polynomial q(y), and finally we have u(ξ,η)=q(η). You can think of the total process as reducing one dimension at a time through the action of evaluating a polynomial interpolant at a point.
The function returned by Function 13.4.1 performs interpolation as described above, using a helper function chebinterp (not shown). The helper performs the evaluation of a polynomial interpolant in one variable using a modified implementation of Function 9.2.1 that exploits the barycentric weights for Chebyshev nodes given in (9.3.3).[1]
Solve the equation on [−1,1]2 with boundary value u(x,y)=tanh(y−2x), and make a surface plot of the result. (Hints: Don’t try to rewrite the PDE. Instead, modify Function 13.4.1 so that ϕ is called with arguments (U,Dx,Dy), and compute the PDE in the form given. Also, since convergence is difficult in this problem, use the boundary data over the whole domain as the initial value for levenberg.)
where ∂n∂ is the derivative in the direction of the outward normal. Either condition can be used at a corner point. (Hint: Define index vectors for each side of the domain.) Apply your solver to the PDE Δu+sin(3πx)=0 on [0,1]2, and make a contour plot of the solution. Why do the level curves intersect two of the sides only at right angles?
The interpolation algorithm in Function 13.4.1 is inefficient when u is to be evaluated on a finer grid, as for plotting. A more careful version could re-use the same values vj=pj(ξ) for multiple values of η.
Pelesko, J. A., & Driscoll, T. A. (2006). The Effect of the Small-Aspect-Ratio Approximation on Canonical Electrostatic MEMS Models. Journal of Engineering Mathematics, 53(3–4), 239–252. 10.1007/s10665-005-9013-2