Vous êtes sur la page 1sur 10

Finite Difference Method for

08.07 Ordinary Differential Equations

After reading this chapter, you should be able to:

1. Understand what the Finite Difference Method is and how to use it to solve
problems.

What is the Finite Difference Method?


An example of a boundary value ordinary differential equation is
d 2 u 1 du u
+ − = 0, u(5) = 0.008731" , u (8) = 0.0030769" (1)
dr 2 r dr r 2
The value of condition is given at the boundaries, that is, at r= 5 and r=8.
This method is used to solve boundary value ordinary differential equations. The
derivatives in such ordinary differential equation are substituted by finite divided
differences approximations, such as
dy yi +1 − yi

dx Δx
d y yi +1 − 2 yi + yi −1
2
≈ (2a, b)
dx 2 (Δx )2
Such substitutions convert the ordinary differential equation into a linear
equation (but with more than one unknown). By writing the resulting linear
equation at different points at which the ordinary differential equation is valid, we
get simultaneous linear equations that can be solved by using techniques such as
Gaussian Elimination, Gauss-Siedel method, etc.
The method is best illustrated by a physical example. Take the case of a
pressure vessel that is being tested in the laboratory to check its ability to
withstand pressure. For a thick pressure vessel of inner radius a and outer radius

08.07.1
08.07.2 Chapter 08.07

b, the differential equation for the radial displacement u of a point along the
thickness is given by
d 2 u 1 du u
+ − =0 (3)
dr 2 r dr r 2
Assume that the inner radius a= 5″ and the outer radius b= 8″, and the
material of the pressure vessel is ASTM36 steel. The ultimate strength of this type
of steel is 36 ksi. Two strain gages that are bonded tangentially at the inner and
the outer radius measure normal tangential strain as
∈t / r =a = 0.00077462
∈t / r =b = 0.00038462 (4a, b)
at the maximum needed pressure. Since the radial displacement and tangential
strain are related simply by
u
∈t = , (5)
r
then
u r =a = 0.00077462 × 5 = 0.0038731' '
u r =b = 0.00038462 × 8 = 0.0030769' ' (6)
The two boundary conditions will allow us to solve the boundary value
ordinary differential equation to find radial displacement as a function of radial
location. How will this help us in determining if it will safely withstand the
pressure. The maximum normal stress in the pressure vessel is at the inner radius
r = a and is given by
E ⎛⎜ u r = a du ⎞

σ max = + ν (7)
1 − ν 2 ⎜⎝ r dr r = a ⎟⎠
where
E = Young’s modulus of steel (E= 30 Msi)
ν = Poisson’s ratio ( ν = 0.3)
Having calculated the maximum stress we can calculate the factor of safety, FS
as
ultimate strength of steel
FS = (8)
σ max
Finite Difference Method 08.07.3

b
i+1
i-1

0…… ……n

a i+1 b
i-1 i

Figure 1. Nodes along the radial direction.

At node i in the pressure vessel,


d 2u ui +1 − 2ui + ui −1

dr 2
(Δr )2
(9)
du ui +1 − ui
≈ (10)
dr Δr
Substituting these approximation from equations (9) and (10) in equation (3)
ui +1 − 2ui + ui −1 1 ui +1 − ui ui
+ − 2 =0 (11)
(Δr )2 ri Δr ri
⎛ 1 1 ⎞ ⎛ 2 1 1⎞ 1
⎜⎜ + ⎟⎟ui +1 + ⎜⎜ − − − 2 ⎟⎟ui + u =0 (12)
⎝ (Δr ) ri Δr ⎠ ⎝ (Δr ) ri Δr ri ⎠ (Δr )2 i −1
2 2

Let us break the thickness, b − a of the pressure vessel to n + 1 nodes, that


is r = a is node i = 0 and r = b is node i = n . That means we have (n + 1)
unknowns.
We can write the above equation for nodes 1,..., n − 1 . This will give us (n-1)
equations. At the edge nodes, i = 0 and i = n , we use the boundary conditions of
08.07.4 Chapter 08.07

u0 = u r = a
u n = u r =b
This gives a total of n + 1 equations. So we have (n + 1) unknowns and
(n + 1) linear equations. These can be solved by any of the numerical methods
used for solving simultaneous linear equations.
Let us show the calculations for n = 5, that is a total of 6 nodes. This gives
b−a
Δr =
n
8−5
=
5
= 0.6 "
At node i = 0, r0 = a = 5 ″, u0 = 0.0038731 ″ (13)
At node i = 1, r1 = r0 + Δr = 5 + 0.6 = 5.6" (14)
1 ⎛ 2 1 1 ⎞ ⎛ 1 1 ⎞
u 0 + ⎜⎜ − − − ⎟u + ⎜⎜ 2 + ⎟u = 0
(0.6) 2
⎝ (0.6)
2
(5.6)(0.6) (5.6) ⎠ ⎝ 0.6 (5.6)(0.6) ⎟⎠ 2
2 ⎟ 1

2.7778u0 − 5.8851u1 + 3.0754u2 = 0 (15)


At node i = 2, r2 = r1 + Δr = 5.6 + 0.6 = 6.2 ″
1 ⎛ 2 1 1 ⎞ ⎛ 1 1 ⎞
u + ⎜⎜ − − − ⎟u + ⎜⎜ 2 + ⎟u = 0
(0.6) 2 1
⎝ 0.6
2
(6.2 )(0.6) 6.2 ⎠ ⎝ 0.6 (6.2 )(0.6) ⎟⎠ 3
2 ⎟ 2

2.7778u1 − 5.8504u 2 +3.0466u3 = 0 (16)

At node i = 3, r3 = r2 + Δr = 6.2 + 0.6 = 6.8 ″


1 ⎛ 2 1 1 ⎞ ⎛ 1 1 ⎞
u + ⎜⎜ − − − ⎟u + ⎜⎜ 2 + ⎟u = 0
0.6 2 2
⎝ 0.6
2
(6.8)(0.6) 6.8 ⎠ ⎝ 0.6 (6.8)(0.6) ⎟⎠ 4
2 ⎟ 3

2.7778u2 − 5.8223u3 + 3.0229u4 = 0 (17)


At node i = 4, r4 = r3 + Δr = 6.8 + 0.6 = 7.4 ″
1 ⎛ 2 1 1 ⎞ ⎛ 1 1 ⎞
u + ⎜⎜ − − − ⎟u + ⎜⎜ 2 + ⎟u = 0
0.6 2 3 2 2 ⎟ 4
⎝ 0.6 (7.4)(0.6) (7.4 ) ⎠ ⎝ 0.6 (7.4)(0.6) ⎟⎠ 5
2.7778u3 − 5.7990u4 + 3.0030u5 = 0 (18)
At node i = 5, r5 = r4 + Δr = 7.4 + 0.6 = 8 ″
u5 = u / r =b = 0.0030769 ″ (19)
Finite Difference Method 08.07.5

Writing Equation (13) to (19) in matrix form gives


⎡ 1 0 0 0 0 0 ⎤ ⎡u0 ⎤ ⎡ 0.0038731⎤
⎢2.7778 − 5.8851 3.0754 0 0 0 ⎥⎥ ⎢u ⎥ ⎢ 0 ⎥
⎢ ⎢ 1⎥ ⎢ ⎥
⎢ 0 2.7778 − 5.8504 3.0466 0 0 ⎥ ⎢u2 ⎥ ⎢ 0 ⎥
⎢ ⎥ ⎢ ⎥ =⎢ ⎥
⎢ 0 0 2.7778 − 5.8223 3.0229 0 ⎥ ⎢u3 ⎥ ⎢ 0 ⎥
⎢ 0 0 0 2.7778 − 5.7990 3.0030⎥ ⎢u4 ⎥ ⎢ 0 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢⎣ 0 0 0 0 0 1 ⎥⎦ ⎢⎣u5 ⎥⎦ ⎢⎣0.0030769⎥⎦

The above equations are a tri-diagonal system of equations and special algorithms
such as Thomas’ algorithm can be used to solve such a system of equations.
u 0 = 0.0038731 ″
u1 = 0.0036165 ″
u2 = 0.0034222 ″
u3 = 0.0032743 ″
u4 = 0.0031618 ″
u5 = 0.0030769 ″
To find the maximum stress, it is given by equation (7) as
E ⎛u du ⎞
σ max = ⎜
2 ⎜
+ν ⎟
1 − ν ⎝ r r =a dr r = a ⎟⎠
E = 30 × 106 psi
ν = 0.3
u r = a = u0 = 0.0038731 ″
du u1 − u0
r =a ≈
dr Δr
0.0036165 − 0.0038731
=
0.6
= −0.00042767
The maximum stress in the pressure vessel then is
30 × 106 ⎛ 0.0038731 ⎞
σ max = 2 ⎜
+ 0.3(− 0.00042767)⎟
1 − 0.3 ⎝ 5 ⎠
= 2.1307 × 10 4 psi
So the factor of safety FS from equation (8) is
08.07.6 Chapter 08.07

36 × 103
FS = = 1.6896
2.1307 × 10 4
The differential equation has an exact solution and is given by the form
C
u = C1r + 2 (20)
r
where C1 and C2 are found by using the boundary conditions at r = a and r = b .
C
u (r = a ) = u (r = 5) = 0.0038731 = C1 (5) + 2
5
C
u (r = b) = u (r = 8) = 0.0030769 = C1 (8) + 2
8
giving
C1 = 0.00013462
C2 = 0.016000
Thus
0.016000
u = 0.00013462 r + (21)
r
du 0.016000
= 0.00013462 − (22)
dr r2
E ⎛u du ⎞
σ max = ⎜ +ν ⎟
2 ⎜
1 − ν ⎝ r r =a dr r =a ⎟⎠
⎛ 0.01600 ⎞
⎜ 0.00013462(5) +
30 × 10 ⎜
6
5 ⎛ 0.016000 ⎞ ⎟⎟
= + 0 . 3⎜ 0 . 0013462 − ⎟
1 − 0 .3 2 ⎜ 5 ⎝ 52 ⎠⎟
⎜ ⎟
⎝ ⎠
= 2.0538 × 10 psi4

The true error, Et is


E t = 2.0538 × 10 4 − 2.1307 × 10 4
= −7.6859 × 10 2
The absolute relative true error, ∈t is
2.0538 × 104 − 2.1307 × 104
∈t = × 100
2.0538 × 104
= 3.744 %
The approximation
Finite Difference Method 08.07.7

dy yi +1 − yi

dx Δx
is first order accurate, that is , the true error is of O (Δx ) .
The approximation
d 2 y yi +1 − 2 yi + yi −1
≈ (21)
dx 2 (Δx )2
(
is second order accurate, that is , the true error is O (Δx )
2
)
Mixing these two approximations will result in the order of accuracy of
( )
O(Δx ) and O (Δx )2 , that is O(Δx ) .
So it is better to approximate
dy yi +1 − yi −1
≈ (22)
dx 2(Δx )
because this equation is second order accurate.
Repeating the problem with this approximation,
At node i in the pressure vessel,
d 2u ui +1 − 2ui + ui −1
≈ (23)
dr 2
(Δr )2
du u i +1 − u i −1
≈ (24)
dr 2Δr
Substituting Equations (23) and (24) in Equation (3) gives
u i +1 − 2u i + u i −1 1 u i +1 − u i −1 u i
+ − 2 =0
(Δr )2 ri 2(Δr ) ri
⎛ 1 1 ⎞ ⎛ 2 1 ⎞⎟ ⎛ 1 1 ⎞
⎜− ⎟ ⎜ ⎜ ⎟
⎜ 2r (Δr ) + (Δr )2 ⎟u i −1 + ⎜ − (Δr )2 − r 2 ⎟u i + ⎜ (Δr )2 + 2r Δr ⎟u i +1 = 0 (25)
⎝ i ⎠ ⎝ i ⎠ ⎝ i ⎠
At node i = 0, r0 = a = 5 "
u0 = 0.0038731 " (26)
At node i = 1, r1 = r0 + Δr = 5 + 0.6 = 5.6"

⎛ 1 1 ⎞ ⎛ 2 1 ⎞ ⎛ 1 1 ⎞
⎜− ⎟ ⎜ ⎟
⎜ 2(5.6 )(0.6) + (0.6)2 ⎟u 0 + ⎜ − (0.6)2 − (5.6)2 ⎟u1 + ⎜⎜ 0.6 2 + 2(5.6)(0.6) ⎟⎟u 2 = 0
⎝ ⎠ ⎝ ⎠ ⎝ ⎠
2.6297u 0 − 5.5874u1 + 2.9266u 2 = 0 (27)
At node i = 2, r2 = r1 + Δr = 5.6 + 0.6 = 6.2 "
08.07.8 Chapter 08.07

⎛ 1 1 ⎞ ⎛ 2 1 ⎞ ⎛ 1 1 ⎞
⎜⎜ − + ⎟u + ⎜ −
2 ⎟ 1
− u + ⎜⎜
2 ⎟ 2
+ ⎟u 3 = 0 (28)
⎝ 2(6.2)(0.6 ) 0.6 ⎠ ⎝ 0.6
2
6.2 ⎠ ⎝ 0.6
2
2(6.2)(0.6 ) ⎟⎠
2.6434u1 − 5.5816u 2 +2.9122u3 = 0
At node i = 3, r3 = r2 + Δr = 6.2 + 0.6 = 6.8 "
⎛ 1 1 ⎞ ⎛ 2 1 ⎞ ⎛ 1 1 ⎞
⎜⎜ − + ⎟u + ⎜ −
2 ⎟ 2
− u + ⎜⎜ 2 +
2 ⎟ 3
⎟u 4 = 0 (29)
⎝ 2(6.8)(0.6) 0.6 ⎠ ⎝ 0.6
2
6.8 ⎠ ⎝ 0.6 2(6.8)(0.6 ) ⎟⎠
2.6552u2 − 5.5738u3 + 2.9003u4 = 0
At node i = 4, r4 = r3 + Δr = 6.8 + 0.6 = 7.4 "
⎛ 1 1 ⎞ ⎛ 2 1 ⎞ ⎛ 1 1 ⎞
⎜⎜ − + ⎟u + ⎜⎜ −
2 ⎟ 3
− ⎟u + ⎜⎜ 2 + ⎟u = 0 (30)
⎝ 2(7.4)(0.6) 0.6 ⎠ ⎝ 0.6
2
(7.4) ⎠ ⎝ 0.6 2(7.4)(0.6) ⎟⎠ 5
2 ⎟ 4

2.6651u3 − 5.6062u4 + 2.8903u5 = 0


At node i = 5, r5 = r4 + Δr = 7.4 + 0.6 = 8 "
u5 = u / r =b = 0.0030769 " (31)

Writing Equations (26) thru (31) in matrix form gives


⎡ 1 0 0 0 0 0 ⎤ ⎡u0 ⎤ ⎡ 0.0038731⎤
⎢2.6297 − 5.5874 2.9266 0 0 0 ⎥ ⎢u ⎥ ⎢ 0 ⎥
⎢ ⎥ ⎢ 1⎥ ⎢ ⎥
⎢ 0 2.6434 − 5.5816 2.9122 0 0 ⎥ ⎢u2 ⎥ ⎢ 0 ⎥
⎢ ⎥ ⎢ ⎥ =⎢ ⎥
⎢ 0 0 2.6552 − 5.5772 2.9003 0 ⎥ ⎢u3 ⎥ ⎢ 0 ⎥
⎢ 0 0 0 2.6651 − 5.5738 2.8903⎥ ⎢u4 ⎥ ⎢ 0 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎣ 0 0 0 0 0 1 ⎦ ⎣⎢u5 ⎦⎥ ⎣⎢0.0030769⎦⎥

The above equations are a tri-diagonal system of equations and special algorithms
such as Thomas’ algorithm can be used to solve such equations.
u 0 = 0.0038731 "
u1 = 0.0036115 "
u2 = 0.0034159 "
u3 = 0.0032689 "
u4 = 0.0031586 "
u5 = 0.0030769 "
Finite Difference Method 08.07.9

du − 3u0 + 4u1 − u 2

2(Δr )
r =a
dr
− 3 × 0.0038731 + 4 × 0.0036115 − 0.0034159
=
2 ( 0 .6 )
= −4.925 × 10 −4
30 × 10 6 ⎛ 0.0038731
σ max = 2 ⎜
1 − 0.3 ⎝ 5
( )⎞
+ 0.3 − 4.925 × 10 − 4 ⎟

= 2.0666 × 10 psi
4

Therefore, the factor of safety FS is


36 × 103
FS =
2.0666 × 10 4
= 1.7420
The true error in calculating the maximum stress is
Et = 2.0538 × 10 4 − 2.0666 × 10 4
= −128
The relative true error in calculating the maximum stress is
− 128
∈t = × 100
2.0538 × 10 4
= 0.62323 %

Table 1. Comparisons of radial displacements from two methods.

r u exact u 1st order |ε t| u 2nd order |ε t|

5 0.0038731 0.0038731 0.0000 0.0038731 0.0000

5.6 0.0036110 0.0036165 1.5160×10-1 0.0036115 1.4540×10-2

6.2 0.0034152 0.0034222 2.0260×10-1 0.0034159 1.8765×10-2

6.8 0.0032683 0.0032743 1.8157×10-1 0.0032689 1.6334×10-2

7.4 0.0031583 0.0031618 1.0903×10-1 0.0031586 9.5665×10-3


08.07.10 Chapter 08.07

8 0.0030769 0.0030769 0.0000 0.0030769 0.0000

ORDINARY DIFFERENTIAL EQUATIONS


Topic Finite Difference Methods of Solving Ordinary Differential Equations
Summary Textbook notes of Finite Difference Methods of Solving Ordinary Differential
Equations
Major General Engineering
Authors Autar Kaw, Cuong Nguyen
Date April 17, 2008
Web Site http://numericalmethods.eng.usf.edu

Vous aimerez peut-être aussi