0% found this document useful (0 votes)
74 views

Example of Implicit Method To Solve Pdes

This document describes the numerical solution of a one-dimensional heat equation using an explicit finite difference scheme. The partial differential equation is discretized using an explicit forward difference scheme. This results in a system of algebraic equations that can be written in matrix form and solved at each time step. A MATLAB code is provided that implements this scheme, applying the initial and boundary conditions to calculate the temperature at discrete points over time.

Uploaded by

KhayrouMezerreg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Example of Implicit Method To Solve Pdes

This document describes the numerical solution of a one-dimensional heat equation using an explicit finite difference scheme. The partial differential equation is discretized using an explicit forward difference scheme. This results in a system of algebraic equations that can be written in matrix form and solved at each time step. A MATLAB code is provided that implements this scheme, applying the initial and boundary conditions to calculate the temperature at discrete points over time.

Uploaded by

KhayrouMezerreg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Example 8.

2: An introduction to computational Fluid Dynamics (second


edition), H K Versteeg and W Malalasekera

The initial condition is,

𝑇 = 200 @𝑡 = 0

And initial conditions are,

𝑑𝑇
=0@𝑥 =0
𝑑𝑥

And

𝑇 = 0 @ 𝑥 = 𝐿 (2 𝑐𝑚 )

Equation for point 1,

𝑑𝑇 𝑑 𝑑𝑇
𝜌𝑐 = (𝑘 )
𝑑𝑡 𝑑𝑥 𝑑𝑥

Integrating above equation for control volume around point 1,


𝑑𝑇 𝑑𝑇 𝑑𝑇
𝜌𝑐∆𝑉 = (𝑘𝐴 ) − (𝑘𝐴 )
𝑑𝑡 𝑑𝑥 𝑒 𝑑𝑥 𝑤

Applying the boundary condition results,

𝑑𝑇 𝑑𝑇 𝑑𝑇
𝜌𝑐∆𝑉 = (𝑘𝐴 ) − (𝑘𝐴 )
𝑑𝑡 𝑑𝑥 𝑒 𝑑𝑥 𝑤

𝑑𝑇 𝑑𝑇
𝜌𝑐∆𝑉 = (𝑘𝐴 )
𝑑𝑡 𝑑𝑥 𝑒

𝑑𝑇 𝑇𝐸 − 𝑇𝑃
𝜌𝑐∆𝑉 = (𝑘𝐴 )
𝑑𝑡 ∆𝑥
𝑑𝑇 𝑇𝐸 − 𝑇𝑃
𝜌𝑐𝐴∆𝑥 = (𝑘𝐴 )
𝑑𝑡 ∆𝑥
𝑑𝑇 𝑘
𝜌𝑐∆𝑥 = (𝑇 − 𝑇𝑃 )
𝑑𝑡 ∆𝑥 𝐸

Now integrating wrt time using explicit scheme,

𝑘
𝜌𝑐∆𝑥(𝑇𝑃 − 𝑇𝑃 0 ) = (𝑇 − 𝑇𝑃 )∆𝑡
∆𝑥 𝐸
∆𝑥 ∆𝑥 0 𝑘 𝑘
𝜌𝑐 𝑇𝑃 − 𝜌𝑐 𝑇𝑃 = 𝑇𝐸 − 𝑇
∆𝑡 ∆𝑡 ∆𝑥 ∆𝑥 𝑃
∆𝑥 𝑘 𝑘 ∆𝑥 0
𝜌𝑐 𝑇𝑃 + 𝑇𝑃 = 𝑇𝐸 + 𝜌𝑐 𝑇
∆𝑡 ∆𝑥 ∆𝑥 ∆𝑡 𝑃
∆𝑥 𝑘 𝑘 ∆𝑥 0
(𝜌𝑐 + ) 𝑇𝑃 = 𝑇𝐸 + 𝜌𝑐 𝑇
∆𝑡 ∆𝑥 ∆𝑥 ∆𝑡 𝑃

(𝑎𝑝0 + 𝑎𝑒 )𝑇𝑃 = 𝑎𝑒 𝑇𝐸 + 𝑎𝑝0 𝑇𝑃 0 − − − − − (1)

Similarly writing equation for the boundary point 5,

𝑑𝑇 𝑑 𝑑𝑇
𝜌𝑐 = (𝑘 )
𝑑𝑡 𝑑𝑥 𝑑𝑥

Integrating above equation for control volume around point 5,

𝑑𝑇 𝑑𝑇 𝑑𝑇
𝜌𝑐∆𝑉 = (𝑘𝐴 ) − (𝑘𝐴 )
𝑑𝑡 𝑑𝑥 𝑒 𝑑𝑥 𝑤

𝑑𝑇 𝑇𝐸 − 𝑇𝑃 𝑇𝑃 − 𝑇𝑊
𝜌𝑐∆𝑉 = (2𝑘𝐴 ) − (𝑘𝐴 )
𝑑𝑡 ∆𝑥 ∆𝑥
𝑑𝑇 𝑇𝐸 − 𝑇𝑃 𝑇𝑃 − 𝑇𝑊
𝜌𝑐𝐴∆𝑥 = (2𝑘𝐴 ) − (𝑘𝐴 )
𝑑𝑡 ∆𝑥 ∆𝑥
𝑑𝑇 𝑇𝐸 − 𝑇𝑃 𝑇𝑃 − 𝑇𝑊
𝜌𝑐∆𝑥 = (2𝑘 ) − (𝑘 )
𝑑𝑡 ∆𝑥 ∆𝑥

Since TB=0, for point 5 TE=TB, therefore the above equation become,

𝑑𝑇 2𝑘 𝑘
𝜌𝑐∆𝑥 = − 𝑇𝑃 − (𝑇 − 𝑇𝑊 )
𝑑𝑡 ∆𝑥 ∆𝑥 𝑃

Now integrating wrt time using explicit scheme,

2𝑘 𝑘
𝜌𝑐∆𝑥(𝑇𝑃 − 𝑇𝑃 0 ) = − ∆𝑡 𝑇𝑃 − ∆𝑡 (𝑇𝑃 − 𝑇𝑊 )
∆𝑥 ∆𝑥
∆𝑥 2𝑘 𝑘
𝜌𝑐 (𝑇𝑃 − 𝑇𝑃 0 ) = − 𝑇𝑃 − (𝑇 − 𝑇𝑊 )
∆𝑡 ∆𝑥 ∆𝑥 𝑃
∆𝑥 2𝑘 𝑘
𝜌𝑐 (𝑇𝑃 − 𝑇𝑃 0 ) = − 𝑇𝑃 − (𝑇 − 𝑇𝑊 )
∆𝑡 ∆𝑥 ∆𝑥 𝑃
∆𝑥 ∆𝑥 0 2𝑘 𝑘 𝑘
𝜌𝑐 𝑇𝑃 − 𝜌𝑐 𝑇𝑃 = − 𝑇𝑃 − 𝑇𝑃 + 𝑇
∆𝑡 ∆𝑡 ∆𝑥 ∆𝑥 ∆𝑥 𝑊
∆𝑥 2𝑘 𝑘 𝑘 ∆𝑥 0
𝜌𝑐 𝑇𝑃 + 𝑇𝑃 + 𝑇𝑃 = 𝑇𝑊 + 𝜌𝑐 𝑇
∆𝑡 ∆𝑥 ∆𝑥 ∆𝑥 ∆𝑡 𝑃
∆𝑥 3𝑘 𝑘 ∆𝑥 0
(𝜌𝑐 + ) 𝑇𝑃 = 𝑇𝑊 + 𝜌𝑐 𝑇
∆𝑡 ∆𝑥 ∆𝑥 ∆𝑡 𝑃

(𝑎𝑝0 + 3𝑎𝑒 )𝑇𝑃 = 𝑎𝑒 𝑇𝑊 + 𝑎𝑝0 𝑇𝑃 0 − − − − − (2)

For point 2, 3, and 4 using equation 8.16 without source term,

(𝑎𝑝0 + 𝑎𝑊 + 𝑎𝐸 )𝑇𝑃 = 𝑎𝑊 𝑇𝑊 + 𝑎𝐸 𝑇𝐸 + 𝑎𝑝0 𝑇𝑃 0 − − − − − (3)

Using the following values,

𝜌𝑐 = 10 × 106 , 𝑘 = 10, ∆𝑥 = 0.004, ∆𝑡 = 2

∆𝑥 0.004
𝑎𝑝0 = 𝜌𝑐 = 10 × 106 = 20000
∆𝑡 2
𝑘 10
𝑎𝑒 = 𝑎𝑤 = = = 2500
∆𝑥 0.004

Using equation 1, 2 and 3 writing the discrete equations for node 1, 2, 3, 4 and 5.
22500 𝑇1 = 2500 𝑇2 + 20000𝑇1 0 − − − − − (𝑝𝑜𝑖𝑛𝑡 1)

25000 𝑇2 = 2500 𝑇1 + 2500 𝑇3 + 20000𝑇2 0 − − − − − (𝑝𝑜𝑖𝑛𝑡 2)

25000 𝑇3 = 2500 𝑇2 + 2500 𝑇4 + 20000𝑇2 0 − − − − − (𝑝𝑜𝑖𝑛𝑡 3)

25000 𝑇4 = 2500 𝑇3 + 2500 𝑇5 + 20000𝑇4 0 − − − − − (𝑝𝑜𝑖𝑛𝑡 4)

27500 𝑇5 = 2500𝑇4 + 20000𝑇5 0 − − − − − (𝑝𝑜𝑖𝑛𝑡 5)

Starting with the initial condition i.e. T=200 for 0<x<l, following matlab code is written,

A 1 2 3 4 5 B
0 sec 200 200 200 200 200 200 200
2 sec 199.9958 199.9958 199.9621 199.6255 196.2925 163.2993 0
4 sec 199.9786 199.9786 199.8412 198.7361 190.5159 136.0828 0
6 sec 199.9364 199.9364 199.5986 197.3199 183.7117 115.6703 0
8 sec 199.8554 199.8554 199.2073 195.4296 176.5295 100.172 0
10 sec 199.7217 199.7217 198.6526 193.1452 169.3631 88.249 0
12 sec 199.5226 199.5226 197.9296 190.5532 162.4406 78.9484 0
14 sec 199.247 199.247 197.0419 187.7353 155.8849 71.5884 0
16 sec 198.886 198.886 195.9985 184.7633 149.752 65.6781 0
18 sec 198.4334 198.4334 194.8119 181.6975 144.0576 60.862 0
20 sec 197.8848 197.8848 193.4967 178.587 138.7928 56.8808 0

Value at point A is similar to point 1 due to dT/dx=0 condition and similarly value at point B is 0 due to
boundary condition.
MATLAB CODE
clear all
clc
T1(1)=200;T2(1)=200;T3(1)=200;T4(1)=200;T5(1)=200;
A=[22500 -2500 0 0 0
-2500 25000 -2500 0 0
0 -2500 25000 -2500 0
0 0 -2500 25000 -2500
0 0 0 -2500 27500
];
for ii=2:11
b=[20000*T1(ii-1)
20000*T2(ii-1)
20000*T3(ii-1)
20000*T4(ii-1)
20000*T5(ii-1)
];

X=A\b;
T1(ii)=X(1);T2(ii)=X(2);T3(ii)=X(3);T4(ii)=X(4);T5(ii)=X(5);
end
[T1' T2' T3' T4' T5']

You might also like