Information Technology Reference
In-Depth Information
7.4.2
Incorporating Dirichlet Boundary Conditions
The observant reader will notice that it is difficult to use (7.91) for computing new
values u `C1
1
and u `C1
n
at the boundary, because (7.91)fori D 1 and i D n involves
values u ` 1
and u nC1
outside the grid. The solution is to use the boundary conditions
( 7.83 )and( 7.84 )fori D 0 and i D n. These must be combined with scheme (7.91).
Suppose we have the boundary conditions u .0; t / D 0 and u .1; t / D 0,previ-
ously categorized as Dirichlet conditions. We can then use (7.91) to update u `C1
i
at
all internal grid points, i D 1;:::;n 1.Fori D 1,(7.91) involves the known values
u 0
, u 1
,and u 2
,and u 0
is zero from the boundary condition. Similarly, for i D n 1,
(7.91) involves the known values u n2
, u n1
, and the boundary condition u n
D 0.
The
computational
procedure
can
be
summarized
as
we
have
done
in
Algorithm 7.1 .
Let us generalize the simple boundary conditions u .0; t / D u .1; t / D 0 a bit to
the choices
u .0; t / D D 0 .t /;
u .1; t / D D 1 .t /;
(7.92)
where D 0 .t / and D 1 .t / are prescribed functions. The computational procedure is
hardly affected by this slight generalization. We use scheme (7.91) for the internal
points i D 2;:::;n 1, and at the boundary points we just insert the correct values:
u `C1
0
u `C1
n
D D 0 .t `C1 /;
D D 1 .t `C1 /:
Algorithm 7.2 incorporates the non-homogeneous Dirichlet conditions (7.92).
7.4.3
Incorporating Neumann Boundary Conditions
Implementing Neumann boundary conditions, such as ( 7.84 ),
@
@x u .1; t / D N 1 .t /;
Algorithm 7.1
Diffusion Equation with u
D
0 at the Boundary.
˛
t =x 2
SET INITIAL CONDITIONS :
u i D I.x i /; for i D 0;:::;n
for ` D 0; 1; : : : ; m 1
UPDATE ALL INNER POINTS :
for i
D
D
1;:::;n
1
˛ u i 1
2 u i C u i C 1
u ` C 1
i
D u i C
C tf `
i
INSERT BOUNDARY CONDITIONS :
u ` C 1
0
u ` C 1
n
D
0;
D
0
 
Search WWH ::




Custom Search