0% found this document useful (0 votes)
14 views

Notes 2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Notes 2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Mat1062: Introductory Numerical Methods for

PDE
Mary Pugh

January 13, 2009

1 Ownership
These notes are the joint property of Rob Almgren and Mary Pugh.

2 Boundary Conditions
We now want to discuss in detail methods for solving the linear di usion
equation for u(x, t)
ut = D uxx (1)
We shall suppose that the domain is XL ≤ x ≤ XR , and that initial data
u0 (x) is given at t = 0:

u(x, 0) = u0 (x), X L ≤ x ≤ XR .

and that suitable boundary conditions are given on x = XL and x = XR


for t > 0. We will consider boundary conditions that are Dirichlet, Neu-
mann, or Robin. Dirichlet boundary conditions specify the value of u at
the endpoints:

u(XL , t) = uL (t), u(XR , t) = uR (t)

where uL and uR are speci ed functions of time. Neumann conditions specify


the derivative ux at the endpoints:

ux (XL , t) = uL (t), ux (XR , t) = uR (t).

1
2 Mary Pugh Mat1062 Jan. 13, 2009

Robin boundary conditions specify a linear combination of u and ux at the


endpoints:

a u(XL , t) + b ux (XL , t) = uL (t), c u(XR , t) + d ux (XR , t) = uR (t)

where a, b, c, and d are xed constants usually determined by material


properties.

2.1 Space Discretization


For given XL and XR , we choose a number N. Our grid spacing is
XR − X L
h =
N
and we place grid points at locations

xj = XL + j h, j = 0, 1, . . . , N,

so that x0 = XL and xN = XR . We represent our solution by a vector U(t)


of length N + 1, whose components are

Uj (t) ≈ u xj , t), j = 0, . . . , N.

That is, the jth component of the vector, Uj (t) is supposed to approximate
the PDE's solution at the xj grid point: u(xj , t).
We take the initial data to be an exact sample of the true initial data
u0 (x):

Uj (0) = u0 xj .

Given Duxx ,, a domain [XL , XR ], and boundary conditions, these determine a


linear operator on a function space. We will approximate this linear operator
by a matrix operating on the vector U. This allows us to de ne U(t) as
satisfying a linear ODE Ut = LU, which we can solve by standard methods.
As we will see below, even if the domain is unchanged and the operation
Duxx is unchanged, di erent boundary conditions lead to di erent linear
operators and hence di erent dynamics. This holds in the continuous case
(where the operator is acting on a function space) and in the discretized case
(where the approximating operator is just a matrix). Boundary conditions
matter!
Mat1062 Jan. 13, 2009 Mary Pugh 3

2.2 Dirichlet Boundary Conditions


Let us consider the case of Dirichlet boundary conditions: u(XL , t) = uL (t)
and u(XR , t) = uR (t). There are N+1 meshpoints and U(t) has a component
for each meshpoint. However, the the components U0 (t) and UN (t) are
speci ed by the boundary conditions and so there are only N − 1 unknowns:
U1 (t) . . . UN−1 (t).
From the January 8 notes, we need to approximate uxx (xj , t) for 1 ≤
j ≤ N − 1. This is done with the nite-di erence approximation. In matrix
form this is
  
1 −2 1 U0
 
uxx (x1 ) 1 −2 1   U1 
  
.. ... ... ...   ...  .

1    
.  ≈ 2
 
h 
    
uxx (xN−1 ) 1 −2 1  UN−1 
 

1 −2 1 UN

However, these expressions are not quite what we want. The vector on the
left is of size N − 1 and will determine the interior grid values. The vector
on the right is of size N + 1; it involves both the interior grid values and the
boundary values. We need to express derivatives at the interior grid points
in terms only of interior grid values and the Dirichlet boundary conditions.
This means that we need to eliminate U0 and UN from the above.
Substituting the boundary values u0 = uL (t), uN = uR (t), we approxi-
mate uxx (with Dirichlet boundary conditions on [XL , XR ]) via the inhomo-
geneous linear operator L1

L 1 U = M 1 U + R1 ,

where M1 is a (N−1)×(N−1) tridiagonal matrix and R1 is an (N−1)-vector


containing the boundary data:
   
−2 1 uL (t)
 1 −2 1  0 
   
. . . .. 

1  1
. . . . . . (2)
  
M1 = 2 
h 
,
 R1 (t) = 2 
h  .  
1 −2 1   0 
  

1 −2 uR (t)

R1 depends on time if the boundary conditions do. In practice, it is often


more convenient to store the boundary values in their natural locations at
4 Mary Pugh Mat1062 Jan. 13, 2009

the endpoints of a linear grid, and then the derivatives can be computed by
doing the (N − 1) × (N + 1) multiplication above.
Of course, the matrix M1 never actually exists in the computer, nor do
we ever actually do a matrix multiply as written above: since most entries
are zero, storing the matrix and doing a matrix multiply would be a huge
waste of memory and time. \Multiplication" really means \apply the linear
operator," which we do by taking di erences.

2.3 Neumann Boundary Conditions


For Neumann boundary conditions (ux (XL , t) = uL (t), ux (XR , t) = uR (t))
the values at the endponts, U0 (t) and UN (t), are unknown. Again, we
approximate the di erentiation operation as
 
  U−1
1 −2 1 


 U0
 
uxx (x0 ) 1 −2 1 U1
  
. . . . .
  
1
..  ≈ 2  .. .. .. .. 
   
.
    
h 
  
uxx (xN ) 1 −2 1  UN−1 
 

 
1 −2 1  UN 
UN+1
Note that we've done something strange here. We refer to U−1 and UN+1
which are the values at XL − h and XR + h respectively. These grid points
are not in our domain. They are arti ces introduced to help implement
the nite di erence approximation of uxx at the endpoints. Such points are
often called \ghost points".
The vector on the left is of size N + 1 and will determine the interior
grid values and the boundary grid values. The vector on the right is of size
N + 3; it involves the interior grid values, the boundary grid values, and the
values at the two ghost points. We need to express the right-hand side in
terms of interior grid values and the boundary grid values only. This means
that we need to use the Neumann boundary conditions to determine the
values at the ghost points. This is done as follows:
U1 − U−1
uL (t) = ux (XL , t) ∼ =⇒ U−1 = U1 − 2huL (t)
2h
as a result
U1 − 2U0 + U−1 2U1 − 2U0 2uL (t)
uxx (XL , t) ∼ 2
= − .
h h2 h
Mat1062 Jan. 13, 2009 Mary Pugh 5

Similarly, at the right-hand endpoint


UN+1 − UN−1
0 = ux (XR , t) ∼ =⇒ UN+1 = UN−1 + 2huR (t)
2h
hence
UN+1 − 2UN + UN−1 2UN−1 − 2UN 2uR (t)
uxx (XR , t) ∼ = + .
h2 h2 h
And so, we approximate uxx (with Neumann boundary conditions on
[XL , XR ]) with the
inhomogeneous linear operator

M 2 U + R2 ,

where M2 is a (N + 1) × (N + 1) tridiagonal matrix and R2 is an N + 1-vector


containing the boundary data:
   
−2 2 −uL (t)
 1 −2 1 0
   
. . . .
  
1  2
. . . . . . . (3)
   
M2 = 2 
h 
,
 R2 (t) = 
h . 

1 −2 1  0
 
  
2 −2 uR (t)

A natural question to ask is why we used centered nite di erences


above to approximate ux (XL ) and ux (XR ) rather than using a left-di erence
for ux (XL ) and a right-di erence for ux (XR ):
U0 − U−1 UN+1 − UN
0 = ux (XL ) ∼ 0 = ux (XR ) ∼
h h
We will revisit this question when we discuss the convergence and accuracy
of our scheme.

2.4 Robin Boundary Conditions


We handle Robin boundary conditions (a u(XL , t) + b ux (XL , t) = uL (t),
c u(XR , t) + d ux (XR , t) = uR (t)) in the same manner that we handle Neu-
mann boundary conditions: by introducing ghost grid points the values at
which are then determined from the boundary conditions.
U1 − U−1
uL (t) = a u(XL , t) + b ux (XL , t) ∼ a U0 + b
2h
2ah 2huL (t)
=⇒ U−1 = U1 + U0 −
b b
6 Mary Pugh Mat1062 Jan. 13, 2009

as a result
U1 − 2U0 + U−1 2U1 − (2 − 2ah/b)U0 2uL (t)
uxx (XL , t) ∼ 2
= − .
h h2 bh
Similarly,
UN+1 − UN−1
uR (t) = c u(XR , t) + d ux (XR , t) ∼ c UN + d
2h
2ch 2huR (t)
=⇒ UN+1 = UN−1 − UN +
d d
hence
U1 − 2U0 + U−1 2UN−1 − (2 + 2ch/d)UN 2uR (t)
uxx (XR , t) ∼ 2
= + .
h h2 dh
In this way, we can approximate uxx (with Robin boundary conditions
on [XL , XR ]) as the inhomogeneous linear operator

= M 3 U + R3

where M2 is a (N + 1) × (N + 1) tridiagonal matrix:


   
−2 + 2ah/b 2 −uL (t)/b
1 −2 1 0
   
. . . ..
   
1  2
.. .. ..
 
M3 = 2 
h 

 , R3 (t) = h 
  . .

1 −2 1 0
  
   
2 −2 − 2ch/d uR (t)/d
(4)
As a reality check, note that if a = c = 0 and if b = d = 1 then this matrix
is the same matrix as for the Neumann boundary conditions.

2.5 Summary
The spatial derivative operator


 on [XL , XR ]
Lu = Duxx
u(XL , t) = uL (t)


u(X , t) = u (t)
R R
Mat1062 Jan. 13, 2009 Mary Pugh 7

has the discrete approximation LU = MU + R where M = DM1 and


R = DR1 with M1 and R1 given in (2). Similarly, the spatial derivative
operator 

 on [XL , XR ]
Lu = Duxx
ux (XL , t) = uL (t)


u (X , t) = u (t)
x R R

has the discrete approximation LU = MU + R where M = DM2 and


R = DR2 with M2 and R2 given in (3). Finally, the spatial derivative
operator 

 on [XL , XR ]
Lu = Duxx
au(XL , t) + bux (XL , t) = uL (t)


cu(X , t) + Du (X , t) = u (t)
R x R R

has the discrete approximation LU = MU + R where M = DM3 and


R = DR3 with M3 and R3 given in (4).
In all three cases, we have L which is an ane linear operator. But the
three matrices M1 , M2 , and M3 are all di erent from one another. They
will have di erent eigenvalues and eigenvectors. All of the eigenvalues of M1
and M2 will be either zero or negative. The matrix M3 can have positive
eigenvalues. They correspond to modes that grow exponentially in time,
rather than decaying | this shows how powerful boundary e ects can be!

You might also like