TDMA - Thomas Algorithm
Dr ARUMUGA PERUMAL
Asst Prof
Dept of Mechanical Engg
NITK, Surathkal
FDM for 1-D diffusion equation
•Unsteady 1-D heat conduction/diffusion in a solid body is governed by (PDE)
y x=a x=b
Eqn 1
x
where 𝑢 is temperature, 𝑡 is time, 𝑥 is space coordinate in x-direction and 𝑘 is
thermal diffusivity.
•Assume that
the initial conditions: distribution of u at t = 0 and
the boundary conditions: u at x = a and b are given.
Backward time central space (BTCS) scheme
•BTCS scheme is first order accurate in time and second order
in space. But BTCS scheme is unconditionally stable.
•The BTCS approximation of Eqn. 1 gives
Eqn 7
Backward time central space (BTCS) scheme
•Eqn. 7 has more than one unknown at nth time level.
•Therefore one equation alone can’t be solved unless it is clubbed with more
number of equations to close the system.
∆𝑥
x=a x=b
Space discretization
Space and time discretization
Solution B
𝑇1𝑛+1 = 𝑇𝑎 Matrix A Vector x Known values
−𝑟𝑇1𝑛+1 + 1 + 2𝑟 𝑇2𝑛+1 − 𝑟𝑇3𝑛+1 = 𝑇2𝑛
−𝑟𝑇2𝑛+1 + 1 + 2𝑟 𝑇3𝑛+1 − 𝑟𝑇4𝑛+1 = 𝑇3𝑛
.
.
𝑛+1 𝑛+1
−𝑟𝑇𝑁−2 + 1 + 2𝑟 𝑇𝑁−1 − 𝑟𝑇𝑁𝑛+1 = 𝑇𝑁−1
𝑛
𝑇𝑁𝑛+1 = 𝑇𝑏
•This tridiagonal matrix can be solved using Thomas algorithm.
•FDM is based on Taylor series expansion.
•Explicit schemes are computationally less expensive. But are
conditionally stable.
•Implicit schemes are computationally more expensive. But are
unconditionally stable.
•Implicit schemes requires solution of set of simultaneous equations.
Tridiagonal matrix solver-Thomas Algo
Algorithm-BTCS scheme
1. Assign parameter L,N, ∆𝑥, ∆𝑡, alpha
(Assume N is traversing from 1 to N, where 1 and N are boundary nodes)
2. create arrays Tn(1:N) and Tn+1(1:N)
3.Initial condition Tn(i)=0
4.Boundary condition Tn(1)=0, Tn(N)=1
5. for i=1 to N
a(i)=-r b(i)=-r d(i)=1+2r B(i)=Tin
Now over write first and last row values to adjust BC:Tn+1(1)=0, Tn+1(N)=1
a(1)=0 b(N)=0 d(1)=1 d(N)=1 B(1)=Ta B(N)=Tb
6. Time stepping starts
Call tridiagonal solver (N,a,b,d,B,x)
% x is the solution vector
Tn+1(i)=x(i)
Tn(i)=Tn+1(i) for i=1,2,….N
Copying new solution in to old solution array
7.Repeat Step 6 until required time.