Information Technology Reference
In-Depth Information
cf. derivation of (7.12)onpage291. In addition we need Fick's law (7.16):
q
D
k
@c
@x
:
(7.109)
Let us divide the global domain into intervals of length x. That is, if the global
domain is the unit interval .0; 1/, and we introduce n
C
1 grid points x
i
, i
D
0;:::;n,
we have x
i
D
ix. We could apply the integral form (7.108) of mass conservation
to one grid cell Œx
i
;x
iC1
. However, to get a final discrete algorithm with the same
indices as in Algorithm
7.1
, we must apply (7.108)toŒx
;x
iC
2
. In this case,
i
2
a
D
x
and b
D
x
:
i
2
iC
2
%q
i
t
%q
iC1
t
C
Z
x
i C
2
x
i
2
%f t d x
D
Z
x
i C
2
x
i
2
%c dx :
Imagine that this is the mass conservation principle at some time level ` such that
a possible expression for c is c
`C1
c
`
, the difference in concentration between
two time levels. All quantities are then sampled at time level ` so we can write
t
C
Z
x
i C
2
x
i
2
%f .x ; t
`
/t dx
D
Z
x
i C
2
x
i
2
%q
i
t
%q
iC1
%.c
`C1
c
`
/dx
:
(7.110)
When i varies throughout the grid, this equation ensures that mass is conserved in
each interval Œx
.
The second integral over c in (7.110) is inconvenient. How should we integrate
a function c whose value is known only in the discrete grid points? An obvious idea
is to perform a numerical approximation of the integral. The midpoint rule is an
attractive candidate, since it involves the c sampled at the point x
i
, i.e., we get an
expression involving the point values c
i
;x
iC
2
i
2
and c
`C1
i
:
Z
x
i C
2
%.c
`C1
c
`
/dx
%.c
`C1
i
c
i
/x :
x
i
2
Since we are already approximating integrals, no more errors are introduced if we
replace the integral over the known function f by a similar midpoint approximation,
Z
x
i C
2
x
i
2
%f .x ; t
`
/t dx
%f
`
tx :
i
The mass conservation statement can be written as
%q
i
t
%q
iC1
t
C
%f
`
i
tx
D
%.c
`C1
i
c
i
/x;