Professional Documents
Culture Documents
Praveen. C
praveen@math.tifrbng.res.in
1 / 23
Heat equation
1
∆x = , xj = j∆x, j = 0, 1, . . . , Mx
Mx
1
∆y = , yk = k∆y, k = 0, 1, . . . , My
My
2 / 23
FTCS scheme
Dt+ unj,k = µ(Dx+ Dx− unj,k + Dy+ Dy− unj,k )
un+1 n
j,k − uj,k unj−1,k − 2unj,k + unj+1,k
Dt+ unj,k = , Dx+ Dx− unj,k =
∆t ∆x2
n n n
uj,k−1 − 2uj,k + uj,k+1
Dy+ Dy− unj,k =
∆y 2
Define
µ∆t µ∆t
rx = , ry =
∆x2 ∆y 2
Define undivided finite differences
δx2 unj,k = unj−1,k − 2unj,k + unj+1,k , δy2 unj,k = unj,k−1 − 2unj,k + unj,k+1
FTCS scheme
un+1 n 2 n 2 n
j,k = uj,k + rx δx uj,k + ry δy uj,k
or
un+1 2 2 n
j,k = (1 + rx δx + ry δy )uj,k
3 / 23
FTCS scheme: maximum stability
un+1 n n n n n
j,k = (1 − 2rx − 2ry )uj,k + rx (uj−1,k + uj+1,k ) + ry (uj,k−1 + uj,k+1 )
If
1
rx + ry ≤
2
then
min(unj±1,k , unj,k±1 , unj,k ) ≤ un+1 n n n
j,k ≤ max(uj±1,k , uj,k±1 , uj,k )
2µ∆t 1 h2
≤ =⇒ ∆t ≤
h2 2 4µ
This time step restriction is half the value in one dimension.
4 / 23
FTCS scheme: Fourier stability
Take Fourier mode with wave-number (ξ, η) ∈ (−π, +π) × (−π, +π)
unj,k = ûn ei(jξ+kη)
Then
ûn+1 = ρûn
where
ρ(ξ, η) = 1 + 2rx (cos ξ − 1) + 2ry (cos η − 1)
= 1 − 4rx sin2 (ξ/2) − 4ry sin2 (η/2)
For stability we need |ρ(ξ, η)| ≤ 1. Maximum value of ρ
ρ=1 at (ξ, η) = (0, 0)
and minimum value of ρ
ρ = 1 − 4rx − 4ry at (ξ, η) = (π, π)
Hence we have stability provided
1
rx + ry ≤
2
5 / 23
BTCS scheme
or
(1 − rx δy2 − ry δy2 )un+1 n
j,k = uj,k
6 / 23
Crank-Nicholson scheme
unj,k + un+1
j,k unj,k + un+1
j,k
un+1 n 2
j,k = uj,k + rx δx + ry δy2
2 2
or
1 1 1 1
(1 − rx δx2 − ry δy2 )un+1 2 2 n
j,k = (1 + rx δx + ry δy )uj,k
2 2 2 2
Amplification factor
7 / 23
Peaceman-Rachford scheme
Update solution in two steps
1 1
tn → tn + ∆t → tn+1 , un → un+ 2 → un+1
2
Step 1: Implicit in x
n+ 1
uj,k 2 − unj,k µ 2 n+ 12 µ 2 n
= δ u + δ u
1
2 ∆t
∆x2 x j,k ∆y 2 y j,k
or
1 n+ 1 1
(1 − rx δx2 )uj,k 2 = (1 + ry δy2 )unj,k
2 2
Step 2: Implicit in y
n+ 1
un+1
j,k − uj,k
2
µ 2 n+ 12 µ 2 n+1
= δx uj,k + δ u
1
2 ∆t
∆x 2 ∆y 2 y j,k
or
1 1 2 n+ 2
1
(1 − ry δy2 )un+1
j,k = (1 + rx δx )uj,k
2 2
8 / 23
Peaceman-Rachford scheme: Fourier stability
Step 1:
1
[1 + 2rx sin2 (ξ/2)]ûn+ 2 = [1 − 2ry sin2 (η/2)]ûn
Step 2:
1
[1 + 2ry sin2 (η/2))ûn+1 = [1 − 2rx sin2 (ξ/2)]ûn+ 2
Combining the two
9 / 23
Peaceman-Rachford scheme: Consistency
From Step 1
1 n+ 1 1
(1 − rx δx2 )uj,k 2 = (1 + ry δy2 )unj,k
2 2
Multiply on both sides
1 1 n+ 1 1 1
(1 + rx δx2 )(1 − rx δx2 )uj,k 2 = (1 + rx δx2 )(1 + ry δy2 )unj,k
2 2 2 2
Operators on left commute
1 1 n+ 1 1 1
(1 − rx δx2 ) (1 + rx δx2 )uj,k 2 = (1 + rx δx2 )(1 + ry δy2 )unj,k
2 | 2 {z } 2 2
use Step 2
Using Step 2
1 1 1 1
(1 − rx δx2 )(1 − ry δy2 )un+1 2 2 n
j,k = (1 + rx δx )(1 + ry δy )uj,k
2 2 2 2
10 / 23
Peaceman-Rachford scheme: Consistency
un+1
j,k − uj,k
n n+1
µ 2 uj,k + uj,k
n n+1
µ 2 uj,k + uj,k
= δ + δ
∆t ∆x2 x 2 ∆y 2 y 2
2 2 2
µ ∆t δx δy
− (un+1 − unj,k )
4 ∆x2 ∆y 2 j,k
This is Crank-Nicholson scheme with an extra term. This term is O ∆t2
since
n
δx2 δy2 ∂5u
n+1 n
+ O ∆t∆x2 + ∆t∆y 2 + ∆t2
2 2
(u j,k − uj,k ) = ∆t 2 2
∆x ∆y ∂t∂ x∂ y j,k
11 / 23
D’Yakonov Scheme
Peaceman-Rachford scheme
1 1 1 1
(1 − rx δx2 ) (1 − ry δy2 )un+1 2 2 n
j,k = (1 + rx δx )(1 + ry δy )uj,k
2 | 2 {z } 2 2
u∗
j,k
12 / 23
Approximate factorization
Peaceman-Rachford scheme is close to Crank-Nicholson scheme
1 1 1 1
(1 − rx δx2 − ry δy2 )un+1 2 2 n
j,k = (1 + rx δx + ry δy )uj,k
2 2 2 2
Factorise operator on left hand side
1 1 1 1 rx ry 2 2
(1 − rx δx2 − ry δy2 ) = (1 − rx δx2 )(1 − ry δy2 ) − δ δ
2 2 2 2 4 x y
We cannot neglect the last term since it is O ∆t2 and the scheme would only
be first order accurate
n+1
∆t2
4
rx ry 2 2 n+1 ∂ u
δ δ u = + higher order terms
4 x y j,k 4 ∂ 2 x∂ 2 y j,k
13 / 23
Peaceman-Rachford Scheme: Dirichlet BC
Step 1 is
1 n+ 1 1
(1 − rx δx2 )uj,k 2 = (1 + ry δy2 )unj,k
2 2
n+ 1
What boundary condition to use for uj,k 2 at j = 0, Mx ?
n+ 1
Option I: Since uj,k 2 ≈ u(xj , yk , tn + 12 ∆t)
n+ 1 1
uj,k 2 = g(xj , yk , tn + ∆t), j = 0, Mx
2
Option II: Using Step 1 and 2
n+ 1 1 1 1 1
uj,k 2 = (1 − ry δy2 )un+1 2 n
j,k + (1 + ry δy )uj,k
2 2 2 2
At j = 0, Mx
n+ 1 1 1 1 1 1
uj,k 2 = (1 − ry δy2 )g(xj , yk , tn + ∆t) + (1 + ry δy2 )g(xj , yk , tn )
2 2 2 2 2
n+ 1
If BC do not depend on t, then uj,k 2 = g(xj , yk )
14 / 23
D’Yakonov Scheme: Dirichlet BC
1
What boundary condition to use for u∗j,k at j = 0, Mx ? Unlike un+ 2 , we do
not know what u∗ represents. Instead use the numerical scheme itself; from
Step 2
1
u∗j,k = (1 − ry δy2 )un+1
j,k
2
Boundary condition for u∗j,k
1
u∗j,k = (1 − ry δy2 )g(xj , yk , tn+1 ), j = 0, Mx
2
E.g., at j = 0
ry n+1 ry n+1
u∗0,k = − n+1
gj,k−1 + (1 + ry )gj,k − gj,k+1
2 2
15 / 23
Peaceman-Rachford Scheme: Implementation
Step 1: For j = 1, . . . , Mx − 1 and k = 1, . . . , My − 1
1 n+ 1 1
(1 − rx δx2 )uj,k 2 = (1 + ry δy2 )unj,k
2 2
For k = 1, . . . , My − 1, solve tridiagonal matrix
rx n+ 12 n+ 1 rx n+ 21 1
− uj−1,k + (1 + rx )uj,k 2 − uj+1,k = (1 + ry δy2 )unj,k , j = 1, . . . , Mx − 1
2 2 2
Step 2: For j = 1, . . . , Mx − 1 and k = 1, . . . , My − 1
1 1 2 n+ 2
1
(1 − ry δy2 )un+1
j,k = (1 + rx δx )uj,k
2 2
For j = 1, . . . , Mx − 1, solve tridiagonal matrix
ry n+1 ry n+1 1 n+ 1
− u + (1 + ry )un+1
j,k − u = (1 + rx δx2 )uj,k 2 , k = 1, . . . , My − 1
2 j,k−1 2 j,k+1 2
We can throw away the last term since we will get first order time accuracy.
But we can make a better approximation as follows.
(1 − rx δx2 )(1 − ry δy2 )un+1 = (1 + rx ry δx2 δy2 )un + rx ry δx2 δy2 (un+1 − un )
| {z }
O(∆t3 )
17 / 23
Douglas-Rachford Scheme: Two step scheme
Two-step process
18 / 23
Douglas-Rachford Scheme: Fourier stability
Amplification factor
19 / 23
Douglas-Rachford Scheme: Dirichlet BC
20 / 23
Source terms
Heat equation with a forcing term
1 1 1 ∆t n
(1 − rx δx2 )un+ 2 = (1 + ry δy2 )un + F
2 2 2
1 1 1 ∆t n+1
(1 − ry δy2 )un+1 = (1 + rx δx2 )un+ 2 + F
2 2 2
1
To check the consistency of the scheme, eliminate un+ 2
1 1 1 1 1
(1 − rx δx2 )(1 − ry δy2 )un+1 = (1 − rx δx2 )(1 + rx δx2 )un+ 2
2 2 2 2
∆t 1
+ (1 − rx δx )F n+1
2
2 2
1 1 ∆t n
= (1 + rx δx )(1 + ry δy2 )un +
2
(F + F n+1 )
2 2 2
rx ∆t 2 n+1
− δx (F − F n)
| 2 {z }
O(∆t3 )
Hence the two-step scheme is second order accurate in time and space.
22 / 23
Source terms: D’Yakonov Scheme
Start with approximately factored Crank-Nicholson scheme
1 1 1 1 ∆t n
(1 − rx δx2 ) (1 − ry δy2 )un+1 = (1 + rx δx2 )(1 + ry δy2 )un + (F + F n+1 )
2 | 2 {z } 2 2 2
u∗
Remark: We cannot spread out the source term into the two steps like this
1 1 1 ∆t n
(1 − rx δx2 )u∗ = (1 + rx δx2 )(1 + ry δy2 )un + F
2 2 2 2
1 ∆t n+1
(1 − ry δy2 )un+1 = u∗ + F
2 2
This scheme is only first order accurate in time.
23 / 23