# Alternating Direction Implicit method for solving 2D Heat diffusion

• I
• Vick

#### Vick

TL;DR Summary
Computation of the discretized grid nodes as per ADI
I'm trying to compute a 2D Heat diffusion parabolic PDE:

$$\frac{\partial u}{\partial t} = \alpha \{ \frac{\partial^2 u}{\partial x^2} + \frac{\partial^2 u}{\partial y^2} \}$$

by the ADI method. I am actually trying to go over the example in this youtube video. The video is in another language, so just by looking at the images is illustrative enough! I've calculated i and j when both are 1, successfully, but it seems I cannot do so for when j=1 and i=2.

My understanding of the subject matter is as follows:

A discretized grid having nodes i and j representing the length of object as in x-axis (columns) and width of object as in y-axis (rows) respectively and as per the video the grid is:

Matrix([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]])

which represents ##0 \leq x \leq 1## and ##0 \leq y \leq 1## with ##dx## and ##dy## at ##0.25## and:
##U(0,y,t) = 0## ;
##U(1,y,t) = 0## ;
##U(x,0,t) = 0## ;
##U(x,1,t) = 0## ;
##U(x,y,0) = 100##

and the first direction formula is:

$$-r_xU_{i-1,j}^{n+\frac{1}{2}} + (1 + 2r_x)U_{i,j}^{n+\frac{1}{2}} - r_xU_{i+1,j}^{n+\frac{1}{2}} = r_yU_{i,j-1}^n + (1 - 2r_y)U_{i,j}^n + r_yU_{i,j+1}^n$$

where ##r_x = \frac{\alpha . dt}{2.dx^2}## and ##r_y = \frac{\alpha . dt}{2.dy^2}##; and alpha being ##\alpha = 1## and ##dt = 1##

Therefore computing for ##i=1## and ##j=1##:
##0 + 17.U_{i,j}^{n+\frac{1}{2}} -8.U_{i+1,j}^{n+\frac{1}{2}} = 8*0 - 15*0 + 8*0##

Are the above correct? Or am I mistaken somewhere?

The above calculations are correct. To compute for i=2 and j=1, we use the same formula:$$-r_xU_{i-1,j}^{n+\frac{1}{2}} + (1 + 2r_x)U_{i,j}^{n+\frac{1}{2}} - r_xU_{i+1,j}^{n+\frac{1}{2}} = r_yU_{i,j-1}^n + (1 - 2r_y)U_{i,j}^n + r_yU_{i,j+1}^n$$where ##r_x = \frac{\alpha . dt}{2.dx^2}## and ##r_y = \frac{\alpha . dt}{2.dy^2}##; and alpha being ##\alpha = 1## and ##dt = 1##Therefore computing for ##i=2## and ##j=1##:##-8.U_{i-1,j}^{n+\frac{1}{2}} + 17.U_{i,j}^{n+\frac{1}{2}} - 8.U_{i+1,j}^{n+\frac{1}{2}} = 8*0 - 15*0 + 8*0##