Introduction FEM, 1D-Example

Transcription

Introduction FEM, 1D-Example
Introduction FEM, 1D-Example
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/cover_sheet.tex
. – p.1/22
Table of contents
1D Example - Finite Element Method
1. 1D Setup – Geometry
2. Governing equation
3. General Derivation of Finite Element Method
4. Shape functions
5. Assembling the matrix
6. Calculation of the matrix entries
7. Solving the set of equations
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/toc_fem_intro.tex
. – p.2/22
1D-Example: Finite Element Method
Given :
1. Geometry
∆x = 1 m
Hlef t
Q
acements
x
4m
2
1
Universität Stuttgart
3
4
5
1
2
3
4
∆x
∆x
∆x
∆x
2. Permeability
kf = 10−5 m/s
3. Boundary conditions
Q = 10−4 m3 /s
Hlef t = 50 m
4. Notation
1 denotes node 1
1 denotes element 1
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/1d_setup_fem.tex
. – p.3/22
Governing Equations (FEM – 1D)
Continuity equation
∇·v−q =0
Momentum equation −→ (Darcy equation)
v = −kf ∇h
−→
∇ · (−kf ∇h) − q = 0
∂
∂h
1D −→
(−kf ) − q = 0
∂x
∂x
Assumption: No sinks or sources
−→
Universität Stuttgart
∂2h
−kf · 2 = 0
∂x
(Laplace-Equation)
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/gov_eqn_fem1.tex
. – p.4/22
Introducing shape functions (FEM – 1D)
We now introduce an approximate function h̃(x) where hˆj is the
piezometric head at the nodes and Nj (x) is called shape function
h̃(x) =
n
X
j=1
hˆj · Nj (x).
Inserting this approximation into the Laplace equation yields a
residuum (error) ε:
−∇ · (kf · ∇h̃) − q = ε
We introduce a weighting function W. The differentiation is transformed making use of the product rule and the integral rule of
Gauss. Then we make use of the boundary condition [vo =
(kf · ∇h̃) · n] and get the weak formulation:
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/starting_equ.tex
. – p.5/22
Starting equation II (FEM – 1D)
Z
G
1D
[∇W ] · kf · [∇h̃]dx =
Z
Z
W · vo dx −
Γ
∂ h̃
∂W
· kf ·
dx =
∂x
∂x
G
Z
Z
W · qdx
G
W · vo dx −
Γ
Z
W · qdx
G
The standard Galerkin method uses the shape functions N as
weighting functions W.
Wi = N i
;
h̃(x) =
n
X
j=1
Universität Stuttgart
hˆj · Nj (x)
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/starting_equ2.tex
. – p.6/22
Equation in matrix from (FEM – 1D)
Z
∂Ni
· kf ·
∂x
∂
P
n
j=1
hˆj · Nj (x)
∂x
Z
Z
dx =
Ni · vo dx − Ni · qdx
{z
}
|
| {z }
F lux over boundary
ĥj does not depend on x.
X
hˆj ·
Z
Z
∂Nj (x)
∂Ni
· kf ·
dx = Ni · vo dx −
∂x
∂x
{z
} |
{z
|
Aij
n
X
j=1
Universität Stuttgart
hˆj · Aij = bi
bi
⇐⇒
A · ĥ = b
Z
Sources/Sinks
Ni · qdx
}
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/stiffnessmat.tex
. – p.7/22
Shape functions (FEM – 1D)
cementsConstruction of the local shape functions N1 and N2 . We can
use linear functions, as we have only first order derivatives in the
“weak approximation”.
Element 1:
(1)
N1
hˆ1
∆x
1
x=0
hˆ2
1
2
x=1
∆x=1m
Universität Stuttgart
(1)
N2
y=1
(1)
y=1
N1
(1)
x
1
x=0
1
2
x=1
x
=1−x
N2 = x
1 : Element 1
1,2 : nodes
∆x=1m
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/shape_funct.tex
. – p.8/22
Shape functions II (FEM – 1D)
Construction of the local shape functions N1 and N2 , which are
also called trial functions, interpolation functions or basis functions. We can use linear functions, as we have only first order
derivatives in the “weak approximation”.
These shape functions need to be adjusted for the other elements. The slope remains the same but the y-intercept changes.
Element 2 for example has the following shape functions
(2)
N1 = 2 − x
Universität Stuttgart
(2)
N2 = x − 1.
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/shape_funct2.tex
. – p.9/22
Shape functions III (FEM – 1D)
By adding the products of piezometric head at the nodes hˆj and
the local ansatz functions Nj one gets an approximate solution
h̃(x) between the nodes
Element 1:
hˆ1
n
X
(1)
h̃
i
i
PSfrag
replacements
hˆ · N (x)
h̃ (x) =
j
j
j=1
h̃(1) (x) = h1 (1 − x) + h2 x
(1)
h̃ (x) = h1 + (h2 − h1 )x
In this case we have a linear in- ∆ x
terpolation.
Universität Stuttgart
1
x=0
1
hˆ2
2
x=1
x
∆x=1m
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/shape_funct3.tex
. – p.10/22
System of equations (FEM – 1D)

(1)
K11
 (1)
K21

 0


 0
0
(1)
K12
(1)
(2)
K22 + K22
(2)
K32
0
0
0
0
(2)
K23
0
(2)
(3)
(3)
K33 + K33
K34
(3)
(3)
(4)
K44 + K44
K34
(4)
0
K54
  

0
h1
−Q1
  

0  h2  −Q2 
  

h3  = −Q3 
0 
  



(4)   
K45  h4  −Q4 
(4)
h5
−Q5
K55
h1 is known (Dirichlet boundary conditions).
→ Delete the corresponding row and column.
 (1)
  
(2)
(2)
(1) 
K22 + K22
K23
0
0
h2
−Q2 − h1 K21
(2)
(2)
(3)
(3)

 h  

K
+
K
K
0
K
−Q

  3 

3
32
33
33
34
=






(3)
(3)
(4)
(4)


−Q4
K44 + K44 K45  h4  
0
K34
(4)
(4)
h5
−Q5
0
0
K54
K55
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/set_of_eqn.tex
. – p.11/22
Calculating matrix entries (FEM – 1D)
Example 1: Calculation of the matrix entry A23 (weighting
function of node 2, shape function of node 3). The stiffness
integral can be divided into different parts. At each element of
A23 , except for element 2, the shape function or the weighting
function equals zero.
(1)
(2)
(3)
A23 = K23 + K23 + K23
(1)
(3)
K23 = K23 = 0
(2)
A23 = K23 =
Z2
=⇒
(2)
(2)
A23 = K23
(2)
∂N1
∂N2
· kf ·
dx
∂x
∂x
1
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/matr_entr_23a.tex.tex
. – p.12/22
Calculating matrix entries II (FEM – 1D)
A23 =
(2)
K23
=
Z2
∂(x − 1)
∂(2 − x)
· kf ·
dx
∂x
∂x
Z2
−1 · kf · 1 dx = kf · [−x]21
1
(2)
A23 = K23 =
1
(2)
A23 = K23 = kf [−(2 − 1)] = −kf
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/matr_entr_23b.tex
. – p.13/22
Calculating matrix entries III (FEM – 1D)
Example 2: Calculation of the matrix entry A55 . The stiffness integral can be divided into different parts.
(1)
(2)
(3)
(4)
A55 = K55 + K55 + K55 + K55
(1)
(2)
(3)
(4)
K55
Z4
K55 = K55 + K55 = 0
A55 =
=
=⇒
(4)
(4)
A55 = K55
(4)
∂N2
∂N2
· kf ·
dx
∂x
∂x
3
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/matr_entr_55a.tex
. – p.14/22
Calculating matrix entries IV (FEM – 1D)
A55 =
(4)
K55
=
Z4
∂(x − 3)
∂(x − 3)
· kf ·
dx
∂x
∂x
3
(4)
A55 = K55 =
Z4
1 · kf · 1 dx = kf · [x]43
3
(4)
A55 = K55 = kf [(4 − 3)] = kf
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/matr_entr_55b.tex
. – p.15/22
Calculating matrix entries V (FEM – 1D)
Example 3: Calculation of the matrix entry A22 . The stiffness integral can be divided into different parts. In this case, only the
weighting function and the shape function in element 3 and 4
equal zero.
(1)
(2)
(3)
(4)
A22 = K22 + K22 + K22 + K22
(3)
(4)
K22 = K22 = 0
(1)
K22 =
=⇒
(1)
Z1
∂N1
∂N1
· kf ·
dx
∂x
∂x
=
Z1
(1)
(2)
A22 = K22 + K22
(1)
0
(1)
K22
∂x
∂x
· kf ·
dx
∂x
∂x
0
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/matr_entr_22a.tex
. – p.16/22
Calculating matrix entries VI (FEM – 1D)
(1)
K22 =
Z1
1 · kf · 1 dx = kf · [x]10
0
(1)
K22
(2)
K22 =
Z2
1
(2)
K22
=
Z2
1
Universität Stuttgart
= kf [1 − 0] = kf
(2)
(2)
∂N1
∂N1
· kf ·
dx
∂x
∂x
∂(2 − x)
∂(2 − x)
· kf ·
dx
∂x
∂x
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/matr_entr_22b.tex
. – p.17/22
Calculating matrix entries VII (FEM – 1D)
(2)
K22 =
Z2
−1 · kf · −1 dx = kf · [x]21
1
(2)
K22 = kf [(2 − 1)] = kf
(1)
(2)
A22 = K22 + K22 = 2kf
All other matrix entries can be calculated analogously.
A32 = A34 = A43 = A45 = A54 = −kf
A33 = A44 = 2kf
A21 = A12 = −kf
Universität Stuttgart
;
A11 = kf
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/matr_entr_22c.tex
. – p.18/22
Inserting values in matrix (FEM – 1D)
Inserting these values one obtains the following system of equations:

  
h2
−Q2 + h1 kf
2 −1 0
0

−1 2 −1 0  h  
−Q3


  3 
kf · 

  = 

0
1
2 −1 h4  
−Q4
h5
−Q5
0
0 −1 1

Q2 = Q3 = Q4 equal zero, as there are no sinks and sources in
the domain. Q5 is the known Neumann boundary condition.
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/values_matrix.tex
. – p.19/22
Solving the set of equations (FEM – 1D)
By transforming the vector representation one obtains a linear
system of equations. Inserting the boundary conditions we have
four equations for four unknowns.
2h2 − h3 = 50
−h2 + 2h3 − h4 = 0
−h3 + 2h4 − h5 = 0
−104
−h4 + h5 =
kf
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/lgse.tex
. – p.20/22
Solving the set of equations (FEM – 1D)
With kf = 10−5 and using the Thomas algorithm, we express our
unknown in terms of one other unknown and the left boundary
condition.
50 1
h2 =
+ h3
2
2
50 2
h3 =
+ h4
3
3
25 3
h4 =
+ h5
2
4
−4
10
25
h5 = 4 − −5 +
.
10
2
Substituting back yields the following result
h1 = 50m ; h2 = 40m ; h3 = 30m ; h4 = 20m ; h5 = 10m.
Universität Stuttgart
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/lgse2.tex
. – p.21/22
Test of the solution (FEM – 1D)
Test: Q1 + Q5 = 0 has to be fulfilled.
h1 ·
(1)
A11
+ h2 ·
50 · kf + 40 · −kf = −Q1
=⇒
Universität Stuttgart
(1)
A12
=⇒
= −Q1
Q1 = −10−4 m/s
Q 1 + Q5 = 0
Institut für Wasserbau, Lehrstuhl für Hydromechanik und Hydrosystemmodellierung
/home/lehre/VL-MHS-1/INHALT/lgse2a.tex
. – p.22/22