From 5807a685b63c2077c25393a1a03b497d0679de9d Mon Sep 17 00:00:00 2001 From: Felix Spanier Date: Thu, 10 Nov 2022 14:26:33 +0100 Subject: [PATCH] NumMeth 22: More Poisson --- nummeth-ws22/skript.tex | 90 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 89 insertions(+), 1 deletion(-) diff --git a/nummeth-ws22/skript.tex b/nummeth-ws22/skript.tex index df2ca3e..f83af65 100644 --- a/nummeth-ws22/skript.tex +++ b/nummeth-ws22/skript.tex @@ -1317,7 +1317,95 @@ However, by taking advantage of the triangular form of $L_*$, the elements of $x x^{(k+1)}_i = \frac{1}{a_{ii}} \left(b_i - \sum_{j=1}^{i-1}a_{ij}x^{(k+1)}_j - \sum_{j=i+1}^{n}a_{ij}x^{(k)}_j \right),\quad i=1,2,\dots,n. \end{align} -How does this very theoretical approach now look like when applied to the Poisson equation +How does this very theoretical approach now look like when applied to the Poisson equation? In 2D we can formulate the finite-difference equation as +\begin{align} + \frac{u_{ij+1}-2u_{ij}+u_{ij-1}}{(\Delta x)^2} + \frac{u_{i+1j}-2u_{ij}+u_{i-1j}}{(\Delta x)^2} = f_{ij} +\end{align} +An iterative solution looks now like +\begin{align} + u_{ij}^{n+1} = \frac{1}{4}(u_{ij+1}^n + u_{i+1j}^n + u_{ij-1}^{n+1} + u_{i-1j}^{n+1} + (\Delta x)^2 f_{ij}) +\end{align} +This Gauss-Seidel algorithm uses updated values of the solution $u$. This is somewhat advantageous in terms of memory usage, but otherwise pretty slow. + +A slighlty updated version of the Gauss-Seidel scheme is the \emph{Red-Black} scheme: Points are alternating red or black. The update runs over red points first, after all red points are updated, the black points will be updated. The main advantage is that the update only relies on old points (which allows for parallelization). + +While the scheme is extremely simple, it is also horribly slow. One way to speed up things is the \emph{successive over-relaxation}. For +\begin{align} + A x = f \Rightarrow A = D + L + U +\end{align} +Where $D$ is the diagonal matrix and $L$ and $U$ are the strictly lower and upper matrix respectively. The relaxation now looks like +\begin{align} + (D+\omega L) x = \omega f -(\omega U+(\omega-1)D) x +\end{align} +Where $\omega > 0$ with $\omega=1$ being the Gauss-Seidel case +\begin{align} + x^{k+1} = (D+\omega L)^{-1}(\omega f - (\omega U + (\omega -1) D)x^k) +\end{align} +Making use of matrix structure then yields +\begin{align} + x_i^{k+1} = (1-\omega) x_i^k + \frac{\omega}{a_{ii}}(f_i - \sum{j>i} a_{ij}x_j^k-\sum_{j1$ yields faster convergence and $\omega<1$ yields convergence safely. + +Another scheme used typically is the Jacobi scheme +\begin{align} + A x =f \Rightarrow A = D + R\\ + x^{k+1} = D^{-1} (f-R x^k) +\end{align} + +\subsection{Multigrid} + +If one looks at previous methods one will notice that methods like Gauss-Seidel are correct on smallest scale, but tend to deviate from the correct solution when larger scales are involved. This is due to the fact that the update only relies on the neighbouring points. + +Before we discuss a strategy to circumvent this problem we need to discuss some terms. We are looking for the correct solution $u$ (which we may or maybe not reach) and approximate this by the iteration $u^n$. The difference these two is the error +\begin{align} + e = u^n - u +\end{align} +Again: If we knew the error we would also know the real solution. We will never know the real solution\dots + +What we know is the residual +\begin{align} + r = f - A u^n +\end{align} +But since for the exact solution we know +\begin{align} + A u = f +\end{align} +we have +\begin{align} + f - A u^n = A (u-u^n ) = r +\end{align} + +Coming back to the original problem: How can we improve our solution on larger levels? One is the so-called Multigrid scheme: Instead of using one fixed grid the data is sampled grids with different resolutions. The ``original'' grid is the finest grid and data is coarsened from there on. + +Using the notation ``superscript describes the coarseness of the grid'' (i.e., $u^n$ is an approximate solution on the finest grid, while $u^{2n}$ is the approximate solution on a grid with double spacing) we need the following ingredients +\begin{itemize} + \item A restriction matrix $R^h_{2h}$ transfers vectors from the fine grid to the coarse grid. + \item The return step to the fine grid is by an interpolation matrix $I = I^h_{2h}$. +\end{itemize} + +Possible interpolation: +\begin{align} + u_{2i,2j} = v_{i,j},\quad u_{2i,2j+1} = \frac{1}{2}(v_{i,j}+v_{i,j+1} +\end{align} +The restriction is essentially the inversion of this. + +A simple two grid v-cycle looks like this +\begin{enumerate} + \item Iterate on $A^h u = b^h$ to reach $u^h$ (say 3 Jacobi or Gauss-Seidel steps). + \item Restrict the residual $r^h = b^h − A^h u^h$ to the coarse grid by $r^{2h} = R^{2h}_h r^h$. + \item Solve $A^{2h} e^{2h} = r^{2h}$ (or come close to $e^{2h}$ by 3 iterations from $e = 0$). + \item Interpolate $e^{2h}$ back to $e^h = I^h_{2h} e_{2h}$. Add $e^h$ to $u^h$. + \item Iterate 3 more times on $A^h u = b^h$ starting from the improved $u^h + e^h$ +\end{enumerate} +Here we solve the Poisson equation on a fine grid and one coarser grid. This scheme can be extended to ever finer grids. + +\begin{figure} + \begin{center} + \pgfimage[width=.7\textwidth]{fig_chapter3/multigrid} + \end{center} + Grapical representation of the multigrid cycle +\end{figure} \chapter{Particle-in-Cell}