Professional Documents
Culture Documents
Computational Hydraulics
Computational Hydraulics
Computational Hydraulics
Introduction to Hydraulics
of Open Channels
Topics to be covered
Basic Concepts
Conservation Laws
Critical Flows
Uniform Flows
Unsteady Flows
Basic Concepts
Open Channel flows deal with flow of water in open channels
Datum head = z
Conservation Laws
Conservation of Mass
Conservation of Momentum
Conservation of Energy
Conservation of Mass
Conservation of Mass
In any control volume consisting of the fluid ( water) under
consideration, the net change of mass in the control volume
due to inflow and out flow is equal to the the net rate of
change of mass in the control volume
Conservation of Energy
This law states that neither the energy can be created or
destroyed. It only changes its form.
Conservation of Energy
Mainly in open channels the energy will be in the form of potential energy
and kinetic energy
Potential energy is due to the elevation of the water parcel while the
kinetic energy is due to its movement
Inthe context of open channel flow the total energy due these factors
between any two sections is conserved
When used between two sections this equation has to account for the
energy loss between the two sections which is due to the resistance to the
flow by the bed shear etc.
Types of Open Channel Flows
Depending on the Froude number (Fr) the flow in an open
channel is classified as Sub critical flow, Super Critical
flow, and Critical flow, where Froude number can be defined
as F V
r
gy
Unsteady Steady
Gradually Gradually
Rapidly Rapidly
Types of Open Channel Flow Cont…
Steady Flow
Flow is said to be steady when discharge does not
change along the course of the channel flow
Unsteady Flow
Flow is said to be unsteady when the discharge
changes with time
Uniform Flow
Flow is said to be uniform when both the depth and
discharge is same at any two sections of the channel
Types of Open Channel Cont…
Gradually Varied Flow
Flow is said to be gradually varied when ever the
depth changes gradually along the channel
E=y
Depth of water Surface (y)
E-y curve
1
Emin
y1
C
Alternate Depths
yc
2
45°
2
Critical Depth
Specific Energy (E) y
Q 2Tc Ac Q2 Ac VC2
3
1 2
gAc Tc gAc Tc g
Characteristics of Critical Flow
For a rectangular channel Ac /Tc=yc
hf
Sf
v22/2g
y1
Control Volume
y2
So
1
z1
z2
Datum
1
Q AR 2 / 3 S 1/ 2
n
Uniform Flow
Thisis a non linear equation in y the depth of flow for which
most of the computations will be made
W sin 0 Px 0
Or Ax sin 0 Px 0
A
Or 0 sin
P
V2 2g
Or cf RS 0 V RS 0 C RS 0
2 cf
dy S 0 S f
dx 1 Fr 2
v2/2g
Water surface (slope = Sw)
Datum
dy 2 g gA2 D
Finally the general differential equation can be
written as
dy S 0 S f
dx 1 Fr 2
Gradually Varied Flow
Numerical integration of the gradually varied flow equation
will give the water surface profile along the channel
Vw V c
Energy equation
p1 V12 p2 V22
1 z1 h p 2 z2 ht hL
2g 2g
p/y
hp
z1
z
Pump
z=0 Datum
0 f V 2 / 8
p L V2
h f
D 2g
64
f
VD
Also we can write in terms of Reynolds number
64
f
Nr
MINOR LOSSES
18.5 106 D 4V 2
h
Cv2 2 g
fL V 2 V 2 L dV
H0 .
D 2g 2g g dt
(V a) (V a ) A
V
a
Since p gH we can write as
a
H V
g
Module 3
2 lectures
Contents
Numerical computing
Computer arithmetic
Parallel processing
Examples of problems
needing numerical
treatment
What is computational hydraulics?
It is one of the many fields of science in which the
application of computers gives rise to a new way
of working, which is intermediate between purely
theoretical and experimental.
0
1 cos 2 ( x)dx
n 4 n!
Computer arithmetic
• Round-off error : digital computers always use floating point
numbers of fixed word length; the true values are not expressed
exactly by such representations. Such error due to this computer
imperfection is round-off error.
Parallel task
A parallel task can take a number of forms, depending on the
application and the software that supports it. For a
Message Passing Interface (MPI) application, a parallel task
usually consists of a single executable running concurrently
on multiple processors, with communication between the
processes.
Parallel processing
Parametric Sweep
A parametric sweep consists of multiple instances of the
same program, usually serial, running concurrently, with
input supplied by an input file and output directed to an
output file. There is no communication or interdependency
among the tasks. Typically, the parallelization is performed
exclusively (or almost exclusively) by the scheduler, based
on the fact that all the tasks are in the same job.
Task flow
A task flow job is one in which a set of unlike tasks are
executed in a prescribed order, usually because one task
depends on the result of another task.
Introduction to numerical analysis
Any physical problem in hydraulics is represented
through a set of differential equations.
Euler method
Modified Euler method
Runge-Kutta method
Predictor-Corrector method
Introduction to numerical analysis
The following methods have been used for
numerical integration of the PDEs
Characteristics method
Finite difference method
Finite element method
Finite volume method
Spectral method
Boundary element method
Problems needing numerical treatment
Computation of normal depth
Computation of water-surface profiles
Contaminant transport in streams through
an advection-dispersion process
Steady state Ground water flow system
Unsteady state ground water flow system
Flows in pipe network
Computation of kinematic and dynamic
wave equations
Solution of System of
Linear and Non Linear
Equations
Module 4
(4 lectures)
Contents
Set of linear equations
Matrix notation
Method of
solution:direct and
iterative
Pathology of linear
systems
Solution of nonlinear
systems :Picard and
Newton techniques
Sets of linear equations
Real world problems are presented through a set of
simultaneous equations
F1( x1, x2 ,..., xn ) 0
F2 ( x1, x2 ,..., xn ) 0
.
.
.
Fn ( x1, x2 ,..., xn ) 0
Solving a set of simultaneous linear equations needs
several efficient techniques
We need to represent the set of equations through matrix
algebra
Matrix notation
Matrix : a rectangular array (n x m) of numbers
a11 a12 . . . a1m
a21 a22 . . . a2 m
.
A aij .
. .
. .
an1 an 2 anm
. . .
nxm
Matrix Addition:
C = A+B = [aij+ bij] = [cij], where cij aij bij
Matrix Multiplication:
AB = C = [aij][bij] = [cij], where
m
cij aikbkj i 1,2,...,n, j 1,2,...,r.
k 1
Matrix notation cont…
*AB BA
kA = C, where cij kaij
No.ofcols.
bi aik xk , i 1,2,...,No.ofrows
k 1
Matrix notation cont…
Matrix multiplication gives set of linear equations as:
a11x1+ a12x2+…+ a1nxn = b1,
a21x1+ a22x2+…+ a2nxn = b2,
. . .
. . .
. . .
an1x1+ an2x2+…+ annxn = bn,
1 0 0 0
0 1 0 0 I .
0 0 1 0 4
0 0 0 1
Matrix notation cont…
Lower triangular matrix: a 0 0
if all the elements above the L b d 0
c e f
diagonal are zero
Tri-diagonal matrix: if a b 0 0 0
nonzero elements only on c d e 0 0
the diagonal and in the T 0 f g h 0
0 0 i j k
position adjacent to the 0
0 0 l m
diagonal
Matrix notation cont…
Determinant of a square 3 1 4
A 0 2 3
matrix A is given by: 1 1 2
a a 3 0 1
A 11 12 T
a21 a22 A 1 2 1
4 3 2
det( A) a11a22 a21a12
Matrix notation cont…
Characteristic polynomial pA() and eigenvalues
of a matrix:
Note: eigenvalues are most important in applied
mathematics
For a square matrix A: we define pA() as
pA() = A - I = det(A - I).
If we set pA() = 0, solve for the roots, we get
eigenvalues of A
If A is n x n, then pA() is polynomial of degree
n
Eigenvector w is a nonzero vector such that
Aw= w, i.e., (A - I)w=0
Methods of solution of set of equations
Direct methods are those that provide the solution in a finite and pre-
determinable number of operations using an algorithm that is often
relatively complicated. These methods are useful in linear system of
equations.
4 2 1 15 4 2 1 15
3 1 4 8, 3R1 4 R2 0 10 19 77
1 1 3 13 ( 1) R1 4 R3 0 2 11 37
4 2 1 15
0 10 19 77
2R2 10R3 0 0 72 216
Gauss-Jordan method
In this method, the elements above the diagonal
are made zero at the same time zeros are
created below the diagonal
Method of solution cont…
Usually diagonal elements are made unity,
at the same time reduction is performed,
this transforms the coefficient matrix into
an identity matrix and the column of the
right hand side transforms to solution
vector
0 2 0 1 0
2 2 3 2 2
4 3 0 1 7
6 1 6 5 6
1 0 0 0.04000 0.58000
0 1 0 0.27993 1.55990
0 0 1 0.82667 1.32000
0 0 0 1.55990 3.11970
Step4: now divide the 4th row by 1.5599 and create zeros
above the diagonal in the fourth column
1 0 0 0 0.49999
0 1 0 0 1.00010
0 0 1 0 0.33326
0 0 0 1 1.99990
Method of solution cont…
Iterative Methods
x1 2 x2 5 x3 1,
2 x1 7 x2 2 x3 5.
1 n
xi ci aij x j , i 1,2,...,n
aii j 1
j i
~ k 1 1 i 1 k 1 n k
xi ci aij x j aij x j ,
aii j 1 j i 1
xik 1 xik w( ~
xik 1 xik ) i 1,2,...,n
Methods of solution cont…
Successive over-relaxation method cont…
Where ~xik 1 determined using standard
Gauss-Siedel algorithm
k=iteration level,
w=acceleration parameter (>1)
Another form
k 1 k w i 1 k 1 n
xi (1 w) xi (ci aij x j aij x kj )
aii j 1 j i 1
Methods of solution cont…
Successive over-relaxation method cont..
Where 1<w<2: SOR method
0<w<1: weighted average Gauss
Siedel method
Previous value may be needed in nonlinear
problems
It is difficult to estimate w
Matrix Inversion
Sometimes the problem of solving the linear
algebraic system is loosely referred to as matrix
inversion
[A]x=c
x= [A-1]c
[A-1][A]=[I]=[A][A-1]
Pathology of linear systems
Any physical problem modeled by a set of linear
equations
Method of iteration
Nonlinear system, example: x 2 y 2 4; e x y 1
Assume x=f(x,y), y=g(x,y)
x2 f 2 ( x1, x2 ,..., xn )
.
.
.
xn f n ( x1, x2 ,..., xn )
A sufficient condition for the iterative process to
converge is
n f i
1,
j 1 x j
Newton technique of linearization
Linear approximation of the function using a tangent to the
curve
Initial estimate x0 not too far from the root
Move along the tangent to its intersection with x-axis, and
take that as the next approximation
Continue till x-values are sufficiently close or function value
is sufficiently near to zero
Newton’s algorithm is widely used because, at least in the
near neighborhood of a root, it is more rapidly convergent
than any of the other methods.
Method is quadratically convergent, error of each step
approaches a constant K times the square of the error of
the previous step.
Newton technique of linearization
The number of decimal places of accuracy doubles at each
iteration
Problem with this method is that of finding of f ’(x).
First derivative f ’(x) can be written as
f ( x0 ) f ( x0 )
tan f ( x)
'
, x1 x0 .
x0 x1 '
f ( x0 )
G( xn h, yn k ) 0 G( xn , yn ) Gx ( xn , yn )h G y ( xn , yn )k
h xn1 xn , k yn1 yn
F1 F F
x1 1 x2 ... 1 xn F1( x1, x2 ,..., xn)
x1 x2 xn
F2 F F
x1 2 x2 ... 2 xn F2 ( x1, x2 ,..., xn)
x1 x2 xn
.
.
.
Fn F F
x1 n x2 ... n xn Fn ( x1, x2 ,..., xn)
x1 x2 xn
Picard’s technique of linearization
Nonlinear equation is linearized through:
Picard’s technique of linearization
h h h
Tx y
T S Q p Rr Rs Q1
x x y y t
Bi, j hi, j 1 Di, j hi 1, j Ei, j hi, j Fi, j hi 1, j Hi, j hi, j 1 Ri, j
Picard’s technique of linearization
Where [Tyi , j Tyi , j 1 ]
Bi, j
2y 2
[Txi , j Txi 1, j ]
Di, j
2x 2
[Txi , j Txi 1, j ]
Fi, j
2x 2
[Tyi , j Tyi , j 1 ]
H i, j
2y 2
Picard’s technique of linearization
Si , j
Ei, j ( Bi, j Di, j Fi, j H i, j )
t
Si, j h0i , j
Ri, j (Q) pi , j ( R) ri , j ( R) si , j
t
B n 1, mi, j h n 1, m 1i, j 1 D n 1, mi, j hi 1, j E n 1, mi, j hi, j
Is negligibly small
The gradient of f w.r.t y is
df dQ j
dy j dy j
Q is a constant
Manning’s equation by Newton’s technique
Assuming Manning’s n constant
df
dy
j
1
So1 / 2
n
d
dy
A R
j j
2/3
1 1 / 2 2 AR1 / 3 dR
2 / 3 dA
So R
n 3 dy dy
j
1 1/ 2 2 / 3 2 dR 1 dA
So A j R j
n 3R dy A dy j
2 dR 1 dA
Q j
3R dy A dy j
The subscript j outside the parenthesis indicates that the contents are
evaluated for y=yj
Manning’s equation by Newton’s technique
Now the Newton’s method is as follows
df 0 f ( y) j
dy
j y j 1 y j
f (y j)
y j 1 y j
(df / dy) j
1 Q/Qj
y j 1 y j
2 dR 1 dA
3R dy A dy
j
x2 y2 4
xy 1
Numerical Differentiation
and Numerical Integration
Module 5
3 lectures
Contents
Derivatives and integrals
Integration formulas
Trapezoidal rule
Simpson’s rule
Gaussian-Quadrature
Multiple integrals
Derivatives
Derivatives from difference tables
We use the divided difference table to estimate values for
derivatives. Interpolating polynomial of degree n that fits at
points p0,p1,…,pn in terms of divided differences,
f ( x) Pn ( x) error
f [ x0 ] f [ x0 , x1](x x0 )
f [ x0 , x1, x 2](x x0 )(x x1)
... f [ x0 , x1,..., xn ] ( x xi )
error
s( s 1) 2 s( s 1)(s 2) 3
Pn ( s) fi sfi fi fi
2! 3!
n 1 n fi
... ( s j ) error;
j 0 n!
n f (n 1) ( )
Error ( s j )
j 0 (n 1)!
,
in [x,x0,xn].
Derivatives continued
The derivative of Pn(s) should approximate f ’(x)
d d ds
Pn ( s) Pn ( s)
dx ds dx
1 n j 1 j 1 j fi
fi ( s l ) .
h j 2 k 0 l 0 j!
l k
ds d ( x xi ) 1
Where
dx dx h h
(1)n hn (n1)
When x=xi, s=0 Error f ( ), in [x1,…, xn].
n 1
Derivatives continued
Simpler formulas
Forward difference approximation
For an estimate of f’(xi), we get
1 1 1 1
f ' ( x) [fi 2 fi 3 fi ... n fi ]x xi
h 2 3 n
With one term, linearly interpolating, using a polynomial of
degree 1, we have (error is O(h))
1 1 "
f ( xi ) [fi ] hf ( ),
'
h 2
1
error h2 f (3) ( ) O(h2 )
6
Derivatives cont…
Higher-Order Derivatives
We can develop formulas for derivatives of higher order
based on evenly spaced data
Difference operator: f ( xi ) fi fi 1 fi
Stepping operator : Efi fi 1
Or : E n fi fi n
Relation between E and : E=1+
d d
Dfi s f ( xi s ) ( E s fi )
dx dx
1 d 1
( E fi ) (ln E ) E s fi
s
h ds h
Derivatives cont…
1
If s=0, we get D ln(1 )
h
1 2 11 4 5 5
fi" f i 3
f i f i f i ...,
2 12 6
h
Divided differences
Central-difference formula
Extrapolation techniques
Second-derivative computations
Richardson extrapolations
Integration formulas
The strategy for developing integration formula is
similar to that for numerical differentiation
Polynomial is passed through the points defined by
the function
Then integrate this polynomial approximation to the
function.
This allows to integrate a function at known values
Newton-Cotes integration
b b
f ( x)dx Pn ( xs )dx
a a
s 1
h ( f 0 sf 0 )ds
s 0
1
2
1 s 1
hf0 s 0 hf 0 h( f 0 f 0 )
2 2
0
2 f 0 ( f1 f 0 ) ( f 0 f1 )
h h
2 2
Newton-Cotes integration formula
cont...
Error in the above integration can be given as
x1 s ( s 1) 1 s2 s
Error h f ( )dx h3 f " (1 )
2 "
ds
x0 2 0 2
1
s 3 s 2
h f (1 )
3 " 1 3 "
h f (1 ),
6 4 12
0
x2 h 1 5 iv
f ( x)dx ( f 0 4 f1 f 2 ) h f ( ),
x 3 90
0
x3 3h 3 5 iv
f ( x)dx ( f 0 3 f1 3 f 2 f3 ) h f ( ).
x 8 80
0
Trapezoidal and Simpson’s rule
Trapezoidal rule-a composite formula
Approximating f(x) on (x0,x1) by a straight line
Romberg integration
Improve accuracy of trapezoidal rule
Simpson’s rule
Newton-Cotes formulas based on quadratic and
cubic interpolating polynomials are Simpson’s rules
Quadratic- Simpson’s 13 rule
Cubic- Simpson’s 8 rule
3
Trapezoidal and Simpson’s rule cont…
Trapezoidal rule-a composite formula
The first of the Newton-Cotes formulas, based on
approximating f(x) on (x0,x1) by a straight line, is
trapezoidal rule
xi 1 f ( xi ) f ( xi 1) h
f ( x)dx (x) ( fi fi 1),
xi 2 2
b h
f ( x)dx ( f1 2 f 2 2 f3 ... 2 f n f n 1).
a 2
Trapezoidal and Simpson’s rule cont…
f(x)
x1 = a x2 x3 x4 x5 xn+1 = b x
Trapezoidal Rule
Trapezoidal and Simpson’s rule cont…
Trapezoidal rule-a composite formula cont…
1 3 "
Local error h f (1), x0 1 x1
12
f ( x)dx f0 3 f1 3 f 2 f3 .
3h
8
3 5 (4)
Error h f ( )
80
With an error of
(b a) 4 (4)
Error h f ( )
80
Extension of Simpson’s rule to Unequally
spaced points
When f(x) is a constant, a straight line, or a
second degree polynomial
x2
f ( x)dx w1 f1 w2 f 2 w3 f3
x1
(b a)t b a ba
x dx dt
If we let 2 so that 2 then
b a (b a)t b a
b 1
a
f ( x)dx f
2 1 2
Multiple integrals
Weighted sum of certain functional values with one variable
held constant
Add the weighted sum of these sums
If function known at the nodes of a rectangular grid, we
use these values
b
d
d b
A
f ( x, y )d A f ( x, y )dy dx f ( x, y )dx dy
ac c a
1 n
f ( x)dx ai f ( xi ).
1 i 1
1 1 1 n n n
f ( x, y, z )dxdydz ai a j ak f ( xi , yi , zk ).
1 1 1 i 1 j 1 k 1
Assignments
1. Use the Taylor series method to derive expressions for f‘(x)
and f ‘‘(x) and their error terms using f-values that
precede f0. ( These are called backward-difference
formulas.)
e dx
3 x 1
dx
x
2
e x
(a) (b)
0 0
Assignments
3. Compute the integral of f(x)=sin(x)/x between x=0 and x=1 using
Simpson’s 1/3 rule with h=0.5 and then with h=0.25. from these two
results, extrapolate to get a better result. What is the order of the
error after the extrapolation? Compare your answer with the true
answer.
4. Integrate the following over the region defined by the portion of a unit
circle that lies in the first quadrant. Integrate first with respect to x
holding y constant, using h=0.25. subdivide the vertical lines into four
panels.
cos( x) sin( 2 y)dxdy
a. Use the trapezoidal rule
b. Use Simpson’s 1/3 rule
Assignments
5. Integrate with varying values of Δx and Δy using the
trapezoidal rule in both directions, and show that the error
decreases about in proportion to h2:
1 1
2 2
( x y )dxdy
0 0
x yz dxdydz
3 2
0 0 1
Numerical Solution of
Ordinary Differential
Equations
Module 6
(6 lectures)
Contents
Taylor series method
If we assume x x0 h
Since y( x0 ) is initial condition, first term is known
y "
( ) h 2
y( x0 h) y( x0 ) y ' ( x0 ) ,
2
yn 1 yn hy'n O(h 2 ).
Euler and modified Euler methods
cont…
Problem is lack of accuracy, requiring an extremely small
step size
If we use the arithmetic mean of the slopes at the
beginning and end of the interval to compute yn+1:
yn' yn 1'
yn 1 yn h .
2
1 1
yn 1 yn h y 'n y 'n 1 y 'n O(h3 ),
2 2
y 'n y 'n 1
yn 1 yn h O(h3 ).
2
Runge-Kutta methods
Fourth and fifth order Runge-Kutta methods
Increment to the y is a weighted average of two estimates
of the increment which can be taken as k1 and k2.
Thus for the equation dy/dx=f(x,y)
yn 1 yn ak1 bk2
k1 hf ( xn , yn ),
k 2 hf ( xn h, yn k1).
1 1
k 2 hf ( xn h, yn k1 ),
2 2
1 1
k3 hf ( xn h, yn k 2 ),
2 2
k 4 hf ( xn h, yn k3 ),
Multi-step methods
Runge-kutta type methods are called single step method
The number of past points that are used sets the degree of
the polynomial and is therefore responsible for the
truncation error.
xn 1 xn 1
dy yn 1 yn f ( x, y)dx
xn xn
We approximate f(x,y) as a polynomial in x, deriving this by making it
fit at several past points
More the past points, better the accuracy, until round-off error is
negligible
Multi-step methods
Suppose that we fit a second degree polynomial through
the last three points (xn,yn),(xn-1,yn-1) and (xn-2,yn-2), we get
a quadratic approximation to the derivative function:
1 2 1
f ( x, y) h ( f n 2 f n1 f n2 ) x 2 h(3 f n 4 f n 1 f n2 ) x f n
2 2
h
yn1 yn (23 f n 16 f n1 5 f n 2 )
12
Multi-step methods
We have the formula to advance y:
h
yn1 yn [23 f n 16 f n1 5 f n 2 ] O(h4 )
12
yn 1 yn 3
4h
2 f n f n1 2 f n2 h y (1 )
28 5 v
3 90
5
yn 1,c yn 1 f n 1 4 f n f n 1
h h v
y ( 2 )
3 90
Where xn1 2 xn1
Multi-step methods
Adam-Moulton Method, more stable than and as
efficient as Milne method .
Adam-Moulton predictor formula:
h 251 5 v
yn 1 yn [55 f n 59 f n 1 37 f n 2 9 f n 3 ] h y (1 )
24 720
w d 2x dx
b kx f ( x, t )
g dt 2 dt
System of equations and higher-order
equations
Reduce to a system of simultaneous first order equations
d 2x dx
f t , x, , x(t0 ) x0, x ' (t0 ) x0'
dt 2 dt
dy
f (t , x, y), y (t0 ) x0'
dt
y1' y2 ,
y2' y3 ,
.
.
.
yn' 1 yn ,
yn' f ( x, y1 , y2 ,..., yn );
Systems of equations and higher-order
equations
With initial conditions
y1 ( x0 ) A1 ,
y2 ( x0 ) A2 ,
.
.
.
yn ( x0 ) An
d
( p z ) 0
ds
dy gB( SoC 2 B 2 y 3 Q 2 )
dx C 2 ( gBy3 BQ2 )
Examples of Pipe Flow Problems
Laminar flow, velocity distribution
r02 r 2 d
u
4 ds ( p z )
d
pA AL sin 0DL (VAL)
dt
Module 7
6 lectures
Contents
Types of finite difference
techniques
Methods of solution
Application of FD
techniques to steady and
unsteady flows in open
channels
Types of FD techniques
Most of the physical situation is represented by
nonlinear partial differential equations for which a
closed form solution is not available except in few
simplified cases
2
( x )
f ( x0 x) f ( x0 ) xf ' ( x0 ) f '' ( x0 ) O(x)3
2!
Types of FD techniques
f ’(x0)=dy/dx at x=x0
O(x)3: terms of third order or higher order of x
Similarly f(x0- x) may be expressed as
' (x) 2 ''
f ( x0 x) f ( x0 ) xf ( x0 ) f ( x0 ) O(x)3
2!
f(x)
y=f(x)
Q
A
x0-x x0 x0+x x
k+1
k
t
k-1
i-1 i i+1 x
Finite Difference Grid Approximation
Explicit and implicit techniques
There are several possibilities for approximating the partial
derivatives
Forward:
f f ik1 fik
x x
Central: f f k
f k
i 1 i 1
x 2x
Explicit and implicit techniques
k 1 k 1
f f f
Central: i 1 i 1
x 2x
Explicit and implicit techniques
By the known time level we mean that the
values of different dependent variables are
known at this time
Unstable scheme
f fik 1 fik
t t
In the above f refers to dependent variables
fik 1 f *
k k
f f f f
i 1 i 1
x 2x t t
Explicit finite difference schemes
where
1 k
f ( fi 1 fik1)
*
2
f fi* fik f f k
f k
i 1
i
t t x x
Explicit finite difference schemes
MacCormack Scheme cont…
The subscript * refers to variables computed during
the predictor part
The corrector
Corrector
fi* fi*1 * * *
2 fi 3 fi 1 fi 2
fx fx
x x
Explicit finite difference schemes
By using the above FD s and
f fi** fik
t t
and using the values of different variables
computed during the predictor part, we obtain the
equations for unknown variables.
k k
f i
k
f k
i 1 f f i
fx fx i 1
x x
Explicit finite difference schemes
Gabutti scheme cont…
By substituting
f fi** fik
t t
k k k
2 f 3 f f 2 f k
3 f k
f k
f x i 1 i 2 f x i 1 i 2
i i
x x
Explicit finite difference schemes
Gabutti scheme cont…
Corrector: in this part the predicted values are used
and the corresponding values of coefficients and
approximate the spatial derivatives by the following
finite differences:
* * * *
f f f f
f x i i 1 f x i 1 i
x x
f ( fik 1 fik1
) ( f i
k
f k
)
1 i 1
t 2t
1 k 1 k 1 1
f ( fi 1 fi ) (1 )( fik1 fik )
2 2
Implicit finite difference schemes
Preissmann Scheme
u 100(2 x) for 0 x 1
Find the temperatures as a function of x and t if both
faces are maintained at 0 degree centigrade. The one
dimensional heat flow equation is given as follows
u k 2u
t c x 2
Module 8
6 lectures
Contents
Classification of PDEs
Approximation of
PDEs through Finite
difference method
Solution methods:
SOR
ADI
CGHS
Introduction
In applied mathematics, partial differential equation
is a subject of great significance
2u 2u 2u u u
A B C D x, y, u, , 0
x 2 xy y 2 x y
Classification of PDEs cont…
The above partial differential equation can be classified
depending on the value of B2 - 4AC,
Elliptic, if B2 - 4AC<0;
parabolic, if B2 - 4AC=0;
hyperbolic, if B2 - 4AC>0.
2u 2u
0
x 2 y 2
Classification of PDEs cont…
1D advective-dispersive transport process is
represented through parabolic equation, where
B=0, C=0, so B2 - 4AC=0
2C C C
Dl u 0
x 2 t x
2u 2u
2u 0
2 2
x y
1
1 4 1
2ui, j 4 20 4ui, j 0.
6h 2
1 4 1
In this case of approximation the error is of order O(h6),
provided u is sufficiently smooth enough
Methods of solution
approximation through FD at a set of grid points (xi,yi), a
set of simultaneous linear equations results which needs to
be solved by Iterative methods
Liebmann’s Method
u (k ) u (k 1) u (k ) u (k 1) 4u (k )
(k 1) (k ) i 1, j i 1, j i, j 1 i, j 1 ij
uij uij
4
2 uL 2u0 u R u A 2u0 u B
u 0
2 2
(x) (y)
Where the subscripts L,R,A, and B indicate nodes left, right, above, and
below the central node 0. If x= y, we can rearrange to the iterative
form
ADI method of solution
Iterative form is as:
u (Ak 2) 2u0(k 2) uB
(k 2)
uL(k 1) 2u0(k 1) uR
(k 1)
ADI method of solution
This removes the bias that would be present if we use only
the row-wise traverse
The name ADI comes from the fact that we alternate the
direction after each traverse
It is implicit, because we do not get u0 values directly but
only through solving a set of equations
As in other iterative methods, we can accelerate
convergence. We introduce an acceleration factor, , by
rewriting equations
(k 2) 1 (k 2)
(k 2) (k 1) 1 (k 1) (k 1)
uA 2 u0 uB uL 2 u0 uR .
CGHS method
The conjugate Gradient (CG) method was
originally proposed by Hestens and Stiefel (1952).
Hi 1 Hi di
CGHS method
Where di is a direction vector, Hi is the
approximation to the solution vector H at the
i th iterative step.
A CG method chooses di such that at each
iteration the B norm of the error vector is
minimized, which is defined as
ei 1 B ei 1, ei 10.5
B
where
ei 1 H Hi 1 ei di
CGHS method
In which ei+1 is the error at the (i+1)th iteration. In
the above equation angle bracket denotes the
Euclidean inner product, which is defined as
n
x, y xi yi
i 1
K 1 A H K 1Y
CGHS method
Different conjugate methods are classified
depending upon the various choices of the pre-
conditioning matrix.
ri 1 ri ai A pi
si 1 K 1ri 1
bi si 1, ri 1 / si , ri
p i 1 si 1 bi pi
i i 1
End do
CGHS method
Where r0 is the initial residue vector, s0 is a
vector, p0 is initial conjugate direction vector,
ri+1,si+1 and pi+1 are the corresponding
vectors at (i+1)th iterative step, k-1 is the
preconditioning matrix and A is the given
coefficient matrix. This conjugate algorithm
has following two theoretical properties:
(a) the value {Hi}i>0 converges to the
solution H within n iterations
(b) the CG method minimizes for all
the values of i Hi H
CGHS method
There are three types of operations that are
performed by the CG method: inner
products, linear combination of vectors and
matrix vector multiplications.
8 1 1 | 8
1 7 2 | 4
2 1 9 | 12
Computation of Gradually
Varied and Unsteady Open
Channel Flows
Module 9
6 lectures
Contents
Numerical integration
methods for solving
Gradually varied flows
Finite difference
methods for Saint
Venant-equations
Examples
Introduction
For most of the practical implications, the flow
conditions in a gradually varied flow are required to
calculate.
These calculations are performed to determine the
water surface elevations required for the planning,
design, and operation of open channels so that the
effects of the addition of engineering works and the
channel modifications on water levels may be
assessed
Also steady state flow conditions are needed to
specify proper initial conditions for the computation
of unsteady flows
Introduction
Improper initial conditions introduce false transients
into the simulation, which may lead to incorrect
results
V2
H z d cos
2g
H= total head
z = vertical distance of the channel bottom above the datum
d= depth of flow section
= bottom slope angle
= energy coefficient
V= mean velocity of flow through the section
Equation of gradually varied flow
Differentiating
dH dz dd d V 2
cos
dx dx dx dx 2 g
dy So S f
dx 1 (Q 2 B) /( gA3 )
This is due to the fact that the flow depth is known at only
control section, we proceed in either the upstream or
downstream direction.
In the previous sections we discussed how to compute the
locations where a specified depth will occur
1V12 2V22
E1 y1 E2 y 2
2g 2g
1V12
H1 z1 y1
2g
Solution of gradually varied flows
Total head at section 2
H 2 H1 h f
2Q 2 1 1
F ( y2 ) y2 S f 2 ( x2 x1) z2 H1 S f1 ( x2 x1) 0
2 gA22 2 2
2Q 2 n 2 dA2 4 Q 2n 2 1 dR2
Co2 A22 R24 / 3 dy2 3 Co2 A22 R24 / 3 R2 dy2
B2 2 S f 2 dR2
2 S f 2
A 3 R2 dy2
2
Solution of gradually varied flows
Here dA2/dy2 is replaced by B2 in the above
equation and substituting for this expression
dF 2Q 2 B2 B 2 S f 2 dR2
1 ( x2 x1) S f 2 2
dy2 gA23 A2 3 R2 dy2
1. Single-step methods
2. Predictor-corrector methods
Solution of gradually varied flows
The single step method is similar to direct step method and
standard step method
Single-step methods
Euler method
' dy
yi f ( xi , yi )
dx i
Solution of gradually varied flows
The rate of change of depth of flow in a gradually varied
flow is given as below
So S fi
f ( xi , yi )
1 (Q 2 Bi ) /( gAi3 )
yi 1 yi yi' 1/ 2 x
or
yi 1 yi f ( xi 1/ 2 , yi 1/ 2 )x
This method, called the modified Euler method, is second-
order accurate.
Solution of gradually varied flows cont..
3. Improved Euler method
Let us call the flow depth at xi 1 obtained by using Euler
method as y * i.e.,
i 1
*
yi 1 yi yi' x
By using this value, we can compute the slope of the curve
y y (x ) at x xi 1 , i.e., yi' 1 f xi 1 , yi*1. Let us
use the average value of the slopes of the curve at xi and
xi 1 . Then we can determine the value of yi 1 from the
equation yi 1 yi
2
1 '
yi yi' 1 x . This equation may be
yi 1 yi
1
f ( xi , yi ) f ( xi 1 , yi*1 ) x
written as 2 . This method
called the improved Euler method, is second order accurate.
Solution of gradually varied flows cont..
4. Fourth-order Runge Kutta Method
k1 f ( xi , yi )
1 1
k2 f ( xi x, yi k1x)
2 2
1 1
k3 f ( xi x, yi k2x)
2 2
k4 f ( xi x, yi k3x)
1
yi 1 yi (k1 2k2 2k3 k4 )x
6
Solution of gradually varied flows cont..
Predictor-corrector methods
In this method we predict the unknown flow depth first,
correct this predicted value, and then re-correct this
corrected value. This iteration is continued till the desired
accuracy is met.
In the predictor part, let us use the Euler method to
predict the value of yi+1, I.e
yi(01) yi f ( xi , yi )x
we may correct using the following equation
1
yi 1 yi [ f ( xi , yi ) f ( xi 1, yi(01) )]x
(1)
2
Solution of gradually varied flows cont..
Now we may re-correct y again to obtain a better
value:
1
(2)
yi 1 yi [ f ( xi , yi ) f ( xi 1, yi(1)1)]x
2
v y v
v g g ( So S f )
x x t
General formulation
n 1 n 1 n n
f ( f i f ) ( f i f )
i 1 i 1
t t
FD methods for Saint Venant equations
Continued…
n 1 n 1
f ( fi 1 fi ) (1 )( fi 1 fi )
n n
x x x
U in 1 U in11 2
t
x
( Fin11 Fin 1) (1 )(Fin1 Fin )
t ( Sin 1 Sin11) (1 )(Sin1 Sin )
U in U in1
FD methods for Saint Venant equations
Downstream boundary:
(va)in 1 (va)in11 2
t
x
(v 2 a gay )in11 (v 2 a gay )in 1
gat ( s0 s f )in11 ( s0 s f )in 1
gat (1 )( s0 s f )in1 ( s0 s f )in
(va)in (va)in1 (1 ) 2
t 2
x
(v a gay )in1 (v 2 a gay )in
dx
1 BV 2 / gA
2. Develop computer programs to compute the water-
surface profile in a trapezoidal channel having a
free overfall at the downstream end. To compute
the profile, use the following methods:
(i) Euler method
1. daily cycles
2. transient fluctuations
Basic equations of transients
Continuity equation: applying the law of
conservation of mass to the control volume (x1
and x2) x2
t ( A)dx ( AV )
x1
2 ( AV )1 0
d
Now using hoop stress, we obtain
D dp
dt 2eE dt
Basic equations of transients
Following the above equations one can write,
1 dA D dp
A dt eE dt
K/
a2
Let us define , where a is wave speed
1 ( DK ) / eE
with which pressure waves travel back and forth.
1 v H f
L1 vv 0
g t x 2 Dg
H a 2 v
L2 0
t g x
Where,
k
a
e1 (kD / E )
Method of characteristics
Where k=bulk modulus of elasticity
=density of fluid
E=Young’s modulus of elasticity of
the material
Assume H=H(x,t);Q=Q(x,t)
Method of characteristics
Writing total derivatives ,
dQ Q Q dx dH H H dx
dt t x dt dt t x dt
Defining the unknown multiplier as
1 dx 1
a 2
dt a
Finally we get
dx dQ gA dH f
a QQ 0
dt dt a dt 2DA
P
Negative characteristic
Positive characteristic
line
line
A C B
x
Characteristic lines
QPi,n 1 Cp Ca H rd
Complex boundary condition
Dead end
At a dead end located at the end of pipe i, the
discharge is always zero:
QPi, n 1 0
Cp
H Pi, n 1
Ca
Complex boundary condition
Downstream valve
In the previous boundaries, either the head or
discharge was specified,
However for a valve we specify a relationship
between the head losses through the valve and the
discharge
Denoting the steady-state values by subscript 0,
the discharge through a valve is given by the
following equation:
Q0 Cd Av0 2gH0
Complex boundary condition
Where
Cd=coefficient of discharge
Av0=area of the valve opening
H0=the drop in head
Q0= a discharge
By assuming that a similar relationship is valid for
the transient state conditions, we get
QPi, n 1 (Cd Av ) P 2 gHPi, n 1
(Cd Av ) P /(Cd Av )0
Q( p )
C 3( m )
h( p) HR (m) C1(m) C 2(m).
QR ( m)
Where HR(m) is the rated head of the m-th pump (m), QR(m) is
the rated discharge of m-th pump (m3/s), C1(m), C2(m) and
C3(m) are empirical constants for the m-th pump obtained
from the pump charateristics. Here p refers to the element
corresponding to the m-th pump. If the actual pump
characteristics are available, the constants C1, C2, C3 may be
evaluated. C1 is determined from the shutoff head as
HO (m)
C1(m)
HR (m)
Network Analysis
Where HO(m) is the shutoff head of the m-th pump. As
h(p)=-HR(m) for rated flow,
C1(m) C 2(m) 1
1
1 H ( j ) H (i ) C 3( m )
Q( p) ()QR (m) C1(m)
C 2( m ) HR ( m )
Each formulation and method of analysis has its own advantages and
limitations. In general path formulation with Newton-Raphson method
gives the fastest convergence with minimum computer storage
requirements.
The node and path formulation can have a self starting procedure
without the need for a guess solution, but this formulation needs the
maximum computer storage.
Node based models
The node (H) equations
The number of equations to be solved can be reduced from
L+J-1 to J by combining the energy equation for each pipe
with continuity equation.
The head loss equation for a single pipe can be written as
h KQ n
nij
H i H j Kij Qij sgn Qij
Then correct the flow in each loop in such a way that the
continuity equations are not violated.
Where
Qii = initial estimate of the flow in i th pipe, L3/T
ΔQl = correction to flow in l th loop, L3/T
ml = number of pipes in l th loop
L = number of loops
Loop based models
The Qi terms are fixed for each pipe and do not change
from one iteration to the next.
and H H
1 / nij
d
i
sgn H i H j
j
1
Hi H j (1 / n )1
nij Kij 1 / n
ij
dHi Kij ij
Solution of pipe network problems
through Hardy-Cross method
The linear theory method and the Newton-Raphson
method can converge to the correct solution rapidly
Manual solution or solution on small computers may not
be possible with these methods
However, the Hardy-cross method, which dates back to
1936, can be used for such calculations, in essence, the
Hardy-Cross method is similar to applying the Newton-
Raphson method to one equation at a time
Hardy cross method is applied to Q equations although it
can be applied to the node equations and even the flow
equations.
The method, when applied to the Q equations, requires
an initial solution which satisfies the continuity equation
Solution of pipe network problems
through Hardy-Cross method
Nevertheless it is still widely used especially for manual
solutions and small computers or hand calculators and
produces adequate results for most problems
For the l th loop in a pipe network the Q equation can be
written as follows
ml
F (Q1) Ki sgn Qii Ql Qii Ql
n
dhl 0
i 1
Where
Ql=correction to l th loop to achieve convergence, L3/T
Qii=initial estimates of flow in i th pipe (satisfies
continuity),L3/T
ml=number of pipes in loop l
Solution of pipe network problems
through Hardy-Cross method
Applying the Newton-Raphson method for a single equation
gives
ml n 1
Ki (Qii Ql ) Qii Ql
Q(k 1) Q i 1
ml n 1
Ki ni Qii Ql
i 1
V V 1 p fV V
V 0
t x x 2D
1
2
8 2 1 - Node with H unknown & C known
- Node with H known & C known
3 4
- Node with H known & C unknown
Unknowns
6 7
H [2], H [4], H [5]
R [4], R [5]
C [6], C [7], C [8]
7 5 6
8 9
Contaminant Transport in
Open Channels and Pipes
Module 11
5 lectures
Contents
Contaminant transport
Definition of terms
Introduction to ADE
equation
Few simple solutions
Solution of ADE through
FD methods
Problems associated with
solution methods
Demonstration of methods
for open channel and pipe
flows
Contaminant transport
Contaminant transport modeling studies are usually
concerned with the movement within an aquifer system of a
solute.
C
u = advection of tracer with fluid
x
2C
Dl = molecular diffusion +Hydrodynamic
x 2
dispersion
C
= time rate of change of concentration
t
at a point
R = reaction term depends on reaction rate and
concentration (chemical or biological, not considered in
the present study)
Few simple solutions
Bear discussed several analytical solutions to relatively
simple, one-dimensional solute transport problems.
However, even simple solutions tend to get overwhelmed
with advanced mathematics.
C (1,0) 0 1 0
C(0, t ) C0 t 0
C (, t ) 0 t 0
Few simple solutions
For these boundary conditions the solution to ADE
equation for a saturated homogeneous porous
medium is:
vl 1 vt
(1 v t )
erfc
C 1
erfc exp
Co 2 2 Dt
2 Dl t Dl l
erfc represents the complimentary error function; l
is the distance along the flow path; and v is the
average water velocity.
For conditions in which the dispersivity Dl of the
porous medium is large or when 1 or t is large, the
second term on the right-hand side of equation is
negligible.
Few simple solutions
This equation can be used to compute the shapes of the
breakthrough curves and concentration profiles
Ci 1 Ci Ci Ci 1 Ci 1 Ci Ci C0
( Dl ) 1 ( Dl ) 1 ui
i x 2 i x 2 x t
2 2
( Dl ) 1 ( Dl ) 1 ( Dl ) 1 ( Dl ) 1
i i i i
u 1 C u
2 i C C0
2 C
i 1
2 2 i
i 1
x 2
x 2
x 2 x t i
x 2 x t
Solution of ADE through FD methods
Continued…
( Dl ) 1 ( Dl ) 1 ( Dl ) 1 ( Dl ) 1
i i i i
u 1 u C
2 C
2 2 i C 2 i C
0
x 2
i 1 x 2 x 2 x t
i x 2 x
i 1
t
Ci 1 Ci flux(x)
C(0, t ) C0 t 0;
Continued Ci 1 Ci fluxx
C (, t ) 0 t 0
Compare and discuss the results with the analytical
method.
2. Write the governing equation for transport of contaminant
in a pipe, neglecting advection and dispersion terms, and
solve to get analytical solution of the same.