Finite Element Application in Water Engineering: Example
Finite Element Application in Water Engineering: Example
Finite Element Application in Water Engineering: Example
Example
Consider the water flow in a one dimensional river
x=0 x=L
d 2h
= − f ( x) (1)
dx 2
h(0, t ) = h0 = 40 cm , h( L, t ) = hL = 200 cm , L = 10 m
1) Discretization
Node 1 2 3 4 5
x=0 x = 10m
2) Element Equations
We use linear elements
1
~
h
hj
hi
i j
xi xj
~
h = N i hi + N j h j (2)
∫ RW dx = 0
i i = 1, 2,…, m (3)
∫ RN dx = 0
i i = 1, 2,…, m (5)
2
1 1
N1 N2
i j
x1
x2
For the one dimensional river, we use linear elements,
x
⎡ 2 ~ ⎤
⎢ d h + f ( x ) ⎥ N i dx = 0 , i = 1, 2
∫
2
x1 ⎢ dx 2
⎥
⎣ ⎦
∫
x 2 d 2 h
N i dx = − ∫
x 2
f ( x ) N i dx , i = 1, 2 (6)
x1 dx 2 x1
dv du
∫ dx udx = uv − ∫ dx
vdx integration by parts
~ ~
dv d 2 h d dh u = Ni
Let = 2
= ( ) ,
dx dx dx dx
x2
⎡ ⎤
i = 1, 2
~ ~ ~
x2 d2 h ⎢ d h ⎥ −
x2 d h dN i ,
∫ x1 dx 2
N i dx = N i
⎢ dx ⎥ ∫ x1 dx dx
dx
⎣ ⎦ x1
For i = 1,
~
⎡ ~ ~
⎤
d h dN 1 d h ( x ) d h ( x1 ) ⎥
dx = ⎢ N 1 ( x 2 )
x2 x2
∫x1 dx dx ⎢ dx
2
− N 1 ( x1 )
dx ⎥
+ ∫x1
f ( x ) N 1 dx
⎣ ⎦
~
d h ( x1 ) x2
= −
dx
+ ∫
x1
f ( x ) N 1 dx (7a)
3
For i = 2,
~
⎡ ~ ~
⎤
x2 d h dN 2 ⎢ d h ( x ) d h ( x1 ) ⎥ x2
∫x1 dx dx
dx = N 2 ( x2 )
⎢ dx
2
− N 2 ( x1 )
dx ⎥ ∫x1
+ f ( x) N 2 dx
⎣ ⎦
~
d h( x2 ) x2
=+ + ∫ f ( x) N 2 dx (7b)
dx x1
dN1 d x 2 − x −1 1
= ( )= = − , l is the length of the element
dx dx x 2 − x1 x 2 − x1 l
dN 2 d x − x1 1 1
= ( )= =
dx dx x2 − x1 x2 − x1 l
~
dh d h h 1
= ( N1h1 + N 2 h2 ) = − 1 + 2 = (−h1 + h2 )
dx dx l l l
~
x2 d h dN1 x2 1 1 1 x2 1
∫x1 dx dx
dx = ∫ (−h1 + h2 )(− )dx = 2 (h1 − h2 ) ∫ dx = (h1 − h2 )
x1 l l l x1 l
The first term in (7b) becomes
~
x2 d h dN 2 x2 1 1 1
∫x1 dx dx
dx = ∫ x1 l
( − h1 + h2 )( ) dx == ( − h1 + h2 )
l l
~
1 d h( x2 ) x2
l
( − h1 + h 2 ) =
dx
+ ∫x1
f ( x ) N 2 dx (8b)
⎧ ~
⎫
⎪− d h ( x1 ) ⎪ ⎧ x2 ⎫
1 ⎡ 1 − 1⎤ ⎧ h1 ⎫ ⎪ dx ⎪ ⎪ ∫x1 f ( x) N1dx ⎪
or ⎨ ⎬=⎨ ~ ⎬+⎨ x ⎬ (9)
l ⎢⎣− 1 1 ⎥⎦ ⎩h2 ⎭ ⎪ d h( x ) ⎪ ⎪ 2 f ( x) N 2 dx ⎪
⎪ dx ⎪ ⎩ 1
2 ∫ x ⎭
⎩ ⎭
--- this is the matrix equation in the local system.
4
In this example, l=10/4=2.5, f(x)=10, then the water source terms in (8a) and (8b)
become
Assembly
Node 1 2 3 4 5
x=0 x = 10 m
5
In the global system the matrix for element 1 becomes
0 ⎤ ⎧ h1 ⎫ ⎧ − d h ( x 1 ) / dx + 12 . 5 ⎫
~
⎡1 −1 0 0
⎢− 1 ⎥ ⎪ ⎪ ⎪ ~ ⎪
1 0 0 0 ⎥ ⎪ h 2 ⎪ ⎪ d h ( x ) / dx + 12 . 5 ⎪
1⎢ ⎪ ⎪ ⎪ 2 ⎪
⎢ 0 0 0 0 0⎥⎨ 0 ⎬ = ⎨ 0 ⎬
l⎢ ⎥⎪ ⎪ ⎪ ⎪
⎢ 0 0 0 0 0⎥ 0
⎪ ⎪ ⎪ 0 ⎪
⎢⎣ 0 0 0 0 0 ⎥⎦ ⎪⎩ 0 ⎪⎭ ⎪ ⎪
⎩ 0 ⎭
⎡0 0 0 0 0⎤ ⎧ 0 ⎫ ⎧ 0 ⎫
⎢0 ⎪ ⎪
0 ⎥⎥ ⎪⎪ h2 ⎪⎪ ⎪ − d h ( x2 ) / dx + 12 .5 ⎪
~
1 −1 0
1⎢ ⎪ ⎪ ⎪ ~ ⎪
⎢0 −1 1 0 0 ⎥ ⎨ h3 ⎬ = ⎨ d h ( x3 ) / dx + 12 .5 ⎬
l⎢ ⎥
⎢0 0 0 0 0⎥ ⎪ 0 ⎪ ⎪ 0
⎪
⎪ ⎪ ⎪ ⎪
⎢⎣ 0 0 0 0 0 ⎥⎦ ⎪⎩ 0 ⎪⎭ ⎪⎩ 0 ⎪⎭
0 ⎤ ⎧ h1 ⎫ ⎧ − d h ( x ) / dx + 12 .5 ⎫
~
⎡1 −1 0 0
⎢− 1 1 + 1 − 1 ⎥ ⎪ ⎪ ⎪ 1 ⎪
0 0 ⎥ ⎪ h2 ⎪ ⎪ 0 + 12 .5 + 12 .5 ⎪
1⎢ ⎪ ⎪ ⎪ ~ ⎪
⎢0 −1 1 0 0 ⎥ ⎨ h3 ⎬ = ⎨ d h ( x ) / dx + 12 .5 ⎬
l⎢ ⎥
0⎥ ⎪ 0 ⎪ ⎪ ⎪
3
⎢0 0 0 0
⎪ ⎪ ⎪ 0 ⎪
⎢⎣ 0 0 0 0 ⎥
0 ⎦ ⎪⎩ 0 ⎪⎭ ⎪ ⎪
⎩ 0 ⎭
0 ⎤ ⎧ h1 ⎫ ⎧− d h( x ) / dx + 12.5⎫
~
⎡ 1 −1 0 0
⎢− 1 1 + 1 − 1 ⎥ ⎪ ⎪ ⎪ 1 ⎪
⎥ ⎪⎪ 2 ⎪⎪ ⎪⎪ ⎪
0 0 h
1⎢
25
⎪
⎢ 0 − 1 1 + 1 − 1 0 ⎥ ⎨h3 ⎬ = ⎨ 25 ⎬
l⎢ ⎥⎪ ⎪ ⎪ ⎪
⎢0 0 − 1 1 + 1 − 1⎥ h4
⎪ ⎪ ⎪ ~ 25 ⎪
⎢⎣ 0 0 0 ⎥
− 1 1 ⎦ ⎪⎩h5 ⎪⎭ ⎪ d h( x ) / dx + 12.5 ⎪
⎩ 5 ⎭
6
~
At the two boundaries h1 = 40 cm and h5 = 200 cm (but d h( x1 ) / dx and
~
d h( x5 ) / dx are not known). Therefore the global equation becomes
0 ⎤ ⎧ 40 ⎫ ⎧− d h( x ) / dx + 12.5⎫
~
⎡1 −1 0 0
⎢− 1 1 + 1 − 1 ⎥⎪ h ⎪ ⎪ ⎪
1
⎢ 0 0 ⎥ ⎪⎪ 2 ⎪
⎪⎪ ⎪ 25 ⎪
⎪
⎢0 − 1 1 + 1 − 1 0 ⎥ ⎨ h3 ⎬ = ⎨ 25 ⎬ × 2 .5
⎢ ⎥
⎢0 0 − 1 1 + 1 − 1⎥ ⎪ h4 ⎪ ⎪ ⎪
⎪ ⎪ ⎪ ~ 25 ⎪
⎢⎣ 0 0 0 − 1 1 ⎥⎦ ⎪⎩200 ⎪⎭ ⎪ d h( x ) / dx + 12.5 ⎪
⎩ 5 ⎭
In the above, there are 3 unknowns in equations 2, 3 and 4, so we can solve these
⎡ 2 − 1 0 ⎤ ⎧h2 ⎫ ⎧ 62 .5 + 40 ⎫ ⎧102 .5 ⎫
⎢ − 1 2 − 1⎥ ⎪ h ⎪ = ⎪ ⎪ ⎪ ⎪
⎢ ⎥⎨ 3 ⎬ ⎨ 62 .5 ⎬ = ⎨ 62 .5 ⎬
⎢⎣ 0 − 1 2 ⎥⎦ ⎪⎩ h 4 ⎪⎭ ⎪62 .5 + 200 ⎪
⎩ ⎭
⎪ 262 .5 ⎪
⎩ ⎭
⎡2 − 1 0 ⎤ ⎧ h2 ⎫ ⎧ 102 . 5 ⎫
⎪ ⎪ ⎪ ⎪
⎢ 0 1 .5
⎢ − 1⎥⎥ ⎨ h3 ⎬ = ⎨113 . 7 . 5 ⎬
⎢⎣ 0 − 1 2 ⎥⎦ ⎪⎩ h4 ⎪⎭ ⎪⎩ 262 . 5 ⎪⎭
⎡2 − 1 0 ⎤ ⎧h2 ⎫ ⎧ 102 .5 ⎫
⎢ 0 1 .5 − ⎥ ⎪ h ⎪ = ⎪113 .7.5⎪
⎢ 1 ⎥⎨ 3 ⎬ ⎨ ⎬
⎢⎣0 0 1.333 ⎥⎦ ⎪⎩h4 ⎪⎭ ⎪⎩ 338 .33 ⎪⎭