Usando diferencias finitas centradas
\begin{align*} \frac{\partial^{2} T}{\partial x^{2}} &= \frac{T_{i+1, j} - 2 T_{i, j} + T_{i-1, j}}{\Delta x^{2}} \\ \frac{\partial^{2} T}{\partial y^{2}} &= \frac{T_{i, j+1} - 2 T_{i, j} + T_{i, j-1}}{\Delta y^{2}} \end{align*}Sustituyendo
\begin{equation*} \frac{T_{i+1, j} - 2 T_{i, j} + T_{i-1, j}}{\Delta x^{2}} + \frac{T_{i, j+1} - 2 T_{i, j} + T_{i, j-1}}{\Delta y^{2}} = 0 \end{equation*}Para una malla cuadrada $\Delta x^{2} = \Delta y^{2}$
\begin{equation*} \frac{T_{i+1, j} - 2 T_{i, j} + T_{i-1, j}}{\Delta x^{2}} + \frac{T_{i, j+1} - 2 T_{i, j} + T_{i, j-1}}{\Delta x^{2}} = 0 \end{equation*}reordenando
\begin{equation*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} = 0 \end{equation*}Nodo (1,1)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{1-1, 1} - 4 T_{1, 1} + T_{1+1, 1} + T_{1, 1-1} + T_{1, 1+1} &= 0 \\ T_{0, 1} - 4 T_{1, 1} + T_{2, 1} + T_{1, 0} + T_{1, 2} &= 0 \end{align*}Nodo (2,1)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{2-1, 1} - 4 T_{2, 1} + T_{2+1, 1} + T_{2, 1-1} + T_{2, 1+1} &= 0 \\ T_{1, 1} - 4 T_{2, 1} + T_{3, 1} + T_{2, 0} + T_{2, 2} &= 0 \end{align*}Nodo (3,1)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{3-1, 1} - 4 T_{3, 1} + T_{3+1, 1} + T_{3, 1-1} + T_{3, 1+1} &= 0 \\ T_{2, 1} - 4 T_{3, 1} + T_{4, 1} + T_{3, 0} + T_{3, 2} &= 0 \end{align*}Nodo (1,2)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{1-1, 2} - 4 T_{1, 2} + T_{1+1, 2} + T_{1, 2-1} + T_{1, 2+1} &= 0 \\ T_{0, 2} - 4 T_{1, 2} + T_{2, 2} + T_{1, 1} + T_{1, 3} &= 0 \end{align*}Nodo (2,2)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{2-1, 2} - 4 T_{2, 2} + T_{2+1, 2} + T_{2, 2-1} + T_{2, 2+1} &= 0 \\ T_{1, 2} - 4 T_{2, 2} + T_{3, 2} + T_{2, 1} + T_{2, 3} &= 0 \end{align*}Nodo (3,2)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{3-1, 2} - 4 T_{3, 2} + T_{3+1, 2} + T_{3, 2-1} + T_{3, 2+1} &= 0 \\ T_{2, 2} - 4 T_{3, 2} + T_{4, 2} + T_{3, 1} + T_{3, 3} &= 0 \end{align*}Nodo (1,3)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{1-1, 3} - 4 T_{1, 3} + T_{1+1, 3} + T_{1, 3-1} + T_{1, 3+1} &= 0 \\ T_{0, 3} - 4 T_{1, 3} + T_{2, 3} + T_{1, 2} + T_{1, 4} &= 0 \end{align*}Nodo (2,3)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{2-1, 3} - 4 T_{2, 3} + T_{2+1, 3} + T_{2, 3-1} + T_{2, 3+1} &= 0 \\ T_{1, 3} - 4 T_{2, 3} + T_{3, 3} + T_{2, 2} + T_{2, 4} &= 0 \end{align*}Nodo (3,3)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{3-1, 3} - 4 T_{3, 3} + T_{3+1, 3} + T_{3, 3-1} + T_{3, 3+1} &= 0 \\ T_{2, 3} - 4 T_{3, 3} + T_{4, 3} + T_{3, 2} + T_{3, 4} &= 0 \end{align*}Sistema de ecuaciones del problema
\begin{align*} - 4 T_{1, 1} + T_{1, 2} + T_{2, 1} &= -75 \\ T_{1, 1} - 4 T_{2, 1} + T_{2, 2} + T_{3, 1} &= 0 \\ T_{2, 1} - 4 T_{3, 1} + T_{3, 2} &= -50 \\ T_{1, 1} - 4 T_{1, 2} + T_{1, 3} + T_{2, 2} &= -75 \\ T_{1, 2} + T_{2, 1} - 4 T_{2, 2} + T_{2, 3} + T_{3, 2} &= 0 \\ T_{2, 2} + T_{3, 1} - 4 T_{3, 2} + T_{3, 3} &= -50 \\ T_{1, 2} - 4 T_{1, 3} + T_{2, 3} &= -175 \\ T_{1, 3} + T_{2, 2} - 4 T_{2, 3} + T_{3, 3} &= -100 \\ T_{2, 3} + T_{3, 2} - 4 T_{3, 3} &= -150 \end{align*}en forma matricial presenta una matriz dispersa
\begin{equation*} \begin{bmatrix} -4 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & -4 & 1 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & -4 & 1 & 0 \\ 1 & -4 & 1 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 1 & -4 & 1 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 1 & -4 & 1 \\ 0 & 1 & -4 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 1 & -4 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 1 & -4 \end{bmatrix} \begin{bmatrix} T_{1,1} \\ T_{1,2} \\ T_{1,3} \\ T_{2,1} \\ T_{2,2} \\ T_{2,3} \\ T_{3,1} \\ T_{3,2} \\ T_{3,3} \end{bmatrix} = \begin{bmatrix} -75 \\ 0 \\ -50 \\ -75 \\ 0 \\ -50 \\ -175 \\ -100 \\ -150 \end{bmatrix} \end{equation*}en forma reducida
\begin{equation*} Ax = B \end{equation*}
In [1]:
A = [[-4 1 0 1 0 0 0 0 0],
[ 1 0 0 -4 1 0 1 0 0],
[0 0 0 1 0 0 -4 1 0],
[1 -4 1 0 1 0 0 0 0],
[0 1 0 1 -4 1 0 1 0],
[0 0 0 0 1 0 1 -4 1],
[0 1 -4 0 0 1 0 0 0],
[0 0 1 0 1 -4 0 0 1],
[0 0 0 0 0 1 0 1 -4]];
In [2]:
B = [[-75],
[0],
[-50],
[-75],
[0],
[-50],
[-175],
[-100],
[-150]];
In [3]:
x = inv(A)*B;
In [4]:
x = transpose(reshape(x,3,3))
for i=1:3
for j=1:3
println("T[$i,$j] = $(x[i,j])")
end
end
Nodo (1,0)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{1-1, 0} - 4 T_{1, 0} + T_{1+1, 0} + T_{1, 0-1} + T_{1, 0+1} &= 0 \\ T_{0, 0} - 4 T_{1, 0} + T_{2, 0} + T_{1, -1} + T_{1, 1} &= 0 \end{align*}aproximando $T_{y}$ con una diferencia finita centrada
\begin{equation*} \frac{\partial T}{\partial y} = \frac{T_{i, j-1} - T_{i, j+1}}{2 \Delta y} = \frac{T_{1, 0-1} - T_{1, 0+1}}{2 \Delta y} = \frac{T_{1, -1} - T_{1, 1}}{2 \Delta y} \end{equation*}despejando $T_{1, -1}$
\begin{equation*} T_{1, -1} = 2 \Delta y \frac{\partial T}{\partial y} + T_{1, 1} \end{equation*}reemplazando
\begin{align*} T_{0, 0} - 4 T_{1, 0} + T_{2, 0} + 2 \Delta y \frac{\partial T}{\partial y} + T_{1, 1} + T_{1, 1} &= 0 \\ T_{0, 0} - 4 T_{1, 0} + T_{2, 0} + 2 \Delta y \frac{\partial T}{\partial y} + 2 T_{1, 1} &= 0 \end{align*}Nodo (2,0)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{2-1, 0} - 4 T_{2, 0} + T_{2+1, 0} + T_{2, 0-1} + T_{2, 0+1} &= 0 \\ T_{1, 0} - 4 T_{2, 0} + T_{3, 0} + T_{2, -1} + T_{2, 1} &= 0 \end{align*}aproximando $T_{y}$ con una diferencia finita centrada
\begin{equation*} \frac{\partial T}{\partial y} = \frac{T_{i, j-1} - T_{i, j+1}}{2 \Delta y} = \frac{T_{2, 0-1} - T_{2, 0+1}}{2 \Delta y} = \frac{T_{2, -1} - T_{2, 1}}{2 \Delta y} \end{equation*}despejando $T_{2, -1}$
\begin{equation*} T_{2, -1} = 2 \Delta y \frac{\partial T}{\partial y} + T_{2, 1} \end{equation*}reemplazando
\begin{align*} T_{1, 0} - 4 T_{2, 0} + T_{3, 0} + 2 \Delta y \frac{\partial T}{\partial y} + T_{2, 1} + T_{2, 1} &= 0 \\ T_{1, 0} - 4 T_{2, 0} + T_{3, 0} + 2 \Delta y \frac{\partial T}{\partial y} + 2 T_{2, 1} &= 0 \end{align*}Nodo (3,0)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{3-1, 0} - 4 T_{3, 0} + T_{3+1, 0} + T_{3, 0-1} + T_{3, 0+1} &= 0 \\ T_{2, 0} - 4 T_{3, 0} + T_{4, 0} + T_{3, -1} + T_{3, 1} &= 0 \end{align*}aproximando $T_{y}$ con una diferencia finita centrada
\begin{equation*} \frac{\partial T}{\partial y} = \frac{T_{i, j-1} - T_{i, j+1}}{2 \Delta y} = \frac{T_{3, 0-1} - T_{3, 0+1}}{2 \Delta y} = \frac{T_{3, -1} - T_{3, 1}}{2 \Delta y} \end{equation*}despejando $T_{3, -1}$
\begin{equation*} T_{3, -1} = 2 \Delta y \frac{\partial T}{\partial y} + T_{3, 1} \end{equation*}reemplazando
\begin{align*} T_{2, 0} - 4 T_{3, 0} + T_{4, 0} + 2 \Delta y \frac{\partial T}{\partial y} + T_{3, 1} + T_{3, 1} &= 0 \\ T_{2, 0} - 4 T_{3, 0} + T_{4, 0} + 2 \Delta y \frac{\partial T}{\partial y} + 2 T_{3, 1} &= 0 \end{align*}Nodo (1,1)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{1-1, 1} - 4 T_{1, 1} + T_{1+1, 1} + T_{1, 1-1} + T_{1, 1+1} &= 0 \\ T_{0, 1} - 4 T_{1, 1} + T_{2, 1} + T_{1, 0} + T_{1, 2} &= 0 \end{align*}Nodo (2,1)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{2-1, 1} - 4 T_{2, 1} + T_{2+1, 1} + T_{2, 1-1} + T_{2, 1+1} &= 0 \\ T_{1, 1} - 4 T_{2, 1} + T_{3, 1} + T_{2, 0} + T_{2, 2} &= 0 \end{align*}Nodo (3,1)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{3-1, 1} - 4 T_{3, 1} + T_{3+1, 1} + T_{3, 1-1} + T_{3, 1+1} &= 0 \\ T_{2, 1} - 4 T_{3, 1} + T_{4, 1} + T_{3, 0} + T_{3, 2} &= 0 \end{align*}Nodo (1,2)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{1-1, 2} - 4 T_{1, 2} + T_{1+1, 2} + T_{1, 2-1} + T_{1, 2+1} &= 0 \\ T_{0, 2} - 4 T_{1, 2} + T_{2, 2} + T_{1, 1} + T_{1, 3} &= 0 \end{align*}Nodo (2,2)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{2-1, 2} - 4 T_{2, 2} + T_{2+1, 2} + T_{2, 2-1} + T_{2, 2+1} &= 0 \\ T_{1, 2} - 4 T_{2, 2} + T_{3, 2} + T_{2, 1} + T_{2, 3} &= 0 \end{align*}Nodo (3,2)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{3-1, 2} - 4 T_{3, 2} + T_{3+1, 2} + T_{3, 2-1} + T_{3, 2+1} &= 0 \\ T_{2, 2} - 4 T_{3, 2} + T_{4, 2} + T_{3, 1} + T_{3, 3} &= 0 \end{align*}Nodo (1,3)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{1-1, 3} - 4 T_{1, 3} + T_{1+1, 3} + T_{1, 3-1} + T_{1, 3+1} &= 0 \\ T_{0, 3} - 4 T_{1, 3} + T_{2, 3} + T_{1, 2} + T_{1, 4} &= 0 \end{align*}Nodo (2,3)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{2-1, 3} - 4 T_{2, 3} + T_{2+1, 3} + T_{2, 3-1} + T_{2, 3+1} &= 0 \\ T_{1, 3} - 4 T_{2, 3} + T_{3, 3} + T_{2, 2} + T_{2, 4} &= 0 \end{align*}Nodo (3,3)
\begin{align*} T_{i-1, j} - 4 T_{i, j} + T_{i+1, j} + T_{i, j-1} + T_{i, j+1} &= 0 \\ T_{3-1, 3} - 4 T_{3, 3} + T_{3+1, 3} + T_{3, 3-1} + T_{3, 3+1} &= 0 \\ T_{2, 3} - 4 T_{3, 3} + T_{4, 3} + T_{3, 2} + T_{3, 4} &= 0 \end{align*}Sistema de ecuaciones del problema
\begin{align*} - 4 T_{1, 0} + 2 T_{1, 1} + T_{2, 0} &= -75 \\ T_{1, 0} - 4 T_{2, 0} + 2 T_{2, 1} + T_{3, 0} &= 0 \\ T_{2, 0} - 4 T_{3, 0} + 2 T_{3, 1} &= -50 \\ T_{1, 0} - 4 T_{1, 1} + T_{1, 2} + T_{2, 1} &= -75 \\ T_{1, 1} + T_{2, 0} - 4 T_{2, 1} + T_{2, 2} + T_{3, 1} &= 0 \\ T_{2, 1} + + T_{3, 0} - 4 T_{3, 1} + T_{3, 2} &= -50 \\ T_{1, 1} - 4 T_{1, 2} + T_{1, 3} + T_{2, 2} &= -75 \\ T_{1, 2} + T_{2, 1} - 4 T_{2, 2} + T_{2, 3} + T_{3, 2} &= 0 \\ T_{2, 2} + T_{3, 1} - 4 T_{3, 2} + T_{3, 3} &= -50 \\ T_{1, 2} - 4 T_{1, 3} + T_{2, 3} &= -175 \\ T_{1, 3} + T_{2, 2} - 4 T_{2, 3} + T_{3, 3} &= -100 \\ T_{2, 3} + T_{3, 2} - 4 T_{3, 3} &= -150 \end{align*}en forma matricial
\begin{equation*} \begin{bmatrix} -4 & 2 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 0 & 0 & 0 & -4 & 2 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & -4 & 2 & 0 & 0 \\ 1 & -4 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 1 & -4 & 1 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & -4 & 1 & 0 \\ 0 & 1 & -4 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 & 0 & 1 & -4 & 1 & 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & -4 & 1 \\ 0 & 0 & 1 & -4 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 1 & -4 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & -4 \end{bmatrix} \begin{bmatrix} T_{1,0} \\ T_{1,1} \\ T_{1,2} \\ T_{1,3} \\ T_{2,0} \\ T_{2,1} \\ T_{2,2} \\ T_{2,3} \\ T_{3,0} \\ T_{3,1} \\ T_{3,2} \\ T_{3,3} \end{bmatrix} = \begin{bmatrix} -75 \\ 0 \\ -50 \\ -75 \\ 0 \\ -50 \\ -75 \\ 0 \\ -50 \\ -175 \\ -100 \\ -150 \end{bmatrix} \end{equation*}
In [5]:
C = [[-4 2 0 0 1 0 0 0 0 0 0 0],
[1 0 0 0 -4 2 0 0 1 0 0 0],
[0 0 0 0 1 0 0 0 -4 2 0 0],
[1 -4 1 0 0 1 0 0 0 0 0 0],
[0 1 0 0 1 -4 1 0 0 1 0 0],
[0 0 0 0 0 1 0 0 1 -4 1 0],
[0 1 -4 1 0 0 1 0 0 0 0 0],
[0 0 1 0 0 1 -4 1 0 0 1 0],
[0 0 0 0 0 0 1 0 0 1 -4 1],
[0 0 1 -4 0 0 0 1 0 0 0 0],
[0 0 0 1 0 0 1 -4 0 0 0 1],
[0 0 0 0 0 0 0 1 0 0 1 -4]];
In [6]:
D = [[-75],
[0],
[-50],
[-75],
[0],
[-50],
[-75],
[0],
[-50],
[-175],
[-100],
[-150]];
In [7]:
u = inv(C)*D;
In [8]:
u = transpose(reshape(u, 4,3))
for i=1:3
for j=1:4
println("T[$i,$(j-1)] = $(u[i,j])")
end
end