Home > Python > Partial Differential Equations

Ch. 17.2 Laplace Equation

Chapters Index
Program 1

Laplace Equation

Python 3.11 Ready

                                
Click "Run Code" to execute script and render figures.

Mathematical Problem Formulation

Laplace's equation on a square grid

$$ \frac{\partial^2 U}{\partial x^2} + \frac{\partial^2 U}{\partial y^2} = 0 $$

Dirichlet Boundary conditions are:

  • Left B.C.: \( U(0, y) = \frac{y}{1 + y^2}, \, \text{for} \, 0 < y < 1 \)
  • Right B.C.: \( U(1, y) = \frac{y}{4 + y^2}, \, \text{for} \, 0 < y < 1 \)
  • Bottom B.C.: \( U(x, 0) = 0, \, \text{for} \, 0 < x < 1 \)
  • Top B.C.: \( U(x, 1) = \frac{1}{(1 + x^2) + 1}, \, \text{for} \, 0 < x < 1 \)

Exact Analytical Solution:

$$ U_A = \frac{y}{(1 + x^2) + y^2} $$

Theoretical Background & Computational Mechanics

Laplace's Equation

Using the iterative solver (such as the Gauss-Seidel method), we begin with Laplace's equation in two dimensions:

\[ \frac{\partial^2 U}{\partial x^2} + \frac{\partial^2 U}{\partial y^2} = 0. \]

Discretization of Laplace's Equation

The 2D Laplace equation is discretized using a finite difference method. In the code, this is done on a uniform grid, where the second derivatives with respect to \(x\) and \(y\) are approximated using central differences. Let's break this down.

Second derivative with respect to \(x\):

\[ \frac{\partial^2 U}{\partial x^2} \approx \frac{U_{i+1,j} - 2U_{i,j} + U_{i-1,j}}{(\Delta x)^2} \] where \(U_{i,j}\) is the value of \(U\) at grid point \((i,j)\) and \(\Delta x = \frac{L_x}{n_x - 1}\).

Second derivative with respect to \(y\):

\[ \frac{\partial^2 U}{\partial y^2} \approx \frac{U_{i,j+1} - 2U_{i,j} + U_{i,j-1}}{(\Delta y)^2} \] where \(\Delta y = \frac{L_y}{n_y - 1}\).

Discretized Laplace Equation

The discrete form of the Laplace equation (by adding the two central differences) becomes:

\[\small \frac{U_{i+1,j} - 2U_{i,j} + U_{i-1,j}}{(\Delta x)^2} + \frac{U_{i,j+1} - 2U_{i,j} + U_{i,j-1}}{(\Delta y)^2} = 0. \]

To simplify, we assume the grid is uniform, meaning \(\Delta x = \Delta y = h\). This gives:

\[\small \frac{U_{i+1,j} - 2U_{i,j} + U_{i-1,j}}{h^2} + \frac{U_{i,j+1} - 2U_{i,j} + U_{i,j-1}}{h^2} = 0. \]

Multiplying through by \(h^2\) and solving for \(U_{i,j}\):

\[ U_{i,j} = \frac{1}{4} \left( U_{i+1,j} + U_{i-1,j} + U_{i,j+1} + U_{i,j-1} \right). \]

Recurrence Relation

The recurrence relation used in the iterative solver is derived from the above discretized equation. The updated value of \(U_{i,j}\) is obtained by averaging the neighboring points:

\[ U_{i,j}^{(new)} = \frac{1}{4} \left( U_{i+1,j}^{(old)} + U_{i-1,j}^{(old)} + U_{i,j+1}^{(old)} + U_{i,j-1}^{(old)} \right). \]

Theoretical Principles & Computational Physics Guide

Laplace Equation: Differential Equations & Dynamical Simulation

Dr. Alorika Chatterjee & Dr. Anirban Shaw Science & Physics Learners Python 3 / NumPy / SciPy

1. Core Principles & Theoretical Framework

Dynamical Evolution: Solves differential equations governing kinematics, planetary orbits, electrical circuits, and wave propagation.
Step-by-Step Stepping: Advances continuous state vectors forward in discrete time intervals $\Delta t$ using slope estimates.
Conservation Laws: Evaluates preservation of physical invariants (total energy, angular momentum) across long integration horizons.

2. Mathematical Formulation & Algorithmic Pipeline

Vector initial value problem and numerical state advancement:

$$ \frac{d\mathbf{y}}{dt} = \mathbf{f}(t, \mathbf{y}), \quad \mathbf{y}(t_0) = \mathbf{y}_0 \implies \mathbf{y}_{n+1} = \mathbf{y}_n + \Delta t \cdot \mathbf{\Phi}(t_n, \mathbf{y}_n, \Delta t) $$

3. Numerical Mechanics & Implementation Logic

  • Coupled Reduction: Convert $n$-th order ODEs into systems of $n$ coupled first-order equations.
  • Intermediate Slopes: Compute weighted intermediate derivatives ($k_1, k_2, k_3, k_4$ in RK4).
  • State Update: Advance state variables simultaneously and verify energy/phase invariants.

4. Relevant Computational Practice Exercises

Exercise 1
Solve the differential equation for Laplace Equation over 1000 time steps and plot state coordinates vs time.
Exercise 2
Compare numerical solution stability for small vs large step sizes $h = \Delta t$.
Exercise 3
Plot phase space trajectory demonstrating physical stability or damping attractors.
Standard Literature & References:
  • John R. Taylor, "Classical Mechanics", University Science Books (2005).
  • Mark Newman, "Computational Physics", University of Michigan (2013).