Heatwave gives you several options on how to solve the heat equation.
(Click on the picture to the left to see some of the UI that controls the heat solver.)
There are three major methods to choose from: forward difference (also called the explicit method),
backward difference (also called the implicit method),
and central difference
(also called the CrankNicolson method).
Central difference combines features of forward and backward difference and is the most accurate of the three.
You can read more about these methods at
Wikipedia's Finitedifference method entry.
I also found
Parallel Numerical Solution of 2D Heat Equation (Horak, Gruber) (PDF)
to be useful.
The forwarddifference method is the simplest to understand. It calculates a (weighted) average with the neighbor cells,
applied to a window that is 3 cells wide in the 1D case. (In 2D it is applied to 5 cells, the center value, the two cells
adjoining in the x direction, and the two cells adjoining in the y direction.)
The value of a cell at position x and time t+dt is calculated from the previous sheet (at time t) as
The forwarddifference method is easy to code, easily made parallel, and fast to run.
But you can only take small forward steps with the forwarddifference method, so although each generation
may be fast to calculate you will need a lot of generations (and a small time step) to reach an equilibrium.
If you try to take big steps with forwarddifference you end up with sheet values that oscillate and grow
with each generation. See the Instabilities page for details.
With the backwarddifference method however you don't have instabilities.
You can make timesteps as big as you want and the solution will not blow up,
although it does get less accurate.
This is the big advantage to using backward difference.
It is more difficult to code than forward difference, and the individual sheet calculations are quite
a bit slower, but the fact that you can take large time steps means you can run a rough simulation
much faster.
The backwarddifference method involves linear algebra.
You have to solve a matrix equation, which means you have to invert a matrix.
You will almost always see this described for the 1D case, since in 1D the matrix is a
tridiagonal matrix, and the equation is easily and quickly solved.
You can read more about tridiagonal matrices here:
Unfortunately the 2D case is not so simple.
The matrix is pentadiagonal (5diagonal), and the nonzero diagonals are not adjacent.
Furthermore the matrix is very large. For a 100x100 sheet the (sparse) matrix is 10000x10000.
Here are some links that describe pentadiagonal matrices:
Of course the 3D case is even worse, with a gigantic 7diagonal matrix.
So instead of solving the 2D sheet all at once, Heatwave solves the sheet along one axis with a 1D solve, and then
solves it again sideways. This is a poor solution however.
Heatwave also let's you choose the centraldifference method, which is a combination of the forward and
reversedifference methods. It has the disadvantages of both — you're restricted to smaller time steps, and
you have to invert a matrix, but it's the more accurate than the other two methods.
Heat wave has a checkbox that lets you choose to "Use parallel algorithm (via QtConcurrent)".
This is provided for timing tests and does not affect the results of a solve.
For more info see:
Heatwave also lets you choose a "Solve technique".
The first choice, "Interleave", means first solve the sheet as a bunch of 1D lines parallel to the xaxis,
and then solve on top of the first result as a bunch of 1D lines along the yaxis.
The second choice, "Simultaneous", performs a onepass 2D solve when the method is forward difference.
When the method is either backward or central difference "Simultaneous" performs 2 onedimensional solves
like it does with "Interleave", but both solves start from the same source sheet, and the results of the
two are added together.
The last the technique choice, "Damped wave", solves the wave equation instead of the heat equation.
We'll talk about that on the next page.
