0% found this document useful (0 votes)
1 views

document_2

The document discusses the Finite Difference Method (FDM) for solving boundary value problems, detailing various finite difference approximations for derivatives and their orders of accuracy. It explains how polynomial fitting can derive these approximations and presents methods for solving parabolic equations using explicit and implicit schemes. Additionally, it provides an example of applying the explicit method to a heat conduction equation with specified boundary and initial conditions.

Uploaded by

vasudhabhuva1296
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

document_2

The document discusses the Finite Difference Method (FDM) for solving boundary value problems, detailing various finite difference approximations for derivatives and their orders of accuracy. It explains how polynomial fitting can derive these approximations and presents methods for solving parabolic equations using explicit and implicit schemes. Additionally, it provides an example of applying the explicit method to a heat conduction equation with specified boundary and initial conditions.

Uploaded by

vasudhabhuva1296
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Finite Di↵erence Method for Boundary Value Problems

Finite Di↵erences
8 f (x+h) f (x)
>
< h + O(h) (Forward Di↵erence)
f (x) f (x h)
f 0 (x) = + O(h) (Backward Di↵erence)
> f (x+h)h f (x h)
:
2h + o(h2 ) (Central Di↵erence)
8 f (x) 2f (x+h)+f (x+2h)
>
< h2 + O(h) (Forward Di↵erence)
00 f (x) 2f (x h)+f (x 2h)
f (x) = h2 + O(h) (Backward Di↵erence)
>
: f (x h) 2f (x)+f (x+h)
h2 + o(h2 ) (Central Di↵erence)

Higher Order Derivatives


2f (x + h) + 3f (x) 6f (x h) + f (x 2h)
f 0 (x) = + O(h3 )
6h
f (x + 2h) + 6f (x + h) 3f (x) f (x h)
f 0 (x) = + O(h3 ) (4.11)
6h
f (x + 2h) + 8f (x + h) 8f (x h) + f (x 2h)
f 0 (x) = + O(h4 ) (4.13)
12h

Order of Approximation
• It is worth considering exactly what is meant by the order of accuracy of a discretization approximation.
• As we refine the grid, for any useful scheme, errors associated with the discretization approximation
can be expected to reduce.
• We reach a grid independent solution when any further grid refinement produces no significant di↵er-
ence in the computed solution. At this stage, the discretization errors are small enough that they can
be neglected.
• Note this does not mean a second order solution on one particular grid will always be more accurate
than a first order one (although this will usually be the case for a sufficiently fine grid).
• It does, however, imply that as we refine the grid the error in the higher order scheme goes down more
rapidly, so we expect the higher order scheme to reach a grid independent solution on a coarser grid
than would be required for a lower order scheme.
• It is worth noting that the behaviour described above for a particular scheme can only
be expected on a reasonably fine grid.

The reason for this can be seen from the Taylor series expansion. For example, in the first order backward
di↵erence scheme we have:

fi fi 1 x 00 ( x)2 000
f 0 (xi ) = + f (xi ) f (xi ) + O( x3 )
x 2! 3!

1
Santanu Manna MA 204N: Finite Di↵erence Method

If the first term in the truncation is to be the leading error term, then x has to be small enough so
that:

( x)2 000 x 00
|f (xi )| ⌧ |f (xi )|
3! 2!
Or,

f 00 (xi )
x⌧3
f 000 (xi )

Polynomial Fitting
• The above approximations for the derivatives could also have been derived by fitting a polynomial to
the function f through xi and surrounding points and then di↵erentiating this polynomial to obtain
its gradient.

• The forward and backward di↵erence schemes arise from fitting a first order polynomial through the
points (xi , xi+1 ) and (xi 1 , xi ) respectively.
• The central di↵erence scheme can be obtained by fitting a quadratic curve through the points xi 1 , xi , xi+1 .

Linear Fit:
The first order polynomial:

(x xi+1 )fi (x xi )fi+1


P1 (x) = f (x) = + , xi < x < xi+1
(xi xi+1 ) (xi+1 xi )
(x
xi+1 )fi + (x xi )fi+1
=
x
The derivative of this function yields the forward di↵erence formula:
fi+1 fi
f 0 (x) =
x

Quadratic Fit:
The central di↵erence scheme can be obtained by fitting a quadratic curve through the points xi 1 , xi , xi+1 .
The resulting polynomial approximation for function f can be written as:

(x xi )(x xi+1 )fi 1 (x xi 1 )(x xi+1 )fi (x xi )(x xi 1 )fi+1


P2 (x) = f (x) = + +
(xi 1 xi )(xi 1 xi+1 ) (xi xi 1 )(xi xi+1 ) (xi+1 xi )(xi+1 xi 1 )

On a uniform grid:

xi+1 xi = xi xi 1 = x and xi+1 xi 1 =2 x

Then we get:

(x xi )(x xi+1 )fi 1 (x xi 1 )(x xi+1 )fi (x xi )(x xi 1 )fi+1


f (x) = + (5.3)
2( x)2 ( x)2 2( x)2

Now di↵erentiating eq. (5.3) with respect to x, we get:

(x xi + x xi+1 )fi 1 (x xi 1+ x xi+1 )fi (x xi + x xi 1 )fi+1


f 0 (x) = +
2( x)2 ( x)2 2( x)2

2
Santanu Manna MA 204N: Finite Di↵erence Method

xfi 1 0 · fi xfi+1
f 0 (xi ) = + +
2( x)2 ( x)2 2( x)2
fi+1 fi 1
) f 0 (xi ) = (5.5)
2 x
Again di↵erentiating eq. (5.4) with respect to x, we get:

(1 + 1)fi 1 (1 + 1)fi (1 + 1)fi+1


f 00 (x) = + +
2( x)2 ( x) 2 2( x)2
fi 1 2fi + fi+1
) f 00 (x) = (5.6)
( x)2
The above expressions are identical to the formulae obtained earlier.

One-sided Approximation
The finite di↵erence approximation for first order derivative along the boundary can be obtained by using
forward di↵erence which is first order accurate.
For second order accuracy, we will use a polynomial approach as follows:
Assume that f can be expressed by the polynomial

f = a + bx + cx2 (5.7)

At grid point 1, x = 0 which yields


f1 = a
At grid point 2, x = x which yields

f2 = a + b x + c( x)2

At grid point 3, x = 2 x which yields

f3 = a + 2b x + c(2 x)2

Solving the above expressions, we get:


3f1 + 4f2 f3 f1 2f2 + f3
a = f1 , b= , c=
2 x 2( x)2

Now the first derivative at grid point 1, i.e., at x = 0 is given by:


✓ ◆
@f
=b
@x x=0
✓ ◆
@f 3f1 + 4f2 f3
= (5.8)
@x x=0 2 x
Now the second derivative at grid point 1, i.e., at x = 0 is given by:
✓ 2 ◆
@ f
= 2c
@x2 x=0
✓ 2 ◆
@ f f1 2f2 + f3
2
= (5.9)
@x x=0 ( x)2
The error in above approximations are of order O( x).

3
Santanu Manna MA 204N: Finite Di↵erence Method

Methods for solving Parabolic Equations:


One-dimensional parabolic equation can be written as:

@u @2u
= ↵ 2, 0  x  L, t > 0 (6.1)
@t @x
Suppose Dirichlet boundary conditions are prescribed at both the ends and an initial condition at time
t > 0 as:
u(0, t) = u0 , u(L, t) = uL , u(x, 0) = f (x), 0  x  L (6.2)
To solve this problem, we first discretize the domain into regular mesh such that xi = i x; i = 0(1)N
where x0 = 0, xL = N . When the values of ui,j is computed up to t = tj = j t i.e., jth time level, the
values at (j + 1)th time level are computed to give ui,j+1 , i = 1(1)N 1, j = 1, 2, . . .

⌥ Explicit Method:
We discretize equation (6.1) at mesh point (i, j) such that the time derivative is replaced by forward di↵erence
and space derivative is replaced by central di↵erence. We get:

u(xi , tj+1 ) u(xi , tj ) u(xi 1 , tj ) 2u(xi , tj ) + u(xi+1 , tj )


= + O( t) + O( x)2
t ( x)2

or we can write this as:


t ⇥ ⇤
ui,j+1 = ui,j + [ui 1,j 2ui,j + ui+1,j ] + t O( t) + O( x)2
( x)2
t
Let ( x)2 = r, and neglecting the error term, we get:

ui,j+1 = rui 1,j + (1 2r)ui,j + rui+1,j (6.3)

Thus value of ui,j+1 can be computed explicitly. This method is also known as explicit method.

Molecule of Explicit Scheme:

Example: Find the numerical solution of the heat conduction equation

@u @2u
= , 0  x  1, t > 0
@t @x2
With boundary conditions u(0, t) = u(1, t) = 1, and initial conditions
(
1 + 2x, 0  x  1/2
u(x, 0) =
3 2x, 1/2 < x  1

⌅ Use explicit method taking x = 0.2, t = 0.02, and compute up to t = 0.24 up to six decimal places.

4
Santanu Manna MA 204N: Finite Di↵erence Method

Solution: Since the initial temperature u(x, 0) is symmetric and boundary conditions at x = 0 and
x = 1 are also same, the problem is symmetric about x = 0.5. i.e., the temperature at the subsequent times
will also remain symmetric.
The domain is subdivided as:

u= 0 0.2 0.4 0.6 0.8 1.0


x= 0 0.2 0.4 0.6 0.8 1
We have xi = 0.2 ⇥ i, i = 0(1)5
Due to symmetry at x = 0.5, for all j,

u0,j = u5,j , u1,j = u4,j , u2,j = u3,j

t 0.02
r= 2
= = 0.5
x 0.04
Putting r = 0.5 in the Explicit formula:

ui,j+1 = rui 1,j + (1 2r)ui,j + rui+1,j

1
ui,j+1 = (ui 1,j + ui+1,j ), i = 1, 2
2
i = 3, 4 can be written by symmetry.
For j = 0,
u0,0 = u5,0 = 1.0, u1,0 = u4,0 = 1.4, u2,0 = u3,0 = 1.8
Computed values are:

t 0.0 0.2 0.4 0.6 0.8 1.0


0.00 1.0 1.4 1.8 1.8 1.4 1.0
0.02 1.0 1.4 1.6 1.6 1.4 1.0
0.04 1.0 1.3 1.5 1.5 1.3 1.0
0.06 1.0 1.25 1.4 1.4 1.25 1.0

Parabolic Equations (Continue. . . )


Implicit Method:
We discretize equation (6.1) at mesh point (i, j + 1) such that the time derivative is replaced by backward
di↵erence and space derivative is replaced by central di↵erence, i.e.,
ui,j+1 ui,j ui 1,j+1 2ui,j+1 + ui+1,j+1
= + O( t) + O( x)2
t ( x)2
t
Let ( x)2 = r, and neglecting the error term, we get:

rui 1,j+1 + (1 + 2r)ui,j+1 rui+1,j+1 = ui,j (6.4)

For i = 1(1)N 1, gives (N 1) equations in ui,j+1 . This formula is known as Laasonen’s formula.

Molecule of Implicit Scheme:


j+1

-r (1-2r) -r
j

1
i 1 i i+1

5
Santanu Manna MA 204N: Finite Di↵erence Method

Crank-Nicolson’s Method:
It is also an implicit scheme. The di↵erence is that the discretization of equation (6.1) is made at the mid-
point of j th and (j + 1)th levels and both the time and space derivatives are replaced by central di↵erence,
i.e.,

✓ ◆ 
@u 1 ui 1,j 2ui,j + ui+1,j ui 1,j+1 2ui,j+1 + ui+1,j+1
= 2
+ + O( t)2 + O( x)2
@t i,j+ 12 2 ( x) ( x)2

t
Using ( x)2 = r, and neglecting the error terms, we can write the above equation as:

rui 1,j+1 + (1 + r)ui,j+1 rui+1,j+1 = rui 1,j + (1 r)ui,j + rui+1,j (6.5)


For i = 1(1)N , there will be (N 1) equations in (N 1) unknowns and their solution will be solved at
(j + 1)th time level.

Molecule of Crank-Nicolson Scheme:

Example:
Find the numerical solution of the heat conduction equation

@u @2u
= , 0  x  1, t > 0
@t @x2
With boundary conditions u(0, t) = u(1, t) = 1 and initial conditions
(
1 + 2x, 0  x  12
u(x, 0) =
3 2x, 12  x  1

⌅ Solve by C-N scheme by taking t = 0.08 and x = 0.2.

Solution: Since the initial temperature u(x, 0) is symmetric and boundary conditions at x = 0 and
x = 1 are also same, so the problem is symmetric about x = 0.5, i.e., the temperature at subsequent times
will also remain symmetric.
Here t = 0.08, r = t/ x2 = 0.08/0.04 = 2, then C-N scheme:

rui 1,j+1 + 2(1 + r)ui,j+1 rui+1,j+1 = rui 1,j + 2(1 r)ui,j + rui+1,j
transforms to:

2ui 1,j+1 + 6ui,j+1 2ui+1,j+1 = 2ui 1,j 2ui,j + 2ui+1,j


or

6
Santanu Manna MA 204N: Finite Di↵erence Method

ui 1,j+1 + 3ui,j+1 ui+1,j+1 = ui 1,j ui,j + ui+1,j


For i = 1,
u0,j+1 + 3u1,j+1 u2,j+1 = u0,j u1,j + u2,j (1)
For i = 2,
u1,j+1 + 3u2,j+1 u3,j+1 = u1,j u2,j + u3,j (2)
Using u0,j = u3,j = 1 and u3,j = u0,j , implies:

From the right-side derivation:

For j = 0 : 3u1,1 u2,1 = 2 ) u1,1 = 1.24, u2,1 = 1.32


For j = 1 : 3u1,2 u2,2 = 2 ) u1,2 = 1.09, u2,2 = 1.145
For j = 2 : 3u1,3 u2,3 = 2 ) u1,3 = 1.04, u2,3 = 1.065

Numerical Solution Table:


t x 0 0.2 0.4 0.6 0.8 1.0
0.00 1.0 1.4 1.8 1.8 1.4 1.0
0.08 1.0 1.24 1.32 1.32 1.24 1.0
(1.20) (1.325)
0.16 1.0 1.090 1.145 1.145 1.090 1.0
[1.086] [1.139]
0.24 1.0 1.040 1.065 1.065 1.040 1.0
[1.037] [1.060]

Compatibility, Stability & Convergence:


Let u represent the exact solution of the PDE and uD is the exact solution of the discretized equation. The
error (u uD ) is called discretization error.
@2u
Assume the parabolic di↵erential equation @u
@t = @x2 , 0  x  L, t > 0, and let
✓ ◆
@ @2
L= , LD denotes the discretizing operator, and T is the truncation error.
@t @x2

Then in operator form:


Lu = 0 = LD (u) + T (7.1)
As uD is the exact solution of LD (u) = 0. If the discretization error (u uD ) ! 0 as x and t ! 0,
then uD ! u, i.e., the finite di↵erence solution is said to converge to the exact solution.

Compatibility and Stability


If the finite di↵erence approximation LD (u) tends to L(u) as x and t tend to zero, i.e., T ! 0 as x and
t ! 0, then the finite di↵erence approximation is said to be compatible with the original PDE.

While finding the solution uD , some errors like rounding/truncation etc., also creep in. So the final
solution is di↵erent from uD , and can be called uC . The error (uD uC ) is called stability error, and if it
tends to zero, then the finite di↵erence scheme is said to be stable.

Hence, total error = u uC = (u uD ) + (uD uC ) (7.2)

You might also like