Can Poisson equation be solved numerically in one shot?

142 Views Asked by At

I am trying to solve the 2-D Poisson heat equation, i.e. $\nabla^2T = C$, with boundary conditions (temperatures) for 3 surfaces, and the north surface is insulated.

So I created an $N \times N$ grid, and I constructed the system of linear equations $Ax=b$ where A (for a $3 \times 3$ grid);

$A=\begin{bmatrix}1&0&0&-1&0&0&0&0&0\\ 0&1&0&0&-1&0&0&0&0\\ 0&0&1&0&0&-1&0&0&0\\ 0&0&0&1&0&0&0&0&0\\ 0&0&0&100&-400&100&0&0&0\\ 0&0&0&0&0&1&0&0&0\\ 0&0&0&0&0&0&1&0&0\\ 0&0&0&0&0&0&0&1&0\\ 0&0&0&0&0&0&0&0&1\end{bmatrix} \backslash \ \ b=\begin{bmatrix}0\\ 0\\ 0\\ T_{north}\\ C\\ T_{east}\\ T_{south}\\ T_{south}\\ T_{south}\\\end{bmatrix}$

(the middle row of $A$ is because of the inverse square of $\Delta_x$, which is $ = 0.1$)

Does this look correct? Can I just solve this and reshape $x$ to $N \times N$, and the values represent the steady state temperatures of each node?

Thanks for any help,

1

There are 1 best solutions below

11
On BEST ANSWER

You A should look like the following (divide it by your $(\Delta_x)^2$):

-4     1     0     1     0     0     0     0     0
 1    -4     1     0     1     0     0     0     0
 0     1    -4     0     0     1     0     0     0
 1     0     0    -4     1     0     1     0     0
 0     1     0     1    -4     1     0     1     0
 0     0     1     0     1    -4     0     0     1
 0     0     0     1     0     0    -4     1     0
 0     0     0     0     1     0     1    -4     1
 0     0     0     0     0     1     0     1    -4

the above represents $$\frac{u_{i+1,j}-2u_{i,j}+u_{i-1,j}}{(\Delta x)^2} + \frac{u_{i,j+1}-2u_{i,j}+u_{i,j-1}}{(\Delta y)^2}$$ with $(\Delta y)^2=(\Delta x)^2=1$

This matrix is too small, but see this row

> 0     1     0     1    -4     1     0     1     0

the the ones closest to 4 are derivative in one direction, the farther ones are the another direction.

Now for the BCs, at the end point (with index as $n$) you have $$\frac{u_{n+1,j}-2u_{n,j}+u_{n-1,j}}{(\Delta x)^2} + \frac{u_{n,j+1}-2u_{n,j}+u_{n,j-1}}{(\Delta y)^2}=f_{n,j}$$ the node $n+1$ exceed the matrix size, but its value is known from BC, so you can move it to the RHS. Similarly with the other end point with index 1, you will get node $1-1$ which exceed the matrix size - move it to the RHS as well.