Boundary Conditions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Boundary Conditions

A 1-d Example. Recall that when we applied finite difference discretization to the 1-d
Poisson equation on the unit interval

d2 u
= f (x),
dx2

0<x<1

we obtained the difference equation


ui1 + 2ui ui+1 = h2 fi ,

(1)

where ui u(xi ). Eqn (1) was derived earlier with equispace grid points xi = ih, i =
1, . . . , N and with homogeneous Dirichlet boundary conditions. By setting u0 = u(0) = 0
and uN +1 = u(xN +1 ) = u(1) = 0, we obtained from (1) the matrix-vector equation
Au = b
where A = tridiag(1, 2, 1) is N N and u and b have entries
[u]i = ui ,

[b]i = h2 fi ,

i = 1, . . . , N.

Nonhomogeneous Dirichlet Boundary Conditions. Suppose u(0) = and u(1) = .


Setting u0 = u(0) = and uN +1 = u(1) = and substituting into eqn (1), we obtain for
i = 1,
2u1 u2 = h2 f1 + ,
and for i = N ,
2uN 1 uN = h2 fN + .
The difference equation remains unchanged for indices i = 2, . . . , N 1. Thus the righthand-side vector b now has entries

h2 f1 + , if i = 1,
if i = 2, . . . , N 1,
[b]i = h2 fi ,

2
h fN + , if i = N.

The coefficient matrix A remains unchanged, and the length of the vector u remains the
same.
Neumann Boundary Conditions. Suppose the left boundary condition is Neumann,

du
(0) = .
dx

The minus sign before the derivative is chosen for consistency with the 2-d case below. There
are several candidates for the difference approximation to apply to the derivative in this case,
1

but we take the centered difference approximation about x0 = 0 because it is second order
accurate (Eqn (1) is also based on a second order approximation). This yields
u(x1 ) u1
= + O(h2 ).
2h

(2)

Note that we made use of a ghost grid point, x1 = h. If we drop the O(h2 ) error term,
substitue the approximations ui u(xi ), and solve for the approximation at the ghost grid
point, we obtain
u1 = u1 + 2h .
(3)
We next add the grid point x0 = 0 to the computational grid h = {ih | i = 1, . . . , N }.
Applying the difference equation (1) for index i = 0 and substituting eqn (3) gives
2u0 2u1 = 2h + h2 f0 .

(4)

This gives rise to several changes in the system Au = b. The length of the vectors u and
b is now N + 1 rather than N , and the matrix A is N + 1 N + 1. The vector b now has
entries
(
h2 f0 + 2h, if i = 0,
[b]i =
h2 f i ,
if i = 1, . . . , N.
The matrix A is still tridiagonal, but the entries on the superdiagonal are no longer constant.
In particular,
[A]0,1 = 2,
[A]i,i+1 = 1 for i = 1, . . . , N 1.
(5)
The entries of the main diagonal are all 2, and the subdiagonal entries are all -1.
Neumann Boundary Conditions in 2-d. To illustrate, consider the 2-d Poisson equation
on the unit square with Neumann boundary conditions on the left boundary,
u n =

u
= (0, y),
x

0 < y < 1,

(6)

and homogeneous Dirichlet boundary conditions on the rest of the boundary. Recall the finite
difference approximation to the Poisson equation on a regular grid with uj,k u(jh, kh),
4uj,k uj1,k uj+1,k uj,k1 uj,k+1 = h2 f (xj , yk ).

(7)

In a manner analogous to the 1-d case, we expand the computation grid,


h = {(xj , yk ) | j = 0, . . . , Nx , k = 1, . . . , Nx },
and we obtain from the partial derivative in eqn (6)
u1,k u1,k = 2h 0,k ,

k = 1, . . . , Nx .

Taking the index j = 0 in eqn (7) and substituting u1,k from eqn (8) gives
4u0,k 2u1,k u0,k1 u0,k+1 = h2 f0,k + 2h0,k ,
2

k = 1, . . . , Nx .

(8)

For indices j = 1, . . . , Nx , eqn (7) holds.


With lexicographical column ordering of the unknown (the index j varies most rapidly),
the resulting system Au = b has an Nx Nx block tridiagonal representation,
A = blocktridiag(I, T, I),
where the blocks are now Nx + 1 Nx + 1. The I denotes the negative identity matrix, with
1 on the main diagonal and 0 elsewhere. The Nx + 1 by Nx + 1 matrix T is tridiagonal.
Its superdiagonal entries are the same as in the 1-d case; see eqn (5). The main diagonal
entries are all 4, and the subdiagonal entries are all 1.

Exercises
1. Outline the finite difference implementation of Poissons equation on the unit interval
in 1-d with Neumann boundary conditions at the right endpoint. Provide explicit
formulas for the entries of the coefficient matrix A and the right-hand-side vector b.
2. Derive a second order accurate finite difference approximation to Robin, or third kind,
boundary conditions in one space dimension. Provide formulas for the entries of the
coefficient matrix A and the right-hand-side vector b for Poissons equation on the unit
interval with Robin boundary conditions on the left boundary.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy