Docsity

Finite Difference Method for the Boundary Value Problems | CS 4803, Study notes of Computer Science

Partial preview of the text

Download Finite Difference Method for the Boundary Value Problems | CS 4803 and more Study notes Computer Science in PDF only on Docsity!

Introduction toModeling andSimulation Finite-Difference Method forBoundary Value Problems

Review 

Boundary-value problems (BVP)

What is it and how do they differ from IVPs?

Give some example problems of BVP



Shooting method for BVP

How does it work?

What are the limitations?



Finite-difference method for BVP

How does it work?

A Concrete Example 

Consider a rod has heat sources on both ends

a

and

b

. Temperature would change until

eventually it reaches a steady state



A steady-state problemwhere

Īŗ

is heat coefficient (density of heat

capacity) and

ψ

is heat source (sink, if

ψ

<0), or

where

f

( x

ψ

( x

Īŗ

( x



We need two boundary conditions

u(a)=

and u(b)=



This is called a two-point BVP

( )

( )

( )

x u

x^

x

Īŗ

ψ

′′^

=

( )

( )

u

x

f^

x

′′^

=

Finite-Difference Solution 

Apply finite-difference method



Introduce mesh points

x

,^ i i =0,1,…,n+1 with unknowns

y

ā‰ˆ j u (

x ) for i

i=1,…,n 

Replace u’’ by centered difference approximation 

We have linear system

Ay

= f

, where

This tridiagonal linear system can be easily solved

How accurate is the solution?

1

1

2 2

(^

)

j^

j^

j

j

y^

y^

y^

f^

x

h āˆ’^

āˆ’^

+^

=

2

1

2 3

2

1

2

2

1

(^

)^

/

1

2

1

(^

)

1

2

1

(^

)

1

,

1

2

1

(^

)

1

2

(^

)^

/ n n f^

x^

h f^

x f^

x

h

f^ x f^ x

h α^ āˆ’ β

āˆ’^

^



āˆ’

^

^

^



^



āˆ’^

^



^

^

^



^



āˆ’

=^

=^ 



^

^

^



^

^

^



^



āˆ’^

^



^

 āˆ’^

āˆ’

^



^

^

^



A^

f









Types of Boundary Conditions 

The preceding problem has

Dirichlet

boundary

condition^ 

Value of

u

(temperature) is specified at boundary



Another common type is

Neumann

boundary

condition^ 

First derivative

u

’ is specified at boundary



Note: specifying Neumann BC on both endswould lead to ill-posed problem (linear system issingular)

E.g., specifying derivative to be 0 at boundary

8

Solution for Neumann BC 

Consider BC u’(a)=

and u(b)=



If we use first-order approximation of u’, solutionwould be only first-order accurate



Introduce virtual point x

and apply centered

finite-difference method, we have



And linear system

Ay

f , where

1 2

2 3

2

1

2

(^
(^
(^
(^
(^
)^
h^ f n n
x
h^
h
f^
x
f^
x
h
f^
x
f^
x^
h
āˆ’^
^
^
^
^
^
āˆ’^
^
^
^
^
^
=^
=^ 
^
^
^
^
^
^
^
āˆ’^
^
^
^
āˆ’^
^
^
^
^
A^
f^

1

0

1

0

2

1

1 0

1

0

1

(^

2

)^

(^

),

1

(^

)^

; so

2 1

(^

)^

(^

).

2

y^

y^

y^

f^

x

h

y^

y

h

h

y^

y^

f^

x

h

āˆ’

āˆ’

āˆ’^

+^

=

āˆ’^

=

āˆ’^

+^

=^

^

Replace partial derivatives by centered difference approximationwhere

u

i , j^

is approximation to true solution u(

x , i

y ) for i

i ,

j =1,…,

n

^

This discretization has a five-point stencil ^

Using natural row-wise ordering of nodes, we get matrix of pattern ^

As in 1-D, solution is also 2

nd

order accurate

Poisson Equation Cont’d

1,^

,^

1,^

,^

1

,^

,^

1

2

2

1,^

1,^

,^

1

,^

1

,

2

(^

,^

), or

(^

)^

(^

,^

i^

j^

i j^

i^

j^

i j^

i j^

i j

i^

j

i^

j^

i^

j^

i j^

i j^

i j^

i^

j

u^

u^

u^

u^

u^

u^

f^

x^

y

h^

h

u^

u^

u^

u^

u^

f^

x^

y

+ h

āˆ’^

+^

āˆ’

+^

āˆ’^

+^

āˆ’

āˆ’^

+^

āˆ’^

+^

+^

+^

+^

āˆ’^

2

4

1 1

4

1 1

4

1

1

,^

where

1

4

1 1

4

h

āˆ’

^

^

^



^

^

^



āˆ’

^

^

^



^

^

^



āˆ’

=^

=

^

^

^



^

^

^



^

^

^



āˆ’

^

^

^

 āˆ’

^

^

^



T^

I I^

T^

I I^

T^

I

A^

T

I^

T^

I I^

T