Skip to content
Projects

Solver backends

The equations of patchwork.solvers.backends, declared on the code that implements them and checked by the tests.

FFTSolver

classsource

The FFT solve of one uniform system (see FFTBackend).

scaled
V−1A ϕ=V−1b,V−1A=−∑aδa2 (the difference Laplacian)V^{-1} A\,\phi = V^{-1} b, \qquad V^{-1} A = -\sum_a \delta^2_a \ \text{(the difference Laplacian)}
dirichlet
λk=4h2sin⁡2πk2n,k=1,…,n−1 (DST-I)\lambda_k = \frac{4}{h^2}\sin^2\frac{\pi k}{2n}, \quad k = 1, \dots, n-1 \ \text{(DST-I)}
neumann
λk=4h2sin⁡2πk2n,k=0,…,n (DCT-I)\lambda_k = \frac{4}{h^2}\sin^2\frac{\pi k}{2n}, \quad k = 0, \dots, n \ \text{(DCT-I)}
periodic
λk=4h2sin⁡2πkn,k=0,…,n−1 (FFT);λk=∣2π fftfreq(n,h)∣2 (spectral)\lambda_k = \frac{4}{h^2}\sin^2\frac{\pi k}{n}, \quad k = 0, \dots, n-1 \ \text{(FFT)}; \qquad \lambda_k = |2\pi\,\texttt{fftfreq}(n, h)|^2 \ (\texttt{spectral})
solve
ϕ^k=b^k∑aλka,ϕ^0=0 where the sum vanishes\hat\phi_\mathbf{k} = \frac{\hat b_\mathbf{k}}{\sum_a \lambda_{k_a}}, \qquad \hat\phi_\mathbf{0} = 0 \text{ where the sum vanishes}
Assumes
  • one level that fills its rectangle, Cartesian, no bodies; both faces of a non-periodic axis of one kind
  • a singular operator gives the solution of zero volume-weighted mean; spectral=True is not the assembled operator
  • O(Nlog⁡N)O(N \log N) per solve, no factorization

LUBackend

classsource

A direct LU factorization of the whole operator, on every rank.

tridiagonal
A=LDL⊤ (pttrf/pttrs, equal off-diagonals),PA=LU (gttrf/gttrs)A = L D L^\top \ (\texttt{pttrf/pttrs}, \text{ equal off-diagonals}), \qquad P A = L U \ (\texttt{gttrf/gttrs})
sparse
PrAPc=LU,Pc minimum degree on the pattern of A+A⊤P_r A P_c = L U, \qquad P_c \text{ minimum degree on the pattern of } A + A^\top
Assumes
  • the whole matrix on every rank; a line without a periodic seam is tridiagonal
  • SuperLU in symmetric mode: diagonal pivots, as the ordering assumes (the operator is diagonally dominant)
  • refuses a singular operator (no Dirichlet face, no body)
References