Heat (or diffusion) equation is a partial differential equation that describes the variation of temperature in a given region over time
where u(x, y, t) is the temperature field that varies in space and time, and α is the thermal diffusivity constant.
We limit ourselvels to two dimensions (a plane) where Laplacian can be discretized in a grid with finite differences as
where ∆x and ∆y are the grid spacing of the temperature grid u.
Given an initial condition (u(t=0) = u0) one can follow the time dependence of the temperature field with explicit time evolution method:
Note: The algorithm is stable only when
A parallel solver for the two-dimensional heat equation has been implemented in C and Fortran. It is almost complete, only MPI routines are missing. :)
To finish off the parallelisation of the code, one needs to implement a halo
exchange between the domains in the decomposition. An example model solution
is also available in C and Fortran.
To build the code, please use the provided Makefile
(by giving the command
make
in the directory).
The solver carries out the time development of the 2D heat equation over the number of time steps provided by the user. The default geometry is a flat rectangle (with grid size provided by the user), but other shapes may be used via input files -- a bottle is given as an example in common/bottle.dat.
Examples on how to run the binary:
./heat
(no arguments - the program will run with the default arguments: 2000x2000 grid and 500 time steps)./heat bottle.dat
(one argument - start from a temperature grid provided in the filebottle.dat
for the default number of time steps)./heat bottle.dat 1000
(two arguments - will run the program starting from a temperature grid provided in the filebottle.dat
for 1000 time steps)./heat 4000 8000 1000
(three arguments - will run the program in a 1024x2048 grid for 1000 time steps)
The program will produce an image (PNG) of the temperature field after every
500 iterations. You can change the frequency by modifying the parameter
image_interval
in main.c (or main.F90).
You can also visualize the images e.g. with the following command:
animate heat_*.png
.