4 Numerical Solution of Flow Equations PDF
4 Numerical Solution of Flow Equations PDF
4 Numerical Solution of Flow Equations PDF
∂A ∂Q
+ −q = 0
∂t ∂x
∂Q ∂( βQ 2 / A) ∂h
+ + gA + Sf + Se − βqυ x + Wf B = 0
∂t ∂x ∂x
2
Of these methods, the finite element method is rarely used when flow is
approximated as one-dimensional such as in the case of Saint-Venant
equations. The other two methods have been commonly applied for the
numerical solution of one-dimensional unsteady flow since 1960s.
3
Considering these advantages, the implicit finite difference technique is
commonly used to solve the governing partial differential equations. In the
implicit formulation, all derivative terms and other parameters are approximated
by using the unknowns at the forward time line (j+1) as seen in the x-t grid
shown below. The implicit finite difference method advances the solution from
one time line to the next simultaneously for all points along the time line.
Time Line
Time, t Space Line
(i,j+1) (i+1,j+1)
j+1
Upstream ∆t Downstream
Boundary j Boundary
(i,j) (i+1,j)
Line Line
∆x
0
Distance, x
0 i i+1
The distance-time grid used to formulate the implicit finite difference scheme
4
Of the various implicit schemes that have been developed, the "weighted
four-point" scheme first used by Preissmann (1961) is very advantageous
since it can readily be used with unequal distance steps, which is particularly
important for natural waterways where channel characteristics are highly
variable even in short distances.
In this scheme, the four grid points from the (j)th and (j+1)th time lines are
used to approximate the terms in the differential equation. A weighing factor,
θ, is used in the approximation of all terms of the equation except for the time
derivatives in order to adjust the influence of the points (i) and (i+1).
5
The approximations of the derivatives and constant terms in the four-
point weighted difference scheme are given as follows for a dummy
parameter K.
∂K K ij++11 − K ij+1 K ij +1 − K i j
Time derivative =ψ + (1 − ψ )
j
∂t ∆t ∆t j
∂K K i j++11 − K i j +1 K ij+1 − K i j
Space derivative =θ + (1 − θ )
∂x ∆x i ∆x i
6
It is possible to create different modifications of the implicit scheme for
various values of the weighing factors. Many researchers preferred using a ψ
value of 0.5 and approximated the time derivative at the center of grid
between (j)th and (j+1)th time lines On the other hand, different values of θ
were used depending on the particular application.
7
Finite Difference Formulation with Preissmann Scheme
In the approximations given below, some of the variables are defined at the
nodes of the grid (i.e., Q, h, and A), whereas the others are defined for the
reach (i.e., Sf, Se, sc, sm and ∆x).
The variables defined for the reach are denoted by the subscript (i+½) in
order to represent that these variables are defined half way between nodes
(i) and (i+1), or on the reach. It is also seen that the solution plane is
represented by a total of N nodes with node numbers starting from 1 and
running through N.
8
Node Reach
Time, t
∆t
(i,j+1) (i+1,j+1)
j+1
∆x
j
Upstream (i,j) (i+1,j) Downstream
Boundary Boundary
i th
Grid
Distance, x
The x-t solution plane used to generate the finite difference equations
9
The space derivatives in Saint-Venant equations are approximated as
∂Q Qi +j +11 − Qi j +1 Qi +j 1 − Qi j
=θ + (1 − θ )
∂x ∆xi +1/ 2 ∆xi +1/ 2
∂( β Q 2 / A ) ( βQ 2 / A) ij++11 − ( βQ 2 / A) ij +1 ( βQ 2 / A) ij+1 − ( βQ 2 / A) ij
=θ + (1 − θ )
∂x ∆x i +1 / 2 ∆x i +1 / 2
∂A Ai +j +11 − Ai +j 1 Ai j +1 − Ai j
= 0.5 + 0.5
∂t ∆t j ∆t j
∂Q Qi +j +11 − Qi +j 1 Qi j +1 − Qi j
= 0.5 + 0.5
∂t ∆t j ∆t j
10
Finally, the constant terms such as q, Sf, Se and A are approximated as
q = θq ij++11/ 2 + (1 − θ )q ij+1 / 2
j +1 j
S f = θS f i +1 / 2 + (1 − θ )S f i +1 / 2
j +1 j
S e = θS e i +1 / 2 + (1 − θ )S e i +1 / 2
where the variables with subscripts (i+½) are defined for the reach
between nodes (i) and (i+1) and the variable with bar (−) represents an
average of the corresponding values at nodes (i) and (i+1).
11
The following explicit formulations are used to define the above variables
2
n i Qi Qi Qi Qi
(Sf )i +1 / 2 = 2 2 4/3
= 2
c1 Ai R i Ki
K ec i Q 2 Q
2
(S e )i +1 / 2 = −
2g∆x i +1 / 2 A i +1 A i
Q i + Q i +1
Qi =
2
Ai + Ai +1
Ai =
2
Ai Ai
Ri = ≈
Pi Bi
B i + B i +1
Bi =
2
K i + K i +1
Ki =
2 12
The Finite Difference Form of Continuity Equation
Substituting the necessary terms in the continuity equation yields:
Ai +j +11 − Ai +j 1 Ai j +1 − Ai j Qi +j +11 − Qi j +1 Qi +j 1 − Qi j
0.5 j
+ 0.5 j
+θ + (1 − θ ) − θ qij++1/1 2 − (1 − θ )qij+1/ 2 = 0
∆t ∆t ∆xi +1/ 2 ∆xi +1/ 2
Ai +j +11 − Ai +j 1 Ai j +1 − Ai j Qi +j +11 − Qi j +1 j +1 Qi +j 1 − Qi j j
0.5 + 0.5 + θ − qi +1/ 2 + (1 − θ ) − qi +1/ 2 = 0
∆t j ∆t j ∆ xi +1/ 2 ∆ x i +1/ 2
∆xi +1/ 2
θ Qi j++11 − Qi j +1 − ∆xi +1/ 2 qij++1/1 2 + (1 − θ ) Qi +j 1 − Qi j − ∆xi +1/ 2 qij+1/ 2 + A
j i +1
j +1
+ Ai
j +1
− A j
i +1 − A j
i =0
2 ∆t
13
The Finite Difference Form of Momentum Equation
Qi +j +11 − Qi +j 1 Qi j +1 − Qi j
0.5 + 0.5 +
∆t j ∆t j
( β Q 2 / A)ij++11 − ( β Q 2 / A)ij +1 ( β Q 2 / A)ij+1 − ( β Q 2 / A)ij
θ + (1 − θ ) +
∆xi +1/ 2 ∆xi +1/ 2
hi +j +11 − hi j +1 hi +j 1 − hi j
(
g θA i
j +1
+ (1 − θ ) A θ
i
j
)
∆xi +1/ 2
+ (1 − θ )
∆xi +1/ 2
j +1 j j +1 j
+ θ S f i +1/ 2 + (1 − θ ) S f i +1/ 2 + θ Sei +1/ 2 + (1 − θ ) Sei +1/ 2 −
(θ (β qυ ) j +1
x i +1/ 2 + (1 − θ )( β qυ x )ij+1/ 2 ) = 0
14
If terms with common multipliers are rearranged, equation takes the
following form
Qi +j +11 − Qi +j 1 Qi j +1 − Qi j
0.5 j
+ 0.5 j
+
∆t ∆t
( β Q 2 / A)ij++11 − ( β Q 2 / A)ij +1 j +1 h
j +1
i +1 − hi
j +1
j +1 j +1 j +1
θ + g Ai + S f i +1/ 2 + Se i +1/ 2 − ( β qυ x )i +1/ 2 +
∆ xi +1/ 2 ∆ xi +1/ 2
( β Q 2 / A)ij+1 − ( β Q 2 / A)ij j h
j
i +1 − hi
j
j j j
(1 − θ ) + g Ai + S f i +1/ 2 + Se i +1/ 2 − ( β qυ x )i +1/ 2 = 0
∆ xi +1/ 2 ∆ xi +1/ 2
15
One might obtain the final finite difference form of momentum
equation by multiplying this equation with ∆xi+1/2:
∆xi +1/ 2
j
Qi
j +1
+ 1 + Qi
j +1
− Qi
j
+ 1 − Qi
j
+
2∆t
θ ( β Q 2 / A)ij++11 − ( β Q 2 / A)ij +1 + g Ai hi +j +11 − hi j +1 + ∆xi +1/ 2 S f i +1/ 2 + ∆xi +1/ 2 Se i +1/ 2 − ∆xi +1/ 2 ( β qυ x )ij++1/1 2 +
j +1
( j +1 j +1
)
(1 − θ ) ( β Q 2 / A)ij+1 − ( β Q 2 / A)ij + g Ai hi +j 1 − hi j + ∆xi +1/ 2 S f i +1/ 2 + ∆xi +1/ 2 Se i +1/ 2 − ∆xi +1/ 2 ( β qυ x )ij+1/ 2 = 0
( )
j j j
16
The terms with subscript (j) in continuity and momentum equations are
known either from initial conditions or from the solution of Saint-Venant
equations at the previous time line.
Since cross sectional area (A) and channel top width (B) are functions of
water surface elevation (h), the only unknown terms in these equations are
discharge (Q) and water surface elevation (h) at the (j+1)th time line at nodes
(i) and (i+1).
Therefore, there are only four unknowns in these equations. All remaining
terms are either constants or are functions of these unknowns. The finite
difference forms of continuity and momentum equations are solved for each
grid shown before.
17
As there are N-1 grids in a time line, a total of 2*(N-1) equations are
formed for one time line between the upstream and downstream
boundary.
There are two unknowns (Q and h) in each of the N nodes giving a total
of 2N unknown along each time line. The system of 2(N-1) equations
with 2N unknown require two additional equations to be determinate.
18
The Boundary Conditions
The two additional equations required for the system to be determinate come
from the external boundaries at the upstream and downstream locales of the
reach. Two types of boundary conditions can be specified at the upstream
boundary:
1. Discharge Hydrograph
2. Stage (or Depth) Hydrograph
1. Discharge Hydrograph
2. Stage (or Depth) Hydrograph
3. Single-Valued Rating Curve
4. Looped Rating Curve
5. Critical Flow Section
19
Upstream Boundary Condition
Q1j +1 − Q(t ) = 0
h1j +1 − h(t ) = 0
where Q1j+1 and h1j+1 are the discharge and stage to be computed at the
upstream boundary node and Q(t) and h(t) are hydrographs inputted to the
model.
20
Downstream Boundary Condition
Discharge Hydrograph
Q Nj +1 − Q (t ) = 0
Stage Hydrograph
hNj +1 − h(t ) = 0
where hNj+1 is the stage to be computed at the downstream boundary and h(t) is
the stage hydrograph value.
22
Single-Valued Rating Curve
Q Nj +1 − Q' (t ) = 0
Qk +1 − Qk j +1
Q' (t ) = Qk +
hk +1 − hk
hN − hk( )
where Qk, Qk+1, hk and hk+1 are consecutive tabular data sets of the rating
curve and hNj+1 is the stage at the downstream boundary.
23
Looped Rating Curve
Q Nj +1 − Q' (t ) = 0
j +1
1.0
Q' (t ) = (
AR 2 / 3 S 1f / 2 ) j +1
n N N
The loop is produced by using the friction slope rather than the channel
slope. The friction slope exceeds the bottom slope during the rising limb of
the hydrograph and falls below it during the recession limb.
24
The friction slope is computed using the full-dynamic wave form of the
momentum equation after neglecting the contributions of lateral inflow and
assuming that the momentum correction factor and sinuosity is equal to unity
1 ∂Q 1 ∂ (Q 2 / A) ∂h
Sf = − − −
gA ∂t gA ∂x ∂x
Sf N
j +1
=−
1
−
(
Q Nj − Q Nj −1 1 Q 2 / A ) − (Q
j
N
2
/A )
N −1
j
hj −hj
− N N −1
gANj ∆t gA ∆x ∆x
Since all the terms in this equation are known from the previous time lines, the
friction slope can easily be calculated and substituted in the Manning’s equation.
It should be noted that the loop rating equation allows the unsteady wave to pass
the downstream boundary with minimal disturbance by the boundary itself, and
hence, is extremely suitable when the boundary condition is located at an
arbitrary location in the waterway rather than at an actual control structure such
25
as a weir or a dam
Critical Flow Section
Q Nj +1 − Qcr (t ) = 0
where QNj+1 is the discharge to be computed at the downstream boundary
and Qcr(t) is the critical discharge value computed according to the
following equation
g 3/ 2
Qcr = A
B
This condition is particularly suitable when the routing ends at an entrance
to a free fall or at a transition to a steep reach
26
The Newton-Raphson Algorithm
Fi ( x1 , x 2 , x 3 ,..., x 2 N ) = 0 i = 1,2,3,...,2 N
If x denotes the entire vector of unknown variables, xi, and F denotes the
entire vector of functions,
Fi, each of the functions Fi can be expanded in the
neighborhood of x as a Taylor series expansion.
2 N ∂F
Fi ( x + δ x) = Fi (x) + ∑
2
i
δ x j + O(δ x ) i = 1, 2,3,..., 2 N
j =1 ∂x j
27
The matrix of first partial derivatives appearing in the above equation is
called the Jacobian matrix:
∂Fi
J=
∂x j
2
F ( x + δ x ) = F ( x ) + J ⋅ δ x + O(δ x )
Neglecting the higher order terms and setting the left hand-side equal to
zero, one can obtain a set of linear equations that are solved for the
corrections δ x
J ⋅δ x = −F
This matrix equation is solved by a matrix solver such as Gaussian
elimination or LU decomposition for the unknown, δ x , and an the
improved estimate of the solution is obtained by:
xnew = xold + δ x
28
The iteration process is continued until a predetermined convergence level
is achieved. It is important to assign different convergence criteria for Q and
h values. A generally accepted convergence criteria for h is 0.01 ft or 3 mm
(Fread, 1985). The convergence criteria for Q is computed according to the
following equality:
ε Q = ε h BV
where εQ and εh are convergence criteria for discharge and water surface
elevation, respectively; B is the top width of the cross section and V is the
flow velocity.
The convergence process depends on a good first estimate for the unknown
variables. A reasonably good estimate for the first time step is to use the
initial condition of discharge (Q) and water surface elevation (h). For any
other time step, the first estimates of the unknown variables can be obtained
by using the linearly extrapolated values from solutions at previous time
steps.
29
Partial Derivatives of Finite Difference Equations
One of the discouraging issues about the Newton-Raphson technique is the
need to evaluate the partial derivative terms of the Jacobian matrix. When the
equations get complex, it might get very difficult to differentiate the difference
equations. However, it is this feature of the technique that provides fast
convergence to the root.
In this regard, the difference forms of continuity and momentum equations are
partially differentiated with respect to the unknown terms h and Q at the (j+1)th
time line for the reaches (i) and (i+1).
30
Partial Derivatives of the Continuity Equation:
The partial derivatives of the continuity (C) equation with respect to hi, hi+1,
Qi and Qi+1 (all at (j+1)th time line) are computed as follows:
∂C
j +1
= −θ
∂Q i
∂C
=θ
∂Q ij++11
31
Partial Derivatives of the Momentum Equation:
The partial derivatives of the momentum (M) equation with respect to hi,
hi+1, Qi and Qi+1 (all at (j+1)th time line) are computed as follows:
2
j +1
j +1 ∂S
j +1
∂S
j +1
βQ B − 1 + ∆x f i + 1 / 2 e i +1 / 2
j +1 + g A i + ∆x +
∂M ∂M ∂Ai A2 i +1 / 2
∂hi j +1 i +1 / 2
∂hi j +1
j +1
= = θ i
∂hi ∂Aij +1 ∂hi j +1
1
2
( j +1 j +1
gB i j +1 hij++11 − hij +1 + S f i +1 / 2 ∆x i +1 / 2 + S e i +1 / 2 ∆x i +1 / 2 )
where
j +1
∂S f i +1 / 2 2 ∆n j +1 5 B j +1 2 ∆B i
j +1
i
S f i +1 / 2
j +1 i
= − +
∂hi j +1 n ij +1 ∆hij +1 3 A ij +1 3B ij +1 ∆hi j +1
j +1
∂S e i +1 / 2
=
(K )
ec i
j +1
(Q 2 ) ij +1 B ij +1
∂hi j +1 g∆x i +1 / 2 ( A 3 ) ij +1
32
2
j +1
j +1
j +1
∂S f i +1 / 2 ∂S e i +1 / 2
j +1
− βQ B
j +1 + g A i 1 + ∆x i +1 / 2 + ∆x i +1 / 2 +
∂M ∂M ∂Ai +1 A2 j +1
∂hi +1 j +1
∂hi +1
= =θ i +1
∂hij++11 ∂Aij++11 ∂hi j++11
1
2
gB i
j +1
+ 1 h i
j +1
+1 − h (
i
j +1
+ S f i
j +1
+ 1 / 2 ∆x i + 1 / 2 + S e i
j +1
+1 / 2 ∆x i +1 / 2 )
where
j +1
∂S f i +1 / 2 2 ∆n j +1 5 B j +1 2 ∆B i +1
j +1
i
S f i +1 / 2
j +1 i +1
= − +
∂hij++11 n ij +1 ∆hij++11 3 A ij +1 3B ij +1 ∆hi j++11
j +1
∂S e i +1 / 2
=
(K )
ec i
j +1
(Q 2 ) ij++11 B ij++11
∂hi j++11 g∆x i +1 / 2 ( A 3 ) ij++11
33
∂M ∆xi +1/ 2 2 β Q j +1 j +1
j +1
∂S f i +1/ 2 ∂Se i +1/ 2
j +1
where
j +1
∂S f i +1 / 2 1 ∆ n j +1 1
i
S f i +1 / 2
j +1
= +
∂Q i j +1 n ij +1 ∆Q j +1 Q j +1
i i
j +1
∂S e i +1 / 2
=
( )
− K ec i
j +1
Q i j +1
∂Q i j +1 g∆x i +1 / 2 ( A 2 ) ij +1
34
∂M ∆x i +1 / 2 2 βQ j +1 j +1
j +1
∂S f i +1 / 2
j +1
∂S e i +1 / 2
=
j +1
s m i +1 / 2 + θ + g Ai ∆x + ∆x i +1 / 2
∂Q i j++11 2∆t j A i +1 i +1 / 2 ∂Q j +1 ∂Q j +1
i +1 i +1
where
j +1
∂S f i +1 / 2 1 ∆ n j +1 1
i
= S f i +1 / 2 j +1 + j +1
j +1
∂Q ij++11 n i ∆Q j +1
Q i
i
j +1
∂S e i +1 / 2
=
( )
− K ec
j +1
i Q i j++11
∂Q i j++11 g∆x i +1 / 2 ( A 2 ) ij++11
35
Partial Derivatives of the Upstream Boundary Conditions:
∂UB
=1
∂Q1j +1
∂∂UB
UB
=0
∂h1j +1
∂UB
=0
∂Q1j +1
∂UB
=1
∂h1j +1
36
Partial Derivatives of the Downstream Boundary Conditions:
∂DB
=1
∂Q1j +1
∂DB
=0
∂h1j +1
∂DB
=0
∂Q1j +1
∂DB
=1
∂h1j +1
37
For the single-valued rating curve, the partial derivatives can be written as
∂DB
j +1
=1
∂Q1
∂DB Qk +1 − Qk
j +1
= −
∂h1 hk +1 − hk
j +1
∂DB 1 ∆n
= 1 + Q '
∂Q1j +1 n ∆Q N
j +1
∂DB 1 ∆n 5 B 2 ∆B
= Q ' − +
∂h1j +1 n ∆ h 3 A 3 B ∆h N
38
Finally, if a critical section is used at the downstream boundary, the partial
derivatives are written as
∂DB
=1
∂Q1j +1
j +1
∂DB 3 B 1 ∆B
j +1
= Qcr − +
∂h1 2 A 2 B ∆h N
39
Solution of Finite Difference Equations
The system of non-linear equations can now be written in functional form in terms
of the unknowns Q and h at time level (j+1)
∂UB ∂UB
δQ1 + δh1 = −RUB k
∂Q1 ∂h1
∂C1 ∂C ∂C1 ∂C
δQ1 + 1 δh1 + δQ 2 + 1 δh 2 = −RC1k
∂Q1 ∂h1 ∂Q 2 ∂h 2 Applying the Newton-
∂M1 ∂M1 ∂M1 ∂M1 Raphson technique by
δQ1 + δh1 + δQ 2 + δh 2 = −RM1k
∂Q1 ∂h1 ∂Q 2 ∂h 2 substituting in the
⋅
⋅
necessary parameters, the
∂C i ∂C i ∂C i ∂C i system of equations takes
δQ i + δh i + δQ i +1 + δhi +1 = −RC ik
∂Q i ∂hi ∂Q i +1 ∂hi +1 the form given here,
∂M i
δQ i +
∂M i
δh i +
∂M i
δQ i +1 +
∂M i
δhi +1 = −RM ik
which can easily be
∂Q i ∂hi ∂Q i +1 ∂hi +1 transformed into the
⋅ matrix form.
⋅
∂C N −1 ∂C N −1 ∂C N −1 ∂C N −1
δQN −1 + δhN −1 + δQ N + δhN = −RC Nk −1
∂QN −1 ∂hN −1 ∂QN ∂hN
∂M N −1 ∂M N −1 ∂M N −1 ∂M N −1
δQN −1 + δhN −1 + δQ N + δhN = −RM Nk −1
∂QN −1 ∂hN −1 ∂QN ∂hN
∂DBN ∂DBN
δQ N + δhN = −RDB k
∂QN ∂hN 42
∂UB ∂UB
0 0 0 ⋅ 0 0 0 0 δQ1 − RUB
∂Q1 ∂h1
∂C1 ∂C1 ∂C1 ∂C1
0 ⋅ 0 0 0 0 δh1 − RC1
∂Q1 ∂h1 ∂Q 2 ∂h 2
∂M1 ∂M1 ∂M1 ∂M1
0 ⋅ 0 0 0 0 δQ 2 − RM1
∂Q1 ∂h1 ∂Q 2 ∂h 2
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
∂C i ∂C i ∂C i ∂C i
0 0 ⋅ ⋅ 0 0 δQ i − RC i
∂Q i ∂hi ∂Q i +1 ∂hi +1
∂M i ∂M i ∂M i ∂M i
0 0 ⋅ ⋅ 0 0 δh i = − RM i
∂Q i ∂hi ∂Q i +1 ∂hi +1
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅ ⋅
∂C N −1 ∂C N −1 ∂C N −1 ∂C N −1
0 0 0 0 0 ⋅ δhN −1 − RC N −1
∂Q N −1 ∂hN −1 ∂QN ∂hN
∂M N −1 ∂M N −1 ∂M N −1 ∂M N −1
0 0 0 0 0 ⋅ δQ N − RM N −1
∂Q N −1 ∂hN −1 ∂QN ∂hN
∂DBN ∂DBN
0 0 0 0 0 ⋅ 0 0 δh N − RDB
∂QN ∂hN
43
A matrix elimination routine such as Gaussian elimination or LU decomposition
can be used to solve such a system given above. However, Fread (1971)
considered the sparse character of Jacobian coefficient matrix with a maximum
of 4 elements in a row and developed an efficient algorithm to solve such a
banded matrix. No matter which scheme is used to solve the matrix, the final
step is to compute the corrected values of the unknowns for the next iteration
according to the following formulae
After solving for the new values of iteration, the convergence criteria are
checked for all Q and h values in the vector as mentioned before
44
Initialize all arrays
Flow Chart
Input global data
Write results 45
Reference
Gündüz, O. (2004). Coupled Flow and Contaminant Transport Modeling in
Large Watersheds. Ph.D. Dissertation, School of Civil and Environmental
Engineering, Georgia Institute of Technology, Atlanta, GA, USA, 467p
46