Professional Documents
Culture Documents
k
λ= … (1)
ah2
Where, λ = 1, hence, k = ah2
λ (Ui+1, j+1 + Ui-1, j+1) – 2(λ+1) Ui, j+1 = 2(λ-1) Ui, j……λ (Ui+1, j + Ui-1, j) … (2)
The equation (1) above is the Crank Nicholson difference scheme. Substituting for λ, equation
(2) reduces to:
1
Ui, j+1 = [Ui-1, j+1 + Ui+1, j+1 + Ui-1, j + Ui+1, j] … (3)
4
Example 1
Ut = Uxx
d2 U du
= ; subject to: U(x, 0) = 100x (1-x)
dx2 dt
U (0, t) = U (1, t) = 0
Solution
1 1 1 1
(Ui+1, j+1 + Ui-1, j+1) – 2 ( + 1) Ui, j+1 = 2( − 1) Ui, j…… (Ui+1, j + Ui-1, j) … (4)
4 4 4 4
1 10 6 1
(Ui+1, j+1 + Ui-1, j+1) - (Ui, j+1) = - (Ui, j)…… (Ui+1, j + Ui-1, j) … (5)
4 4 4 4
(Ui+1, j+1 + Ui-1, j+1) – 10(Ui, j+1) = -6 (Ui, j) …… (Ui+1, j + Ui-1, j) … (6)
L M R
0 0 0
Ui-1, j+1 Ui, j+1 Ui+1, j+1
Figure 2.0
From figure 2.0 above we can rewrite equation (2) as follows:
where,
M = Middle
L = Left
R = Right
TM = Top Middle
TL = Top Left
TR = Top Right
Solving:
= 50 × 0.5 = 25
= 75 × 0.25 = 18.75
From the calculated values above we can generate a table as shown below:
Solving simultaneously:
-98U2 = - 2150
Therefore, U2 = 21.94
−137.5−21.94
U1 = = 15.94
−10
Substituting for U1 and U2 in equation (11):
Hence, U3 = 15.56
Therefore,
U1 = 15.94
U2 = 21.94
U3 = 15.56
Example 2
d2 u du
Solve by Crank Nicholson method,: - = 0; 0 ≤ x ≤ subject to the following constraints:
dx2 dt
U (0, t) = 0
U (1, t) = 0
Solution
Also, from the constraints and step size, we can develop a table as shown below, similar to
what we had in the previous example:
substituting:
U2 – 4U1 = - 25 … (16)
(L+R) – 4M = - 1(TL+TR)
(L+R) – 4M = - 1(TL+TR)
U2 + 0 – 4U3 = - 37.5
Solving simultaneously:
U2 – 4U1 = - 25
U2 = - 25 + 4U1 … (19)
U1 + U3 - 4U2 = - 37.5
-60U1 + U2 = - 587.5
U2 = - 25 + 4U1
U2 = - 25 + 4U1
=- 25 + 4(10.04) = 15.04
U2 – 4U3 = - 37.5
−52.54
U3 = = 13.135
−4
Therefore,
U1 = 10.04
U2 = 15.04
U3 = 13.135
Example 3
d2 u du
Solve by Crank Nicholson simplified formula: - = 0, with the following constraints:
dx2 dt
U (0, t) = 0
U (1, t) = 2t
U (x, 0) = 0
Solution
At U (1, t) = 2(0) = 0
For step 1:
For step 2:
From the above constraints, we can generate the table shown below:
At λ = 1:
Substituting:
0 + U2 – 4U1 = - (0 + 0)
U2 – 4U1 = 0
U2 = 4U1 … (23)
U1 + U3 – 4U2 = - (0 + 0)
U1 + U3 – 4U2 = 0 … (24)
U2 + 0.125 – 4U3 = - (0 + 0)
Solving Simultaneously:
U1 + U3 – 4(4U1) = 0
U1 – 16U1 + U3 = 0
-15U1 + U3 = 0 … (26)
-56U1 = - 0.125
U1 = 0.00223
U2 = 4U1
U2 = 4(0.00223) = 0.00892
−0.13392
U3 = = 0.03348
−4
From the calculated values, table 3.0 is updated as shown below:
Solving Simultaneously:
-56U4 = - 0.66056
U4 = 0.01179
U5 – 4(0.01179) = - 0.00892
U5 – 0.04718 = - 0.00892
U5 = 0.03826
-4U6 = - 0.42218
U6 = 0.10554
Therefore,
U1 = 0.00223
U2 = 0.00892
U3 = 0.03348
U4 = 0.01179
U5 = 0.03826
U6 = 0.10554
Table 3.0c