Information Technology Reference
In-Depth Information
Algorithm 7.2
Diffusion Equation with u .0; t /
D
D 0 .t / and u .1; t /
D
D 1 .t / .
˛ D t =x 2
SET INITIAL CONDITION :
u i D
I.x i /;
for i
D
0;:::;n
t 0 D
0
for `
D
0; 1; : : : ; m
1
t ` C 1 D
t
UPDATE ALL INNER POINTS :
for i
t ` C
D
1;:::;n
1
˛ u `
u i C 1
u ` C 1
i
u i C
2 u i C
tf `
i
D
C
INSERT BOUNDARY CONDITIONS :
u ` C 1
0
D
u ` C 1
n
D
D 0 .t ` C 1 /;
D 1 .t ` C 1 /
where N 1 is known, is more difficult than implementing the conditions where u is
known (Dirichlet conditions). The recipe goes as follows. First, we discretize the
derivative at the boundary, i.e., replace @ u =@x by a finite difference. Since we use
a centered spatial difference in the PDE, we should use a centered difference at the
boundary too:
@x u .1; t ` / u nC1
u n1
2x
@
:
(7.93)
The discrete version of the boundary condition then reads
u nC1
u n1
2x
D N 1 .t ` /:
(7.94)
Unfortunately, this formula involves a u value outside the grid, u nC1
.However,if
we use scheme (7.91) at the boundary point x D x n ,
u n1
C tf n
C t
x 2
u `C1
n
D u n
2 u n
C u nC1
;
(7.95)
we have two equations, both involving the fictitious value u nC1
. This enables us to
eliminate this value. Solving (7.94) with respect to u nC1
,
u nC1
D u n1
C 2N 1
x :
Inserting this expression in (7.95) yields a modified scheme at the boundary:
u n1
x C tf n
t
x 2
u `C1
n
D u n
u n
C N 1
C 2
:
(7.96)
 
Search WWH ::




Custom Search