Sie sind auf Seite 1von 49

Numerical Method in

Chemical Engineering
AGUNG NUGROHO
UNIVERSITAS PERTAMINA
Numerical Solution
to Partial Differential
Equations (PDE)
What is a Partial Differential
Equation ?
Ordinary Differential Equations have only one independent variable
𝑑𝑦
3 + 5𝑦 2 = 3𝑒 −𝑥 , 𝑦(0) = 5
𝑑𝑥

Partial Differential Equations have more than one independent


variable
𝜕2𝑢 𝜕2𝑢
3 2 + 2 = 𝑥2 + 𝑦2
𝜕𝑥 𝜕𝑦

subject to certain conditions: where u is the dependent variable, and x


and y are the independent variables.
Types of PDE
The classification of linear PDEs
𝜕2𝑢 𝜕2𝑢 𝜕2𝑢 𝜕𝑢 𝜕𝑢
𝐴 2+𝐵 +𝐶 2+𝐷 +𝐸 +𝐹𝑢 =𝐺
𝜕𝑥 𝜕𝑥𝜕𝑦 𝜕𝑦 𝜕𝑥 𝜕𝑦

Simplified
form  𝐴 𝑢𝑥𝑥 + 𝐵 𝑢𝑥𝑦 + 𝐶 𝑢𝑦𝑦 + 𝐷𝑢𝑥 + 𝐸𝑢𝑦 + 𝐹 𝑢 = 𝐺

• parabolic, if B2-4AC = 0 (diffusion and heat transfer)


• hyperbolic, if B2- 4AC > 0 (vibrating systems and wave phenomena)
• elliptic, if B2-4AC < 0 (steady-state phenomena)
Type of Boundary Condition
The three most important types of BC are
• Dirichlet BC: 𝑢 = g(t)
concentration is specified on the boundary
• Mixed BC: 𝜕𝑢
+ λ u = g(t)
concentration of the surrounding medium is 𝜕𝑛
specified
• Von Neumann BC: 𝜕𝑢
= g(t)
concentration flux across the boundary is 𝜕𝑛
specified
Finite Difference Approximation
o Most PDE problems analytical solutions are difficult
approximated numerically.
o To approximate the model equations by finite differences we
divide the closed domain by a set of lines parallel to the spatial
and time axes to form a grid or a mesh.
o Assumption:
o The sets of lines are equally spaced such that the distance
between crossing points is x and t respectively.
o The crossing points are called the grid points or the mesh
points.
Solution of parabolic PDE
using FDM
1. Explicit
2. Implicit
3. Crank Nicolson
Explicit Discretization
Consider PDE : 𝜕 2 𝑇 𝜕𝑇
𝛼 2= 𝑗+1
𝜕𝑥 𝜕𝑡
Using forward in time and central in space, we get : 𝑗

𝑗 𝑗 𝑗 𝑗+1 𝑗
𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1 𝑇𝑖 − 𝑇𝑖
𝛼 =
Δ𝑥 2 Δ𝑡
𝛼 Δ𝑡
Solving for the temp at the time node 𝑛 + 1 gives choosing, 𝜆 = Δ𝑥 2
𝑗+1 𝛼 Δ𝑡 𝑗 𝑗 𝑗 𝑗
𝑇𝑖 = 𝑇 − 2𝑇 + 𝑇 + 𝑇
Δ𝑥 2 𝑖+1 𝑖 𝑖−1 𝑖
we can write the equation as,
𝑗+1 𝑗 𝑗 𝑗 𝑗
𝑇𝑖 = 𝜆 𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1 + 𝑇𝑖
This equation is called Forward Time Centered Space or FTCS
The Explicit Method (FTCS)
𝑗+1 𝑗 𝑗 𝑗 𝑗
𝑇𝑖 = 𝜆 𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1 + 𝑇𝑖
 This equation can be solved explicitly because it can be written for each
internal location node of the rod for time node 𝑗 + 1 in terms of the
temperature at time node 𝑗.

 In other words, if we know the temperature at node 𝑗 = 0 (IC), and the


boundary temperatures, we can find the temperature at the next time step.

 We continue the process by first finding the temperature at all nodes 𝑗 = 1,


and using these to find the temperature at the next time node, 𝑗 = 2 .

 This process continues until we reach the time at which we are interested in
finding the temperature.
Example 1: Explicit Method
Consider a steel rod that is subjected to a temperature of 100oC on the
left end and 25oC on the right end. If the rod is of length 0.05 m ,use the
explicit method to find the temperature distribution in the rod from 𝑡 = 0
and 𝑡 = 9 seconds. Use ∆𝑥 = 0.01 𝑚 , ∆𝑡 = 3 .
Given: 𝑘 = 54 𝑊 𝑚.𝐾 , 𝜌 = 7800 𝑘𝑔 𝑚3 , 𝑐 = 490 𝐽 𝑘𝑔.𝐾
The initial temperature of the rod is 20oC.

0 1 2 3 4 5

𝑇 = 100°𝐶 𝑇 = 25°𝐶

0.01𝑚
Example 1: Explicit Method
Recall, Number of time steps, 𝑡𝑓𝑖𝑛𝑎𝑙 − 𝑡𝑖𝑛𝑖𝑡𝑖𝑎𝑙
𝑘 =
𝛼= Δ𝑡
𝜌𝐶
9−0
= =3
therefore, 3
54 Boundary Conditions
𝛼 =
7800 × 490 𝑗
𝑇0 = 100°𝐶
= 1.4129 × 10−5 𝑚2 /𝑠 . 𝑗
for all 𝑗 = 0,1,2,3
𝑇5 = 25°𝐶
Then, All internal nodes are at 20°𝐶 for 𝑡 = 0 sec
Δ𝑡
𝜆=𝛼 This can be represented as,
Δ𝑥 2
3
= 1.4129 × 10−5 2
𝑇10 = 𝑇20 = 𝑇30 = 𝑇40 = 20°𝐶
0.01
= 0.4239
.
Example 1: Explicit Method
Nodal temperatures when 𝑡 = 0 sec , 𝑗 = 0 : 𝑇00 = 100°𝐶
𝑇10 = 20°𝐶
𝑇20 = 20°𝐶
0 Interior nodes
𝑇3 = 20°𝐶
𝑇40 = 20°𝐶
𝑇50 = 25°𝐶

We can now calculate the temperature at each node explicitly using


the equation formulated earlier,

𝑗+1 𝑗 𝑗 𝑗 𝑗
𝑇𝑖 = 𝑇𝑖 + 𝜆 𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1
Example 1: Explicit Method
Nodal temperatures when 𝑡 = 0 sec , 𝑗 = 0 (Example Calculations)
setting 𝑖 = 0 
𝑇01 = 100°𝐶 − Boundary Condition
𝑖=1 𝑖=2
𝑇11 = 𝑇10 + 𝜆 𝑇20 − 2𝑇10 + 𝑇00 𝑇21 = 𝑇20 + 𝜆 𝑇30 − 2𝑇20 + 𝑇10
= 20 + 0.4239 20 − 2(20) + 100 = 20 + 0.4239 20 − 2(20) + 20
= 20 + 0.4239 80 = 20 + 0.4239 0
= 20 + 33.912 = 20°𝐶
= 53.912°𝐶
Nodal temperatures when 𝑡 = 3sec , 𝑗 = 1:
𝑇01 = 100°𝐶 − Boundary Condition
𝑇11 = 53.912°𝐶
𝑇21 = 20°𝐶
Interior nodes
𝑇31 = 20°𝐶
𝑇41 = 22.120°𝐶
𝑇51 = 25°𝐶 − Boundary Condition
Example 1: Explicit Method
Nodal temperatures when 𝑡 = 3 sec , 𝑗 = 1 (Example Calculations)
setting 𝑖 = 0  𝑇 2 = 100°𝐶 − Boundary Condition
0

𝑖=1 𝑖=2
𝑇12 = 𝑇11 + 𝜆 𝑇21 − 2𝑇11 + 𝑇01 𝑇22 = 𝑇21 + 𝜆 𝑇31 − 2𝑇21 + 𝑇11
= 53.912 + 0.4239 20 − 2(53.912) + 100 = 20 + 0.4239 20 − 2(20) + 53.912
= 53.912 + 0.4239 12.176 = 20 + 0.4239 33.912
= 53.912 + 5.1614 = 20 + 14.375
= 59.073°𝐶 = 34.375°𝐶

Nodal temperatures when 𝑡 = 6 sec , 𝑗 = 2:


𝑇02 = 100°𝐶 − BoundaryCondition
𝑇12 = 59.073°𝐶
𝑇22 = 34.375°𝐶
2 Interior nodes
𝑇3 = 20.889°𝐶
𝑇42 = 22.442°𝐶
𝑇52 = 25°𝐶 − BoundaryCondition
Example 1: Explicit Method
Nodal temperatures when 𝑡 = 6 sec , 𝑗 = 2 (Example Calculations)

setting 𝑖=0 𝑇03 = 100°𝐶 − Boundary Condition

𝑖=1 𝑖=2
𝑇13 = 𝑇12 + 𝜆 𝑇22 − 2𝑇12 + 𝑇02 𝑇23 = 𝑇22 + 𝜆 𝑇32 − 2𝑇22 + 𝑇12
= 59.073 + 0.4239 34.375 − 2(59.073) + 100 = 34.375 + 0.4239 20.899 − 2(34.375) + 59.073
= 59.073 + 0.4239 16.229 = 34.375 + 0.4239 11.222
= 59.073 + 6.8795 = 34.375 + 4.7570
= 65.953°𝐶 = 39.132°𝐶

Nodal temperatures when 𝑡 = 9 sec , 𝑗 = 3:


𝑇03 = 100°𝐶 − BoundaryCondition
𝑇13 = 65.953°𝐶
𝑇23 = 39.132°𝐶
Interior nodes
𝑇33 = 27.266°𝐶
𝑇43 = 22.872°𝐶
𝑇53 = 25°𝐶 − BoundaryCondition
Summary Example 1:
Explicit Method
To better visualize the temperature variation at different locations at different
times, the temperature distribution along the length of the rod at different times is
plotted below.
Explicit vs Implicit Method
Disadvantage of Explicit method:
o Not stable for all values of ∆𝑥 𝑎𝑛𝑑 ∆𝑡.
Δ𝑡 1
o Explicit method only stable when 𝜆 = 𝛼 ≤
Δ𝑥 2 2

o When not stable  become divergence

Implicit
Method

o Stable for all values of ∆𝑥 𝑎𝑛𝑑 ∆𝑡


Implicit Discretization
Consider PDE : 𝜕 2 𝑇 𝜕𝑇
𝛼 2=
𝜕𝑥 𝜕𝑡
𝑗+1
Using backward in time and central in space, we get : 𝑗

𝛼 Δ𝑡 𝑗+1
𝑇𝑖+1 − 2𝑇𝑖
𝑗+1 𝑗+1
+ 𝑇𝑖−1 𝑇𝑖
𝑗+1
− 𝑇𝑖
𝑗
𝜆= 𝛼 =
Δ𝑥 2 Δ𝑥 2 Δ𝑡
𝑗+1 𝑗+1 𝑗+1 𝑗+1 𝑗
𝜆 𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1 = 𝑇𝑖 − 𝑇𝑖
𝑗+1 𝑗+1 𝑗+1 𝑗+1 𝑗
𝜆𝑇𝑖−1 − 2𝜆𝑇𝑖 + 𝜆𝑇𝑖+1 − 𝑇𝑖 = −𝑇𝑖
Rearranging yields 𝑗+1 𝑗+1 𝑗+1 𝑗
𝜆𝑇𝑖−1 − 2𝜆 + 1 𝑇𝑖 + 𝜆𝑇𝑖+1 = −𝑇𝑖

The rearranged equation can be written for every node during each time step. These
equations can then be solved as a simultaneous system of linear equations to find the
nodal temperatures at a particular time.
Example 2: Implicit Method
Consider a steel rod that is subjected to a temperature of 100oC on the left
end and 25oC on the right end. If the rod is of length 0.05 m, use the
implicit method to find the temperature distribution in the rod from 𝑡 = 0
and 𝑡 = 9 seconds. Use ∆𝑥 = 0.01 𝑚 , ∆𝑡 = 3 .
Given: 𝑘 = 54 𝑊 𝑚.𝐾 , 𝜌 = 7800 𝑘𝑔 𝑚3 , 𝑐 = 490 𝐽 𝑘𝑔.𝐾
The initial temperature of the rod is 20oC.

0 1 2 3 4 5

𝑇 = 100°𝐶 𝑇 = 25°𝐶

0.01𝑚
Example 2: Implicit Method
Recall, Number of time steps, 𝑡𝑓𝑖𝑛𝑎𝑙 − 𝑡𝑖𝑛𝑖𝑡𝑖𝑎𝑙
𝑘 =
𝛼= Δ𝑡
𝜌𝐶
9−0
= =3
therefore, 3
54 Boundary Conditions
𝛼 =
7800 × 490 𝑗
𝑇0 = 100°𝐶
= 1.4129 × 10−5 𝑚2 /𝑠 . 𝑗
for all 𝑗 = 0,1,2,3
𝑇5 = 25°𝐶
Then, All internal nodes are at 20°𝐶 for 𝑡 = 0 sec
Δ𝑡
𝜆=𝛼 This can be represented as,
Δ𝑥 2
3
= 1.4129 × 10−5 2 𝑇10 = 𝑇20 = 𝑇30 = 𝑇40 = 20°𝐶
0.01
= 0.4239
.
Example 2: Implicit Method
Nodal temperatures when 𝑡 = 0 sec , 𝑗 = 0 : 𝑇00 = 100°𝐶
𝑇10 = 20°𝐶
𝑇20 = 20°𝐶
Interior nodes
𝑇30 = 20°𝐶
𝑇40 = 20°𝐶
𝑇50 = 25°𝐶

We can now calculate the temperature at each node explicitly using the
equation formulated earlier,

𝑗+1 𝑗+1 𝑗+1 𝑗


𝜆𝑇𝑖−1 − 2𝜆 + 1 𝑇𝑖 + 𝜆𝑇𝑖+1 = −𝑇𝑖
Example 2: Implicit Method
Nodal temperatures when 𝑡 = 0 sec
from BC  𝑇01 = 100°𝐶 , and 𝑇51 = 25°𝐶
For the interior nodes setting 𝑗 = 0 and 𝑖 = 1,2,3,4 gives the following,
−𝜆𝑇01 + (1 + 2𝜆)𝑇11 − 𝜆𝑇21 = 𝑇10
𝑖=1 (−0.4239 × 100) + (1 + 2 × 0.4239)𝑇11 − (0.4239𝑇21 ) = 20
−42.39 + 1.8478𝑇11 − 0.4239𝑇21 = 20
𝟏. 𝟖𝟒𝟕𝟖𝑻𝟏𝟏 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟏𝟐 = 𝟔𝟐. 𝟑𝟗𝟎

𝑖=2 −𝜆𝑇11 + (1 + 2𝜆)𝑇21 − 𝜆𝑇31 = 𝑇20


−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟏𝟏 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟏𝟐 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟏𝟑 = 𝟐𝟎

𝑖=3 −𝜆𝑇21 + (1 + 2𝜆)𝑇31 − 𝜆𝑇41 = 𝑇30


−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟏𝟐 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟏𝟑 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟏𝟒 = 𝟐𝟎
𝑖=4 −𝜆𝑇31 + (1 + 2𝜆)𝑇41 − 𝜆𝑇51 = 𝑇40
−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟏𝟑 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟏𝟒 = 𝟑𝟎. 𝟓𝟗𝟖

For the 1st time step we can write four such equations with four unknowns, expressing
them in matrix form yields
Example 2: Implicit Method
1.8478 −0.4239 0 0 𝑇11 62.390
1
−0.4239 1.8478 −0.4239 0 𝑇2 20
=
0 −0.4239 1.8478 −0.4239 𝑇31 20
0 0 −0.4239 1.8478 𝑇41 30.598

Gauss elimination Method

𝑇01 = 100°𝐶
𝑇11 = 39.451 Hence, the nodal temps 𝑇11 = 39.451°𝐶
𝑇21 = 24.792 at 𝑡 = 3 sec are 𝑇21 = 24.792°𝐶
𝑇31 = 21.438 𝑇31 = 21.438°𝐶
𝑇41 = 21.477 𝑇41 = 21.477°𝐶
𝑇51 = 25°𝐶
Example 2: Implicit Method
Nodal temperatures when 𝑡 = 3sec
from BC  𝑇02 = 100°𝐶 , and 𝑇52 = 25°𝐶
For the interior nodes setting 𝑗 = 1 and 𝑖 = 1,2,3,4 gives the following,
−𝜆𝑇02 + (1 + 2𝜆)𝑇12 − 𝜆𝑇22 = 𝑇11
𝑖=1 (−0.4239 × 100) + (1 + 2 × 0.4239)𝑇12 − 0.4239𝑇22 = 39.451
−42.39 + 1.8478𝑇12 − 0.4239𝑇22 = 39.451
𝟏. 𝟖𝟒𝟕𝟖𝑻𝟐𝟏 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟐𝟐 = 𝟖𝟏. 𝟖𝟒𝟏

𝑖=2 −𝜆𝑇12 + (1 + 2𝜆)𝑇22 − 𝜆𝑇32 = 𝑇21


−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟐𝟏 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟐𝟐 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟐𝟑 = 𝟐𝟒. 𝟕𝟗𝟐

𝑖=3 −𝜆𝑇22 + (1 + 2𝜆)𝑇32 − 𝜆𝑇42 = 𝑇31


−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟐𝟐 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟐𝟑 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟐𝟒 = 𝟐𝟏. 𝟒𝟑𝟖

𝑖=4 −𝜆𝑇32 + (1 + 2𝜆)𝑇42 − 𝜆𝑇52 = 𝑇41


−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟐𝟑 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟐𝟒 = 𝟑𝟐. 𝟎𝟕𝟓

For the 2nd time step we can write four such equations with four unknowns, expressing
them in matrix form yields
Example 2: Implicit Method
1.8478 −0.4239 0 0 𝑇12 81.841
2
−0.4239 1.8478 −0.4239 0 𝑇2 24.792
=
0 −0.4239 1.8478 −0.4239 𝑇32 21.438
0 0 −0.4239 1.8478 𝑇42 32.075

Gauss elimination Method

𝑇02 = 100°𝐶
𝑇12 = 51.326 Hence, the nodal temps 𝑇12 = 51.326 °𝐶
𝑇22 = 30.669 at 𝑡 = 6 sec are 𝑇22 = 30.669 °𝐶
𝑇32 = 23.876 𝑇32 = 23.876 °𝐶
𝑇42 = 22.836 𝑇42 = 22.836 °𝐶
𝑇52 = 25°𝐶
Example 2: Implicit Method
Nodal temperatures when 𝑡 = 6sec
from BC  𝑇03 = 100°𝐶 , and 𝑇53 = 25°𝐶
For the interior nodes setting 𝑗 = 2 and 𝑖 = 1,2,3,4 gives the following,
−𝜆𝑇03 + (1 + 2𝜆)𝑇13 − 𝜆𝑇23 = 𝑇12
𝑖=1 (−0.4239 × 100) + (1 + 2 × 0.4239)𝑇13 − (0.4239𝑇23 ) = 51.326
−42.39 + 1.8478𝑇13 − 0.4239𝑇23 = 51.326
𝟏. 𝟖𝟒𝟕𝟖𝑻𝟑𝟏 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟑𝟐 = 𝟗𝟑. 𝟕𝟏𝟔

𝑖=2 −𝜆𝑇13 + (1 + 2𝜆)𝑇23 − 𝜆𝑇33 = 𝑇22


−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟑𝟏 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟑𝟐 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟑𝟑 = 𝟑𝟎. 𝟔𝟔𝟗

𝑖=3 −𝜆𝑇23 + (1 + 2𝜆)𝑇33 − 𝜆𝑇43 = 𝑇32


−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟑𝟐 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟑𝟑 − 𝟎. 𝟒𝟐𝟑𝟗𝑻𝟑𝟒 = 𝟐𝟑. 𝟖𝟕𝟔

𝑖=4 −𝜆𝑇33 + (1 + 2𝜆)𝑇43 − 𝜆𝑇53 = 𝑇42


−𝟎. 𝟒𝟐𝟑𝟗𝑻𝟑𝟑 + 𝟏. 𝟖𝟒𝟕𝟖𝑻𝟑𝟒 = 𝟑𝟑. 𝟒𝟑𝟒

For the 3rd time step we can write four such equations with four unknowns, expressing
them in matrix form yields
Example 2: Implicit Method
1.8478 −0.4239 0 0 𝑇13 93.716
3
−0.4239 1.8478 −0.4239 0 𝑇2 30.669
=
0 −0.4239 1.8478 −0.4239 𝑇33 23.876
0 0 −0.4239 1.8478 𝑇43 33.434

Gauss elimination Method

𝑇03 = 100°𝐶
𝑇13 = 59.043 Hence, the nodal temps 𝑇13 = 59.043 °𝐶
𝑇23 = 36.292 at 𝑡 = 9 sec are 𝑇23 = 36.292 °𝐶
𝑇33 = 26.809 𝑇33 = 26.809 °𝐶
𝑇43 = 24.243 𝑇43 = 24.243 °𝐶
𝑇53 = 25°𝐶
Summary Example 2:
Implicit Method
To better visualize the temperature variation at different locations at different
times, the temperature distribution along the length of the rod at different times is
plotted below.
The Crank-Nicolson Method
WHY:
𝜕2 𝑇
Using the implicit method our approximation of was of 𝑂(Δ𝑥)2 accuracy,
𝜕𝑥 2

𝜕𝑇
while our approximation of was of 𝑂(Δ𝑡) accuracy.
𝜕𝑡

We can achieve similar orders of accuracy by approximating the second derivative, on the
left hand side of the heat equation, at the midpoint of the time step. Doing so yields

𝑗 𝑗 𝑗 𝑗+1 𝑗+1 𝑗+1


𝜕2𝑇 1 𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1 𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1
≈ +
𝜕𝑥 2 2 Δ𝑥 2 Δ𝑥 2
𝑖,𝑗

The first derivative, on the right hand side of the heat equation, is approximated
using the forward divided difference method at time level 𝑗 + 1,
𝑗+1 𝑗
𝜕𝑇 𝑇𝑖 − 𝑇𝑖

𝜕𝑡 𝑖,𝑗
Δ𝑡
Crank-Nicolson Discretization
Consider PDE : 𝜕 2 𝑇 𝜕𝑇
𝛼 2=
𝜕𝑥 𝜕𝑡 𝑗+1
𝑗
Using forward in time and central in space, we get :

𝑗+1 𝑗+1 𝑗+1 𝑗 𝑗 𝑗 𝑗+1 𝑗


𝛼 𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1 𝑇𝑖+1 − 2𝑇𝑖 + 𝑇𝑖−1 𝑇𝑖 − 𝑇𝑖
2 + =
2 Δ𝑥 Δ𝑥 2 Δ𝑡

Δ𝑡
𝜆=𝛼
Δ𝑥 2

𝑗+1 𝑗+1 𝑗+1 𝑗 𝑗 𝑗


−𝜆𝑇𝑖−1 + 2(1 + 𝜆)𝑇𝑖 − 𝜆𝑇𝑖+1 = 𝜆𝑇𝑖−1 + 2(1 − 𝜆)𝑇𝑖 + 𝜆𝑇𝑖+1
Example 3: Crank-Nicolson
Consider a steel rod that is subjected to a temperature of 100oC on the
left end and 25oC on the right end. If the rod is of length 0.05 m ,use the
Crank-Nicolson method to find the temperature distribution in the rod
from 𝑡 = 0 and 𝑡 = 9 seconds. Use ∆𝑥 = 0.01 𝑚 , ∆𝑡 = 3 .
Given: 𝑘 = 54 𝑊 𝑚.𝐾 , 𝜌 = 7800 𝑘𝑔 𝑚3 , 𝑐 = 490 𝐽 𝑘𝑔.𝐾
The initial temperature of the rod is 20oC.

0 1 2 3 4 5

𝑇 = 100°𝐶 𝑇 = 25°𝐶

0.01𝑚
Example 3: Crank-Nicolson
Recall, Number of time steps, 𝑡𝑓𝑖𝑛𝑎𝑙 − 𝑡𝑖𝑛𝑖𝑡𝑖𝑎𝑙
𝑘 =
𝛼= Δ𝑡
𝜌𝐶
9−0
= =3
therefore, 3
54 Boundary Conditions
𝛼 =
7800 × 490 𝑗
𝑇0 = 100°𝐶
= 1.4129 × 10−5 𝑚2 /𝑠 . 𝑗
for all 𝑗 = 0,1,2,3
𝑇5 = 25°𝐶
Then, All internal nodes are at 20°𝐶 for 𝑡 = 0 sec
Δ𝑡
𝜆=𝛼 This can be represented as,
Δ𝑥 2
3
= 1.4129 × 10−5 2 𝑇10 = 𝑇20 = 𝑇30 = 𝑇40 = 20°𝐶
0.01
= 0.4239
.
Example 3: Crank-Nicolson
Nodal temperatures when 𝑡 = 0sec , 𝑗 = 0 : 𝑇00 = 100°𝐶
𝑇10 = 20°𝐶
𝑇20 = 20°𝐶
Interior nodes
𝑇30 = 20°𝐶
𝑇40 = 20°𝐶
𝑇50 = 25°𝐶

We can now calculate the temperature at each node explicitly using the
equation formulated earlier,

𝑗+1 𝑗+1 𝑗+1 𝑗 𝑗 𝑗


−𝜆𝑇𝑖−1 + 2(1 + 𝜆)𝑇𝑖 − 𝜆𝑇𝑖+1 = 𝜆𝑇𝑖−1 + 2(1 − 𝜆)𝑇𝑖 + 𝜆𝑇𝑖+1
Example 3: Crank-Nicolson
Nodal temperatures when 𝑖 = 0, 𝑡 = 3sec, 𝑇01 = 100°𝐶 − BoundaryCondition ,
(Example Calculations)
𝑖=1
For the interior nodes setting 𝑗 = 0 and 𝑖 = 1,2,3,4 gives the following
−𝜆𝑇01 + 2(1 + 𝜆)𝑇11 − 𝜆𝑇21 = 𝜆𝑇00 + 2(1 − 𝜆)𝑇10 + 𝜆𝑇20
(−0.4239 × 100) + 2(1 + 0.4239)𝑇11 − 0.4239𝑇21 = (0.4239)100 + 2(1 − 0.4239)20 + (0.4239)20
−42.39 + 2.8478𝑇11 − 0.4239𝑇21 = 42.39 + 23.044 + 8.478

2.8478𝑇11 − 0.4239𝑇21 = 116.30

For the 1st time step we can write four such equations with four unknowns,
expressing them in matrix form yields
Example 3: Crank-Nicolson
2.8478 −0.4239 0 0 𝑇11 116.30
1
−0.4239 2.8478 −0.4239 0 𝑇2 40.000
=
0 −0.4239 2.8478 −0.4239 𝑇31 40.000
0 0 −0.4239 2.8478 𝑇41 52.718

Gauss elimination Method

𝑇01 = 100°𝐶
𝑇11 = 44.372 Hence, the nodal temps 𝑇11 = 44.372°𝐶
𝑇21 = 23.746 at 𝑡 = 3sec are 𝑇21 = 23.746°𝐶
𝑇31 = 20.797 𝑇31 = 20.797°𝐶
𝑇41 = 21.607 𝑇41 = 21.607°𝐶
𝑇51 = 25°𝐶
Example 3: Crank-Nicolson
Nodal temperatures when 𝑖 = 0 , 𝑡 = 6sec, 𝑇02 = 100°𝐶 − BoundaryCondition
(Example Calculations)
𝑖=1 For the interior nodes setting 𝑗 = 1 and 𝑖 = 1,2,3,4 gives the following,

−𝜆𝑇02 + 2(1 + 𝜆)𝑇12 − 𝜆𝑇22 = 𝜆𝑇01 + 2(1 − 𝜆)𝑇11 + 𝜆𝑇21


(−0.4239 × 100) + 2(1 + 0.4239)𝑇12 − 0.4239𝑇22 = (0.4239)100 + 2(1 − 0.4239)44.372 + (0.4239)23.746
−42.39 + 2.8478𝑇12 − 0.4239𝑇22 = 42.39 + 51.125 + 10.066

2.8478𝑇12 − 0.4239𝑇22 = 145.971

For the 2nd time step we can write four such equations with four unknowns,
expressing them in matrix form yields
Example 3: Crank-Nicolson
2
2.8478 −0.4239 0 0 𝑇1 145.971
2
−0.4239 2.8478 −0.4239 0 𝑇2 54.985
=
0 −0.4239 2.8478 −0.4239 𝑇32 43.187
0 0 −0.4239 2.8478 𝑇 2 54.908
4

Gauss elimination Method

𝑇02 = 100°𝐶
𝑇12 = 55.883 Hence, the nodal temps 𝑇12 = 55.883 °𝐶
𝑇22 = 31.075 at 𝑡 = 6 sec are 𝑇22 = 31.075 °𝐶
𝑇32 = 23.174 𝑇32 = 23.174 °𝐶
𝑇42 = 22.730 𝑇42 = 22.730 °𝐶
𝑇52 = 25°𝐶
Example 3: Crank-Nicolson
Nodal temperatures when 𝑖 = 0, 𝑡 = 9 sec, 𝑇03 = 100°𝐶 − BoundaryCondition
(Example Calculations)
𝑖=1 For the interior nodes setting 𝑗 = 2 and 𝑖 = 1,2,3,4 gives the following,

−𝜆𝑇03 + 2(1 + 𝜆)𝑇13 − 𝜆𝑇23 = 𝜆𝑇02 + 2(1 − 𝜆)𝑇12 + 𝜆𝑇22


(−0.4239 × 100) + 2(1 + 0.4239)𝑇23 − 0.4239𝑇23 = (0.4239)100 + 2(1 − 0.4239)55.883 + (0.4239)31.075
−42.39 + 2.8478𝑇13 − 0.4239𝑇23 = 42.39 + 64.388 + 13.173

2.8478𝑇13 − 0.4239𝑇23 = 162.34

For the 3rd time step we can write four such equations with four unknowns,
expressing them in matrix form yields
Example 3: Crank-Nicolson
2.8478 −0.4239 0 0 𝑇13 162.34
3
−0.4239 2.8478 −0.4239 0 𝑇2 69.318
=
0 −0.4239 2.8478 −0.4239 𝑇33 49.509
0 0 −0.4239 2.8478 𝑇43 57.210

Gauss elimination Method

𝑇03 = 100°𝐶
𝑇13 = 62.604 Hence, the nodal temps 𝑇13 = 62.604 °𝐶
𝑇23 = 37.613 at 𝑡 = 9 sec are 𝑇23 = 36.613 °𝐶
𝑇33 = 26.562 𝑇33 = 26.562 °𝐶
𝑇43 = 24.042 𝑇43 = 24.042 °𝐶
𝑇53 = 25°𝐶
Summary Example 3:
Crank-Nicolson Method
To better visualize the temperature variation at different locations at different
times, the temperature distribution along the length of the rod at different times is
plotted below.
Internal Temperatures at 9 sec.
The table below allows you to compare the results from all three methods
discussed in previously with the analytical solution.

Crank-
Node Explicit Implicit Analytical
Nicolson
𝑇13 65.953 59.043 62.604 62.510
𝑇23 39.132 36.292 37.613 37.084
𝑇33 27.266 26.809 26.562 25.844
𝑇43 22.872 24.243 24.042 23.610
Exercise
1.
at all time, t
∆𝑥 = 0.2 𝑐𝑚, ∆𝑡 = 2 𝑠
𝑥 = 0.4 𝑐𝑚
𝑡 =2𝑠
Exercise
2.
at all time, t

, 𝑢𝑠𝑖𝑛𝑔 𝑚𝑎𝑡𝑙𝑎𝑏
Data: h = 25 W/m2
Exercise 𝑘 = 54 𝑊 𝑚.𝐾
𝜌 = 7800 𝑘𝑔 𝑚3
𝐽
𝑐 = 490 𝑘𝑔. 𝐾

Suatu slab dengan ketebalan L = 0.1 m mula-mula suhunya Ta = 25oC. Kemudian


tiba2 (t=t), suhu di x=0, berubah menjadi Ts=200oC dan pada saat yang sama,
permukaan di x=L dibiarkan terekspos dengan udara yang bersuhu Ts=200 oC.
Fenomena yang terjadi di x=L  qkonduksi=qkonveksi
Sehingga keadaan batasnya menjadi 𝜕𝑇
−𝑘 = ℎ(𝑇 − 𝑇𝑠 )
𝜕𝑥 𝑥=𝐿

Model matematis untuk kasus diatas adalah:

Dengan IC  𝑇(𝑥, 0) = 𝑇𝑎
𝜕𝑇(𝐿, 𝑡)
BC 𝑇(0, 𝑡) = 𝑇𝑠 dan −𝑘 = ℎ(𝑇 − 𝑇𝑠 )
𝜕𝑥
Tentukan distribusi suhu pada berbagai posisi dan waktu sampai t=100s (implicit
dan Crank Nicolson) dengan mengambil nilai ∆𝑥 = 0.02 𝑚, ∆𝑡 = 10 𝑠
𝑗+1 𝑗+1 𝑗+1 𝑗
𝜆𝑇𝑖−1 − 2𝜆 + 1 𝑇𝑖 + 𝜆𝑇𝑖+1 = −𝑇𝑖
𝑗+1 𝑗+1 𝑗+1 𝑗
𝑖 =1 𝜆𝑇0 − 1 + 2𝜆 𝑇1 + 𝜆𝑇2 = −𝑇1
𝑗+1 𝑗+1 𝑗+1 𝑗
𝑖 =2 𝜆𝑇1 − 1 + 2𝜆 𝑇2 + 𝜆𝑇3 = −𝑇2
𝑗+1 𝑗+1 𝑗+1 𝑗
𝑖 =3 𝜆𝑇2 − 1 + 2𝜆 𝑇3 + 𝜆𝑇4 = −𝑇3
𝑗+1 𝑗+1 𝑗+1 𝑗
𝑖 =4 𝜆𝑇3 − 1 + 2𝜆 𝑇4 + 𝜆𝑇5 = −𝑇4
𝑗+1 𝑗+1 𝑗+1 𝑗
𝑖 =5 𝜆𝑇4 − 1 + 2𝜆 𝑇5 + 𝜆𝑇6 = −𝑇5

𝑗+1 𝑗+1
𝑇6 −𝑇4 𝑗+1 2ℎ ∆𝑥
At the BC x=L  −𝑘 = ℎ(𝑇5 − 𝑇𝑠 )  𝑇6𝑗+1 = 𝑇4𝑗+1 − 𝑗+1
(𝑇5 − 𝑇𝑠 )
2∆𝑥 𝑘

𝑗+1 𝑗+1 𝑗+1 2ℎ ∆𝑥 𝑗+1 𝑗


𝜆𝑇4 − 1 + 2𝜆 𝑇5 + 𝜆 𝑇4 − (𝑇5 − 𝑇𝑠 ) = −𝑇5
𝑘

𝑗+1 𝑗+1 𝑗+1 2ℎ ∆𝑥 𝑗+1 2ℎ ∆𝑥 𝑗


𝜆𝑇4 − 1 + 2𝜆 𝑇5 + 𝜆𝑇4 −𝜆 𝑇5 + 𝜆 𝑇𝑠 = −𝑇5
𝑘 𝑘

𝑗+1 2ℎ𝜆∆𝑥 𝑗+1 𝑗 2ℎ ∆𝑥


2𝜆𝑇4 − 1 + 2𝜆 + 𝑇5 = −𝑇5 −𝜆 𝑇𝑠
𝑘 𝑘
𝑗 𝑗+1
− 1 + 2𝜆 𝜆 0 0 0 𝑗+1 𝑗+1 𝑗 −𝑇𝑗+1
1 − 𝜆𝑇0
𝑇1 𝑇1 −𝑇1 − 𝜆𝑇0 𝑗
𝜆 − 1+
− 2𝜆
1 + 2𝜆 𝜆𝜆 00 0 0 𝑗+1 −𝑇2
𝑗+1 𝑇2 𝑗
0 𝜆 𝜆 − 1 −+
1+2𝜆2𝜆 𝜆𝜆 0 0 𝑇2 𝑗+1
−𝑇2 −𝑇3
𝑗
0 = 𝑇3 =
0 0 𝜆𝜆 −− 11 ++ 2𝜆
2𝜆 𝜆 𝜆
𝑇3
𝑗+1
𝑗+1 −𝑇3
𝑗
−𝑇4
𝑗

0 00 𝜆 2ℎ𝜆∆𝑥 𝑇4
0 0 2𝜆 −−1 1
++2𝜆2𝜆
+ 𝑇𝑘4
𝑗+1
𝑗+1
𝑗
−𝑇4 −−𝑇
𝜆𝑇𝑗
𝑗+1 2ℎ ∆𝑥
𝑇5 5 5− 𝜆 𝑇𝑠
𝑘

𝑗+1 𝑗 𝑗+1
−1.7064 0.3532 0 0 0 𝑇1 −𝑇1 − 𝜆𝑇0
𝑗+1 𝑗
0.3532 −1.7064 0.3532 0 0 𝑇2 −𝑇2

0 0.3532 −1.7064 0.3532 0 𝑗+1


𝑇3 = −𝑇3
𝑗

𝑗+1 𝑗
0 0 0.3532 −1.7064 0.3532 𝑇4 −𝑇4
𝑗+1 𝑗
0 0 0 0.7064 −1.7130 𝑇5 −𝑇5 − 1.3082

Dengan mengambil j=0, kita bisa hitung semua nilai T di j=1 (t=10s)
−1.7064 0.3532 0 0 0
1
𝑇1 −95.6436 𝑇11 = 62.9265
1
0.3532 −1.7064 0.3532 0 0 𝑇2 −25
𝑇21 = 33.2271
0 0.3532 −1.7064 0.3532 0 𝑇3
1
= −25
𝑇31 = 26.8195
1
0 0 0.3532 −1.7064 0.3532 𝑇4 −25
1 𝑇41 = 25.5630
0 0 0 0.7064 −1.7130 𝑇5 −26.3082
𝑇51 = 25.9004
Dengan mengambil j=1, kita bisa hitung semua nilai T di j=2 (t=20s)

−1.7064 0.3532 0 0 0 𝑇12 −133.5701


𝑇 2 𝑇12 = 87.3474
0.3532 −1.7064 0.3532 0 0 2 −33.2271
0 0.3532 −1.7064 0.3532 0 2
𝑇3 = −26.8195 𝑇22 = 43.8331
0 0 0.3532 −1.7064 0.3532 𝑇42 −25.5630 𝑇32 = 30.3455
0 0 0 0.7064 −1.7130 𝑇 2 −27.2086
5 𝑇42 = 26.8407
𝑇52 = 26.9530

Dengan mengambil j=2, kita bisa hitung semua nilai T di j=3 (t=30s)

𝑇13
−1.7064 0.3532 0 0 0
3
−157.9910 𝑇13 = 103.8526
0.3532 −1.7064 0.3532 0 0 𝑇 −43.8331
2
3 𝑇23 = 54.4331
0 0.3532 −1.7064 0.3532 0 𝑇3 = −30.3455
0 0 0.3532 −1.7064 0.3532 𝑇43 −26.8407 𝑇33 = 35.0233
0 0 0 0.7064 −1.7130 𝑇 3
5
−28.2612 𝑇43 = 28.8570
𝑇53 = 28.3990
End

Das könnte Ihnen auch gefallen