292
9 Solving Partial Differential Equations
This approximation involves a fictitious point x N+1 outside the domain. A common
trick is to use (9.7) for i = N and eliminate u N+1 by use of the discrete boundary
condition (u N+1 = u N−1 ):
du N (t)
dt
= β
2u N−1 (t) − 2u N (t)
Δx 2
+ g N (t) .
(9.8)
That is, we have a special version of (9.7) at the boundary i = N.
What about simpler finite differences at the boundary?
Some reader may think that a smarter trick is to approximate the boundary
condition ∂u/∂x at x = L by a one-sided difference:
∂u
∂x
i=N
≈
u N − u N−1
Δx
= 0 .
This gives a simple equation u N = u N−1 for the boundary value, and a
corresponding ODE u
N = u
N−1 . However, this approximation has an error
of order Δx, while the centered approximation we used above has an error of
order Δx 2 . The finite difference approximation we used for the second-order
derivative in the diffusion equation also has an error of order Δx 2 . Thus, if
we use the simpler one-sided difference above, it turns out that we reduce the
overall accuracy of the method.
We are now in a position to summarize how we can approximate the PDE
problem (9.1)–(9.4) by a system of ordinary differential equations:
du 0
dt
= s
(t),
(9.9)
du i
dt
=
β
Δx 2 (u i+1 (t) − 2u i (t) + u i−1 (t)) + g i (t), i = 1, . . . , N − 1, (9.10)
du N
dt
=
2β
Δx 2 (u N−1 (t) − u N (t)) + g N (t) .
(9.11)
The initial conditions are
u 0 (0) = s(0),
(9.12)
u i (0) = I (x i ), i = 1, . . . , N .
(9.13)
We can apply any method for systems of ODEs to solve (9.9)–(9.11).
Précédent

- 311/350

Suivant