Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

Department of Mechanical and Aerospace Engineering

Aerospace Computational Mechanics

The Method of Weighted Residuals

Prof. Murray Rudman


Department of Mechanical and Aerospace Engineering,
Monash University

Lecture 28
Problems with the Finite Difference Approach

•  When solving problems with finite difference methods


we are faced with several problems:
•  Geometric problems
•  We are forced to consider simple geometries
•  Δx and Δy are (often) constant throughout the domain.

•  Difficulty in handing boundary conditions


•  For an irregular boundary shape, it is difficult to apply
Nuemann (derivative) boundary conditions

•  Matrix size problems


•  In general, we have to find the inverse of a large, sparse
matrix to solve the problem.
•  This problem won’t go away with MWR.

2
An Industrial Example – Tube bundle heat exchanger

•  The flow over the


tubes significantly
affects the cooling
potential.

•  How would you use


the finite-difference
method to solve this
problem?

3
An Industrial Example

•  Multi-phase fluid flow.

•  The image to the right shows


bubble formation around
heating rods in a fluidized bed.

•  How would you use the finite-


difference method to solve this
problem?

•  It will be difficult due to the


complex geometry.

4
A real world example – Weather prediction

•  Meteorolgy predictions
require very large domains.

•  The image on the right is a


snapshot of tornadoes
forming.

•  On the bottom right is a www.psc.edu/science/droeg.html

schematic of the mesh used.

•  The volume required was


67x67x17 km.

5
A real world example – Weather prediction

•  When adding a
landmass, the
mesh used is not
only very large,
but also very
complex.

6
Examples in Industry

•  The images here show the stress


and displacement of a pressure
vessel under load.

•  A finite element technique was used


to calculate these solutions and
generate the images.

7
The Method of Weighted Residuals (MWR)

•  To date, we have considered solving an ordinary- or partial-


differential equation by approximating the derivative terms.

•  For example, the 1D (non-dimensionalised) heat equation:

∂Q ∂2Q
= 2
∂t ∂x
has been rewritten in finite difference format as:

Q n+1
j − Q n
j Q n
− 2Q n
+ Q n
= j−1 j j+1

Δt Δx 2

•  You should know how to describe this differencing scheme AND


also know what it’s limitations are

8
The Method of Weighted Residuals

•  By contrast, in the method of weighted residuals (MWR) we


assume the answer can be written analytically.
•  For example, to obtain the solution for the diffusion equation:

∂Q ∂2Q
= 2
∂t ∂x
Using MWR, the following approximate solution is written:
N
Q = ∑ a j (t) φ j (x)
j=1

Where:
•  aj are unknown coefficients and
•  φj are known analytic functions

9
The Method of Weighted Residuals

N
Q = ∑ a j (t) φ j (x)
j=1

•  If we choose φj well, then we should be able to approximate the


exact answer.

•  An example of this type of solution is the use of a Fourier series


approximation:

Q= ∑ k
A e ikx

k=−∞

•  In general:

φj(x) are referred to as the trial functions and


Q is referred to as the trial solution.
10
General Formulation – Defining the Residual

•  The starting point for a MWR is to assume an approximate


solution. Our approximation to Q is written
N
Q(x, t) = Q0 (x, t) + ∑ a j (t) φ j (x)
j=1

•  Here Q0(x,t) is chosen to satisfy boundary and initial


conditions.

•  Remember, the trial functions φj(x) are known, the aim is to


determine the coefficients aj(t).

•  We determine aj(t) by solving a system of equations


generated from the governing (differential) equation.

11
General Formulation

•  As an example, we will consider the heat equation:

∂Q ∂2Q ∂Q ∂2Q
=κ 2 OR L(Q) = −κ 2 = 0
∂t ∂x ∂t ∂x

•  Here, we write the exact solution with an overbar, Q.

•  If we apply the operator L to our approximate solution, Q, it will not


in general be exactly zero

•  Therefore, we may write:


∂Q ∂2Q
L(Q) = −κ 2 = R
∂t ∂x

•  Where R is referred to as the residual.


12
General Formulation

•  A visual example of the residual might look like:

The area
highlighted in
blue is the
residual

Here the red line is the 'real' answer. The blue dashed line is the
approximate solution.

As we include more terms in the approximate solution (that defines


the blue dashed line), it approximates the red line more closely.
13
General Formulation

•  A visual example of the residual might look like:

The area
highlighted in
blue is the
residual

Here the red line is the 'real' answer. The blue dashed line is the
approximate solution.

As we include more terms in the approximate solution (that defines


the blue dashed line), it approximates the red line more closely.
14
General Formulation
N
Q(x, t) = Q0 (x, t) + ∑ a j (t) φ j (x)
j=1

•  As suggested on the previous slide, given sufficient trial


functions φj(x) we can, in principle, determine
coefficients aj(t) which will provide a good
approximation.

Ensuring a good approximation to the real solution


requires that:

L(Q) ⇒ 0

across the computational domain.


15
General Formulation

•  In general, the coefficients aj(t) are determined by


requiring that the integral of the residual (multiplied by a
weight function) over the domain is zero:

∫ W (x) R(x)dx = 0
m (1-D problem) OR

∫∫∫ W (x, y, z) R(x, y, z)dx dy dz = 0


m (3-D problem)

where, Wm is known as the weight function.

•  The weight function allows us to choose a Q which


does not exactly satisfy the analytical solution.

Why do we want to do this?


16
General Formulation

•  If we substitute our definition of the residual into the


previous equation we obtain:

∫W m (x) L(Q)dx = 0

•  This is known as the 'weak form' of our original


problem. We want to solve for this 'weak form'.

•  Remember, the heat equation we are looking at is:

∂Q ∂2Q
L(Q) = −κ 2
∂t ∂x
17
General Formulation

∫W m (x) L(Q)dx = 0 OR ∫Wm (x) R(x)dx = 0

•  Different choices of Wm (the weight function) create


different methods of solving the differential problem.

•  Several methods exist, including:

•  Subdomain method
•  Collocation method
•  Least-Squares method
•  Galerkin method

18
Different Techniques - Subdomain method

∫∫ W m (x, y) R(x, y)dx dy = 0


The subdomain method (in 2-D)

In this method, the domain is first divided into a series


of sub-domains.
Dm
We set:

Wm = 1 inside subdomain Dm

Wm= 0 outside Dm
19
Different Techniques - Subdomain method

∫∫ W m (x, y) R(x, y)dx dy = 0

The subdomain method

•  The subdomain method is equivalent to the finite


volume method.

20
Different Techniques - Collocation method

∫∫ W m (x, y) R(x, y)dx dy = 0

The collocation method

•  For the collocation method, we set: rm =(xm ,ym)

Wm (x, y) = δ ( r − rm ) r =(x,y)

•  Here δ is the dirac delta function.

•  This is equivalent to setting R(xm , ym) = 0.

21
Different Techniques - Collocation method

∫∫ W m (x, y) R(x, y)dx dy = 0

The collocation method

•  Setting R(xm) = 0 states that we will obtain the exact


solution of our problem at a set of points xm.

T1 T2 T3
The collocation method
is equivalent to the finite T4 T5 T6
difference method.

T7 T8 T9
22
Different Techniques – The Galerkin method

∫∫ W m (x, y) R(x, y)dx dy = 0

The Galerkin method

•  Here, we set Wm(x,y) =φm(x,y)

It has been shown that for certain types of


functions φm, the Galerkin method will always
approach the analytical answer as m→ ∞.

The Galerkin method is used within the Finite


Element method.
23
Summary: The Finite Element Method

•  Most finite element computer software uses:

•  A Method of Weighted Residuals to formulate the problem


solution.

•  The Galerkin method to specify the weighting function.

24
Summary: The Method of Weighted Residuals

•  When using the method of weighted residuals, we


follow the following steps.

1.  Choose the trial functions


2.  Analytically determine the residual
3.  Choose the weight functions
4.  Solve the following equation

∫∫ W m (x, y) R(x, y)dx dy = 0

•  By solving this equation we may determine the unknown


coefficients aj and solve the original problem.

•  This integral problem is known as the 'weak' form of the


original problem. 25
Department of Mechanical and Aerospace Engineering

Aerospace Computational Mechanics

Solution to an ODE - The Galerkin method

Prof. Murray Rudman


Department of Mechanical and Aerospace Engineering,
Monash University

Lecture 28
Application to an Ordinary Differential Equation

•  We will now apply the Galerkin technique to solve the


following ordinary differential equation:

dq
−q = 0 for 0 ≤ x ≤ 1
dx
We will set a boundary condition q =1 at x = 0

This problem has an exact solution:

x
q(x) = e

Noting the solution is just a function of x, our first step is to write:


N
q(x) = q0 (x) + ∑ a jφ j (x)
j=1
27
Application to an Ordinary Differential Equation

N
q(x) = q0 (x) + ∑ a jφ j (x)
j=1

•  The second step is to choose a set of trial functions φj(x)

j
•  Here we choose: φ j (x) = x
and note that φj(0) = 0

•  Remember that here q0 must satisfy the boundary conditions


- in this case q = 1 at x = 0.
N
•  Therefore we have: q(x) = 1+ ∑ a j x j
j=1

28
Application to an Ordinary Differential Equation
N
q(x) = 1+ ∑ a j x j
j=1
•  This form of the solution naturally satisfies the boundary
conditions. That is, q = 1 at x = 0,

•  Our next step is to substitute this approximate solution into the


ordinary differential equation to obtain an equation for the residual:

dq
−q = R
dx
•  Here, I have a derivative term, this may be determined as:

dq N
= ∑ a j j x j−1
dx j=1
29
Application to an Ordinary Differential Equation

•  Take our expressions for q and dq/dx


N
dq N
q(x) = 1+ ∑ a j x j = ∑ a j j x j−1
j=1 dx j=1

•  Substitute them into our equation for the residual


dq
−q = R
dx
•  Gives us an expression for the residual

N
R = −1+ ∑ a j ( j x j−1 − x j )
j=1

30
Application to an Ordinary Differential Equation
N
R = −1+ ∑ a j ( j x j−1 − x j )
j=1

•  Now that we have an equation for the residual we can


write the 'weak' form of our problem:
1

∫W m (x) R(x)dx = 0
x=0

•  The limits of the integration are the limits from the


original problem:
1 # N &
∫ Wm (x)%%−1+ ∑ a j ( j x − x )(( dx = 0
j−1 j

x=0 $ j=1 '


31
Application to an Ordinary Differential Equation
1 # N &
∫ Wm (x)%%−1+ ∑ a j ( j x − x )(( dx = 0
j−1 j

x=0 $ j=1 '

•  The choice of Wm depends on the type of solution


method that we are going to choose.

•  For this problem, we will consider the Galerkin


technique.

•  Therefore our weight functions are the same as our trial


functions:
Wm (x) = φ m (x) = x m
32
Application to an Ordinary Differential Equation
1 # N &
∫ Wm (x)%%−1+ ∑ a j ( j x − x )(( dx = 0
j−1 j

x=0 $ j=1 '

Wm (x) = φ m (x) = x m
•  What does the subscript m imply?

•  Note that there are N unknown coefficients aj.

•  Therefore we need N equations to determine the coefficients.


•  We will determine them by choosing N different values of m.

•  This will give us N equations which must be solved


simultaneously.

•  This will be shown further into the example.

33
Application to an Ordinary Differential Equation
1 # N &
∫ Wm (x)%%−1+ ∑ a j ( j x − x )(( dx = 0
j−1 j

x=0 $ j=1 '

•  Substituting Wm= xm into the above equation yields:


1 # N &
∫ x m %%−1+ ∑ a j ( j x j−1 − x j )(( dx = 0
x=0 $ j=1 '

•  Which can be written as:

1 #% N '
m+ j %
∫ $%−x + ∑ a j ( j x − x )(% dx = 0
m m+ j−1

x=0 & j=1 )

•  We now determine the analytic solution to this integral equation.


34
Application to an Ordinary Differential Equation
1 #% N '
m+ j %
∫ $%−x + ∑ a j ( j x − x )(% dx = 0
m m+ j−1

x=0 & j=1 )

•  This equation may be integrated as:


1 1
" −x m+1 % N "( x m+ j x m+ j+1 +%
$ ' + ∑ a j $* j − -' = 0
# m +1 &0 j=1 #) m + j m + j +1 ,&0

•  Or:
N
−1 " j 1 %
+ ∑aj $ − '=0
m +1 j=1 # m + j m + j +1 &
for 1 ≤ m ≤ N (i.e., we have N equations)

35
Application to an Ordinary Differential Equation

N
−1 " j 1 %
+ ∑aj $ − '=0
m +1 j=1 # m + j m + j +1 &

•  In this equation, the only unknowns are the coefficients


aj.

•  Once we know these coefficients we can substitute


them back into the equation for the trial solution for q
N
q(x) = 1+ ∑ a j x j
j=1

•  Remember, q(x) is the approximate solution to the


problem.
36
Application to an Ordinary Differential Equation

N
−1 " j 1 %
+ ∑aj $ − '=0
m +1 j=1 # m + j m + j +1 &

•  We can rewrite this equation in matrix form as:

[C] [ A ] = [ D]
•  Where C is a matrix ⎛ j 1 ⎞
Cm , j = ⎜⎜ − ⎟⎟
⎝ m + j m + j + 1 ⎠
1
D is a column vector Dm =
m +1

and [A] is a column vector of the unknown coefficients, aj


37
Application to an Ordinary Differential Equation

[C] [ A ] = [ D]

•  Now that the problem is written in matrix format, we can


easily solve the problem.

•  Thus:
−1
[ A ] = [C] [ D]

•  We could also use Gauss-Seidel or the SOR method to


solve this problem.

38
Application to an Ordinary Differential Equation
N
•  An example: −1 " j 1 %
+ ∑aj $ − '=0
m +1 j=1 # m + j m + j +1 &
Let N = 3. Determine the coefficients aj and hence the approximate
solution the ODE

By setting N = 3, we develop the following system of equations:

⎡ 1 / 6 5 / 12 11 / 20 ⎤ ⎡ a1 ⎤ ⎡1 / 2⎤
⎢1 / 12 3 / 10 13 / 30⎥ ⎢a ⎥ = ⎢1 / 3⎥
⎢ ⎥ ⎢ 2 ⎥ ⎢ ⎥
⎢⎣1 / 20 7 / 30 5 / 14 ⎥⎦ ⎢⎣ a3 ⎥⎦ ⎢⎣1 / 4⎥⎦

This has the following solution:


a1 = 1.0345
a2 = 0.3879
a3 = 0.3017
39
Application to an Ordinary Differential Equation

a1 = 1.0345, a2 = 0.3879, a3 = 0.3017

•  Using these three coefficients, we write the approximate solution


as: q(x) = 1+1.0345x + 0.3879x 2 + 0.3017x 3
3

2.5

•  Compare to the 2
actual solution
q(x) = e x 1.5

•  We find an RMS approximation solution


0.5
error of 0.0388. exact solution
0
0 0.2 0.4 0.6 0.8 1 1.2

•  This error reduces as we include more terms in the trial solution,


i.e. more of the φj(x)
40
Comparison of FDM vs. MWR

•  The Finite Difference Method (FDM) to solve PDE


•  Basic strategy: approximate the derivatives in the equations
and then solve these finite difference equations at the grid
points
•  Pros: easy to understand, conceptually easy
•  Cons: irregular geometry, unusual boundary condition and
heterogeneous materials difficult to include

•  The Method of Weighted Residuals (MWR)


•  Basic strategy: approximate the solution by expansions of trial
functions and solved the “weak form” of ODE/PDE
•  Pros: it is a general framework to derive several popular
numerical methods. No restrictions by geometry
•  Cons: complicated mathematics
Learning Objectives from today's lecture

•  We have considered some new ideas today.

•  You should be able to describe each of the following


after today's lecture:

•  Weighted Residual methods

•  The Galerkin technique

•  The 'weak' form of a differential problem.

While an example was shown, you are not expected to


repeat this under exam conditions.

42

You might also like