This is a Julia version of an educational heat-equation implementation in C/C++/Fortran demostrating various parallel programming approaches from CSC – IT Center for Science.
Heat (or diffusion) equation is
where u(x, y, t) is the temperature field that varies in space and time, and α is thermal diffusivity constant. The two dimensional Laplacian can be discretized with finite differences as
Given an initial condition (u(t=0) = u0) one can follow the time dependence of the temperature field with explicit time evolution method:
Note: Algorithm is stable only when
An example run is demonstrated in example.jl:
using HeatEquation
ncols, nrows = 1000, 1000
nsteps = 500
# initialize current and previous states to the same state
curr, prev = initialize(ncols, nrows)
# visualize initial field
visualize_field(curr)
# simulate temperature evolution for nsteps
simulate!(curr prev, nsteps)
# visualize final field
visualize_field(curr)
cd test
julia --project=.. runtests.jl