Coefficient matrix for an implicit scheme for heat equation

895 Views Asked by At

I have a problem where I have 1D filament that is heated in one end (x=0) at a temperature T=210C (this is the first non-homogenous BC), and the other end (x=L) we have two boundary conditions: T(x=L)=25C and there is no flux (Neumann BC) at this point where dT(x=L)/dx=0.

I am using the implicit Euler scheme in time and central difference in space to solve the !D heat equation and model this system. However, looking at the solution I can see that the coefficient matrix of this scheme is given by: enter image description here enter image description here Which has been confusing me a lot! Could you please shed some light on why the matrix looks like this. Specifically speaking, why A(0,0) = A(N,N) = 1 instead of -2, and why A(0,1)=0, and lastly why A(N-1)=A(N-2)=-1!

Thanks in advance.

1

There are 1 best solutions below

12
On

The first thing to note is that the finite difference scheme

$$ \Bigl[\frac{\Delta x^2}{\alpha\Delta t}+2\Bigr]T_i^n-[1]T_{i+1}^n-[1]T_{i-1}^n=\Bigl[\frac{\Delta x^2}{\alpha\Delta t}\Bigr]T_i^{n-1} $$

applied to all interior points $i=2 \cdots N-1$ can be represented as

$$a_iT_i^n + b_iT_{i+1}^n + c_iT_{i-1}^n=d_i$$

where $$a_i = \Bigl[\frac{\Delta x^2}{\alpha\Delta t}+2\Bigr]$$

$$b_i = c_i =-1$$

and $$d_i = \Bigl[\frac{\Delta x^2}{\alpha\Delta t}\Bigr]T_i^{n-1}$$

which represents a tri-diagonal matrix, so that there is no need for the storage of a full matrix.

The boundary conditions are implemented as

$$ a_1 = 1,\hspace{0.5 in}b_1=0,\hspace{0.5 in}c_1=0,\hspace{0.5 in}d_1=T_0 $$

and using a simple backward finite-difference for the Neuman condition at $x=L$, ($i=N$), we have

$$ a_N = 1,\hspace{0.5 in}b_N=0,\hspace{0.5 in}c_N=-1,\hspace{0.5 in}d_N=0 $$

So you start with the initial condition $T_i^0 = T(x)$ at all nodes and then solve the tri-diagonal system at each time step, and then update the temperatures until the desired time interval has been simulated.

The tri-diagonal system can be very efficiently solved with the Tri-Diagonal Matrix Algorithm (TDMA or Thomas) Algorithm which is described at

https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm

I wrote the section in the wiki page above that also has the code for solving a TDMA so feel free to ask me if anything isn't clear.

Hope this helps. Note that my indexing runs from $1$ to $N$, but can just as easily be implemented from $0$ to $N$.