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

Technological and Higher Education Institute of Hong Kong

Faculty of Science and Technology


Civil Engineering

SCE5401 Computational and Engineering Analysis

Tutorial 7 – Solutions

Question 1

Solve the boundary value problem in Illustrative Example 1 of Topic 3 Part 1 again using Galerkin’s
method with boundary conditions given below. The trial function is to have one basis function. The
ODE is
𝑑! 𝑢
− = 𝑢 − 𝑥 ! ; 𝑥 ∈ (0, 1)
𝑑𝑥 !
and the boundary conditions are
u(0) = 0
u(1) = 1
Compare the solution against the exact solution, which is
2(1 − cos 1)
𝑢(𝑥) = 2 cos 𝑥 + sin 𝑥 + 𝑥 ! − 2
sin 1

Solution

Step 1 – Convert the differential equation to weak form


The strong form is
𝑑! 𝑢
− = 𝑢 − 𝑥!
𝑑𝑥 !
Rearrange the strong form into residual equation
𝑑! 𝑢
𝑅= + 𝑢 − 𝑥!
𝑑𝑥 !
Multiply the residual equation by weighting function
𝑑! 𝑢
𝑤" 𝑅 = 𝑤" 7 ! + 𝑢 − 𝑥 ! 8
𝑑𝑥
Set the sum of weighted residual within the domain to 0
#
9 𝑤" 𝑅 = 0
$

Therefore,
#
𝑑! 𝑢
9 𝑤" 7 ! + 𝑢 − 𝑥 ! 8 = 0
$ 𝑑𝑥
which is the weak form of the differential equation.

Revision : Rev0
Prepared by : Dr. Cliff Leung Page 1 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions

Step 2 – Form the trial function


The trial function is to have one basis function, therefore it will have the following form
𝑢: = 𝑢# 𝜙# + 𝜙$

The trial function needs to satisfy the following:


(a) the basis function must be 0 at where the essential boundary conditions (EBC) are imposed
EBC are imposed at x = 0 and x = 1
To satisfy this, 𝜙# can be
𝝓𝟏 = 𝒙(𝒙 − 𝟏)
Check:
𝜙# (0) = 0(0 − 1) = 0 ⟶ OK
𝜙# (1) = 1(1 − 1) = 0 ⟶ OK

(b) the trial function must satisfy EBC


The trial function needs to satisfy EBC u(0) = 0 and u(1) = 1.
To satisfy EBC, 𝜙$ can be
𝝓𝟎 = 𝒙
Check:
𝑢: = 𝑢# 𝑥(𝑥 − 1) + 𝑥
𝑢:(0) = 𝑢# (0)(0 − 1) + 0 = 0 ⟶ OK
𝑢:(1) = 𝑢# (1)(1 − 1) + 1 = 1 ⟶ OK

Therefore, an admissible trial function is 𝑢: = 𝑢# 𝑥(𝑥 − 1) + 𝑥

Step 3 – Apply trial function to the weak form and solve for the coefficients of the trial function
Let 𝑢 = 𝑢:. Therefore, the weak form becomes
#
𝑑! 𝑢:
9 𝑤" 7 ! + 𝑢: − 𝑥 ! 8 = 0
$ 𝑑𝑥
Expand the weak form as follows.
# # #
𝑑! 𝑢:
9 𝑤" ! + 9 𝑤" 𝑢: − 9 𝑤" 𝑥 ! = 0
$ 𝑑𝑥 $ $

Apply integration-by-parts to the first term on the left hand side, we have
𝑑𝑢: # #
𝑑𝑤" 𝑑𝑢: # #
@𝑤" AB − 9 𝑑𝑥 + 9 𝑤" 𝑢: 𝑑𝑥 − 9 𝑤" 𝑥 ! 𝑑𝑥 = 0
𝑑𝑥 $ $ 𝑑𝑥 𝑑𝑥 $ $

which is the expanded weak form.

In this case, we have one weighting function since there is only one basis function in the trial
function. The weighting function is to be the same as the basis function, therefore
𝑤# = 𝜙# = 𝑥(𝑥 − 1)

Revision : Rev0
Prepared by : Dr. Cliff Leung Page 2 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions

Apply w1 to the expanded weak form


𝑑𝑢: # #
𝑑𝑤# 𝑑𝑢: # #
@𝑤# AB − 9 𝑑𝑥 + 9 𝑤# 𝑢: 𝑑𝑥 − 9 𝑤# 𝑥 ! 𝑑𝑥 = 0
𝑑𝑥 $ $ 𝑑𝑥 𝑑𝑥 $ $

# # #
𝑑𝑢:(1) 𝑑𝑢:(0) 𝑑𝑤# 𝑑𝑢:
C𝑤# (1) − 𝑤# (0) D−9 𝑑𝑥 + 9 𝑤# 𝑢: 𝑑𝑥 − 9 𝑤# 𝑥 ! 𝑑𝑥 = 0
𝑑𝑥 𝑑𝑥 $ 𝑑𝑥 𝑑𝑥 $ $

# # #
𝑑𝑢: (1) 𝑑𝑢:(0) 𝑑𝑤# 𝑑𝑢:
C(0) − (0) D−9 𝑑𝑥 + 9 𝑤# 𝑢: 𝑑𝑥 − 9 𝑤# 𝑥 ! 𝑑𝑥 = 0
𝑑𝑥 𝑑𝑥 $ 𝑑𝑥 𝑑𝑥 $ $

# # #
𝑑𝑤# 𝑑𝑢:
−9 𝑑𝑥 + 9 𝑤# 𝑢 − 9 𝑤# 𝑥 ! = 0
$ 𝑑𝑥 𝑑𝑥 $ $

# #
− 9 (2𝑥 − 1)(2𝑢# 𝑥 − 𝑢# + 1) 𝑑𝑥 + 9 𝑥(𝑥 − 1)(𝑢# 𝑥(𝑥 − 1) + 𝑥) 𝑑𝑥
$ $
#
− 9 𝑥(𝑥 − 1)𝑥 ! 𝑑𝑥 = 0
$
# #
4 1 2 1 1 1
− @ 𝑢# 𝑥 ' − 2𝑢# 𝑥 ! + 𝑥 ! + 𝑢# 𝑥 − 𝑥AB + @ 𝑢# 𝑥 ( − 𝑢# 𝑥 ) + 𝑥 ) + 𝑢# 𝑥 ' − 𝑥 ' AB
3 $ 5 4 4 3 3 $
#
1 1
− @ 𝑥 ( − 𝑥 ) AB = 0
5 4 $

3 1
− 𝑢# − =0
10 30
1
𝑢# = −
9

Therefore, by Galerkin’s method, the approximate solution, which is the trial function, is
𝟏
𝒖
J = − 𝒙(𝒙 − 𝟏) + 𝒙
𝟗
(ANS.)

The exact function and trial function are plotted below for comparison. The two functions are very
close.

1.5

1
u

0.5

0
0 0.2 0.4 0.6 0.8 1
x

Revision : Rev0
Prepared by : Dr. Cliff Leung Page 3 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions

Question 2

Determine an admissible trial function for a boundary value problem with the following boundary
conditions.
(a) u(1) = 1; u(2) = 3; trial function is to be formed by 2 basis functions
(b) u(3) = 1; u(5) = 3; trial function is to be formed by 1 basis functions
(c) u′(1) = 1; u(2) = 3; trial function is to be formed by 1 basis functions
(d) u′(1) = 1; u(2) = 3; trial function is to be formed by 2 basis functions

Solution – Part (a)

Since we are using 2 basis functions in this case, the trial function has the form
𝑢: = 𝑢# 𝜙# + 𝑢! 𝜙! + 𝜙$
Step 1 – Determine the basis functions 𝜙# and 𝜙!
We know that 𝜙# and 𝜙! must be 0 at where E.B.C. are imposed.
E.B.C. are imposed at x = 1 and x = 2, therefore
𝜙# can be 𝜙# = (𝑥 − 1)(𝑥 − 2)
𝜙! can be 𝜙! = (𝑥 − 1)! (𝑥 − 2)!
Check:
𝜙# (1) = (1 − 1)(1 − 2) = 0 ∴ OK
𝜙# (2) = (2 − 1)(2 − 2) = 0 ∴ OK
𝜙! (1) = (1 − 1)! (1 − 2)! = 0 ∴ OK
𝜙! (2) = (2 − 1)! (2 − 2)! = 0 ∴ OK
Step 2 – Determine the function 𝜙$
𝜙$ can be a constant or a function that makes the trial function satisfies the E.B.C.
The E.B.C. are u(1) = 1 and u(2) = 3. Therefore, the trial function,
𝑢: = 𝑢# 𝜙# + 𝑢! 𝜙! + 𝜙$
needs to be such that
(i) 𝑢:(1) must give the value 1 and
(ii) 𝑢:(2) must give the value 3
Therefore, 𝜙$ must be a linear function in order to satisfy (i) and (ii), i.e. 𝜙$ is in the form of
𝜙$ = 𝑚𝑥 + 𝑏
We need to solve for m and b to find the function of 𝜙$ .
Apply condition (i),
𝑢:(1) = 1
𝑢: = 𝑢# (𝑥 − 1)(𝑥 − 2) + 𝑢! (𝑥 − 1)! (𝑥 − 2)! + 𝜙$
1 = 𝑢# (1 − 1)(1 − 2) + 𝑢! (1 − 1)! (1 − 2)! + 𝑚(1) + 𝑏
1 = 𝑢# (0) + 𝑢! (0) + 𝑚(1) + 𝑏
1=𝑚+𝑏 (Eq. 1)

Revision : Rev0
Prepared by : Dr. Cliff Leung Page 4 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions

Apply condition (ii),


𝑢:(2) = 3
𝑢: = 𝑢# (𝑥 − 1)(𝑥 − 2) + 𝑢! (𝑥 − 1)! (𝑥 − 2)! + 𝜙$
3 = 𝑢# (2 − 1)(2 − 2) + 𝑢! (2 − 1)! (2 − 2)! + +𝑚(2) + 𝑏
3 = 𝑢# (0) + 𝑢! (0) + 𝑚(2) + 𝑏
3 = 2𝑚 + 𝑏 (Eq. 2)
Solving Eq. 1 and 2 we have
m = 2 and b = -1
Therefore, 𝜙$ is
𝜙$ = 2𝑥 − 1

Therefore an admissible trial function in this case is


𝑢: = 𝑢# (𝑥 − 1)(𝑥 − 2) + 𝑢! (𝑥 − 1)! (𝑥 − 2)! + 2𝑥 − 1 (ANS.)

Solution – Part (b)

Since we are using 1 basis function in this case, the trial function has the form
𝑢: = 𝑢# 𝜙# + 𝜙$
Step 1 – Determine the basis functions 𝜙#
We know that 𝜙# must be 0 at where E.B.C. are imposed.
E.B.C. are imposed at x = 3 and x = 5, therefore
𝜙# can be 𝜙# = (𝑥 − 3)(𝑥 − 5)
Check:
𝜙# (3) = (3 − 3)(3 − 5) = 0 ∴ OK
𝜙# (5) = (5 − 3)(5 − 5) = 0 ∴ OK

Step 2 – Determine the function 𝜙$


𝜙$ can be a constant or a function that makes the trial function satisfies the E.B.C.
The E.B.C. are u(3) = 1 and u(5) = 3. Therefore, the trial function,
𝑢: = 𝑢# 𝜙# + 𝜙$
needs to be such that
(i) 𝑢:(3) must give the value 1 and
(ii) 𝑢:(5) must give the value 3
Therefore, 𝜙$ must be a linear function in order to satisfy (i) and (ii), i.e. 𝜙$ is in the form of
𝜙$ = 𝑚𝑥 + 𝑏
We need to solve for m and b to find the function of 𝜙$ .
Apply condition (i),
𝑢:(3) = 1
𝑢: = 𝑢# (𝑥 − 3)(𝑥 − 5) + 𝜙$

Revision : Rev0
Prepared by : Dr. Cliff Leung Page 5 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions

1 = 𝑢# (3 − 3)(3 − 5) + 𝑚(3) + 𝑏
1 = 𝑢# (0) + 𝑢! (0) + 𝑚(3) + 𝑏
1 = 3𝑚 + 𝑏 (Eq. 1)
Apply condition (ii),
𝑢:(5) = 3
𝑢: = 𝑢# (𝑥 − 3)(𝑥 − 5) + 𝜙$
3 = 𝑢# (5 − 3)(5 − 5) + 𝑚(5) + 𝑏
3 = 5𝑚 + 𝑏 (Eq. 2)
Solving Eq. 1 and 2 we have
m = 1 and b = -2
Therefore, 𝜙$ is
𝜙$ = 𝑥 − 2

Therefore an admissible trial function in this case is


𝑢: = 𝑢# (𝑥 − 3)(𝑥 − 5) + 𝑥 − 2 (ANS.)

Solution – Part (c)

Since we are using 1 basis function in this case, the trial function has the form
𝑢: = 𝑢# 𝜙# + 𝜙$
Step 1 – Determine the basis functions 𝜙#
We know that 𝜙# must be 0 at where E.B.C. are imposed.
E.B.C. are imposed at x = 2, therefore
𝜙# can be 𝜙# = 𝑥 − 2
Check:
𝜙# (2) = 2 − 2 = 0 ∴ OK

Step 2 – Determine the function 𝜙$


𝜙$ can be a constant or a function that makes the trial function satisfies the E.B.C.
The E.B.C. is u(2) = 3. Therefore, the trial function,
𝑢: = 𝑢# 𝜙# + 𝜙$
needs to be such that
(i) 𝑢:(2) must give the value 3
Therefore, to satisfy the E.B.C., 𝜙$ can be
𝜙$ = 3
Check:
𝑢: = 𝑢# 𝜙# + 𝜙$
𝑢: = 𝑢# (𝑥 − 2) + 3
𝑢:(2) = 𝑢# (2 − 2) + 3 = 3 ; which satisfies E.B.C. ∴ OK

Revision : Rev0
Prepared by : Dr. Cliff Leung Page 6 of 7
SCE5401 Computational and Engineering Analysis
Tutorial 7 – Solutions

Therefore an admissible trial function in this case is


𝑢: = 𝑢# (𝑥 − 2) + 3 (ANS.)

Solution – Part (d)

Since we are using 2 basis functions in this case, the trial function has the form
𝑢: = 𝑢# 𝜙# + 𝑢! 𝜙! + 𝜙$
Step 1 – Determine the basis functions 𝜙# and 𝜙!
We know that 𝜙# and 𝜙! must be 0 at where E.B.C. are imposed.
E.B.C. are imposed at x = 2, therefore
𝜙# can be 𝜙# = 𝑥 − 2
𝜙! can be 𝜙! = (𝑥 − 2)!
Check:
𝜙# (2) = 2 − 2 = 0 ∴ OK
𝜙! (2) = (2 − 2)! = 0 ∴ OK

Step 2 – Determine the function 𝜙$


𝜙$ can be a constant or a function that makes the trial function satisfies the E.B.C.
The E.B.C. is u(2) = 3. Therefore, the trial function,
𝑢: = 𝑢# 𝜙# + 𝑢! 𝜙! + 𝜙$
needs to be such that
(i) 𝑢:(2) must give the value 3
Therefore, to satisfy the E.B.C., 𝜙$ can be
𝜙$ = 3
Check:
𝑢: = 𝑢# 𝜙# + 𝑢! 𝜙! + 𝜙$
𝑢: = 𝑢# (𝑥 − 2) + 𝑢! (𝑥 − 2)! + 3
𝑢:(2) = 𝑢# (2 − 2) + 𝑢! (2 − 2)! + 3 = 3 ; which satisfies E.B.C. ∴ OK

Therefore an admissible trial function in this case is


𝑢: = 𝑢# (𝑥 − 2) + 𝑢! (𝑥 − 2)! + 3 (ANS.)

Revision : Rev0
Prepared by : Dr. Cliff Leung Page 7 of 7

You might also like