MTH3007b Lecture 10
Me, in the lecture
zzzzz…
This session moves from 1D time-dependent PDEs to a 2D steady-state problem: the Laplace equation. We solve it iteratively using Liebmann’s method (Gauss-Seidel applied to PDEs) and cover the Python array/matrix tools needed to implement it.
The 2D Laplace Equation
The 2D Laplace equation is the steady-state condition applied to the 2D diffusion equation:
Finite Difference Discretisation
Applying the centred second-derivative stencil in both and on a uniform grid with spacing :
When , this simplifies to the Laplacian difference equation:
Rearranging gives the update rule for each interior point:
Liebmann’s Method
Liebmann’s method is Gauss-Seidel iteration applied to the 2D Laplace equation. Starting from an initial guess (e.g. all zeros at interior points, with boundary values fixed), we repeatedly update each interior point using the formula above until the solution converges.
Convergence Criterion
Iteration continues until the maximum change over all interior points falls below a tolerance :
A typical value is .
Convergence is guaranteed because the resulting matrix is diagonally dominant: the diagonal entry has magnitude greater than the sum of the absolute values of the off-diagonal entries - just at the boundary of strict diagonal dominance, but the fixed boundary conditions ensure convergence.
Computing the Maximum Error
Two equivalent approaches:
The np.amax version is more concise and vectorised.
Algorithm
- Create two 2D arrays
u_xyandunew_xyof size , initialised to zero. - Set Dirichlet boundary conditions on all four edges of
u_xy. - Copy
u_xytounew_xy. - Loop over all interior points ; update
unew_xy[i,j]using the four neighbours fromu_xy. - Compute
max_error = np.amax(np.abs(unew_xy - u_xy)). - Copy
unew_xyintou_xy(useu_xy = 1.0*unew_xyto copy by value). - Repeat from step 4 until
max_error < epsilon. - Plot the result with
matplotlib’splot_surface.
Arrays and Matrices in Python
Creating and Indexing
Array copying
B = Adoes not copy an array - it creates an alias. BothAandBthen point to the same data. UseB = 1.0*AorB = A.copy()to get an independent copy.
Pre-Lecture Notes from University Notes
- 2D Laplace equation: ; steady-state condition on 2D diffusion.
- Finite difference discretisation gives: .
- Liebmann update: .
- Iterate until (e.g. ).
- Convergence guaranteed by diagonal dominance of the system matrix.
- Max error:
np.amax(np.abs(unew_xy - u_xy))is the vectorised approach. - Array copy:
B=1.0*AorB=A.copy(); neverB=Afor independent copies. - Next session: revision - feedback on Python implementations and a list of practice exercises.