spectral.solve_bvp#
- spectral.solve_bvp(r1: float, r2: float, Nr: int, Ntheta: int) tuple[ndarray, ndarray, ndarray, ndarray]#
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:
- Returns:
- Phi
np.ndarray Analytical solution on the grid
- Phi_hat
np.ndarray Numerical solution on the grid
- Rs
np.ndarray Radial meshgrid
- Theta
np.ndarray Angular meshgrid
- Phi
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)\]