spectral.solve_polar_bvp#

spectral.solve_polar_bvp(r1: float, r2: float, Nr: int, Ntheta: int) tuple[ndarray, ndarray, ndarray, ndarray][source]#

Solve Exercise B: Laplace’s equation in polar coordinates using mixed spectral collocation.

Solves:

\[\nabla^2 \phi = \frac{1}{r}\frac{\partial}{\partial r} \left(r \frac{\partial \phi}{\partial r}\right) + \frac{1}{r^2}\frac{\partial^2 \phi}{\partial \theta^2} = 0\]

on the domain \((r, \theta) \in [r_1, r_2] \times [0, 2\pi]\).

Parameters:
r1float

Inner radius

r2float

Outer radius

Nrint

Number of radial collocation points

Returns:
Phinp.ndarray

Analytical solution on the grid

Phi_hatnp.ndarray

Numerical solution on the grid

Rsnp.ndarray

Radial meshgrid

Thetanp.ndarray

Angular meshgrid

Notes

Uses mixed spectral collocation:

  • Legendre-Gauss quadrature for the radial direction \(r\)

  • Fourier collocation for the periodic angular direction \(\theta\)

The analytical solution is:

\[\phi(r,\theta) = V_\infty \left(r + \frac{r_1^2}{r}\right)\cos(\theta)\]

with \(V_\infty = 1\).

The system is vectorized using the Kronecker product identity:

\[\text{Vec}(A U C) = (C^T \otimes A) \text{Vec}(U)\]

Examples using spectral.solve_polar_bvp#

Polar BVP - Data Generation

Polar BVP - Data Generation