Professional Documents
Culture Documents
Computational Hydraulics
Computational Hydraulics
Introduction to Hydraulics
of Open Channels
Module 1
3 lectures
Topics to be covered
Basic Concepts
Conservation Laws
Critical Flows
Uniform Flows
Unsteady Flows
Basic Concepts
Open
Conservation Laws
The main conservation laws used in open channels are
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
This
Since
Essentially
Conservation of Energy
Conservation of Energy
Mainly
Potential
In
the context of open channel flow the total energy due these factors
between any two sections is conserved
This
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.
gy
Critical flow
Fr=1
Uniform
Steady
Varied
Gradually
Gradually
Rapidly
Rapidly
Unsteady Flow
Uniform Flow
kinematic wave
diffusion wave
dynamic wave
Definitions
Specific Energy
Specific
condition
Specific Force
Definitions
F = Q2/gA +yA
Critical Flow
Flow is critical when the specific energy is minimum.
Also whenever the flow changes from sub critical to
super critical or vice versa the flow has to go
through critical condition
figure is shown in next slide
Sub-critical
Super-critical
Critical
E=y
E-y curve
1
y1
Emin
Critical Depth
Alternate Depths
45
yc
For
Q 2Tc
gAc
=1
Ac
Q2
=
2
Tc
gAc
Ac VC2
=
Tc
g
Vc
gy c
=1
Uniform Flows
This
flows
The
1 2 / 3 1/ 2
V= R S
n
Where R = the hydraulic radius = A/P
P = wetted perimeter = f(y, S0)
Y = depth of the channel bed
S0 = bed slope (same as the energy slope, Sf)
n = the Mannings dimensional empirical constant
Uniform Flows
2
1
y1
v22/2g
Sf
hf
V12/2g
y2
Control Volume
1
z2
z1
So
Datum
Uniform Flow
Example
This
The
In
1
Q = AR 2 / 3 S 1/ 2
n
Uniform Flow
This
Derivation
direction of flow
Uniform Flow
W sin 0 Px = 0
Or
Or
Ax sin 0 Px = 0
A
0 = sin
P
Uniform Flow
0 = c f (V 2 / 2)
V2
cf
= RS 0
2
V =
2g
RS 0 = C RS 0
cf
1.49 1 / 6
C=
R
n
dy S 0 S f
=
dx 1 Fr 2
the variation of depth y with the channel distance x
is shown to be a function of bed slope S0, Friction Slope Sf
and the flow Froude number Fr.
Where
This
v2/2g
Datum
V1
V2
y1 +
+ S 0 x = y 2 +
+ S f x
2g
2g
=
2g
2g
dx 2 g
After simplification,
S0 S f
dy
=
dx 1 + d V 2 / 2 g / dy
dy 2 g dy 2 gA 2
3
dy 2 g 2 gA dy
=
F
=
r
dy 2 g gA 2 D
Depending
Unsteady flows
Vw = V c
2.
3.
4.
5.
Unsteady flows
+V
=0
The equation
Q A
+ q' = 0
+
t
x
Review of Hydraulics of
Pipe Flows
Module2
3 lectures
Contents
General introduction
Energy equation
General Introduction
General introduction
Energy equation
p1
Where
p/ =pressure head
V2/2g =velocity head
z =elevation head
hp=head supplied by a pump
ht =head supplied to a turbine
hL =head loss between 1 and 2
Energy equation
Energy Grade Line
Hydraulic Grade Line
z2
hp
p/y
v2/2g
z1
Pump
z=0
Datum
Energy equation
Velocity head
V 3A
0 = f V 2 / 8
h =
L V2
= f
D 2g
32V
f =
D 2 g
64
VD
64
f =
Nr
S=
MINOR LOSSES
18.5 106 D 4V 2
Cv2 2 g
18.5 106 D 2
Cv2
P1 V12
P2 V22
z1 +
+
= z2 +
+
+ hL
g 2 g
g 2 g
If the flow velocity at a point does vary with time, the flow
is unsteady
When the flow conditions are changed from one steady
state to another, the intermediate stage flow is referred to
as transient flow
The terms fluid transients and hydraulic transients are used
in practice
The different flow conditions in a piping system are
discussed as below:
1.
2.
3.
( AV 2 ) in = ( AV 2 ) out
D=pipe diameter
L=pipe length
=specific weight of fluid
0=shear stress at the pipe wall
= .
H0
D 2g
2g
g dt
H 0 = 1 +
D 2 g
D + fL V02 V 2
d
0 = Adx + (VA)out (VA)in
dt x1
For a steady flow first term on the right hand side is zero, then we obtain
0 = ( + )(V + a + V )A (V + a )A
V +a
Since
V
a
p = gH we can write as
H =
a
V
g
Introduction to Numerical
Analysis and Its Role in
Computational Hydraulics
Module 3
2 lectures
Contents
Numerical computing
Computer arithmetic
Parallel processing
Examples of problems
needing numerical
treatment
1 + cos 2 ( x ) dx
Computer arithmetic
x x2 x3
p3 ( x ) = 1 + +
+
1! 2! 3!
xn
e = p3 ( x) +
n = 4 n!
x
Computer arithmetic
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.
through mathematical expressions which have some coefficients that
are imperfectly known.
but since humans are involved in programming, operation, input
preparation, and output interpretation, blunders or gross errors do
occur more frequently than we like to admit.
Parallel processing
Parallel processing
Parallel processing
Types of parallel processing job: In general there are three
types of parallel computing jobs
Parallel task
Parametric sweep
Task flow
Parallel task
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
Euler method
Modified Euler method
Runge-Kutta method
Predictor-Corrector method
Characteristics method
Finite difference method
Finite element method
Finite volume method
Spectral method
Boundary element method
Solution of System of
Linear and Non Linear
Equations
Module 4
(4 lectures)
Contents
F2 ( x1, x2 ,..., xn ) = 0
.
.
.
Fn ( x1, x2 ,..., xn ) = 0
Matrix notation
Matrix : a rectangular array (n x m) of numbers
a11 a12
a21 a22
A = aij = .
.
.
an1 an 2
[ ]
.
.
.
.
.
.
Matrix Addition:
C = A+B = [aij+ bij] = [cij], where
a1m
a2 m
.
.
.
anm
nxm
Matrix Multiplication:
AB = C = [aij][bij] = [cij], where
m
i = 1,2,..., n,
j = 1,2,..., r.
cij = kaij
bi =
No.ofcols.
k =1
aik xk ,
i = 1,2,..., No.ofrows
A= .
.
.
an1 an 2
.
.
.
.
.
.
a1m
a2 m
.
,
.
.
anm
x1
x2
.
x = ,
.
.
xn
b1
b2
.
b = ,
.
.
bn
0
1
0
0
0
0
1
0
0
0 = I .
0 4
1
a 0
L = b d
c e
0
0
f
a
U = 0
0
c
e
f
Tri-diagonal matrix: if
a
c
T = 0
0
0
b
d
0
b 0 0 0
d e 0 0
f g h 0
0 i j k
0 0 l m
Transpose of a matrix A
(AT): Rows are written as
columns or vis a versa.
Determinant of a square
matrix A is given by:
a
a
A = 11 12
a21 a22
Examples
4
3 1
A = 0 2 3
1 1
2
0 1
3
2 1
A = 1
4 3 2
T
of a matrix:
Note: eigenvalues are most important in applied
mathematics
For a square matrix A: we define pA() as
2
1
1
1
x1 15
4 x2 = 8
x 3 13
3
1
4
3
M
M
M
15
8
13
2
1
1
1
4
3
4
3R1 + 4 R2 0
(1) R1 + 4 R3 0
15
8 ,
13
2 R2 10 R3
2
1
1
4
0
0
2
10
0
2
10
2
1
19
11
15
77
37
15
1
19
77
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
5
3
.
66670
4
0 3.66670 4
4.33340 11
0
2
0
1
0
0 1.5000
1 2.9999
1.2000
2.2000
1.4000
2.4000
0 15.0000 12.4000 19.8000
0 0 0.04000 0.58000
1 0 0.27993 1.55990
0 1 0.82667 1.32000
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 0.49999
1 0 0 1.00010
0 1 0 0.33326
0 0 1 1.99990
1 u12
0 1
0 0
l33
l43 l44 0 0
0
0
0
0
0
a13
a23
a33
a43
a14
a24
a34
a44
j i,
i = 1,2,..., n
li1 = ai1
j 1
uij =
lii
i j,
j = 2,3,..., n.
u1 j =
a1 j
l11
a1 j
a11
Iterative Methods
Point iterative method
Jacobi method
GaussGauss-Siedel Method
x1 + 2 x2 5 x3 = 1,
2 x1 + 7 x2 + 2 x3 = 5.
x1 = 1.8333 + 0.3333x2 0.1667 x3
x2 = 0.7143 + 0.2857 x1 0.2857 x3
x3 = 0.2000 + 0.2000 x1 + 0.4000 x2
1
xi =
ci aij x j ,
aii
j =1
j i
i = 1,2,..., n
i 1
n
1
~
k +1
k +1
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
Matrix Inversion
[A]x=c
x= [A-1]c
[A-1][A]=[I]=[A][A-1]
unknowns)
x + y = 3, 2x + 2y = 6
Inconsistent
x + y = 3, 2x + 2y = 7
Method of iteration
Nonlinear system, example:
Assume x=f(x,y), y=g(x,y)
x 2 + y 2 = 4; e x + y = 1
g
g
+
<1
x
y
f ( x0 )
'
f ( x0 )
x1 = x0
f ( x1 )
'
f ( x1 )
xn +1 = xn
f ( xn )
'
f ( xn )
n = 0,1,2,...
Newton-Raphson method
F(x,y)=0, G(x,y)=0
Expand the equation, using Taylor series about xn and yn
F ( xn + h, yn + k ) = 0 = F ( xn , yn ) + Fx ( xn , yn )h + Fy ( xn , yn )k
G ( x n + h, y n + k ) = 0 = G ( x n , y n ) + G x ( x n , y n ) h + G y ( x n , y n ) k
h = xn +1 xn , k = yn +1 yn
h=
GFy FGY
FxG y G x Fy
FG x GFx
k=
FxG y G x Fy
Newton-Raphson method
F
F
F1
x1 + 1 x2 + ... + 1 xn = F1 ( x1, x2 ,..., xn)
xn
x2
x1
F
F
F2
x1 + 2 x2 + ... + 2 xn = F2 ( x1, x2 ,..., xn)
xn
x2
x1
.
.
.
Fn
F
F
x1 + n x2 + ... + n xn = Fn ( x1, x2 ,..., xn)
x1
x2
xn
i = 1,2,3,..., n
y
x
t
x x y y
Where
Bi, j =
Di, j =
Fi, j =
H i, j =
[T yi , j + T yi , j +1 ]
2y 2
[Txi , j + Txi 1, j ]
2x 2
[Txi , j + Txi +1, j ]
2x 2
[T yi , j + T yi , j +1 ]
2y 2
Ri, j =
Si, j h0i , j
t
Si , j
t
(Q ) pi , j + ( R) ri , j + ( R ) si , j
Is negligibly small
The gradient of f w.r.t y is
dQ j
df
=
dy j
dy j
Q is a constant
df
d
1
= So1 / 2
A j R 2j / 3
dy
dy j n
1 1 / 2 2 AR 1 / 3 dR
2 / 3 dA
= So
+R
n
dy
dy
3
j
1 1/ 2
1 dA
2 / 3 2 dR
= 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
y j +1 = y j
f (y j)
(df / dy ) j
1 Q/Qj
2 dR 1 dA
3R dy + A dy
1 Q/Qj
5 Bw + 6 y j
3 y j ( Bw + 2 y j )
Assignments
1. Solve the following set of equations by Gauss elimination:
x1 + x2 + x3 = 3
2 x1 + 3x2 + x3 = 6
x1 x2 x3 = 3
9 x + 4 y + z = 17,
x 2 y 6 z = 14,
x + 6 y = 4,
Assignments
3. Solve the following system by Newtons method
to obtain the solution near (2.5,0.2,1.6)
x2 + y2 + z 2 = 9
xyz = 1
x + y z2 = 0
2 x1 + x2 8 x3 = 15
x1 7 x2 + x3 = 10
Assignments
5. Find the roots of the equation to 4 significant
digits using Newton-Raphson method
x 4x +1 = 0
3
x2 + y2 = 4
xy = 1
Numerical Differentiation
and Numerical Integration
Module 5
3 lectures
Contents
Integration formulas
Trapezoidal rule
Simpsons rule
Gaussian-Quadrature
Multiple integrals
Derivatives
Derivatives from difference tables
Derivatives continued
(n + 1)!
n
f ( n +1) ( )
,
Error = ( xi x j )
j =0
(n + 1)!
j i
in [x,x0,xn].
Derivatives continued
Evenly spaced data
s=
( x xi )
h
s ( s 1) 2
s ( s 1)( s 2) 3
Pn ( s ) = f i + sf i +
fi +
fi
2!
3!
n f i
+ error ;
+ ... + ( s j )
n!
j =0
n 1
n
f ( n +1) ( )
Error = ( s j )
,
j = 0
(n + 1)!
in [x,x0,xn].
Derivatives continued
j fi
n
1
j 1 j 1
.
= fi + ( s l )
h
j = 2 k = 0 l = 0
j!
l k
Where
ds d ( x xi ) 1
=
=
dx dx
h
h
(1) n h n ( n +1)
Error =
f
( ),
n +1
in [x1,, xn].
Derivatives continued
Simpler formulas
Forward difference approximation
1
1
1
1
[f i 2 f i + 3 fi ... n fi ] x = xi
h
2
3
n
1
1 2 1 2 (3)
f
f i + h f ( ),
i
h
2
3
Derivatives cont
Central difference approximation
'
1
1
(
)
(
2
)
f
f
+
f
f
+
f
i +1
i
i+2
i +1
i + error
2
h
1 fi + 2 fi
+ error ,
h
2
1
error = h 2 f (3) ( ) = O(h 2 )
6
Derivatives cont
Higher-Order Derivatives
We can develop formulas for derivatives of higher order
based on evenly spaced data
f ( xi ) = f i = f i +1 f i
Difference operator:
Ef i = f i +1
Stepping operator :
Or
:
E n fi = fi + n
Relation between E and : E=1+
D( f ) = df / dx, D n ( f ) = d n / dx n ( f )
Differentiation operator:
s
Let us start with f i + s = E f i ,
where s = ( x xi ) / h
Dfi + s =
d
d
f ( xi + s ) =
( E s fi )
dx
dx
1 d
1
s
=
( E f i ) = (ln E ) E s f i
h ds
h
Derivatives cont
If s=0, we get
D=
1
ln(1 + )
h
1
1
1
1
fi 2 f i + 3 f i 4 f i + ... ,
h
2
3
4
1 2
11 4
5 5
+
f
f
f
f
...
,
i
i
i
i
2
12
6
Divided differences
Central-difference formula
Extrapolation techniques
Second-derivative computations
Richardson extrapolations
Integration formulas
Newton-Cotes integration
f ( x)dx = Pn ( xs )dx
a n + 1
( )dx
x1
x0
x0
f ( x)dx = ( f 0 + sf 0 )dx
s =1
= h ( f 0 + sf 0 )ds
s =0
= hf 0 s ]10 + hf 0
1
2
1
s
= h( f 0 + f 0 )
2
2
0
h
h
= [2 f 0 + ( f1 f 0 )] = ( f 0 + f1 )
2
2
x1 s ( s 1)
2 "
Error =
x0
h f ( )dx = h3 f " (1 )
s 3 s 2
1 3 "
= h f (1 )
= h f (1 ),
6
4
12
0
3 "
ds
f ( x)dx =
x0
x2
f ( x)dx =
x0
x3
f ( x)dx =
x0
h
1
( f 0 + f1 ) h3 f " ( )
2
12
h
1 5 iv
( f 0 + 4 f1 + f 2 )
h f ( ),
3
90
3h
3 5 iv
( f 0 + 3 f1 + 3 f 2 + f 3 )
h f ( ).
8
80
Romberg integration
Simpsons rule
f ( x)dx =
xi
f ( xi ) + f ( xi +1 )
h
(x) = ( f i + f i +1 ),
2
2
n h
i =12
f ( x)dx =
b
( f i + f i +1 ) =
f ( x)dx =
h
( f1 + f 2 + f 2 + f 3 + ... + f n + f n +1 );
2
h
( f1 + 2 f 2 + 2 f 3 + ... + 2 f n + f n +1 ).
2
f(x)
x1 = a x2
x3
x4
x5
Trapezoidal Rule
xn+1 = b
x0 < 1 < x1
Local error
Global error
1 3 "
= h [ f (1 ) + f " ( 2 ) + ... + f " ( n )],
12
12
Romberg Integration
1
2n 1
(more
Quadratic- Simpsons
rule
1
3
[ f0 + 4 f1 + f 2 ].
1
3
rule cont
With an error of
(b a ) 4 ( 4)
Error =
h f ( )
180
3
8
rule
3 5 ( 4)
h f ( )
80
3
8
rule cont
With an error of
(b a ) 4 ( 4)
Error =
h f ( )
80
f ( x)dx = w1 f1 + w2 f 2 + w3 f 3
x1
Gaussian quadrature
Other formulas based on predetermined evenly spaced x
values
Now unknowns: 3 x-values and 3 weights; total 6
unknowns
For this a polynomial of degree 5 is needed to interpolate
These formulas are Gaussian-quadrature formulas
Applied when f(x) is explicitly known
Example: a simple case of a two term formula containing
four unknown parameters 1 f (t ) = af (t ) +bf (t ).
If we let
x=
1
(b a )t + b + a
2
b a (b a )t + b + a
f ( x)dx =
f
2 1
2
so that
ba
dx =
dt
2
then
Multiple integrals
d
d
f ( x , y ) d A = f ( x , y ) dy dx = f ( x , y ) dx dy
a c
c a
j =1
i =1
f ( x, y )dxdy = v j wi f ij
=
y x
3 2
Multiple integrals
i =1
f ( x)dx = ai f ( xi ).
1 1 1
n n
f ( x, y, z )dxdydz = ai a j ak f ( xi , yi , z k ).
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.)
2. Evaluate the following integrals by
(i)
Gauss method with 6 points
(ii)
Trapezoidal rule with 20 points
(iii)
Simpsons rule with 10 points
Compare the results. Is it preferable to integrate backwards or
forwards?
5
(a)
x
e
dx
0
(b)
3 x 1
x
e dx
0
Assignments
3. Compute the integral of f(x)=sin(x)/x between x=0 and x=1 using
Simpsons 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.
a.
b.
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
3
2
x
yz
dxdydz
0 0 1
Numerical Solution of
Ordinary Differential
Equations
Module 6
(6 lectures)
Contents
Introduction
Introduction
Introduction
Introduction
Introduction
y ( x) = y (a ) + f (t )dt
a
Taylor-series method
If we assume x x0 = h
Since y( x0 ) is initial condition, first term is known
y '' ( x0 ) 2 y ''' ( x0 ) 3
y ( x) = y ( x0 ) + y ( x0 )h +
h +
h + ...
2!
3!
'
where 0<<h
( ) 5
h ,
5!
h
(
)
,
y ( x0 + h) = y ( x0 ) + y ' ( x0 ) +
2
yn +1 = yn + hy 'n + O (h 2 ).
1 yn +1' y 'n
'
yn +1 = yn + h y n +
+ O(h) h + O(h3 ),
2
h
1
1
y 'n + y 'n +1
+ O(h3 ).
yn +1 = yn + h
Runge-Kutta methods
yn +1 = yn + ak1 + bk 2
k1 = hf ( xn , yn ),
k 2 = hf ( xn + h, yn + k1).
f ' ( xn , yn ) + ...
df/dx=fx+fydy/dx==fx+fyf, is
1
1
yn +1 = yn + hf n + h 2 f x + f y f
2
2
n
1
(k1 + 2k 2 + 2k3 + k 4 )
6
k1 = hf ( xn , yn ),
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
Multi-step methods
x n +1
x n +1
xn
xn
dy = yn +1 yn = f ( x, y )dx
Multi-step methods
f ( x, y ) =
1
1 2
h ( f n 2 f n 1 + f n 2 ) x 2 + h(3 f n 4 f n 1 + f n 2 ) x + f n
2
2
Multi-step methods
Multi-step methods
Multi-step methods
Multi-step methods
Milnes method
dy
= f ( x, y )
dx
xn+1
xn+1
xn+1
dy
x dx dx = x f ( x, y)dx = x P2 ( x)dx
n 3
n 3
n 3
yn +1 yn 3
Where
4h
28 5 v
(2 f n f n1 + 2 f n2 ) + h y (1 )
=
3
90
xn 3 < 1 < xn +1
Multi-step methods
xn+1
xn+1
dy
x dx dx = x f ( x, y)dx = x P2 ( x)dx
n 1
n 1
n 1
5
h
h v
yn +1,c yn 1 = ( f n +1 + 4 f n + f n 1 )
y ( 2 )
3
90
Where
xn 1 < 2 < xn +1
Multi-step methods
h
251 5 v
[55 f n 59 f n 1 + 37 f n 2 9 f n 3 ] +
h y (1 )
24
720
dx
= f t , x, ,
dt
dt 2
x(t0 ) = x0,
dx
= y,
dt
x(t0 ) = x0,
dy
= f (t , x , y ),
dt
y (t0 ) = x0'
(n)
= f ( x, y, y ,..., y
y ( x0 ) = A1 ,
y ' ( x0 ) = A2 ,
.
.
.
y ( n 1) ( x0 ) = An
'
( n 1)
),
ds ( p + z )
Assignments
1. Use the simple Euler method to solve for y(0.1)
from
dy
dx
= x + y + xy
y ( 0) = 1
y (0) = 2
Assignments
3. Solve the following simultaneous differential equations by
using
(i)
A fourth order Runge-Kutta method
(ii)
A fourth order Milne predictor-corrector algorithm
dy
dz
= x yz, = y xz, y (0) = 0, z (0) = 1.0
dx
dx
For
0.5 x 0.0
''
'
''
'
Assignments
5. Find y at x=0.6, given that
y '' = yy ' , y (0) = 1, y ' (0) = 1
Begin the solution by the Taylor-series method, getting
y(0.1),y(0.2),y(0.3). The advance to x=0.6 employing the
Adams-Moulton technique with h=0.1 on the equivalent set
of first-order equations.
6. Solve the pair of simultaneous equations by the modified
Euler method for t=0.2(0.2)0.6. Recorrect until reproduced
to three decimals.
dx
dy
= xy + t , x(0) = 0, = x t , y (0) = 1,
dt
dt
Introduction to Finite
Difference Techniques
Module 7
6 lectures
Contents
Types of FD techniques
Types of FD techniques
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!
'
Types of FD techniques
f(x)
y=f(x)
B
x0-x
x0
x0+x
Types of FD techniques
Similarly
f ( x0 ) f ( x0 x)
df
=
+ O(x)
dx x = x
x
0i
k+1
k
t
k-1
i-1 i i+1
Forward:
Central:
f ik f ik1
f
=
x
x
f ik+1 f ik
f
=
x
x
k
k
f
f
f
i 1
= i +1
x
2 x
Central:
k +1
k +1
f
f
f
i
i 1
=
x
x
f ik++11 f ik +1
f
=
x
x
k +1
k +1
f
f
f
i 1
= i +1
x
2x
Unstable scheme
Approximations
k
k
f
f
f
i 1
= i +1
x
2x
f ik +1 f ik
f
=
t
t
f
f
i 1
= i +1
x
2 x
f ik +1 f *
f
=
t
t
k
k
f
f
f
i
i 1
=
x
x
f i*+1 f i*
f
=
x
x
Predictor
k
k
k
2
3
f
f
+
f
i
i 1
i2
f x+ =
x
k
k
f
f
i
f x = i +1
x
Corrector
fi* fi*1
+
fx =
x
*
*
*
2 f i + 3 f i 1 f i 2
fx =
k +1
1 *
= ( fi + fi** )
2
Predictor:
Step1: spatial derivatives are approximated as
follows:
k
k
f
f
i
+
i 1
fx =
x
k
k
f
f
i
+
1
i
fx =
x
By substituting
f i** f ik
f
=
t
t
f
+
f
2
3
i
i 1
i2
f x+ =
x
k
k
k
f
+
f
f
2
3
i
i 1
i 2
f x =
x
f
i
f x = i +1
x
*
*
f
f
i 1
f x+ = i
x
( f ik++11 f ik +1 )
x
(1 )( f ik+1 f ik )
+
x
1
1
k +1
k +1
f = ( fi +1 + fi ) + (1 )( fik+1 + fik )
2
2
Assignments
1. A large flat steel plate is 2 cm thick. If the initial
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
k 2u
u
=
c x 2
t
Assignments
2. Solve for the temperature at t=2.06 sec in the 2-cm thick
steel slab of problem (1) if the initial temperatures are
given by
x
u ( x , 0 ) = 100 sin
sin( x / 2 )
k
= f (x)
c
2
x
t
Contents
Classification of PDEs
Approximation of
PDEs through Finite
difference method
Solution methods:
SOR
ADI
CGHS
Introduction
Classification of PDEs
2u
2u
u u
A
+B
+C
+ D x, y, u , , = 0
xy
x y
x 2
y 2
2u
y
= 0
2C
C
C
+u
=0
2 t
x
x
Tg 2 y
=0
2
2
w x
t
FD Approximation of PDEs
FD Approximation of PDEs
FD Approximation of PDEs
2u
x
2u
y
=0
u ( xi +1, yi ) 2u ( xi , yi ) + u ( xi 1, yi )
(x) 2
u ( xi , yi +1 ) 2u ( xi , yi ) + u ( xi , yi 1 )
=0
(y ) 2
FD Approximation of PDEs
ui , j =
ui +1, j 2ui, j + ui 1, j
(x) 2
= 0.
x= y=h
2
ui , j =
u
+ ui 1, j + ui, j +1 + ui, j 1 4ui, j = 0.
2 i +1, j
h
FD Approximation of PDEs
2
ui , j =
1 4 1ui, j = 0.
2
1
h
This approximation has error of order O(h2),provided u is
sufficiently smooth enough
We can also derive nine point formula for Laplaces
equation by similar methods to get
4 1
1
1
2 ui , j =
4 20 4ui, j = 0.
4 1
6h 2 1
In this case of approximation the error is of order O(h6),
provided u is sufficiently smooth enough
Methods of solution
Liebmanns Method
2 ui , j =
1
4
1
ui, j = 0.
2
1
h
uij
= uij +
A method for the steady state heat equation, called the alternatingdirection-implicit (A.D.I) method, results in tridiagonal matrices and is
of growing popularity.
u L 2u0 + u R u A 2u0 + u B
u=
+
=0
2
2
(x)
( y )
2
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
+ u L
( k +1)
( k + 2)
( k + 2)
u0( k + 2) = u0( k +1) + u L( k +1) 2u0( k +1) + u R
2u0( k + 2) + u B
.
+ u A
uL
+ + 2 u0
uR
= u A 2 u0 + u B
( k + 2)
( k +1)
( k + 2) 1
( k + 2)
( k +1) 1
( k +1)
uA
+ + 2 u0
uB
= uL
2 u0
+ uR
.
CGHS method
CGHS method
CGHS method
where
ei +1 = H H i +1 = ei di
CGHS method
< x, y >= xi yi
i =1
CGHS method
CGHS method
CGHS method
CGHS method
Initialize
s0 = K r0
p0 = s 0
i=0
CGHS method
Cont
End do
CGHS method
CGHS method
Assignments
1. The equation
2u 2u u
2 2+ 2
=2
x
y
x
2 u = xy ( x 2)( y 2)
On the region 0 x 2 , 0 y 2 , with u=0 on all
boundaries except for y=0, where u=1.0.
Assignments
3. Repeat the exercise 2, using A.D.I method. Provide the
Poisson equation as well as the boundary conditions as
given in the exercise 2.
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
Introduction
Introduction
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
Differentiating
dH dz
dd
d V 2
=
+ cos
+
dx dx
dx
dx 2 g
=
=
=
3
3
dy 2 g
2 g dy
dy
gA
gA
Since, Z = A3 / T
The above may be written as
d V 2
dy 2 g
=
2
gZ
After substituting
Zc2
d V 2
=
2
dy 2 g
Z
2.22 R 4 / 3
n V
In general form,
V2
C 2R
Sf =
Q2
K2
y 2 dx
x1
y1 dy
x = x2 x1 = dx =
dy
V 2
2g
Where
H = elevation of energy line above datum;
z =elevation of the channel bottom above the datum;
y = flow depth;
V = mean flow velocity, and
=velocity-head coefficient
The rate of variation of flow depth, y, with respect to
distance x is obtained by differentiating the above equation.
downward direction)
S0 = longitudinal slope of the channel bottom
Sf = slope of the energy line
B = top water surface width
g = acceleration due to gravity
A = flow area
Q = rate of discharge
In which,
f ( x, y ) =
So S f
1 (Q 2 B) /( gA3 )
x2
y1
x1
dy = f ( x, y )dx
y2 = y1 + f ( x, y )dx
x1
= F ( x, y )
In which
1 (Q 2 B) /( gA3 )
F ( x, y ) =
So S f
y2
x2 = x1 + F ( x, y )dy
y1
1V12
2g
E2 = y 2 +
2V22
2g
Sf =
Sf =
S f1 S f 2
2 S f1 S f 2
S f1 + S f 2
1
( S f1 + S f 2 )( x2 x1)
2
1
( S f1 + S f 2 )( x 2 x1 )
2
E2 E1
1
S o ( S f1 + S f 2 )
2
2.
3.
1V12
2g
1
( S f1 + S f 2 )( x 2 x1 )
2
2Q 2
2 gA22
1
1
S f 2 ( x2 x1 ) + z2 H1 + S f1 ( x2 x1 ) = 0
2
2
In the above equation. A2 and Sf2 are functions of y2, and all
other quantities are either known or already have been
calculated at section 1.
The flow depth y2 is then determined by solving the
following nonlinear algebraic equation:
2Q 2
1
1
F ( y2 ) = y2 +
+ S f 2 ( x 2 x1 ) + z 2 H 1 + S f1 ( x 2 x1 ) = 0
2
2
2
2 gA2
Q 2n 2
2 2
2 2
dR2
= 2Q n dA2 4 Q n
2 2 4 / 3
2 2 4 / 3 dy
3 Co2 A22 R 7 / 3 dy2
2
2
Co A2 R2 Co A2 R2
2Q 2 n 2 dA2 4 Q 2 n 2
1 dR2
=
B2 2 S f 2 dR2
= 2 S f 2
+
3 R2 dy2
A
2
dF
2 Q 2 B2
B
2
2
=1
( x 2 x1 ) S f 2
+
dy 2
A2 3 R2 dy 2
gA23
y*2
If
F ( y2 )
[dF / dy2 ]*
1.
2.
Single-step methods
Predictor-corrector methods
dx i
= f ( xi , yi )
S o S fi
1 ( Q 2 Bi ) /( gAi3 )
yi +1 = yi + f ( xi , yi )( xi +1 xi )
, in which xi+1/ 2 =
1
(xi + xi+1 ) and yi +1/ 2 = yi + 1 yi' x .
2
2
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 secondorder accurate.
yi +1 = yi + yi' x
i +1
yi +1 = yi +
1 '
yi + yi' +1 x
2
yi +1 = yi +
1
f ( xi , yi ) + f ( xi +1 , yi*+1 ) x
2
. This method
written as
called the improved Euler method, is second order accurate.
1
yi +1 = yi + (k1 + 2k 2 + 2k3 + k 4 )x
6
yi(+01) = yi + f ( xi , yi )x
1
[ f ( xi , yi ) + f ( xi +1, yi(1+)1 )]x
2
Iteration until
tolerance
1
[ f ( xi , yi ) + f ( xi +1, yi(+j11) )]x
2
yi(+j1) yi(+j11)
, where = specified
Saint-Venant equations
Friction slope
Sf =
n 2v 2
r4 / 3
Saint-Venant equations
t + (v c ) x v c t + (v c ) x y = g (S o S f )
= g (S o S f )
dt
dt c dt
In which
a
=
U
va
va
F = 2
v a + gay
S=
ga ( s0 s f )
General formulation
n +1
n +1
n
n
f
+
f
f
+
f
(
)
(
)
f
i
i
i
i
+
1
+
1
=
t
t
Continued
n +1
n +1
n
n
f ( f i +1 + f i ) (1 )( f i +1 + f i )
=
+
x
x
x
f =
1
1
( f in++11 + fin +1 ) + (1 )( f in+1 + f in )
2
2
U in +1 + U in++11 = 2
t
( Fin++11 Fin +1) + (1 )( Fin+1 Fin )
x
Boundary conditions:
Downstream boundary:
Solution procedure
{[
t
(va)in++11 (va)in +1 + (1 ) (va)in+1 (va)in
x
]}
= ain + ain+1
(va)in +1 + (va)in++11 + 2
{[
= gat {(1 )[( s
{[
t
(v 2 a + gay )in++11 (v 2 a + gay )in +1
x
]}
n
n
)
(
)
s
+
s
s
0
f i +1
0
f i
+ (va)in + (va)in+1 (1 ) 2
]}
]}
t 2
(v a + gay )in+1 (v 2 a + gay )in
x
Assignments
1. Prove the following equation describes the
gradually varied flow in a channel having variable
cross section along its length:
2
dy SO S f + V / gA A / x
=
dx
1 BV 2 / ( gA)
Assignments
3. Using method of characteristics, write a
computer program to solve 1D gradually
varied unsteady flow in an open channel as
given by Saint-Venant equations, assuming
initial and boundary conditions.
Contents
Basic equation of
transients
Method of
characteristics for its
solution
Complex boundary
condition
Pipe network problems
Node based and Loop
based models
Solution through
Newton and Picard
techniques
1. daily cycles
2. transient fluctuations
t ( A)dx +( AV )
( AV )1 = 0
x1
( A) + ( AV ) = 0
t
x
dt
K dt
dt
d
D dp
=
dt 2eE dt
a2 =
1+
=0
K eE / DK dt
K/
1 + ( DK ) / eE
Let us define
, where a is wave speed
with which pressure waves travel back and forth.
+V
+ a 2
=0
Method of characteristics
H
Q
=0
+ gA
t
x
Method of characteristics
Where,
H a 2 v
L2 =
+
=0
t
g x
k
a=
e[1 + (kD / E )]
Method of characteristics
+ gA
+
x
t
T x 2 DA
Assume H=H(x,t);Q=Q(x,t)
Method of characteristics
dx
= a 2
dt
1
a
Finally we get
dx
= a
dt
dH H H dx
=
+
dt
t
x dt
dQ gA dH
f
+
QQ =0
dt
a dt
2 DA
Method of characteristics
Figure
t
P
Negative characteristic
line
Positive characteristic
line
Characteristic lines
Cp
Ca
Where
Cv = (Q0 ) 2 /(Ca H 0 )
2.
3.
4.
5.
Q( p) + Q( p) + C ( j ) = 0,
p { j}
j = 1,..., NJ
p { j}
Network Analysis
2. Energy conservation equations the energy conservation
equations state that the energy loss along a path equals
the difference in head at the starting node and end node
of the path.
l = 1,..., NL + NPATH
p {l}
p {l}
Where h(p) is the head loss in element p(m), s(l) is the
starting node of path l, e(l) is the end of path 1, NL is the
number of loops, and NPATH is the number of paths other
than loops and p {l} refers to the pipes belonging to path
l. loop is a special case of path, wherein, the starting node
and end node are the same, making the head loss around
a loop zero, that is,
( )h( p) + ( )h( p) = 0
Network Analysis
3. Element characteristics the equations defining the
element characteristics relate the flow through the element
to the head loss in the element. For a pipe element, h(p) is
given by,
e
h( p ) = R( p )Q( p )
Network Analysis
For a pump element, h(p) is negative as head is gained in the
element. The characteristics of the pump element are defined
by the head-discharge relation of the pump. This relationship
may be expressed by a polynomial or in an alternate form. In
this study, the following equation is used.
C 3( m )
Q( p)
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
From which C2(m)is determined. C3 (m) is obtained by
fitting the equation to the actual pump characteristics.
For a pipe element,
h( p )
Q( p) =
R
(
p
)
(1 / e )
H (i ) H ( j )
R( p ) (1/ e ) H (i ) H ( j )
(11 / e )
H (i ) H ( j )
R ( p ) 0.54 H (i ) H ( j )
0.46
Network Analysis
HR
(
m
)
C
2
(
m
)
1
C 3( m )
Network Analysis
The network analysis problem reduces to one of solving a set of nonlinear algebraic equations. Three types of formulation are used the
nodal, the path and the node and path formulation.
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 formulation is conceptually simple with a very convenient
data base, but it has not been favoured earlier, because in
conjunction with Newton-Raphson method, the convergence to the
final solution was found to depend critically on the quality of the initial
guess solution.
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.
nij
sgn Qij
Qij = sgn( H i H j )( H i H j / K ij )
Qki = U i
k =1
mi
1 / nki
= Ui
Then correct the flow in each loop in such a way that the
continuity equations are not violated.
= dhl
(l=1,2,,L)
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
The Qi terms are fixed for each pipe and do not change
from one iteration to the next.
The Q terms refer to the loop in which the pipe falls
The flow in a pipe is therefore Qi + Q for a pipe that lies in
only one loop.
For a pipe that lies in several loops (say ,a b, and c) the
flow might be
Qi + Qa Qb + Qc
dF F ( x + x) F ( x)
=
dx
x
x =
F ( x)
F ' ( x)
1 / nij
Ui = 0
(i = 1,2,..., K )
F
F
F
H k
H 2 + ... +
H1 +
H k
H 2
H1
[ (
and
)]
1 / nij
H H
j
d
i
sgn H i H j
dH i
K ij
[ (
)]
(H i H j )(1 / n )1
(nij )(Kij )1 / n
ij
ij
1 / nij
(nij )(Kij )1 / n
ij
(H i H j )(1 / n )1
ij
dhl = 0
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
K i (Qii + Ql ) Qii + Ql
Q(k + 1) = Q i =1
ml
K i ni Qii + Ql
n 1
n 1
i =1
Assignments
1. How many Q equations must be set up for a network
with L loops (and pseudo-loops), N nodes, and P pipes?
How many H-equations must be set up?
2. What are the primary differences between the HardyCross and Newton-Raphson method for solving the Q
equations?
3. For two pipes in parallel, with K1>K2, what is the
relationship between K1, K2, and Ke , the K for the
equivalent pipe replacing 1 and 2 (h=KQn)?
a. K1>K2>Ke
b. K1>Ke>K2
c. Ke>K1>K2
Assignments
4. Derive the following momentum equation by applying
conservation of momentum for a control volume for
transient flow through a pipe
V 1 p fV V
V
+
=0
+
+V
2D
x x
t
5. Develop the system of equations for the following network
(consists of 8 nodes and 9 elements, out of which 8 are
pipe elements and the other is a pump element) to find the
values of the specified unknowns. Also write a computer
program to solve the system of equations.
Assignments continued
1
2
- Pump element
6
7
Unknowns
H [2], H [4], H [5]
R [4], R [5]
C [6], C [7], C [8]
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
Definition of terms
Terminologies related to contaminant
transport
Diffusion: It refers to random scattering of
particles in a flow to turbulent motion
C
x
2C
x 2
1 0
C (0, t ) = C0
t0
C ( , t ) = 0
t0
vl
C
1
(1 v t )
erfc
=
+ exp
Co 2
Dl
2 Dl t
1 + vt
erfc
2 Dt
1
x i +
x i 1
( Dl ) 1
i+
Ci +1 Ci
x 2
2 u Ci +1 Ci = Ci C0
i
Ci Ci 1
Ci +1 Ci Ci C0
( Dl ) 1
ui
=
2
x
t
i
x
2
( Dl ) 1
( Dl ) 1 ( Dl ) 1
i+
i
i+
i
u
u
C0
1
2 C
2 +
2 i +
2 i C
C +
=
i +1
i
i 1
2
2
2
2
x
t
x
t
x
x
x
x
( Dl ) 1
( Dl ) 1
i
i+
i+
u
u
C
1
2 C
2 +
2 i +
2 i C
C
+
= 0
i
1
i
i
+
1
x 2
x 2
x t
x
t
x 2
x 2
( Dl ) 1
Ci +1 = Ci + flux(x)
x > 0;
C (0, t ) = C0
t > 0;
Ci 1 = Ci flux(x )
Assignments
1. Considering the one-dimensional flow of a solute through
the soil column, write a computer program for solving the
given contaminant transport equation by finite difference
technique. The boundary conditions represented by the
step function input are described mathematically as:
C (1,0) = 0
1 0
C (0, t ) = C0
t0
C ( , t ) = 0
t0