# Finite difference discretisation of the heat equation

Here is the equation to be discretised:

$$k\left(\frac{\partial^2 T}{\partial x^2} + \frac{\partial^2 T}{\partial y^2}\right) = \dot{q}$$

Using the following discretisation scheme:

$$\frac{\partial^2 T}{\partial x^2} = \frac{T_{i+2,j} - 2T_{i+1,j} + T_{i-1,j}}{3(\Delta x)^2} \\ \frac{\partial^2 T}{\partial y^2} = \frac{T_{i,j+2} - 2T_{i,j+1} + T_{i,j-1}}{3(\Delta y)^2}$$

Moreover the domain is a simple square where the left and top side have, respectively, imposed Boundary Condition $\frac{\partial T}{\partial x} = 0$ & $\frac{\partial T}{\partial y} = 0$ and the right and bottom side have imposed Boundary Condition $T=T_0$.

When full discretised I get: $$2A \cdot T_{i+1,j} - A \cdot T_{i+2,j} - A \cdot T_{i-1,j} + 2B \cdot T_{i,j+1} - B \cdot T_{i,j+2} - B \cdot T_{i,j-1} = q_{i,j}$$ where $A = \frac{k}{3(\Delta x)^2}$ and $B = \frac{k}{3(\Delta y)^2}$

Now I am asked to find the coefficient matrix and right hand side. The coefficient matrix is quite straight forward but my issue is the right hand side where I can't see to put in both boundary conditions...

• The boundary condition $T=T_0$ is just a set of equations $T_{i,j} = T_0$ where $(i,j)$ is such that it falls on that part of the boundary. But $\dot q =0$ does not look like a boundary condition to me. Boundary conditions are supposed to involve the function you're solving for, that is $T$. – user147263 Jan 10 '16 at 23:23
• the question states that the walls are isolated thermally meaning $q_{i,j} = 0$ which implies $2A * T_{i+1,j} - A * T_{i+2,j} - A * T_{i-1,j} + 2B * T_{i,j+1} - B * T_{i,j+2} - B * T_{i,j-1} = 0$ – Guillaume Jan 11 '16 at 9:18
• or would isolated thermally simply mean $\frac{\partial T}{\partial x} = 0$ ? in that case how do you introduce the two types of boundary conditions matrix notation ? – Guillaume Jan 11 '16 at 14:42
• If this is to be the heat equation then $\dot{q} = \frac{\partial T}{\partial t}$ right? Also I fixed your notation slightly: $\frac{\partial T^2}{\partial x^2} \to \frac{\partial^2 T}{\partial x^2}$ as the former is usually used to denote the derivative of $T^2$. – Winther Jan 11 '16 at 14:48
• the boundary condition can be set by $2$ different ways : your $T$ unknown vector is of size $N^2$ where $N$ is the size of your discretization in both axis, the matrix $M$ of the LHS in of size $N^2 \times n^2$ and has coefficients $(i*N+j,iN^2+j) = 2$ , $(i*N+j,iN^2+j-1) = (i*N+j,iN^2+j-1) = -1$, with the equation $M \times T = C$ where $C$ is a vector of size $N^2$ with $C_{i N^2+ j} = q_{i,j}$. – reuns Jan 11 '16 at 15:07