Vous êtes sur la page 1sur 50

ELE 626/726 Computational Methods in Electromagnetics (H.U.

)
EE 522 Numerical Methods for Electromagnetics (METU)

Lecture 6:
Introduction to Finite Element Method (FEM)

by
zlem zgn & Mustafa Kuzuolu

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 1


Variational Methods
FEM is a variational method developed for the approximate solution
of boundary value problems governed by partial differential equations.

A variational principle is a scientific principle used within the calculus


of variations, which develops general methods for finding functions
which minimize or maximize the value of quantities that depend upon
those functions.

FEM is an element-wise
application of a variational
method."

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 2


Boundary Value Problem (BVP)
There is a partial differential equation (PDE) valid in a region, which is a
subset of , , or .

The partial differential operator is shown by ,


the unknown function by ,
and the unknown right-hand-side (RHS) function .

(1) LD u = f in
The boundary condition (BC) is given as:

(2) Bu = g on

where is a partial differential operator, is a
given function, and is the boundary of .

(1)+(2) is the definition of a BVP.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 3


Boundary Conditions

Dirichlet BC (it prescribes the field value at the boundary, and is an essential
BC that must be imposed explicitly)

u = g
Neumann BC (it requires the normal derivative of the field value to vanish at
the boundary, and is called a natural BC since it is satisfied implicitly and
automatically in the solution phase)

u n
= n u = g
n

du
Mixed BC u + =g
dn
If =0 , Dirichlet BC
If = 0, Neumann BC

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 4


Boundary Value Problem (BVP)

Example: (Poisson Equation in Electrostatics)

2u = f in
u=0 on

2 2 2

2 = = 2 + 2 + 2
x y z
Laplacian operator

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 5


Approximate Numerical Solution

Consider a DE in operator form: LD u = f

Step 1: Express the unknown function in terms of


some known functions as follows:
N
u u = u j j
j =1

where , ( = , , , ) are unknown coefficients,


and , ( = , , , ) are approximating, expansion, trial,
shape or basis functions.

As a result of this approximation, we have only a finite


number of unknowns (i.e., coefficients ).

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 6


Approximate Numerical Solution

Consider a DE in operator form: LD u = f

Step 2: Substitute the approximation into the operator equation, and


use the linearity of the operator.

LD u f
N
LD u j j f
j =1
Using linearity:
N

u L
j =1
j D j f

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 7


Approximate Numerical Solution

Consider a DE in operator form: LD u = f

Step 3: Define , which is the residual (or error function).

Note that " or " $,


because = " is satisfied only for the exact solution.

The residual is defined as: R = f LD u


f
Our aim is to minimize the residual (error), R
i.e., to make as small as possible.
LD u
analogy
Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 8
Approximate Numerical Solution

Two classes of variational methods for finding approximate solutions

Ritz Method Method of


(based on minimization Weighted
of a "functional") Residuals
(to be used in this course)

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 9


Ritz Method

It is a variational method where the BVP is formulated in terms of a functional.


Functional (function of a function) is a function that takes a function as its
input argument, and returns a scalar.

1
F ( u ) = Lu , u f , u
2

To obtain an approximate solution, the functional is minimized with respect


to the unknown coefficients.

F
=0
ui
A matrix system is formed and solved for the unknown coefficients.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 10


Method of Weighted Residuals

Remember the residual: R = f LD u

To minimize the residual, we take the inner product of the residual


with some linearly independent weighting (or testing) functions %& ,
' = 1, 2, , * and equate the result to zero.

R , wi = 0 or R w d = 0

i i = 1, 2,..., N

This approach is called Method of Weighted Residuals.

Why is weighting needed?


It guarantees obtaining as many algebraic equations as there are
unknown coefficients in the approximate solution
(i.e., * equations in * unknowns).

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 11


Method of Weighted Residuals
We obtain * equations in * unknowns as follows:

R , wi = 0
f LD u , wi = 0
LD u , wi = f , wi
N

u L ,w
j =1
j D j i = f , wi

u
j =1
j LD j , wi = f , wi i = 1, 2,..., N

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 12


Method of Weighted Residuals

Form the matrix equation: [ A][ x ] = [b ] or Aij u j = [ bi ]

Elements of the matrix [,] are: Aij = LD j , wi = wi LD j d


Elements of the right-hand-side bi = f , wi = wi f d


(RHS) vector b are:
i, j = 1, 2,..., N

T
Unknown vector: x = [u1 u2 ... u N ]
Solution of this matrix system gives the unknown coefficients ..

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 13


Method of Weighted Residuals

Depending on the choice of weight functions,


there are different weighted residual methods.

Collocation Subsectional Galerkin Petrov- Least


(or point-matching) Collocation Method Galerkin Squares
method Method Method Method
(to be used in
this course)

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 14


Galerkin Method

The weight functions are chosen to be the same as the basis functions.

wi = i ' = 1, 2, , *

R , i = 0

Matrix entries: Aij = LD j , i bi = f , i

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 15


An Example

Consider the following DE: d 2u


2 = 1 + 4x2
dx
Find (/) in [0, 1] given that (0) = (1) = 0
2
Note that LD u = f L =
d 2
, f = 1 + 4 x
dx 2

Use these basis functions j = x x j +1 , j = 1, 2,..., N

Note that these basis


functions satisfy the
given BCs.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 16


An Example
Approximate the unknown function as a weighted sum of basis functions:

N N
u ( x ) = u j j ( x ) = u j ( x x j +1 )
j =1 j =1

Substitute it into DE:

d2 N j +1
2 u j ( x x ) = 1 + 4 x 2
dx j =1
Linearity

Simplify
d2 j +1
N N

u j 2
( x x ) = 1 + 4 x 2
j
u j ( j + 1) x j 1
= 1 + 4 x 2

j =1 dx j =1

LD j
Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 17
An Example
Using the Galerkin approach, the weight functions are chosen to be the same as
the basis functions.

wi = i = x x i +1 , i = 1, 2,..., N

Using the method of weighted residuals, multiply the equation by the weight
function and integrate.
1 1
d 2u
0 dx 2 i 0
2
w ( x ) d x = (1 + 4 x ) wi ( x ) dx

LD u f

LD u , w = f , w
Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 18
An Example
Therefore,
1 N 1

j
j 1 2
u j ( j + 1) x wi dx = (1 + 4 x ) wi dx
0 j =1 0

N 1 1

j
u j
j =1
( j + 1) x j 1
( x x i +1
) dx = (1 + 4 x 2
) ( x x i +1
) dx
0 0

N
ij i (3i + 8)

j =1
uj =
i + j + 1 2(i + 2)(i + 4)

Aij bi

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 19


An Example

Matrix system:

[ A][ x ] = [b ]
ij
Aij =
i + j +1
', 0 = 1, 2, , *
i (3i + 8)
bi =
2(i + 2)(i + 4)

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 20


An Example

For N = 1:

1 11 11 11
A11 = b1 = u1 = u( x ) ( x x 2 )
3 30 10 10

For N = 2:

1 1 11 1
3 2 u1 30 u1 10
= u = 2
1 4 u2 7 2
2 5 12 3

1 2
u( x )
10
( x x 2
) +
3
( x x3 )

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 21


An Example
For N = 3:

1 1 3 11
3 1
2 5 u 30 u1 2
1
1 4
1 u2 = 7 u = 0
2 5 12 2
3 u u3 1
9 3 51
1 3
5 7 70

1 1 (exact
u( x )
2
( x x 2
) +
3
( x x4 ) solution)

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 22


An Example

For N = 4: For N = 5:

1 1
u1 2 u1 2
u 0 u 0
2 = 2
u3 1 u3 = 1
3 3
u4 u4
0 u5 0
0

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 23


An Example

u(x)

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 24


Weak Variational Form

The weighted integral in the previous slides is NOT solved directly.


Instead, it is converted to weak form by applying the integration by
parts technique.

Weak Form is defined as a weighted integral statement of a


differential equation in which the differentiation is transferred
from the dependent variable to the weight function such that all
natural boundary conditions of the problem are also included in
integral statement.

i.e., It becomes easy to impose BCs.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 25


Weak Variational Form

Consider the following BVP:

d du
a ( x ) = f ( x ) for 0< x<
dx dx

BCs: u (0) = u0 du
a = Q
dx x =

Here, 1 / , / , 2 , 3 are known, and is the size of the domain.

In electrostatics, is the electric potential, 1 / is 7 / and


/ is the charge density. Typically, 2 = 0 and 3 = 0.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 26


Development of Weak Variational Form

Step 1: Based on the weighted residual method,


move all terms of the differential equation to one side,
multiply the equation by the weight function 8(/),
and integrate over the domain 9 = ($, ).


d du
0 w dx a dx f dx = 0

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 27


Development of Weak Variational Form

Step 2: Using the integration-by-parts technique,


express the integral as follows:


d du

du dw du
0 dx a dx
w f dx = 0

0 a dx dx w f dx wa = 0
dx 0
Original (strong form) New (weak form)

w dv = v dw + [ wv ]0
integration-by-parts
technique
0 0

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 28


Development of Weak Variational Form
Step 3: Impose the boundary conditions.


du du du
Consider the term: wa dx = wa dx wa dx
0 x = x =0

( wQ ) x =0 ( wQ ) x =
Since 0 = 2 w(0) =0


du dw
Weak Form: 0 a dx dx wf dx ( wQ ) x = = 0

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 29


We havent discussed so far how to systematically define the
approximation (basis, shape) functions.

Traditional variational methods have difficulty in constructing the


approximation functions, especially when the given domain is complex.

Finite Element Method


overcomes these difficulties by providing a systematic way of
constructing the approximation functions.

FEM is an element-wise application of a variational method."

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 30


Basic Idea in FEM

Divide the entire region into small subdomains


(called elements),
Use approximation functions over each
element,
Apply the method of weighted residuals in
each element,
Combine the elemental equations to get the
global equation system and solution.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 31


Types of Finite Elements

Element geometry is defined by node locations.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 32


FEM
Consider the following 1D BVP:

d 2u
2 u = x2 0< x <1
dx
u (0) = 0, u (1) = 0

Exact solution:

sin( x ) + 2 sin(1 x )
u exact = + x2 2
sin(1)

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 33


FEM
Assume that the interval is divided into 4 elements.

There are 5 nodes (NN = 5) and 4 elements (NE = 4).

Elements e =1 e =2 e =3 e =4

Global Nodes 1 2 3 4 5
x
Coordinates x1 x2 x3 x4 x5

x1=0 e = 0.25 x5=0

This is a mesh of linear elements (elements are defined by 2 nodes).

This mesh is uniform, i.e., element length : = 0.25 is constant.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 34


FEM
The approximate solution is written as:

NN NN : Number of Nodes
u = u j j . : Nodal unknown coefficients
j =1 =. : Basis/approximation functions

With linear elements, we obtain a piecewise linear approximation to solution.

u
u3
u4
u2

u1 = 0 u5 = 0
x
x1 x2 x3 x4 x5

e=1 e=2 e=3 e=4

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 35


FEM
Define linear approximation functions:

e-2 e-1 e e+1 x


j-2 j-1 j j+1 j+2

The above sum should provide nodal unknown values at the nodes.
This is satisfied if the following Kronecker-Delta property holds:

1 if i = j
j ( xi ) = , i , j = 1, 2,..., NN
0 if i j

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 36


1
1

x
FEM
e =1 e =2 e =3 e =4

1 2 1 2 3 4 5
1
x

x
1 e =1 e =2 e =3 e =4
3

x These are Lagrange type basis functions.


They satisfy the Kronecker-Delta property.
1
4 They make sure that the solution is
continuous across elements, but not its first
x derivative.
They have local support, i.e., nonzero only
1 5 over at most two elements.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 37


FEM

u33 Each j is multiplied with uj


u3 u44
u4
u22
u2

u11 u55
u1 =u5 = 0 x
e=1 e=2 e=3 e=4

u
u3 NN
u4
u = u j j
u2 j =1

u1 = 0 u5 = 0
x
e=1 e=2 e=3 e=4

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 38


FEM
Instead of thinking about nodal basis functions, concentrate on elements.
j j+1

e-2 e-1 e e+1


Node based thinking j-2 j-1 j j+1 j+2
x

j j+1

Element based thinking e x


j j+1

N1e N 2e

1
"Shape" functions e x
1 2

e = x j +1 x j = x2e x1e

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 39


FEM
Local node numbering
Global node
numbers

j e j+1
x
xj xj+1

Local node
numbers

1 e 2
e e x
x 1
x 2

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 40


FEM
N1e N 2e
Similar to s, shape functions also have
the Kronecker-Delta property: 1
x
1 if i = j e
x x e
N (x ) =
e
j
e
i
1 2

0 if i j e
e
x2e x x x
Linear element shape functions are: e
N1 = N 2e = 1

e e
FEM solution over eth element is:

u1e ue ( x) Number of elements nodes


u2e NEN (=2 for linear elements)
e
u = j j
u e
N e

N1e N 2e j =1

1
x Nodal unknown at eth
x1e x2e elements jth node

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 41


FEM

Weak form over the d 2u


entire domain [0, 1] R = 2 u + x2
dx

1 1
d 2u 2
R w dx = 0
0
0 dx 2
w w u + w x dx = 0

Integration by parts

1 1
dw du du
0 dx dx dx w dx 0

1 1
dw du 2 du
Weak form: w u + wx dx w =0
0 dx 0
dx dx

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 42


FEM
Elemental weak form over eth element

x2e
du dw 2 du du
e dx dx w u + wx dx w dx x = xe + w dx x = xe = 0
x1 2 1

e
Using Galerkin method, weight functions are
chosen to be identical to shape functions.
wi = N i

x2e
dN ej dN ie dN e
dN j
e

e dx dx N i N j + N i x dx N i dx e + N i dx e = 0
e e e 2 e j e

x1 x = x2 x = x1

', 0 = 1,2

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 43


FEM

This will yield > > elemental matrix system:

Ae x e = b e

Elemental Elemental Elemental


matrix unknown RHS
> > vector vector
> >

NEN = 2 for linear elements.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 44


FEM

1
Positions of elemental matrix systems
in global matrix system:
x
e =1 e =2 e =3 e =4

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 45


FEM
Assembly Process: Combine the elemental systems to obtain the global system.

x
e =1 e =2 e =3 e =4

A111 1
A12 0 0 0 u1 b11
1 1 u 1 2
A21 A22 + A112 A122 0 0 2 b2 + b1
0 A221 2
A22 + A113 A132 0 u3 = b22 + b13
3 4 3 4
0 0 A21 A232 + A114 A12 u4 b2 + b1
0 0 0 4
A21 A242 u5 b24

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 46


FEM

Global matrix system:

[ A][ x ] = [b ]
Global Global Global RHS
matrix unknown vector
vector

This system has 5 equations for 5 unknowns (NN=5).

But, 1 and 5 are known due to the BCs.

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 47


FEM
Imposition of Dirichlet BCs: Apply reduction to the **** system and drop
the 1st and 5th equations, because 1 and 5 are known and zero.

A11 A12 0 0 0 u1 b1
A A22 A23 0 0 u2 b2
21
0 A32 A33 A34 0 u3 = b3

0 0 A43 A44 A45 u4 b4
0 0 0 A54 A55 u5 b5

The reduced system is 33

A22 A23 0 u2 b2 A21u1 A25u5


A A33 A34 u3 = b3 A31u1 A35u5
= 5=0
1
32 due to BCs
0 A43 A44 u4 b4 A41u1 A45u5

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 48


FEM

Solving this system gives


FEM
u2 0.0232
u = 0.0405
3
u4 0.0392
u(x)
Exact values are
exact
u2 0.0234
u = 0.0408
3
u4 0.0394
x

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 49


FEM
Higher order elements in 1D problems:
Linear elements have 2 nodes.
It is possible to use higher order elements, which make use of more nodes.
When quadratic (3-node) elements are used, the solution is approximated by
quadratic polynomial functions.
The following solution uses 3 quadratic elements (NE=3) with a total number
of 7 nodes (NN=7).

Prepared by zlem zgn (Hacettepe U.) and Mustafa Kuzuolu (METU) 50

Vous aimerez peut-être aussi