Finite Difference Methods
Finite Difference Methods
Dierence
Methods
(FDMs)
1
1st-order
Approxima9on
Recall Taylor series expansion:
Forward difference:
Backward difference:
Central difference:
2nd-order
Approxima9on
Forward difference:
Backward difference:
Central difference:
2D
Ellip9c
PDEs
The general elliptic problem that is faced in 2D is to solve
(14.1)
where
is the Laplacian
is gradient of u in x direction
is gradient of u in y direction
% Define domain
a = 0; b = 1;
c = 0; d = 1;
(14.5)
where
2D
Poisson
Equa9on
(Dirichlet
Problem)
The local truncation error satisfies
where .
(14.6)
(14.7)
The difference replacement (14.7) is depicted as in the five-
point stencil:
2D
Poisson
Equa9on
(Dirichlet
Problem)
Step 3: Solve the linear system of algebraic equations (14.7)
to get the approximate values for the solution at all grid
points.
Arranging in
matrix-vector
form yields:
2D
Poisson
Equa9on
(Dirichlet
Problem)
The third column gives
Right
BC
2D
Poisson
Equa9on
(Dirichlet
Problem)
For general case, we focus on the equations on the i-th
column of the grid. Since the unknowns in this column are
linked only to unknowns on the two neighboring columns,
these can be expressed as
% Build matrix B
r2 = 2*ones(M-1,1);
r = -ones(M-2,1);
B = diag(r2,0) + diag(r,1) + diag(r,-1);
% Sparse matrix B
B = sparse(B);
function f = poisson_rhs(X,Y)
f = 20*cos(3*pi*X).*sin(2*pi*Y);
gives us
Rearrange to get
(14.9)
Neumann
Problem
Along the boundary where (note the
negative sign appropriate for the outward normal on this
boundary), when this is applied at the grid point and
we neglect the remainder term, we obtain
or
(14.10)
This approximation involves the value of U at the fictitious
grid point which lies outside the domain D.
We write the approximation (14.7) at the boundary points
(14.11)
Neumann
Problem
We may eliminate between (14.10) and (14.11) to
obtain a difference formula with a four point stencil by
rearranging the formula in (14.10) into
(14.12)
and substitute this into (14.11) to get
or
(14.13)
Neumann
Problem
Along the boundary or at where now the
outward normal is positive or , we obtain
(14.14)
where we have substitution for the fictitious grid point
that lies outside the domain D:
(14.15)
Similar to the left boundary, the approximation (14.7) at the
right boundary becomes
(14.16)
Neumann
Problem
=
c44ous
point
Neumann
Problem
Equation (14.13) also holds with at the corner
where we also have (note the positive sign)
which is approximated by
(14.17)
(14.18)
Neumann
Problem
For the bottom point at where the outward normal
becomes , the approximation is represented by
(14.20)
Neumann
Problem
In summary, for Neumann BC we need approximation for
for the corner points, which, from
where
Example
Solve the BVP defined by: