Persamaan Diferensial Parsial...

25

Transcript of Persamaan Diferensial Parsial...

Tim Ilmu Komputasi

Coordinator contact:Dr. Putu Harry [email protected]

Persamaan Diferensial

Parsial CNH3C3Week 9: Finite Di�erenceMethod for ODE (Intro to

FDM for PDE)

1 Motivation

2 Explicit and Implicit scheme

3 Crank-Nicholson Scheme

4 Homework

5 Next

Motivation

The decay problem

The so-called decay problemis chosen as a �rst example to

demonstrate what numerical modelling is. In mathematical terms,

this problem can be expressed as:

dC

dt= −κ · C (1.1)

where C is concentration of substance, t is time, and κ is a positive

constant parameter.

Motivation

The decay problem

The physical interpretation:

dC

dt(1.2)

refer to the temporal change of concentration per unit time. And

−κ · C (1.3)

speci�es the temporal change. For κ = 0, there will no change in

time. With κ 6= 0 is negative since concentration is always a

positive quantity. Accordingly, C will gradually decrease with time

at a rate in propotion to concentration itself.

Motivation

Example

Grandma used to keep a 10-litre cartoon of milk in a storage room.

Every night I take away 10% of the milk concentration on a daily

basis and replace it by a tab water. The following table shows the

result of this example. Notation I is the Milk content and II is the

Milk concentration.

Motivation

Example

Day I II (%) Day I II (%)

0 10 100 12 2.82 28.2

1 9.0 90 13 2.54 15.4

2 8.1 81 14 2.29 22.9

3 7.29 72.9 15 2.06 20.6

4 6.56 65.6 16 1.85 18.5

5 5.9 59.0 17 1.67 16.7

6 5.31 53.1 18 1.5 15.0

7 4.78 47.8 19 1.35 13.5

8 4.3 43.0 20 1.22 12.2

9 3.87 38.7 21 1.09 10.9

10 3.49 34.9 22 0.98 9.8

11 3.14 31.4

Motivation

Example

Explicit and Implicit scheme

The decay problem

Now we are interested with the discrete problem of

dC

dt= −κ · C (2.1)

The exact solution of this problem with initial concentration C0 is

C (t) = C0exp(−κ · t) (2.2)

In this case, three schemes are proposed which are Explicit, Implicit

and Crank-Nicholson Scheme.

Explicit and Implicit scheme

The decay problem

Now we are interested with the discrete problem of

dC

dt= −κ · C (2.1)

The exact solution of this problem with initial concentration C0 is

C (t) = C0exp(−κ · t) (2.2)

In this case, three schemes are proposed which are Explicit, Implicit

and Crank-Nicholson Scheme.

Explicit and Implicit scheme

The decay problem

Now we are interested with the discrete problem of

dC

dt= −κ · C (2.1)

The exact solution of this problem with initial concentration C0 is

C (t) = C0exp(−κ · t) (2.2)

In this case, three schemes are proposed which are Explicit, Implicit

and Crank-Nicholson Scheme.

Explicit and Implicit scheme

Discrete domain

The equation contains only one unknown variable which is t time

(C (t)), thus we only consider the discrete of time domain

(t ∈ [0,T ])

t=0- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -t=T

n-1 n n+1

Then we have a constant time step ∆t, thus we denote

C (t) ≈ Cn and C (t + ∆t) ≈ Cn+1 (2.3)

where n ∈ 0, 1, 2, · · ·N, with N = T/∆t.

Explicit and Implicit scheme

Explicit �nite di�erence

Thus we have �rst order �nite di�erence scheme

dC

dt≈ C (t + ∆t)− C (t)

∆t(2.4)

or can be written as

dC

dt≈ Cn+1 − Cn

∆t(2.5)

Explicit and Implicit scheme

Explicit �nite di�erence

Next the explicit FDM scheme of decay problem can be written as

Cn+1 − Cn

∆t= −κCn (2.6)

or

Cn+1 = (1− κ∆t)Cn (2.7)

Explicit and Implicit scheme

Algorithm Explicit

1. Start

2. De�ne �nal time T , ∆t, C0

3. Compute N = T/∆t, C 1 = C0

4. For n=1:N

5. Cn+1 = (1− κ∆t)Cn

6. End

7. plot(t, C)

Explicit and Implicit scheme

Algorithm Explicit

Problem of Grandma, using C0 = 100, ∆t = 3600, T = 15 hours.

Explicit and Implicit scheme

Implicit �nite di�erence

Next the explicit FDM scheme of decay problem can be written as

Cn+1 − Cn

∆t= −κCn+1 (2.8)

or

Cn+1 =Cn

(1 + κ∆t)(2.9)

Explicit and Implicit scheme

Algorithm Implicit

1. Start

2. De�ne �nal time T , ∆t, C0

3. Compute N = T/∆t, C 1 = C0

4. For n=1:N

5. Cn+1 = Cn/(1 + κ∆t)

6. End

7. plot(t, C)

Explicit and Implicit scheme

Algorithm Implicit

Problem of Grandma, using C0 = 100, ∆t = 3600, T = 15 hours.

Crank-Nicholson Scheme

Crank-Nicholson

As can be seen, the explicit scheme slightly underestimates the

correct concentration, whereas the implicit scheme slightly

overestimates concentration. A semi-implicit approach would

probably give the best solution, but this remains to be veri�ed by

the reader.

Crank-Nicholson Scheme

Crank-Nicholson

The semi-implicit scheme or Crank Nicholson of decay problem can

be written as

Cn+1 − Cn

∆t= −κ

(α · Cn+1 + (1− α) · Cn

)(3.1)

or

Cn+1 =(1− (1− α)κ∆t) · Cn

(1 + ακ∆t)(3.2)

where α = 0.5.

Crank-Nicholson Scheme

Algorithm Implicit

1. Start

2. De�ne �nal time T , ∆t, C0

3. Compute N = T/∆t, C 1 = C0

4. For n=1:N

5. Cn+1 = (1−(1−α)κ∆t)Cn

(1+ακ∆t)

6. End

7. plot(t, C)

Crank-Nicholson Scheme

Algorithm Implicit

Problem of Grandma, using C0 = 100, ∆t = 3600, T = 15 hours.

Homework

Homework

Repeat the exercise with

1. Explicit and Implicit scheme using ∆t = 1;

2. Semi-implicit using α = 0.25 and α = 0.75.

Next

Next

Next, the Finite Di�erence Method (FDM), explicit scheme will be

given in order to approximate the solution of 1D heat di�usion

problem.

Good Luck

End of presentation!