4
$\begingroup$

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

enter image description here

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:

enter image description here

$\endgroup$
  • $\begingroup$ Make sure your linear system $Ax=f$ only involves interior points, then enforce the boundary conditions manually. $\endgroup$ – icurays1 Dec 9 '13 at 14:07
  • $\begingroup$ 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. $\endgroup$ – Daniel Dec 9 '13 at 14:11
  • $\begingroup$ Ah right, sorry - I misread. $\endgroup$ – icurays1 Dec 9 '13 at 14:29
3
$\begingroup$

Your matrix is correct, but your boundary conditions are not being enforced on your RHS vector.

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.