The Galerkin method is a numerical technique that transforms boundary value problems, particularly partial differential equations (PDEs), into a system of linear algebraic equations by projecting the problem onto a finite-dimensional subspace.
Steps of the Galerkin Method
Problem Setup:
Start with the weak form of the differential equation integrated against a test function.
Choice of Basis Functions:
Select basis functions \( \{\phi_i\}_{i=1}^n \) that satisfy the boundary conditions.
Approximation of the Solution:
Assume \( u(x) \approx u_n(x) = \sum_{i=1}^n c_i \phi_i(x) \).
Galerkin Projection:
Ensure the residual is orthogonal to the span of the basis functions:
\[
\int \text{Residual} \cdot \phi_j \, dx = 0 \quad \text{for all } j.
\]
Example: One-Dimensional Poisson Equation
Consider the problem
\[
-u''(x) = f(x), \quad u(0) = u(1) = 0.
\]
on the interval \([0,1]\).
Step 1: Weak Form
Multiply by a test function \( v(x) \) and integrate by parts to get:
\[
\int_0^1 u'(x) v'(x) \, dx = \int_0^1 f(x) v(x) \, dx.
\]
Step 2: Discretization
Choose linear basis functions and assume:
\[
u(x) \approx u_n(x) = \sum_{i=1}^n c_i \phi_i(x).
\]
Step 3: Galerkin Projection
Insert the approximation into the weak form using basis functions as test functions:
\[
\sum_{i=1}^n c_i \int_0^1 \phi_i'(x) \phi_j'(x) \, dx = \int_0^1 f(x) \phi_j(x) \, dx \quad \text{for all } j.
\]
Step 4: Matrix Formulation
Define the stiffness matrix \( \mathbf{A} \) and load vector \( \mathbf{b} \) as follows:
\[
A_{ij} = \int_0^1 \phi_i'(x) \phi_j'(x) \, dx, \quad b_j = \int_0^1 f(x) \phi_j(x) \, dx.
\]
This leads to the linear system:
\[
\mathbf{Ac} = \mathbf{b},
\]
where \( \mathbf{c} \) is the vector of coefficients.
\subsection*{Example: Very simple and concrete}
Take a differential equation
\[
\frac{d^2y}{dx^2} + x+ y = 0 , 0 \le x \le 1
\]
with boundary condition \(y(0) = y(1) = 0 \)
Example:
Step 1
Take a trail solution \(y(x) = a_0+a_1x+a_2 x^2\). Always take the number of constants one greater than the highest differential power. Here we have second order differential. So, we take \( 2+1=3\) constants \(a_0,a_1,a_2\).
Apply boundary conditions \( x=0,y=0 \). This leads to \( a_0 =0 \). Then apply boundary condition \(x = 1, y = 0\) leads to \(a_1 = -a_2 \). Then the trail function becomes \( y(x) = a_2(x^2-x) \). This is one parameter solution - namely \( a_2 \).
Step 2
Compute Weighting function
\[
W(x) = \frac{\partial{y}}{a_2} = x^2 - x
\]
Step 3
Compute domain residuals. Simply substitute the trail function into original differential equation.
\begin{align*}
R_d &= \frac{d^2y}{dx^2} + x + y \\
R_d(x) &= \frac{d a_2(x^2-x)}{d x^2} + x + a_2(x^2-x)
\end{align*}
Step 4
Minimization of domain residual:
\[
\int_0^1 W(x) R_d(x) dx = 0
\]
Compute minimization. You will get \( a_2 = -\frac{5}{98} \).
Then the solution is \( y(x) = -\frac{5}{98}(x - x^2) \).
Other formulations
For the differential equation \( -u{''} = f \), we can write this as first order by setting
\[
\sigma = -u' , \sigma' = f
\]
The pair \( \sigma,f \) can be characterized variationally as unique critical point of the functional
\[
I(\sigma,u) = \int_{-1}^1 (\frac{1}{2}\sigma^2 - u \sigma') dx + \int_{-1}^1 fu dx
\]
over \( H^1(-1,1) \times L^2(-1,1) \)
Note if we take the original \(J(x)\) the Energy functional and substitute, we get above.
\begin{align*}
J(u) &= \frac{1}{2}\int_{-1}^1 |u'(x)|^2 dx - \int_{-1}^1f(x)u(x)dx \\
&= \frac{1}{2}\int_{-1}^1\sigma^2 - \int_{-1}^1 f(x) u(x) dx \\
&= \frac{1}{2}\int_{-1}^1\sigma^2 + f(x)\int_{-1}^1u(x)dx - \int_{-1}^1\int_{-1}^1u(x) dx f'(x) dx \\
&= \frac{1}{2}\int_{-1}^1\sigma^2 + 0 \\
&= \frac{1}{2}\int_{-1}^1\sigma^2 + \int_{-1}^1f(x)u(x)dx - \int_{-1}^1f(x)u(x)dx \\
&= \int_{-1}^1\frac{1}{2}\sigma^2 - f \sigma' + \int_{-1}^1f(x)u(x)dx
\end{align*}
No comments:
Post a Comment