Академический Документы
Профессиональный Документы
Культура Документы
2
= 2
t x
n+1
j j j1 2j + j+1
=
t x2
n+1
j = j + s (j1 2j + j+1 )
where s = t/x2 . This scheme is stable as long as 2s < 1, which, from a Hirt analysis, is
required in order to render the sign of the 4th-order derivative leading truncation error term
negative.
In most practical problems, the action of diffusion is usually confined to a relatively small
portion of the flow. Some examples are depicted in Figures 1, 2, and 3.
Because the effects of diffusion are confined to very small regions of the flow, it is common
to add more grid points near boundaries or at fronts for improved resolution. This poses a
CEE262c Lecture 5 2
x2
t <
2
As an example, consider the flow in an estuary that is 10 m deep and the finest resolution
near the surface is z = 0.25 m. If we assume a near-surface, wind-induced turbulent
diffusion coefficient of = 0.01 m2 s1 , this implies
0.252
t < = 3.125 s
2 0.01
which is much less than the restriction imposed by advection, since if first-order upwinding
is used with forward Euler in time for advection, and if the vertical velocity is roughly
0.01 m s1 , then
z 0.25
t < = = 25 s
w 0.01
In order to remove the strict stability limitation associated with diffusion, the diffusion term
is often treated implicitly.
CEE262c Lecture 5 3
If instead of using Forward Euler for the diffusion term, we employ Backward Euler, then
the diffusion equation is discretized as
2
= 2
t x
n+1
j jn
n+1
j 2n+1
j + n+1
j
=
t x2
Substitution of a Fourier mode nj = n exp(ikxj ) yields
n+1 n
exp(ikxj ) = 2
(exp(ikx) 2 + exp(ikx)) n+1 exp(ikxj )
t x
n+1 n = s (2 + exp(ikx) + exp(ikx)) n+1
n+1 n = 2s (1 cos(kx))) n+1
n+1 [1 + 2s(1 cos(kx))] = n
n+1 1
Gn = n =
1 + 2s(1 cos(kx))
Since 0 1 cos(kx) 2, then |Gn | < 1 for all s > 0, so the scheme is unconditionally
stable. The advantage of this implicit scheme is that it removes the stability limitation
associated with the diffusion operator. The disadvantage is that the problem becomes more
expensive to solve numerically. Consider the implicit discretization of the diffusion equation
n+1
j = nj + s n+1 n+1
j1 2j + nj
sn+1 n+1
j1 + (1 + 2s)j sn+1 n
j+1 = j
aj n+1 n+1
j1 + bj j + cj n+1 n
j+1 = j
aj = s bj = 1 + 2s cj = s
n+1
1 = b (tn+1 )
Since n+1
1 is specified, this now alters the equation at j = 2. Writing the discretized equation
at j = 2 requires n+1
1 :
a2 n+1
1 + b2 n+1
2 + c2 n+1
3 = n2
a2 b (tn+1 ) + b2 n+1
2 + c2 n+1
3 = n2
b2 n+1
2 + c2 n+1
2 = n2 a2 b (tn+1 )
a1 n+1
0 + b1 n+1
1 + c1 n+1
2 = n1
CEE262c Lecture 5 5
Boundaries are now located half-way between points, as shown in Figure 6. Dirichlet condi-
tion specifies a value, which now must be interpolated:
1 n+1
n+1 = + n+1
+ O x 2
= b (tn+1 )
1/2
2 0 1
n+1
0 = n+1
1 xg (tn+1 )
a1 n+1
0 + b1 n+1
1 + c1 n+1
2 = n1
1 ):
Finite difference w/Dirichlet: b2 n+1
2 + c2 n+1
3 = n2 a2 b (tn+1 )
a1 n+1
0 + b1 n+1
1 + c1 n+1
2 = n1
to
b1 n+1
1 + c1 n+1
2 = n1 + b1
aN n+1 n+1
N 1 + bN N + cN n+1 n
N +1 = N
requires the ghost point N +1 . Using the appropriate boundary conditions, the equation at
i = N becomes
aN n+1 n+1
N 1 + bN N = nN + bN
CEE262c Lecture 5 7
We can also use this notation to discretize the problem in time with a different discretization
scheme, such as the second-order accurate Crank-Nicolson scheme, for which
rn+1 rn 1
= Drn + Drn+1
t 2
CEE262c Lecture 5 8
Of course, this is mostly a convenient way of writing the method of solution. In practice, the
matrices are usually not constructed (if they are sparse) and the right hand side is usually
computed element by element rather than with a matrix-vector product.
2
+u = 2
t x x
we can employ the spatial discretization first to write the partial differential equation as
dr
= U r + Dr
dt
where U is the advection matrix (with opposite sign to that described in lecture 2), and D
is the diffusion matrix. This equation assumes that all appropriate boundary conditions are
imposed when constructing the matrices. We can discretize each term individually in time
with a different scheme based on the stability limitations of that scheme. For example, if
we would like to remove the stability limitation associated with the diffusion term, we can
discretize it implicitly with the backward Euler scheme and the advection term explicitly
with the forward Euler scheme:
Z tn+1 Z tn+1
dr
dt = (U r + Dr) dt
tn dt tn
rn+1 rn
= U rn + O (t) + Drn+1 + O (t)
t
The solution would then be given by
As another example, using Crank-Nicolson for diffusion and forward Euler for advection we
would have
rn+1 rn 1
= U rn + O (t) + D rn + rn+1 + O t2
t
2
t t
I D rn+1 = I + tU + D rn + O (t)
2 2
where now the method is first-order accurate due to the discretization of the advection term.
The solution can then be obtained with
1
n+1 t t
r = I D I + tU + D rn + O (t)
2 2
Discretizing the advection and diffusion terms with second-order central differences in space
gives
Dj u
+ (i+1 i1 ) = (i1 2i + i+1 ) ,
Dt 2x x2
CEE262c Lecture 5 10
Stability will always be determined by the term in the equation that is discretized explicitly.
The amplification factors for each of the schemes in terms of D h and A h are given by
This is the most restrictive scheme, since both terms are evaluated explicitly. The
region of stability for this scheme is given by the circle of radius 1 centered about
D h = 1 and A h = 0 which requires
Substitution yields
Three cases:
(a) cos(kx) = 0
4s + 4s2 + C 2 < 0
C 2 < 4s(1 s)
(b) cos(kx) = +1
(c) cos(kx) = 1
From the last condition we know that s < 1/2, and when this is true 2s < 4s(1 s).
Therefore, we can neglect the first condition to yield the stability bounds shown in
Figure 7, i.e.
C 2 < 2s < 1
CEE262c Lecture 5 12
C 2 4s < 0
C 2 < 4s
(b) cos(kx) = +1
C 2 4s < C 2
C 2 < 2s
(c) cos(kx) = 1
C 2 4s < C 2
s > 0
Since condition (b) is more restrictive than condition (a) for s > 0, the resulting
stability limit is
C 2 < 2s
and we have removed the limitation on s because of the implicit treatment of the
diffusion term.
CEE262c Lecture 5 13
2 Ah2<2Dh
A h
2
A h
4
4 2 0 2 4 4 2 0 2 4
D h D h
Figure 7: Stability regions for the four schemes discussed in the text.
The most convenient way to discretize this equation is with a non-uniform grid so that more
resolution can be employed to resolve the bottom boundary layer.
Discretizing equation (1) with the theta method in time gives (ignoring the pressure term
for convenience)
n+1 n
un+1 un n u n u
= t + (1 ) t ,
t z z z z
where we have lagged the eddy-viscosity so that it can be evaluated at time step n. Now
discretizing the vertical derivatives on the non-uniform finite-volume grid depicted in Figure
8.
CEE262c Lecture 5 15
Figure 8: Detail of the non-uniform grid used to discretize the diffusion equation.
" #
u 1 u u
t = t t
z z k zk z k+1/2 z k+1/2
1 uk+1 uk uk uk1
= t,k+1/2 t,k1/2
zk zk+1/2 zk1/2
t,k+1/2 t,k1/2
= (uk+1 uk ) (uk uk1 )
zk zk+1/2 zk zk1/2
t,k1/2 1 t,k1/2 t,k+1/2 t,k+1/2
= uk1 + uk + uk+1
zk zk1/2 zk zk1/2 zk+1/2 zk zk+1/2
ak 1 ak+1
= uk1 (ak + ak+1 )uk + uk+1
zk zk zk
where
t,k1 +t,k
t,k1/2 2 t,k1 + t,k
ak = = zk1 +zk
=
zk1/2 zk1 + zk
2
ak n+1 1 ak+1 n+1
t uk1 + 1 + t (ak + ak+1 ) un+1
k t u =
zk zk zk k+1
ak n 1 ak+1 n
(1 )t uk1 + 1 (1 )t (ak + ak+1 ) unk + (1 )t u
zk zk zk k+1
CEE262c Lecture 5 16
This is a tridiagonal system of equations with nonconstant coefficients and can be written
as
MIn U n+1 = MEn U n ,
where MI and ME are the implicit and explicit diffusion operators, respectively. Note that
because the eddy-viscosity is lagged and evaluated at time step n, this discretization is
formally first-order accurate in time.
At k = 1:
" #
u 1 u u
t = t t
z z 1 z1 z 3/2 z 1/2
At the lower wall k = 1/2, we apply a quadratic drag law of the form
u
t = CD |u1 |u1 . (2)
z 1/2
The drag coefficient is obtained by assuming a log-law velocity profile of the form
u z
u= ln ,
z0
CEE262c Lecture 5 17
At k = Nk :
u 1 t u
u
t = t
z z Nk zNk
z N +1/2 z
Nk 1/2
| {z k }
Stress-free
At the free-surface k = Nk + 1/2, we apply a no-stress condition such that
u
t =0
z Nk +1/2
CEE262c Lecture 5 18
Substituting,
u 1 t,Nk 1/2
t = (uNk uNk 1 )
z z 1 zNk zNk 1/2
1 1
= aNk 1 uNk 1 aN 1 uNk
zNk zNk k
equation
The first step at tackling this equation is deciding on the time-advancement scheme, since
this will determine in a large part the computational complexity of the discretization (i.e. ex-
plicit=cheap/easy, implicit=expensive/complex). The following is a list of time-advancment
possiblities and their advantages and disadvantages:
where
n
Anx () = (u ) ,
x
n
Any () = (v ) ,
y
n n
Dx () = t ,
x x
Dyn () = nt ,
y y
and the implies a spatial discretization. This scheme would behave well for the
hyperbolic term and is formally second-order accurate in time. However, it would be
unconditionally unstable for any spatial discretization of the diffusion term and would
require a filter to stabilize it.
CEE262c Lecture 5 19
This scheme is succeptible to a stability limitation but behaves well as long as the
aformentioned stability limitations associated with advection and diffusion are satisfied.
For example, if central differencing is employed in space for the advection terms then
enough diffusion must be added such that
Cx2 Cy2
+ < 2,
sx sy
and
1
sx + sy ,
2
where Cx = ut/x, Cy = vt/y, sx = t t/x2 , and sy = t t/y 2 . The
greatest disadvantage to this method is the time-step limitation associated with these
stability constraints.
= n t [Ax ( ) Dx ( )] ,
n+1 = t An+1
y (n+1 ) Dyn+1 (n+1 ) .