# Problem with Static 2D Heat Eqaution

So I am basically trying to solve the simplest case possible for the heat equation:

on the domain [0;1] x [0,1] with boundary conditions 1.5 on one face of the square and 1.0 on all other faces.

I am using octave and I am solving the mathematical system from scratch, for learning purposes. (I know it is inefficient)

The matrix I am getting:

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


WRONG RHS VECTOR FROM MY QUESTION

And the RHS vector is:

f =
-1.00000
-1.00000
-1.00000
-1.00000
-1.00000
-0.00000
-0.00000
-1.00000
-1.00000
-0.00000
-0.00000
-1.00000
-1.00000
-1.50000
-1.50000
-1.00000


CORRECT UPDATED RHS VECTOR FROM THE ANSWER BELOW

f =
-2.00000
-1.00000
-1.00000
-2.00000
-1.00000
-0.00000
-0.00000
-1.00000
-1.00000
-0.00000
-0.00000
-1.00000
-2.50000
-1.50000
-1.50000
-2.50000


The problem is that I am getting some artifacts near the corners, like in the following print screen with added boundary conditions:

• Make sure your linear system $Ax=f$ only involves interior points, then enforce the boundary conditions manually. – icurays1 Dec 9 '13 at 14:07
• It only has the interior points, but for the boundary conditions, don't I have to include them in $f$ just like I did above? Those are supposed to be my BCs. – Daniel Dec 9 '13 at 14:11
• Ah right, sorry - I misread. – icurays1 Dec 9 '13 at 14:29

For example, consider the row corresponding to an interior corner point that will use the two distinct boundary values. The RHS vector of this row should be

$$-1.0 - 1.5$$

because the corners require two values to be subtracted to the RHS. The same is true for your other (interior) corner points where two distinct boundary condition values meet.

• I think I see where you are going. I will try it out and will come with a feedback. Thanks! – Daniel Dec 9 '13 at 14:49
• That fixed it. I will also update my question with the correct vector $f$, so people know this if they also hit this problem. – Daniel Dec 9 '13 at 14:59